Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2345VOR
rt-thread
提交
a447b5f3
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,发现更多精彩内容 >>
提交
a447b5f3
编写于
1月 04, 2015
作者:
G
Grissiom
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lpc43xx: refactor uart drivers
上级
c3515abf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
54 addition
and
99 deletion
+54
-99
bsp/lpc43xx/Libraries/Device/NXP/LPC43xx/Source/Templates/ARM/startup_LPC43xx_M0.s
...ice/NXP/LPC43xx/Source/Templates/ARM/startup_LPC43xx_M0.s
+9
-9
bsp/lpc43xx/drivers/drv_uart.c
bsp/lpc43xx/drivers/drv_uart.c
+45
-90
未找到文件。
bsp/lpc43xx/Libraries/Device/NXP/LPC43xx/Source/Templates/ARM/startup_LPC43xx_M0.s
浏览文件 @
a447b5f3
...
...
@@ -96,10 +96,10 @@ __Vectors DCD __initial_sp ; 0 Top of Stack
DCD
ADC1_IRQHandler
; 37 ADC1
DCD
SSP0_OR_SSP1_IRQHandler
; 38 SSP0 or SSP1
DCD
EVENTROUTER_IRQHandler
; 39 Event router
DCD
U
SART0_IRQHandler
; 40 USART0
DCD
U
ART0_IRQHandler
; 40 USART0
DCD
UART1_IRQHandler
; 41 UART1/Modem
DCD
U
SART2_OR_C_CAN1_IRQHandler
; 42 USART2 or C CAN1
DCD
U
SART3_IRQHandler
; 43 USART3
DCD
U
ART2_OR_C_CAN1_IRQHandler
; 42 USART2 or C CAN1
DCD
U
ART3_IRQHandler
; 43 USART3
DCD
I2S0_OR_I2S1_OR_QEI_IRQHandler
; 44 I2S0 or I2S1 or QEI
DCD
C_CAN0_IRQHandler
; 45 C CAN0
DCD
0
; 46 Reserved
...
...
@@ -175,10 +175,10 @@ Default_Handler PROC
EXPORT
ADC1_IRQHandler
[
WEAK
]
EXPORT
SSP0_OR_SSP1_IRQHandler
[
WEAK
]
EXPORT
EVENTROUTER_IRQHandler
[
WEAK
]
EXPORT
U
SART0_IRQHandler
[
WEAK
]
EXPORT
U
ART0_IRQHandler
[
WEAK
]
EXPORT
UART1_IRQHandler
[
WEAK
]
EXPORT
U
SART2_OR_C_CAN1_IRQHandler
[
WEAK
]
EXPORT
U
SART3_IRQHandler
[
WEAK
]
EXPORT
U
ART2_OR_C_CAN1_IRQHandler
[
WEAK
]
EXPORT
U
ART3_IRQHandler
[
WEAK
]
EXPORT
I2S0_OR_I2S1_OR_QEI_IRQHandler
[
WEAK
]
EXPORT
C_CAN0_IRQHandler
[
WEAK
]
...
...
@@ -206,10 +206,10 @@ SPI_OR_DAC_IRQHandler
ADC1_IRQHandler
SSP0_OR_SSP1_IRQHandler
EVENTROUTER_IRQHandler
U
S
ART0_IRQHandler
UART0_IRQHandler
UART1_IRQHandler
U
S
ART2_OR_C_CAN1_IRQHandler
U
S
ART3_IRQHandler
UART2_OR_C_CAN1_IRQHandler
UART3_IRQHandler
I2S0_OR_I2S1_OR_QEI_IRQHandler
C_CAN0_IRQHandler
...
...
bsp/lpc43xx/drivers/drv_uart.c
浏览文件 @
a447b5f3
...
...
@@ -26,19 +26,7 @@ struct lpc_uart
static
rt_err_t
lpc_configure
(
struct
rt_serial_device
*
serial
,
struct
serial_configure
*
cfg
)
{
// struct lpc_uart *uart;
RT_ASSERT
(
serial
!=
RT_NULL
);
// uart = (struct lpc_uart *)serial->parent.user_data;
// Initialize FIFO for UART0 peripheral
// UART_FIFOConfig(uart->USART, &UARTFIFOConfigStruct);
// UART_TxCmd(uart->USART, ENABLE);
return
RT_EOK
;
}
...
...
@@ -95,60 +83,62 @@ static const struct rt_uart_ops lpc_uart_ops =
lpc_getc
,
};
#if defined(RT_USING_UART0)
/* UART0 device driver structure */
struct
lpc_uart
uart0
=
{
LPC_USART0
,
USART0_IRQn
,
};
struct
rt_serial_device
serial0
;
void
UART0_IRQHandler
(
void
)
static
void
_do_uart_isr
(
struct
rt_serial_device
*
sdev
)
{
struct
lpc_uart
*
uart
;
volatile
uint32_t
intsrc
,
temp
;
uart
=
&
uart0
;
/* enter interrupt */
rt_interrupt_enter
();
uart
=
sdev
->
parent
.
user_data
;
/* Determine the interrupt source */
intsrc
=
uart
->
USART
->
IIR
&
UART_IIR_INTID_MASK
;
switch
(
intsrc
)
{
case
UART_IIR_INTID_RLS
:
/* Receive Line Status interrupt
*/
case
UART_IIR_INTID_RLS
:
/* Receive Line Status interrupt
*/
/* read the line status */
intsrc
=
uart
->
USART
->
LSR
;
/* Receive an error data */
if
(
intsrc
&
UART_LSR_PE
)
{
temp
=
LPC_USART0
->
RBR
;
temp
=
uart
->
USART
->
RBR
;
}
break
;
case
UART_IIR_INTID_RDA
:
/* Receive data */
case
UART_IIR_INTID_CTI
:
/* Receive data timeout */
case
UART_IIR_INTID_RDA
:
/* Receive data */
case
UART_IIR_INTID_CTI
:
/* Receive data timeout */
/* read the data to buffer */
while
(
uart
->
USART
->
LSR
&
UART_LSR_RDR
)
{
rt_hw_serial_isr
(
&
serial0
,
RT_SERIAL_EVENT_RX_IND
);
rt_hw_serial_isr
(
sdev
,
RT_SERIAL_EVENT_RX_IND
);
}
break
;
default:
break
;
}
}
/* leave interrupt */
#if defined(RT_USING_UART0)
/* UART0 device driver structure */
struct
lpc_uart
uart0
=
{
LPC_USART0
,
USART0_IRQn
,
};
struct
rt_serial_device
serial0
;
void
UART0_IRQHandler
(
void
)
{
rt_interrupt_enter
();
_do_uart_isr
(
&
serial0
);
rt_interrupt_leave
();
}
#endif
#if defined(RT_USING_UART2)
/* UART2 device driver structure */
struct
lpc_uart
uart2
=
{
LPC_USART2
,
...
...
@@ -158,47 +148,12 @@ struct rt_serial_device serial2;
void
UART2_IRQHandler
(
void
)
{
struct
lpc_uart
*
uart
;
uint32_t
intsrc
,
temp
;
uart
=
&
uart2
;
/* enter interrupt */
rt_interrupt_enter
();
/* Determine the interrupt source */
intsrc
=
uart
->
USART
->
IIR
&
UART_IIR_INTID_MASK
;
switch
(
intsrc
)
{
case
UART_IIR_INTID_RLS
:
/* Receive Line Status interrupt*/
/* read the line status */
intsrc
=
uart
->
USART
->
LSR
;
/* Receive an error data */
if
(
intsrc
&
UART_LSR_PE
)
{
temp
=
LPC_USART0
->
RBR
;
}
break
;
case
UART_IIR_INTID_RDA
:
/* Receive data */
case
UART_IIR_INTID_CTI
:
/* Receive data timeout */
/* read the data to buffer */
while
(
uart
->
USART
->
LSR
&
UART_LSR_RDR
)
{
rt_hw_serial_isr
(
&
serial0
,
RT_SERIAL_EVENT_RX_IND
);
}
break
;
default:
break
;
}
/* leave interrupt */
_do_uart_isr
(
&
serial2
);
rt_interrupt_leave
();
}
#endif
void
rt_hw_uart_init
(
void
)
{
struct
lpc_uart
*
uart
;
...
...
@@ -212,7 +167,7 @@ void rt_hw_uart_init(void)
config
.
parity
=
PARITY_NONE
;
config
.
stop_bits
=
STOP_BITS_1
;
config
.
invert
=
NRZ_NORMAL
;
config
.
bufsz
=
RT_SERIAL_RB_BUFSZ
;
config
.
bufsz
=
RT_SERIAL_RB_BUFSZ
;
serial0
.
ops
=
&
lpc_uart_ops
;
serial0
.
config
=
config
;
...
...
@@ -221,22 +176,22 @@ void rt_hw_uart_init(void)
LPC_CCU1
->
CLK_M4_GPIO_CFG
|=
0x01
;
while
(
!
(
LPC_CCU1
->
CLK_M4_GPIO_STAT
&
0x01
));
/* Enable USART
1
peripheral clock */
/* Enable USART
0
peripheral clock */
LPC_CCU2
->
CLK_APB0_USART0_CFG
|=
0x01
;
while
(
!
(
LPC_CCU2
->
CLK_APB0_USART0_STAT
&
0x01
));
/* Enable USART
1
register interface clock */
/* Enable USART
0
register interface clock */
LPC_CCU1
->
CLK_M4_USART0_CFG
|=
0x01
;
while
(
!
(
LPC_CCU1
->
CLK_M4_USART0_STAT
&
0x01
));
/* Init GPIO pins */
LPC_SCU
->
SFSP2_0
=
(
1
<<
6
)
|
/* Input buffer enabled */
(
1
<<
4
)
|
/* Pull-up disabled */
(
1
<<
0
)
;
/* Pin P2_0 used as U0_TXD */
(
1
<<
4
)
|
/* Pull-up disabled */
(
1
<<
0
)
;
/* Pin P2_0 used as U0_TXD */
LPC_SCU
->
SFSP2_1
=
(
1
<<
6
)
|
/* Input buffer enabled */
(
1
<<
4
)
|
/* Pull-up disabled */
(
1
<<
0
)
;
/* Pin P2_1 used as U0_RXD */
(
1
<<
4
)
|
/* Pull-up disabled */
(
1
<<
0
)
;
/* Pin P2_1 used as U0_RXD */
/* Init USART0 */
LPC_USART0
->
LCR
=
0x83
;
/* 8 bits, no Parity, 1 Stop bit */
...
...
@@ -250,7 +205,7 @@ void rt_hw_uart_init(void)
/* Enable Interrupt for UART channel */
NVIC_EnableIRQ
(
uart
->
USART_IRQn
);
/* register UART
1
device */
/* register UART
0
device */
rt_hw_serial_register
(
&
serial0
,
"uart0"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
uart
);
...
...
@@ -263,7 +218,7 @@ void rt_hw_uart_init(void)
config
.
parity
=
PARITY_NONE
;
config
.
stop_bits
=
STOP_BITS_1
;
config
.
invert
=
NRZ_NORMAL
;
config
.
bufsz
=
RT_SERIAL_RB_BUFSZ
;
config
.
bufsz
=
RT_SERIAL_RB_BUFSZ
;
serial2
.
ops
=
&
lpc_uart_ops
;
serial2
.
config
=
config
;
...
...
@@ -272,22 +227,22 @@ void rt_hw_uart_init(void)
LPC_CCU1
->
CLK_M4_GPIO_CFG
|=
0x01
;
while
(
!
(
LPC_CCU1
->
CLK_M4_GPIO_STAT
&
0x01
));
/* Enable USART
1
peripheral clock */
LPC_CCU2
->
CLK_APB0_USART
0
_CFG
|=
0x01
;
/* Enable USART
2
peripheral clock */
LPC_CCU2
->
CLK_APB0_USART
2
_CFG
|=
0x01
;
while
(
!
(
LPC_CCU2
->
CLK_APB2_USART2_STAT
&
0x01
));
/* Enable USART2 register interface clock */
LPC_CCU1
->
CLK_M4_USART
0
_CFG
|=
0x01
;
LPC_CCU1
->
CLK_M4_USART
2
_CFG
|=
0x01
;
while
(
!
(
LPC_CCU1
->
CLK_M4_USART2_STAT
&
0x01
));
/* Init GPIO pins */
LPC_SCU
->
SFSP1_15
=
(
1
<<
6
)
|
/* Input buffer enabled */
(
1
<<
4
)
|
/* Pull-up disabled */
(
1
<<
0
)
;
/* Pin P1_15 used as U2_TXD */
(
1
<<
4
)
|
/* Pull-up disabled */
(
1
<<
0
)
;
/* Pin P1_15 used as U2_TXD */
LPC_SCU
->
SFSP1_16
=
(
1
<<
6
)
|
/* Input buffer enabled */
(
1
<<
4
)
|
/* Pull-up disabled */
(
1
<<
0
)
;
/* Pin P1_16 used as U2_RXD */
(
1
<<
4
)
|
/* Pull-up disabled */
(
1
<<
0
)
;
/* Pin P1_16 used as U2_RXD */
/* Init USART2 */
LPC_USART2
->
LCR
=
0x83
;
/* 8 bits, no Parity, 1 Stop bit */
...
...
@@ -295,14 +250,14 @@ void rt_hw_uart_init(void)
LPC_USART2
->
DLM
=
0x00
;
LPC_USART2
->
FDR
=
0xC1
;
LPC_USART2
->
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 UART
1
device */
/* register UART
2
device */
rt_hw_serial_register
(
&
serial2
,
"uart2"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
uart
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录