diff options
Diffstat (limited to 'bsp/ls2kdev/drivers')
| -rw-r--r-- | bsp/ls2kdev/drivers/board.c | 2 | ||||
| -rw-r--r-- | bsp/ls2kdev/drivers/drv_spi.c | 5 | ||||
| -rw-r--r-- | bsp/ls2kdev/drivers/drv_uart.c | 22 |
3 files changed, 18 insertions, 11 deletions
diff --git a/bsp/ls2kdev/drivers/board.c b/bsp/ls2kdev/drivers/board.c index 1d165cf5ef..9b79902c41 100644 --- a/bsp/ls2kdev/drivers/board.c +++ b/bsp/ls2kdev/drivers/board.c @@ -90,7 +90,7 @@ void rt_hw_board_init(void) /* init hardware UART device */ rt_hw_uart_init(); /* set console device */ - rt_console_set_device("uart0"); + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_HEAP diff --git a/bsp/ls2kdev/drivers/drv_spi.c b/bsp/ls2kdev/drivers/drv_spi.c index 3f3ad90802..5a42acbee8 100644 --- a/bsp/ls2kdev/drivers/drv_spi.c +++ b/bsp/ls2kdev/drivers/drv_spi.c @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2020-10-28 0xcccccccccccc Initial Version + * 2021-01-17 0xcccccccccccc Bug Fixed : clock division cannot been adjusted as expected due to wrong register configuration. */ /** * @addtogroup ls2k @@ -21,11 +22,11 @@ #ifdef RT_USING_SPI static void spi_init(uint8_t spre_spr, uint8_t copl, uint8_t cpha) { - SET_SPI(SPSR, 0xc0 | (spre_spr & 0b00000011)); + SET_SPI(SPSR, 0xc0); SET_SPI(PARAM, 0x40); SET_SPI(PARAM2, 0x01); SET_SPI(SPER, (spre_spr & 0b00001100) >> 2); - SET_SPI(SPCR, 0x50 | copl << 3 | cpha << 2); + SET_SPI(SPCR, 0x50 | copl << 3 | cpha << 2 | (spre_spr & 0b00000011)); SET_SPI(SOFTCS, 0xff); } diff --git a/bsp/ls2kdev/drivers/drv_uart.c b/bsp/ls2kdev/drivers/drv_uart.c index 9421078769..5b5c39c595 100644 --- a/bsp/ls2kdev/drivers/drv_uart.c +++ b/bsp/ls2kdev/drivers/drv_uart.c @@ -156,26 +156,32 @@ struct rt_serial_device serial, serial4; void rt_hw_uart_init(void) { - struct rt_uart_ls2k *uart, *uart4; struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; - uart = &uart_dev0; - uart4 = &uart_dev4; +#ifdef RT_USING_UART0 + struct rt_uart_ls2k *uart0; + uart0 = &uart_dev0; serial.ops = &ls2k_uart_ops; serial.config = config_uart0; - serial4.ops = &ls2k_uart_ops; - serial4.config = config; - rt_hw_interrupt_install(uart->IRQ, uart_irq_handler, &serial, "UART0"); - rt_hw_interrupt_install(uart4->IRQ, uart_irq_handler, &serial4, "UART4"); + rt_hw_interrupt_install(uart0->IRQ, uart_irq_handler, &serial, "UART0"); /* register UART device */ rt_hw_serial_register(&serial, "uart0", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, - uart); + uart0); +#endif + +#ifdef RT_USING_UART4 + struct rt_uart_ls2k *uart4; + uart4 = &uart_dev4; + serial4.ops = &ls2k_uart_ops; + serial4.config = config; + rt_hw_interrupt_install(uart4->IRQ, uart_irq_handler, &serial4, "UART4"); rt_hw_serial_register(&serial4, "uart4", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, &uart_dev4); +#endif } /*@}*/ |
