2727
2828#if MYNEWT_VAL (UART_0 ) || MYNEWT_VAL (UART_1 ) || MYNEWT_VAL (UART_2 )
2929#include "uart/uart.h"
30+ #if MYNEWT_VAL (HAL_UART )
3031#include "uart_hal/uart_hal.h"
32+ #else
33+ #include "uart_da1469x/uart_da1469x.h"
34+ #endif
3135#endif
3236#if MYNEWT_VAL (BUS_DRIVER_PRESENT )
3337#include "bus/bus.h"
@@ -89,7 +93,11 @@ static struct crypto_dev os_bsp_crypto;
8993#endif
9094
9195#if MYNEWT_VAL (UART_0 )
96+ #if MYNEWT_VAL (UART_HAL )
9297static struct uart_dev os_bsp_uart0 ;
98+ #else
99+ static struct da1469x_uart_dev os_bsp_uart0 ;
100+ #endif
93101static const struct da1469x_uart_cfg os_bsp_uart0_cfg = {
94102 .pin_tx = MYNEWT_VAL (UART_0_PIN_TX ),
95103 .pin_rx = MYNEWT_VAL (UART_0_PIN_RX ),
@@ -99,7 +107,11 @@ static const struct da1469x_uart_cfg os_bsp_uart0_cfg = {
99107};
100108#endif
101109#if MYNEWT_VAL (UART_1 )
110+ #if MYNEWT_VAL (UART_HAL )
102111static struct uart_dev os_bsp_uart1 ;
112+ #else
113+ static struct da1469x_uart_dev os_bsp_uart1 ;
114+ #endif
103115static const struct da1469x_uart_cfg os_bsp_uart1_cfg = {
104116 .pin_tx = MYNEWT_VAL (UART_1_PIN_TX ),
105117 .pin_rx = MYNEWT_VAL (UART_1_PIN_RX ),
@@ -109,7 +121,11 @@ static const struct da1469x_uart_cfg os_bsp_uart1_cfg = {
109121};
110122#endif
111123#if MYNEWT_VAL (UART_2 )
124+ #if MYNEWT_VAL (UART_HAL )
112125static struct uart_dev os_bsp_uart2 ;
126+ #else
127+ static struct da1469x_uart_dev os_bsp_uart2 ;
128+ #endif
113129static const struct da1469x_uart_cfg os_bsp_uart2_cfg = {
114130 .pin_tx = MYNEWT_VAL (UART_2_PIN_TX ),
115131 .pin_rx = MYNEWT_VAL (UART_2_PIN_RX ),
@@ -334,6 +350,20 @@ da1469x_periph_create_adc(void)
334350#endif
335351}
336352
353+ static int
354+ da1469x_uart_create (struct da1469x_uart_dev * dev , const char * name , uint8_t priority ,
355+ const struct da1469x_uart_cfg * cfg )
356+ {
357+ #if MYNEWT_VAL (HAL_UART )
358+ return os_dev_create (& dev -> ud_dev , "uart0" ,
359+ OS_DEV_INIT_PRIMARY , priority , uart_hal_init ,
360+ (void * )& os_bsp_uart0_cfg );
361+ #else
362+ (void )priority ;
363+ return da1469x_uart_dev_create (dev , name , priority , cfg );
364+ #endif
365+ }
366+
337367static void
338368da1469x_periph_create_uart (void )
339369{
@@ -342,21 +372,15 @@ da1469x_periph_create_uart(void)
342372 (void )rc ;
343373
344374#if MYNEWT_VAL (UART_0 )
345- rc = os_dev_create (& os_bsp_uart0 .ud_dev , "uart0" ,
346- OS_DEV_INIT_PRIMARY , 0 , uart_hal_init ,
347- (void * )& os_bsp_uart0_cfg );
375+ rc = da1469x_uart_create (& os_bsp_uart0 , "uart0" , 0 , & os_bsp_uart0_cfg );
348376 assert (rc == 0 );
349377#endif
350378#if MYNEWT_VAL (UART_1 )
351- rc = os_dev_create (& os_bsp_uart1 .ud_dev , "uart1" ,
352- OS_DEV_INIT_PRIMARY , 1 , uart_hal_init ,
353- (void * )& os_bsp_uart1_cfg );
379+ rc = da1469x_uart_create (& os_bsp_uart1 , "uart1" , 1 , & os_bsp_uart1_cfg );
354380 assert (rc == 0 );
355381#endif
356382#if MYNEWT_VAL (UART_2 )
357- rc = os_dev_create (& os_bsp_uart1 .ud_dev , "uart2" ,
358- OS_DEV_INIT_PRIMARY , 2 , uart_hal_init ,
359- (void * )& os_bsp_uart2_cfg );
383+ rc = da1469x_uart_create (& os_bsp_uart2 , "uart2" , 2 , & os_bsp_uart2_cfg );
360384 assert (rc == 0 );
361385#endif
362386}
0 commit comments