Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
5df3ac20
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5df3ac20
编写于
10月 11, 2019
作者:
lymzzyh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][k210] update sdk support for v0.5.6
上级
8e6ec4df
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
23 deletion
+36
-23
bsp/k210/driver/board.c
bsp/k210/driver/board.c
+0
-7
bsp/k210/driver/drv_uart.c
bsp/k210/driver/drv_uart.c
+36
-16
未找到文件。
bsp/k210/driver/board.c
浏览文件 @
5df3ac20
...
@@ -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
;
...
...
bsp/k210/driver/drv_uart.c
浏览文件 @
5df3ac20
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录