Skip to content

Commit 3c93283

Browse files
committed
CR changes for PWm nRF52 part 2.
1 parent 3519122 commit 3c93283

File tree

1 file changed

+7
-25
lines changed
  • hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF52832

1 file changed

+7
-25
lines changed

hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF52832/pwmout_api.c

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,19 @@
5353
#define MAX_PWM_PERIOD_MS ((MAX_PWM_PERIOD_US / 1000) + 1) // approximations advance
5454
#define MAX_PWM_PERIOD_S ((MAX_PWM_PERIOD_US / 1000000) + 1) // approximations advance
5555

56-
#ifdef PWM0_ENABLED
57-
#define __PWM0_NUM 1
58-
#else
59-
#define __PWM0_NUM 0
60-
#endif
61-
62-
#ifdef PWM1_ENABLED
63-
#define __PWM1_NUM 1
64-
#else
65-
#define __PWM1_NUM 0
66-
#endif
67-
68-
#ifdef PWM2_ENABLED
69-
#define __PWM2_NUM 1
70-
#else
71-
#define __PWM2_NUM 0
72-
#endif
73-
7456

75-
#define PWM_INSTANCE_COUNT (__PWM0_NUM + __PWM1_NUM + __PWM2_NUM)
57+
#define PWM_INSTANCE_COUNT (PWM_COUNT) // import from the PWM driver header
7658

7759
///> instances of nRF52 PWM driver
7860
static const nrf_drv_pwm_t m_pwm_driver[PWM_INSTANCE_COUNT] =
7961
{
80-
#ifdef PWM0_ENABLED
62+
#if PWM0_ENABLED
8163
NRF_DRV_PWM_INSTANCE(0),
8264
#endif
83-
#ifdef PWM1_ENABLED
65+
#if PWM1_ENABLED
8466
NRF_DRV_PWM_INSTANCE(1),
8567
#endif
86-
#ifdef PWM2_ENABLED
68+
#if PWM2_ENABLED
8769
NRF_DRV_PWM_INSTANCE(2)
8870
#endif
8971
};
@@ -104,13 +86,13 @@ typedef struct
10486

10587
static pwm_t m_pwm[PWM_INSTANCE_COUNT] =
10688
{
107-
#ifdef PWM0_ENABLED
89+
#if PWM0_ENABLED
10890
{.p_pwm_driver = NULL},
10991
#endif
110-
#ifdef PWM0_ENABLED
92+
#if PWM1_ENABLED
11193
{.p_pwm_driver = NULL},
11294
#endif
113-
#ifdef PWM0_ENABLED
95+
#if PWM2_ENABLED
11496
{.p_pwm_driver = NULL}
11597
#endif
11698
}; /// Array of internal PWM instances.

0 commit comments

Comments
 (0)