diff options
Diffstat (limited to 'firmware/target/arm/imx233/pwm-imx233.c')
-rw-r--r-- | firmware/target/arm/imx233/pwm-imx233.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/firmware/target/arm/imx233/pwm-imx233.c b/firmware/target/arm/imx233/pwm-imx233.c index 1ebfe02a1c..c0417c55d0 100644 --- a/firmware/target/arm/imx233/pwm-imx233.c +++ b/firmware/target/arm/imx233/pwm-imx233.c | |||
@@ -30,15 +30,15 @@ void imx233_pwm_init(void) | |||
30 | 30 | ||
31 | bool imx233_pwm_is_channel_enable(int channel) | 31 | bool imx233_pwm_is_channel_enable(int channel) |
32 | { | 32 | { |
33 | return HW_PWM_CTRL & HW_PWM_CTRL__PWMx_ENABLE(channel); | 33 | return BF_RD(PWM_CTRL, PWMx_ENABLE(channel)); |
34 | } | 34 | } |
35 | 35 | ||
36 | void imx233_pwm_enable_channel(int channel, bool enable) | 36 | void imx233_pwm_enable_channel(int channel, bool enable) |
37 | { | 37 | { |
38 | if(enable) | 38 | if(enable) |
39 | __REG_SET(HW_PWM_CTRL) = HW_PWM_CTRL__PWMx_ENABLE(channel); | 39 | BF_SET(PWM_CTRL, PWMx_ENABLE(channel)); |
40 | else | 40 | else |
41 | __REG_CLR(HW_PWM_CTRL) = HW_PWM_CTRL__PWMx_ENABLE(channel); | 41 | BF_CLR(PWM_CTRL, PWMx_ENABLE(channel)); |
42 | } | 42 | } |
43 | 43 | ||
44 | void imx233_pwm_setup_channel(int channel, int period, int cdiv, int active, | 44 | void imx233_pwm_setup_channel(int channel, int period, int cdiv, int active, |
@@ -56,11 +56,9 @@ void imx233_pwm_setup_channel(int channel, int period, int cdiv, int active, | |||
56 | imx233_set_pin_drive_strength(IMX233_PWM_PIN_BANK(channel), IMX233_PWM_PIN(channel), | 56 | imx233_set_pin_drive_strength(IMX233_PWM_PIN_BANK(channel), IMX233_PWM_PIN(channel), |
57 | PINCTRL_DRIVE_4mA); | 57 | PINCTRL_DRIVE_4mA); |
58 | /* watch the order ! active THEN period */ | 58 | /* watch the order ! active THEN period */ |
59 | HW_PWM_ACTIVEx(channel) = active << HW_PWM_ACTIVEx__ACTIVE_BP | | 59 | HW_PWM_ACTIVEn(channel) = BF_OR2(PWM_ACTIVEn, ACTIVE(active), INACTIVE(inactive)); |
60 | inactive << HW_PWM_ACTIVEx__INACTIVE_BP; | 60 | HW_PWM_PERIODn(channel) = BF_OR4(PWM_PERIODn, PERIOD(period - 1), |
61 | HW_PWM_PERIODx(channel) = period | active_state << HW_PWM_PERIODx__ACTIVE_STATE_BP | | 61 | ACTIVE_STATE(active_state), INACTIVE_STATE(inactive_state), CDIV(cdiv)); |
62 | inactive_state << HW_PWM_PERIODx__INACTIVE_STATE_BP | | ||
63 | cdiv << HW_PWM_PERIODx__CDIV_BP; | ||
64 | /* restore */ | 62 | /* restore */ |
65 | imx233_pwm_enable_channel(channel, enable); | 63 | imx233_pwm_enable_channel(channel, enable); |
66 | } | 64 | } |