| 153 | #endif /* RT_USING_UART3 */ |
| 154 | |
| 155 | void rt_hw_uart_init(void) |
| 156 | { |
| 157 | struct rt_uart_ls1c *uart; |
| 158 | struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; |
| 159 | |
| 160 | #ifdef RT_USING_UART2 |
| 161 | uart = &uart2; |
| 162 | |
| 163 | serial2.ops = &ls1c_uart_ops; |
| 164 | serial2.config = config; |
| 165 | |
| 166 | pin_set_purpose(36, PIN_PURPOSE_OTHER); |
| 167 | pin_set_purpose(37, PIN_PURPOSE_OTHER); |
| 168 | pin_set_remap(36, PIN_REMAP_SECOND); |
| 169 | pin_set_remap(37, PIN_REMAP_SECOND); |
| 170 | |
| 171 | rt_hw_interrupt_install(uart->IRQ, uart_irq_handler, &serial2, "UART2"); |
| 172 | |
| 173 | /* register UART2 device */ |
| 174 | rt_hw_serial_register(&serial2, |
| 175 | "uart2", |
| 176 | //RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_DMA_RX, |
| 177 | RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, |
| 178 | uart); |
| 179 | #endif /* RT_USING_UART2 */ |
| 180 | |
| 181 | #ifdef RT_USING_UART1 |
| 182 | uart = &uart1; |
| 183 | |
| 184 | serial1.ops = &ls1c_uart_ops; |
| 185 | serial1.config = config; |
| 186 | |
| 187 | pin_set_purpose(2, PIN_PURPOSE_OTHER); |
| 188 | pin_set_purpose(3, PIN_PURPOSE_OTHER); |
| 189 | pin_set_remap(2, PIN_REMAP_FOURTH); |
| 190 | pin_set_remap(3, PIN_REMAP_FOURTH); |
| 191 | |
| 192 | rt_hw_interrupt_install(uart->IRQ, uart_irq_handler, &serial1, "UART1"); |
| 193 | |
| 194 | /* register UART1 device */ |
| 195 | rt_hw_serial_register(&serial1, |
| 196 | "uart1", |
| 197 | //RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_DMA_RX, |
| 198 | RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, |
| 199 | uart); |
| 200 | #endif /* RT_USING_UART1 */ |
| 201 | |
| 202 | #ifdef RT_USING_UART3 |
| 203 | uart = &uart3; |
| 204 | |
| 205 | serial3.ops = &ls1c_uart_ops; |
| 206 | serial3.config = config; |
| 207 | |
| 208 | pin_set_purpose(0, PIN_PURPOSE_OTHER); |
| 209 | pin_set_purpose(1, PIN_PURPOSE_OTHER); |
| 210 | pin_set_remap(0, PIN_REMAP_FOURTH); |
| 211 | pin_set_remap(1, PIN_REMAP_FOURTH); |
| 212 |
no test coverage detected