[bsp]clean code

This commit is contained in:
tanek liang 2017-12-07 13:15:52 +08:00
parent 5fd89e4461
commit 6a88e5b20e
1 changed files with 12 additions and 13 deletions

View File

@ -27,7 +27,7 @@
#error "Please define at least one UARTx" #error "Please define at least one UARTx"
#endif #endif
#include <rtdevice.h> #include <rtdevice.h>
/* imxrt uart driver */ /* imxrt uart driver */
@ -130,7 +130,7 @@ static const struct imxrt_uart uarts[] = {
"uart1", "uart1",
}, },
#endif #endif
}; };
/* Get debug console frequency. */ /* Get debug console frequency. */
@ -210,9 +210,9 @@ static rt_err_t imxrt_configure(struct rt_serial_device *serial, struct serial_c
RT_ASSERT(cfg != RT_NULL); RT_ASSERT(cfg != RT_NULL);
uart = (struct imxrt_uart *)serial->parent.user_data; uart = (struct imxrt_uart *)serial->parent.user_data;
imxrt_uart_gpio_init(uart); imxrt_uart_gpio_init(uart);
LPUART_GetDefaultConfig(&config); LPUART_GetDefaultConfig(&config);
config.baudRate_Bps = cfg->baud_rate; config.baudRate_Bps = cfg->baud_rate;
@ -249,13 +249,13 @@ static rt_err_t imxrt_configure(struct rt_serial_device *serial, struct serial_c
config.parityMode = kLPUART_ParityDisabled; config.parityMode = kLPUART_ParityDisabled;
break; break;
} }
config.enableTx = true; config.enableTx = true;
config.enableRx = true; config.enableRx = true;
LPUART_Init(uart->uart_base, &config, BOARD_DebugConsoleSrcFreq()); LPUART_Init(uart->uart_base, &config, BOARD_DebugConsoleSrcFreq());
return RT_EOK; return RT_EOK;
} }
@ -273,7 +273,7 @@ static rt_err_t imxrt_control(struct rt_serial_device *serial, int cmd, void *ar
LPUART_DisableInterrupts(uart->uart_base, kLPUART_RxDataRegFullInterruptEnable); LPUART_DisableInterrupts(uart->uart_base, kLPUART_RxDataRegFullInterruptEnable);
/* disable rx irq */ /* disable rx irq */
DisableIRQ(uart->irqn); DisableIRQ(uart->irqn);
break; break;
case RT_DEVICE_CTRL_SET_INT: case RT_DEVICE_CTRL_SET_INT:
/* enable interrupt */ /* enable interrupt */
@ -295,7 +295,7 @@ static int imxrt_putc(struct rt_serial_device *serial, char ch)
LPUART_WriteByte(uart->uart_base, ch); LPUART_WriteByte(uart->uart_base, ch);
while(!(LPUART_GetStatusFlags(uart->uart_base) & kLPUART_TxDataRegEmptyFlag)); while(!(LPUART_GetStatusFlags(uart->uart_base) & kLPUART_TxDataRegEmptyFlag));
return 1; return 1;
} }
@ -323,7 +323,7 @@ static void uart_isr(struct rt_serial_device *serial)
struct imxrt_uart *uart = (struct imxrt_uart *) serial->parent.user_data; struct imxrt_uart *uart = (struct imxrt_uart *) serial->parent.user_data;
RT_ASSERT(uart != RT_NULL); RT_ASSERT(uart != RT_NULL);
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
@ -332,7 +332,7 @@ static void uart_isr(struct rt_serial_device *serial)
{ {
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
} }
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
@ -350,7 +350,6 @@ int imxrt_hw_usart_init(void)
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
int i; int i;
for (i = 0; i < sizeof(uarts) / sizeof(uarts[0]); i++) for (i = 0; i < sizeof(uarts) / sizeof(uarts[0]); i++)
{ {
uarts[i].serial->ops = &imxrt_uart_ops; uarts[i].serial->ops = &imxrt_uart_ops;