|
46 | 46 | #include <usart.h> |
47 | 47 |
|
48 | 48 | #include <os/os_dev.h> |
49 | | -#if MYNEWT_VAL(UART_0) |
| 49 | +#if MYNEWT_VAL(UART_0) || MYNEWT_VAL(UART_1) |
50 | 50 | #include <uart/uart.h> |
51 | 51 | #include <uart_hal/uart_hal.h> |
52 | 52 | #include <mcu/hal_uart.h> |
53 | 53 |
|
54 | | -static struct uart_dev hal_uart0; |
55 | 54 | #endif |
56 | 55 | #if MYNEWT_VAL(SPI_0) |
57 | 56 | /* configure the SPI port for arduino external spi */ |
@@ -84,18 +83,31 @@ struct samd21_i2c_config i2c_config = { |
84 | 83 | #endif |
85 | 84 |
|
86 | 85 | #if MYNEWT_VAL(UART_0) |
87 | | -static const struct samd21_uart_config uart_cfgs[] = { |
88 | | - [0] = { |
89 | | - .suc_sercom = SERCOM2, |
90 | | - .suc_mux_setting = USART_RX_3_TX_2_XCK_3, |
91 | | - .suc_generator_source = GCLK_GENERATOR_0, |
92 | | - .suc_sample_rate = USART_SAMPLE_RATE_16X_ARITHMETIC, |
93 | | - .suc_sample_adjustment = USART_SAMPLE_ADJUSTMENT_7_8_9, |
94 | | - .suc_pad0 = 0, |
95 | | - .suc_pad1 = 0, |
96 | | - .suc_pad2 = PINMUX_PA10D_SERCOM2_PAD2, |
97 | | - .suc_pad3 = PINMUX_PA11D_SERCOM2_PAD3 |
98 | | - } |
| 86 | +static const struct samd21_uart_config uart0_cfg = { |
| 87 | + .suc_sercom = SERCOM5, |
| 88 | + .suc_mux_setting = USART_RX_3_TX_2_XCK_3, |
| 89 | + .suc_generator_source = GCLK_GENERATOR_0, |
| 90 | + .suc_sample_rate = USART_SAMPLE_RATE_16X_ARITHMETIC, |
| 91 | + .suc_sample_adjustment = USART_SAMPLE_ADJUSTMENT_7_8_9, |
| 92 | + .suc_pad0 = PINMUX_UNUSED, |
| 93 | + .suc_pad1 = PINMUX_UNUSED, |
| 94 | + .suc_pad2 = PINMUX_PB22D_SERCOM5_PAD2, |
| 95 | + .suc_pad3 = PINMUX_PB23D_SERCOM5_PAD3, |
| 96 | +}; |
| 97 | +#endif |
| 98 | + |
| 99 | +#if MYNEWT_VAL(UART_1) |
| 100 | +static const struct samd21_uart_config uart1_cfg = { |
| 101 | + .suc_sercom = SERCOM2, |
| 102 | + .suc_mux_setting = USART_RX_3_TX_2_XCK_3, |
| 103 | + .suc_generator_source = GCLK_GENERATOR_0, |
| 104 | + .suc_sample_rate = USART_SAMPLE_RATE_16X_ARITHMETIC, |
| 105 | + .suc_sample_adjustment = USART_SAMPLE_ADJUSTMENT_7_8_9, |
| 106 | + .suc_pad0 = PINMUX_UNUSED, |
| 107 | + .suc_pad1 = PINMUX_UNUSED, |
| 108 | + .suc_pad2 = PINMUX_PA10D_SERCOM2_PAD2, |
| 109 | + .suc_pad3 = PINMUX_PA11D_SERCOM2_PAD3 |
| 110 | + |
99 | 111 | }; |
100 | 112 | #endif |
101 | 113 |
|
@@ -129,7 +141,6 @@ hal_bsp_core_dump(int *area_cnt) |
129 | 141 | return dump_cfg; |
130 | 142 | } |
131 | 143 |
|
132 | | - |
133 | 144 | /** |
134 | 145 | * Returns the configured priority for the given interrupt. If no priority |
135 | 146 | * configured, return the priority passed in |
@@ -157,8 +168,16 @@ hal_bsp_init(void) |
157 | 168 | #endif |
158 | 169 |
|
159 | 170 | #if MYNEWT_VAL(UART_0) |
160 | | - rc = os_dev_create((struct os_dev *) &hal_uart0, "uart0", |
161 | | - OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *)&uart_cfgs[0]); |
| 171 | + static struct uart_dev hal_uart0; |
| 172 | + rc = os_dev_create((struct os_dev *)&hal_uart0, "uart0", OS_DEV_INIT_PRIMARY, |
| 173 | + 0, uart_hal_init, (void *)&uart0_cfg); |
| 174 | + SYSINIT_PANIC_ASSERT(rc == 0); |
| 175 | +#endif |
| 176 | + |
| 177 | +#if MYNEWT_VAL(UART_1) |
| 178 | + static struct uart_dev hal_uart1; |
| 179 | + rc = os_dev_create((struct os_dev *)&hal_uart1, "uart1", OS_DEV_INIT_PRIMARY, |
| 180 | + 0, uart_hal_init, (void *)&uart1_cfg); |
162 | 181 | SYSINIT_PANIC_ASSERT(rc == 0); |
163 | 182 | #endif |
164 | 183 |
|
|
0 commit comments