19
19
#include <zephyr/logging/log_ctrl.h>
20
20
#include <zephyr/sys/util.h>
21
21
22
+ #include <board-config.h>
23
+
22
24
LOG_MODULE_REGISTER (app , CONFIG_BLE_NUS_SAMPLE_LOG_LEVEL );
23
25
24
26
BLE_ADV_DEF (ble_adv ); /* BLE advertising instance */
@@ -29,11 +31,7 @@ BLE_QWR_DEF(ble_qwr); /* BLE QWR instance */
29
31
static uint16_t conn_handle = BLE_CONN_HANDLE_INVALID ;
30
32
31
33
/** NUS UARTE instance */
32
- #if defined(CONFIG_SOC_SERIES_NRF52X )
33
- static const nrfx_uarte_t uarte_inst = NRFX_UARTE_INSTANCE (0 );
34
- #elif defined(CONFIG_SOC_SERIES_NRF54LX )
35
- static const nrfx_uarte_t uarte_inst = NRFX_UARTE_INSTANCE (30 );
36
- #endif
34
+ static const nrfx_uarte_t uarte_inst = NRF_UARTE_INST_GET (BOARD_APP_UARTE_INST );
37
35
38
36
/* Maximum length of data (in bytes) that can be transmitted to the peer by the
39
37
* Nordic UART service module.
@@ -290,13 +288,13 @@ static int uarte_init(void)
290
288
{
291
289
int err ;
292
290
293
- nrfx_uarte_config_t uarte_config = NRFX_UARTE_DEFAULT_CONFIG (CONFIG_BLE_UART_PIN_TX ,
294
- CONFIG_BLE_UART_PIN_RX );
291
+ nrfx_uarte_config_t uarte_config = NRFX_UARTE_DEFAULT_CONFIG (BOARD_APP_UARTE_PIN_TX ,
292
+ BOARD_APP_UARTE_PIN_RX );
295
293
296
294
#if defined(CONFIG_BLE_UART_HWFC )
297
295
uarte_config .config .hwfc = NRF_UARTE_HWFC_ENABLED ;
298
- uarte_config .cts_pin = CONFIG_BLE_UART_PIN_CTS ;
299
- uarte_config .rts_pin = CONFIG_BLE_UART_PIN_RTS ;
296
+ uarte_config .cts_pin = BOARD_APP_UARTE_PIN_CTS ;
297
+ uarte_config .rts_pin = BOARD_APP_UARTE_PIN_RTS ;
300
298
#endif
301
299
302
300
#if defined(CONFIG_BLE_UART_PARITY )
@@ -306,32 +304,17 @@ static int uarte_init(void)
306
304
uarte_config .interrupt_priority = CONFIG_BLE_UART_IRQ_PRIO ;
307
305
308
306
/** We need to connect the IRQ ourselves. */
309
- #if defined(CONFIG_SOC_SERIES_NRF52X )
310
- IRQ_CONNECT (NRFX_IRQ_NUMBER_GET (NRF_UARTE_INST_GET (0 )), CONFIG_BLE_UART_IRQ_PRIO ,
311
- NRFX_UARTE_INST_HANDLER_GET (0 ), 0 , 0 );
312
-
313
- irq_enable (NRFX_IRQ_NUMBER_GET (NRF_UARTE_INST_GET (0 )));
314
- #elif defined(CONFIG_SOC_SERIES_NRF54LX )
315
- IRQ_CONNECT (NRFX_IRQ_NUMBER_GET (NRF_UARTE_INST_GET (30 )), CONFIG_BLE_UART_IRQ_PRIO ,
316
- NRFX_UARTE_INST_HANDLER_GET (30 ), 0 , 0 );
307
+ IRQ_CONNECT (NRFX_IRQ_NUMBER_GET (NRF_UARTE_INST_GET (BOARD_APP_UARTE_INST )), CONFIG_BLE_UART_IRQ_PRIO ,
308
+ NRFX_UARTE_INST_HANDLER_GET (BOARD_APP_UARTE_INST ), 0 , 0 );
317
309
318
- irq_enable (NRFX_IRQ_NUMBER_GET (NRF_UARTE_INST_GET (30 )));
319
- #endif
310
+ irq_enable (NRFX_IRQ_NUMBER_GET (NRF_UARTE_INST_GET (BOARD_APP_UARTE_INST )));
320
311
321
312
err = nrfx_uarte_init (& uarte_inst , & uarte_config , uarte_evt_handler );
322
313
if (err != NRFX_SUCCESS ) {
323
314
LOG_ERR ("Failed to initialize UART, nrfx err %d" , err );
324
315
return err ;
325
316
}
326
317
327
- /* optional: enable pull-up on RX pin in case pin may become floating.
328
- * Induced noise on a floating RX input may lead to an UARTE error condition
329
- */
330
- #if defined(CONFIG_SOC_SERIES_NRF52X )
331
- NRF_GPIO -> PIN_CNF [uarte_config .rxd_pin ] |=
332
- (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos );
333
- #endif
334
-
335
318
return 0 ;
336
319
}
337
320
0 commit comments