Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
f609a635
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,发现更多精彩内容 >>
提交
f609a635
编写于
1月 04, 2015
作者:
G
Grissiom
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lpc43xx: add uart3 support
上级
a447b5f3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
79 addition
and
11 deletion
+79
-11
bsp/lpc43xx/drivers/drv_uart.c
bsp/lpc43xx/drivers/drv_uart.c
+79
-11
未找到文件。
bsp/lpc43xx/drivers/drv_uart.c
浏览文件 @
f609a635
...
...
@@ -154,6 +154,22 @@ void UART2_IRQHandler(void)
}
#endif
#if defined(RT_USING_UART3)
struct
lpc_uart
uart3
=
{
LPC_USART3
,
USART3_IRQn
,
};
struct
rt_serial_device
serial3
;
void
UART3_IRQHandler
(
void
)
{
rt_interrupt_enter
();
_do_uart_isr
(
&
serial3
);
rt_interrupt_leave
();
}
#endif
void
rt_hw_uart_init
(
void
)
{
struct
lpc_uart
*
uart
;
...
...
@@ -194,11 +210,11 @@ void rt_hw_uart_init(void)
(
1
<<
0
)
;
/* Pin P2_1 used as U0_RXD */
/* Init USART0 */
LPC_USART0
->
LCR
=
0x83
;
/* 8 bits, no Parity, 1 Stop bit */
LPC_USART0
->
DLL
=
0x06
;
/* 115200 Baudrate @ 12 MHz IRC */
LPC_USART0
->
DLM
=
0x00
;
LPC_USART0
->
FDR
=
0xC1
;
LPC_USART0
->
LCR
=
0x03
;
/* DLAB = 0 */
uart
->
USART
->
LCR
=
0x83
;
/* 8 bits, no Parity, 1 Stop bit */
uart
->
USART
->
DLL
=
0x06
;
/* 115200 Baudrate @ 12 MHz IRC */
uart
->
USART
->
DLM
=
0x00
;
uart
->
USART
->
FDR
=
0xC1
;
uart
->
USART
->
LCR
=
0x03
;
/* DLAB = 0 */
/* preemption = 1, sub-priority = 1 */
NVIC_SetPriority
(
uart
->
USART_IRQn
,
((
0x01
<<
3
)
|
0x01
));
...
...
@@ -228,7 +244,7 @@ void rt_hw_uart_init(void)
while
(
!
(
LPC_CCU1
->
CLK_M4_GPIO_STAT
&
0x01
));
/* Enable USART2 peripheral clock */
LPC_CCU2
->
CLK_APB
0
_USART2_CFG
|=
0x01
;
LPC_CCU2
->
CLK_APB
2
_USART2_CFG
|=
0x01
;
while
(
!
(
LPC_CCU2
->
CLK_APB2_USART2_STAT
&
0x01
));
/* Enable USART2 register interface clock */
...
...
@@ -245,11 +261,11 @@ void rt_hw_uart_init(void)
(
1
<<
0
)
;
/* Pin P1_16 used as U2_RXD */
/* Init USART2 */
LPC_USART2
->
LCR
=
0x83
;
/* 8 bits, no Parity, 1 Stop bit */
LPC_USART2
->
DLL
=
0x06
;
/* 115200 Baudrate @ 12 MHz IRC */
LPC_USART2
->
DLM
=
0x00
;
LPC_USART2
->
FDR
=
0xC1
;
LPC_USART2
->
LCR
=
0x03
;
/* DLAB = 0 */
uart
->
USART
->
LCR
=
0x83
;
/* 8 bits, no Parity, 1 Stop bit */
uart
->
USART
->
DLL
=
0x06
;
/* 115200 Baudrate @ 12 MHz IRC */
uart
->
USART
->
DLM
=
0x00
;
uart
->
USART
->
FDR
=
0xC1
;
uart
->
USART
->
LCR
=
0x03
;
/* DLAB = 0 */
/* preemption = 1, sub-priority = 1 */
NVIC_SetPriority
(
uart
->
USART_IRQn
,
((
0x01
<<
3
)
|
0x01
));
...
...
@@ -262,4 +278,56 @@ void rt_hw_uart_init(void)
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
uart
);
#endif
#ifdef RT_USING_UART3
uart
=
&
uart3
;
config
.
baud_rate
=
BAUD_RATE_115200
;
config
.
bit_order
=
BIT_ORDER_LSB
;
config
.
data_bits
=
DATA_BITS_8
;
config
.
parity
=
PARITY_NONE
;
config
.
stop_bits
=
STOP_BITS_1
;
config
.
invert
=
NRZ_NORMAL
;
config
.
bufsz
=
RT_SERIAL_RB_BUFSZ
;
serial3
.
ops
=
&
lpc_uart_ops
;
serial3
.
config
=
config
;
/* Enable GPIO register interface clock */
LPC_CCU1
->
CLK_M4_GPIO_CFG
|=
0x01
;
while
(
!
(
LPC_CCU1
->
CLK_M4_GPIO_STAT
&
0x01
));
/* Enable USART3 peripheral clock */
LPC_CCU2
->
CLK_APB2_USART3_CFG
|=
0x01
;
while
(
!
(
LPC_CCU2
->
CLK_APB2_USART3_STAT
&
0x01
));
/* Enable USART3 register interface clock */
LPC_CCU1
->
CLK_M4_USART3_CFG
|=
0x01
;
while
(
!
(
LPC_CCU1
->
CLK_M4_USART3_STAT
&
0x01
));
/* Init GPIO pins */
LPC_SCU
->
SFSP2_3
=
(
1
<<
6
)
|
/* Input buffer enabled */
(
1
<<
4
)
|
/* Pull-up disabled */
(
2
<<
0
)
;
/* Pin P1_15 used as U2_TXD */
LPC_SCU
->
SFSP2_4
=
(
1
<<
6
)
|
/* Input buffer enabled */
(
1
<<
4
)
|
/* Pull-up disabled */
(
2
<<
0
)
;
/* Pin P1_16 used as U2_RXD */
/* Init USART3 */
uart
->
USART
->
LCR
=
0x83
;
/* 8 bits, no Parity, 1 Stop bit */
uart
->
USART
->
DLL
=
0x06
;
/* 115200 Baudrate @ 12 MHz IRC */
uart
->
USART
->
DLM
=
0x00
;
uart
->
USART
->
FDR
=
0xC1
;
uart
->
USART
->
LCR
=
0x03
;
/* DLAB = 0 */
/* preemption = 1, sub-priority = 1 */
NVIC_SetPriority
(
uart
->
USART_IRQn
,
((
0x01
<<
3
)
|
0x01
));
/* Enable Interrupt for UART channel */
NVIC_EnableIRQ
(
uart
->
USART_IRQn
);
/* register UART2 device */
rt_hw_serial_register
(
&
serial3
,
"uart3"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
uart
);
#endif
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录