3232
3333BUILD_ASSERT (DT_NODE_HAS_PROP (ANTENNA_SWITCH_NODE , ant_gpios ));
3434
35+ #define NUM_GPIOS DT_PROP_LEN(ANTENNA_SWITCH_NODE, ant_gpios)
36+
3537#if MULTIPLEXED
3638#if CONFIG_BT_CTLR_SDC_CS_NUM_ANTENNAS == 2
37- BUILD_ASSERT (DT_PROP_LEN ( ANTENNA_SWITCH_NODE , ant_gpios ) >= 1 );
39+ BUILD_ASSERT (NUM_GPIOS >= 1 );
3840#else
39- BUILD_ASSERT (DT_PROP_LEN ( ANTENNA_SWITCH_NODE , ant_gpios ) >= 2 );
41+ BUILD_ASSERT (NUM_GPIOS >= 2 );
4042#endif
4143#else
42- BUILD_ASSERT (DT_PROP_LEN ( ANTENNA_SWITCH_NODE , ant_gpios ) >= CONFIG_BT_CTLR_SDC_CS_NUM_ANTENNAS );
44+ BUILD_ASSERT (NUM_GPIOS >= CONFIG_BT_CTLR_SDC_CS_NUM_ANTENNAS );
4345#endif /* MULTIPLEXED */
4446
4547static uint8_t currently_active_antenna = ANTENNA_NOT_SET ;
@@ -76,8 +78,10 @@ void cs_antenna_switch_func(uint8_t antenna_number)
7678 err = gpio_pin_set_dt (& gpio_dt_spec_table [0 ], antenna_number & (1 << 0 ));
7779 __ASSERT_NO_MSG (err == 0 );
7880
81+ #if NUM_GPIOS > 1
7982 err = gpio_pin_set_dt (& gpio_dt_spec_table [1 ], antenna_number & (1 << 1 ));
8083 __ASSERT_NO_MSG (err == 0 );
84+ #endif
8185#else
8286 if (currently_active_antenna != antenna_number ) {
8387 if (currently_active_antenna != ANTENNA_NOT_SET ) {
@@ -97,7 +101,7 @@ void cs_antenna_switch_init(void)
97101{
98102 int err ;
99103
100- for (uint8_t i = 0 ; i < DT_PROP_LEN ( ANTENNA_SWITCH_NODE , ant_gpios ) ; i ++ ) {
104+ for (uint8_t i = 0 ; i < NUM_GPIOS ; i ++ ) {
101105 err = gpio_pin_configure_dt (& gpio_dt_spec_table [i ], GPIO_OUTPUT_INACTIVE );
102106 __ASSERT (err == 0 , "Failed to initialize GPIOs for CS (%d)" , err );
103107 }
@@ -107,7 +111,7 @@ void cs_antenna_switch_clear(void)
107111{
108112 int err ;
109113
110- for (uint8_t i = 0 ; i < DT_PROP_LEN ( ANTENNA_SWITCH_NODE , ant_gpios ) ; i ++ ) {
114+ for (uint8_t i = 0 ; i < NUM_GPIOS ; i ++ ) {
111115 err = gpio_pin_set_dt (& gpio_dt_spec_table [i ], false);
112116 __ASSERT_NO_MSG (err == 0 );
113117 }
0 commit comments