提交 5df3ac20 编写于 作者: lymzzyh's avatar lymzzyh

[bsp][k210] update sdk support for v0.5.6

上级 8e6ec4df
...@@ -19,13 +19,6 @@ ...@@ -19,13 +19,6 @@
#include "fpioa.h" #include "fpioa.h"
#include "dmac.h" #include "dmac.h"
#include "uarths.h"
void rt_hw_console_output(const char *str)
{
uarths_puts(str);
return ;
}
void init_bss(void) void init_bss(void)
{ {
unsigned int *dst; unsigned int *dst;
......
...@@ -15,11 +15,14 @@ ...@@ -15,11 +15,14 @@
#include "drv_uart.h" #include "drv_uart.h"
#include <stdio.h> #include <stdio.h>
#include <sysctl.h>
// #include "uart.h" // #include "uart.h"
#include "uarths.h" #include "uarths.h"
#include "plic.h" #include "plic.h"
static volatile uarths_t *const _uarths = (volatile uarths_t *)UARTHS_BASE_ADDR;
struct device_uart struct device_uart
{ {
rt_uint32_t hw_base; rt_uint32_t hw_base;
...@@ -66,9 +69,6 @@ int rt_hw_uart_init(void) ...@@ -66,9 +69,6 @@ int rt_hw_uart_init(void)
uart->hw_base = UARTHS_BASE_ADDR; uart->hw_base = UARTHS_BASE_ADDR;
uart->irqno = IRQN_UARTHS_INTERRUPT; uart->irqno = IRQN_UARTHS_INTERRUPT;
/* initialize UART HS */
uarths_init();
rt_hw_serial_register(serial, rt_hw_serial_register(serial,
"uarths", "uarths",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
...@@ -114,6 +114,8 @@ static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_co ...@@ -114,6 +114,8 @@ static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_co
{ {
rt_uint32_t baud_div; rt_uint32_t baud_div;
struct device_uart *uart; struct device_uart *uart;
uint32_t freq = sysctl_clock_get_freq(SYSCTL_CLOCK_CPU);
uint16_t div = freq / cfg->baud_rate - 1;
RT_ASSERT(serial != RT_NULL); RT_ASSERT(serial != RT_NULL);
serial->config = *cfg; serial->config = *cfg;
...@@ -121,15 +123,22 @@ static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_co ...@@ -121,15 +123,22 @@ static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_co
uart = serial->parent.user_data; uart = serial->parent.user_data;
RT_ASSERT(uart != RT_NULL); RT_ASSERT(uart != RT_NULL);
/* Init UART Hardware */ if (uart->hw_base == UARTHS_BASE_ADDR)
{
/* Enable UART clock */ _uarths->div.div = div;
_uarths->txctrl.txen = 1;
/* Set both receiver and transmitter in UART mode (not SIR) */ _uarths->rxctrl.rxen = 1;
_uarths->txctrl.txcnt = 0;
/* Set databits, stopbits and parity. (8-bit data, 1 stopbit, no parity) */ _uarths->rxctrl.rxcnt = 0;
_uarths->ip.txwm = 1;
/* set baudrate */ _uarths->ip.rxwm = 1;
_uarths->ie.txwm = 0;
_uarths->ie.rxwm = 1;
}
else
{
/* other uart */
}
return (RT_EOK); return (RT_EOK);
} }
...@@ -167,7 +176,8 @@ static int drv_uart_putc(struct rt_serial_device *serial, char c) ...@@ -167,7 +176,8 @@ static int drv_uart_putc(struct rt_serial_device *serial, char c)
uart = serial->parent.user_data; uart = serial->parent.user_data;
if (uart->hw_base == UARTHS_BASE_ADDR) if (uart->hw_base == UARTHS_BASE_ADDR)
{ {
uarths_putchar(c); while (_uarths->txdata.full);
_uarths->txdata.data = (uint8_t)c;
} }
else else
{ {
...@@ -184,8 +194,11 @@ static int drv_uart_getc(struct rt_serial_device *serial) ...@@ -184,8 +194,11 @@ static int drv_uart_getc(struct rt_serial_device *serial)
if (uart->hw_base == UARTHS_BASE_ADDR) if (uart->hw_base == UARTHS_BASE_ADDR)
{ {
ret = uarths_getc(); uarths_rxdata_t recv = _uarths->rxdata;
if (ret != EOF) return ret; if (recv.empty)
return EOF;
else
return (recv.data & 0xff);
} }
/* Receive Data Available */ /* Receive Data Available */
...@@ -203,7 +216,14 @@ static void uart_irq_handler(int irqno, void *param) ...@@ -203,7 +216,14 @@ static void uart_irq_handler(int irqno, void *param)
/* read interrupt status and clear it */ /* read interrupt status and clear it */
if (uart->hw_base == UARTHS_BASE_ADDR) if (uart->hw_base == UARTHS_BASE_ADDR)
{ {
if (uarths->ip.rxwm) if (_uarths->ip.rxwm)
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
} }
} }
/* WEAK for SDK 0.5.6 */
RT_WEAK void uart_debug_init(int uart_channel)
{
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册