drivers: pwm_nrfx: use IS_ENABLED to eliminate a bunch of #ifndefs
For the macros that take on 0/1 values, we can use the existing IS_ENABLED macro to remove a bunch of code. Signed-off-by: Jim Paris <jim@jtan.com>
This commit is contained in:
parent
4aaa08acfd
commit
f1137e4782
1 changed files with 3 additions and 63 deletions
|
@ -352,15 +352,15 @@ static int pwm_nrfx_pm_control(struct device *dev,
|
|||
|
||||
#define PWM_NRFX_OUTPUT_PIN(dev_idx, ch_idx) \
|
||||
(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CH##ch_idx##_PIN | \
|
||||
(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CH##ch_idx##_INVERTED ? \
|
||||
(IS_ENABLED(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CH##ch_idx##_INVERTED) ?\
|
||||
NRFX_PWM_PIN_INVERTED : 0))
|
||||
|
||||
#define PWM_NRFX_DEFAULT_VALUE(dev_idx, ch_idx) \
|
||||
(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CH##ch_idx##_INVERTED ? \
|
||||
(IS_ENABLED(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CH##ch_idx##_INVERTED) ? \
|
||||
PWM_NRFX_CH_VALUE_INVERTED : PWM_NRFX_CH_VALUE_NORMAL)
|
||||
|
||||
#define PWM_NRFX_COUNT_MODE(dev_idx) \
|
||||
(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CENTER_ALIGNED ? \
|
||||
(IS_ENABLED(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CENTER_ALIGNED) ? \
|
||||
NRF_PWM_MODE_UP_AND_DOWN : NRF_PWM_MODE_UP)
|
||||
|
||||
#define PWM_NRFX_DEVICE(idx) \
|
||||
|
@ -402,125 +402,65 @@ static int pwm_nrfx_pm_control(struct device *dev,
|
|||
&pwm_nrfx_drv_api_funcs)
|
||||
|
||||
#ifdef CONFIG_PWM_0
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CENTER_ALIGNED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_0_CENTER_ALIGNED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH0_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_0_CH0_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH0_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_0_CH0_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH1_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_0_CH1_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH1_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_0_CH1_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH2_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_0_CH2_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH2_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_0_CH2_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH3_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_0_CH3_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH3_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_0_CH3_INVERTED 0
|
||||
#endif
|
||||
PWM_NRFX_DEVICE(0);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PWM_1
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CENTER_ALIGNED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_1_CENTER_ALIGNED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH0_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_1_CH0_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH0_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_1_CH0_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH1_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_1_CH1_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH1_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_1_CH1_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH2_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_1_CH2_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH2_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_1_CH2_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH3_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_1_CH3_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH3_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_1_CH3_INVERTED 0
|
||||
#endif
|
||||
PWM_NRFX_DEVICE(1);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PWM_2
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CENTER_ALIGNED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_2_CENTER_ALIGNED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH0_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_2_CH0_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH0_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_2_CH0_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH1_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_2_CH1_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH1_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_2_CH1_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH2_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_2_CH2_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH2_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_2_CH2_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH3_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_2_CH3_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH3_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_2_CH3_INVERTED 0
|
||||
#endif
|
||||
PWM_NRFX_DEVICE(2);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PWM_3
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CENTER_ALIGNED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_3_CENTER_ALIGNED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH0_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_3_CH0_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH0_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_3_CH0_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH1_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_3_CH1_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH1_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_3_CH1_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH2_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_3_CH2_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH2_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_3_CH2_INVERTED 0
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH3_PIN
|
||||
#define DT_NORDIC_NRF_PWM_PWM_3_CH3_PIN NRFX_PWM_PIN_NOT_USED
|
||||
#endif
|
||||
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH3_INVERTED
|
||||
#define DT_NORDIC_NRF_PWM_PWM_3_CH3_INVERTED 0
|
||||
#endif
|
||||
PWM_NRFX_DEVICE(3);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue