Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2345VOR
rt-thread
提交
421d980b
R
rt-thread
项目概览
2345VOR
/
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,发现更多精彩内容 >>
提交
421d980b
编写于
7月 24, 2013
作者:
R
reynoldxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add NRZ feature on K60
上级
a927b480
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
86 addition
and
12 deletion
+86
-12
bsp/K60Fxxxx/K60/K60.pro
bsp/K60Fxxxx/K60/K60.pro
+43
-0
bsp/K60Fxxxx/drivers/drv_uart.c
bsp/K60Fxxxx/drivers/drv_uart.c
+43
-12
未找到文件。
bsp/K60Fxxxx/K60/K60.pro
0 → 100644
浏览文件 @
421d980b
HEADERS
+=
\
..
/
rtconfig
.
h
\
..
/
drivers
/
led
.
h
\
..
/
drivers
/
drv_uart
.
h
\
..
/
drivers
/
board
.
h
\
..
/../../
components
/
drivers
/
include
/
rtdevice
.
h
\
..
/../../
components
/
drivers
/
include
/
drivers
/
serial
.
h
\
..
/../../
include
/
rtthread
.
h
\
..
/../../
include
/
rtservice
.
h
\
..
/../../
include
/
rtm
.
h
\
..
/../../
include
/
rthw
.
h
\
..
/../../
include
/
rtdef
.
h
\
..
/../../
include
/
rtdebug
.
h
\
..
/../../
src
/
module
.
h
\
..
/../../../../../../../
Keil
/
ARM
/
INC
/
Freescale
/
Kinetis
/
MK60F12
.
H
SOURCES
+=
\
..
/
applications
/
startup
.
c
\
..
/
applications
/
application
.
c
\
..
/
drivers
/
system_MK60F12
.
c
\
..
/
drivers
/
led
.
c
\
..
/
drivers
/
drv_uart
.
c
\
..
/
drivers
/
board
.
c
\
..
/../../
components
/
drivers
/
serial
/
serial
.
c
\
..
/../../
src
/
timer
.
c
\
..
/../../
src
/
thread
.
c
\
..
/../../
src
/
slab
.
c
\
..
/../../
src
/
scheduler
.
c
\
..
/../../
src
/
object
.
c
\
..
/../../
src
/
module
.
c
\
..
/../../
src
/
mempool
.
c
\
..
/../../
src
/
memheap
.
c
\
..
/../../
src
/
mem
.
c
\
..
/../../
src
/
kservice
.
c
\
..
/../../
src
/
irq
.
c
\
..
/../../
src
/
ipc
.
c
\
..
/../../
src
/
idle
.
c
\
..
/../../
src
/
device
.
c
\
..
/../../
src
/
clock
.
c
OTHER_FILES
+=
\
..
/
drivers
/
startup_MK60F12
.
s
\
..
/../../
src
/
SConscript
bsp/K60Fxxxx/drivers/drv_uart.c
浏览文件 @
421d980b
...
...
@@ -39,52 +39,83 @@ static struct k60_serial_device _k60_node =
static
rt_err_t
_configure
(
struct
rt_serial_device
*
serial
,
struct
serial_configure
*
cfg
)
{
unsigned
int
reg_C1
=
0
,
reg_C4
=
0
,
reg_BDH
=
0
,
reg_BDL
=
0
,
reg_S2
,
reg_BRFA
=
0
;
unsigned
int
reg_C1
=
0
,
reg_C
3
=
0
,
reg_C
4
=
0
,
reg_BDH
=
0
,
reg_BDL
=
0
,
reg_S2
,
reg_BRFA
=
0
;
unsigned
int
cal_SBR
=
0
;
UART_Type
*
uart_reg
;
/* ref : drivers\system_MK60F12.c Line 64 ,BusClock = 60MHz */
/* ref : drivers\system_MK60F12.c Line 64 ,BusClock = 60MHz
* calculate baud_rate
*/
uart_reg
=
((
struct
k60_serial_device
*
)
serial
->
parent
.
user_data
)
->
baseAddress
;
/
/calc SBR
/
* calc SBR */
cal_SBR
=
60000000
/
(
16
*
cfg
->
baud_rate
);
/
/calc baud_rate
/
* calc baud_rate */
reg_BDH
=
(
cal_SBR
&
0x1FFF
)
>>
8
&
0x00FF
;
reg_BDL
=
cal_SBR
&
0x00FF
;
/
/fractional divider
/
* fractional divider */
reg_BRFA
=
((
60000
*
32000
)
/
(
cfg
->
baud_rate
*
16
))
-
(
cal_SBR
*
32
);
reg_C4
=
(
unsigned
char
)(
reg_BRFA
&
0x001F
);
//calc bit_order
/*
* set bit order
*/
if
(
cfg
->
bit_order
==
BIT_ORDER_LSB
)
reg_S2
&=
~
(
UART_S2_MSBF_MASK
<<
UART_S2_MSBF_SHIFT
);
else
if
(
cfg
->
bit_order
==
BIT_ORDER_MSB
)
reg_S2
|=
UART_S2_MSBF_MASK
<<
UART_S2_MSBF_SHIFT
;
//calc data_bits
/*
* set data_bits
*/
if
(
cfg
->
data_bits
==
DATA_BITS_8
)
reg_C1
&=
~
(
UART_C1_M_MASK
<<
UART_C1_M_SHIFT
);
else
if
(
cfg
->
data_bits
==
DATA_BITS_9
)
reg_C1
|=
UART_C1_M_MASK
<<
UART_C1_M_SHIFT
;
//clac parity
/*
* set parity
*/
if
(
cfg
->
parity
==
PARITY_NONE
)
reg_C1
&=
~
(
UART_C1_PE_MASK
<<
UART_C1_PE_SHIFT
);
{
reg_C1
&=
~
(
UART_C1_PE_MASK
);
}
else
{
reg_C1
&=
~
(
UART_C1_PE_MASK
<<
UART_C1_PE_SHIFT
);
/* first ,set parity enable bit */
reg_C1
|=
(
UART_C1_PE_MASK
);
/* second ,determine parity odd or even*/
if
(
cfg
->
parity
==
PARITY_ODD
)
reg_C1
|=
UART_C1_PT_MASK
<<
UART_C1_PT_SHIFT
;
reg_C1
|=
UART_C1_PT_MASK
;
if
(
cfg
->
parity
==
PARITY_EVEN
)
reg_C1
&=
~
(
UART_C1_PT_MASK
<<
UART_C1_PT_SHIFT
);
reg_C1
&=
~
(
UART_C1_PT_MASK
);
}
/*
* set stop bit
* not supported on Tower? need ur help!
*/
/*
* set NZR mode
* not tested
*/
if
(
cfg
->
invert
!=
NRZ_NORMAL
)
{
/* not in normal mode ,set inverted polarity */
reg_C3
|=
UART_C3_TXINV_MASK
;
}
switch
(
(
int
)
uart_reg
)
{
/* Tower board use UART5 for communication
* if you're using other board
* set clock and pin map for UARTx
*/
case
UART5_BASE
:
//set UART5 clock
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录