Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
7563849a
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看板
提交
7563849a
编写于
1月 03, 2019
作者:
C
chenchaoqun@rt-thread.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][stm32f40x][adapt] to serial frame about dma
上级
d9a3cc9a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
3 deletion
+39
-3
bsp/stm32f40x/drivers/usart.c
bsp/stm32f40x/drivers/usart.c
+39
-3
未找到文件。
bsp/stm32f40x/drivers/usart.c
浏览文件 @
7563849a
...
...
@@ -66,6 +66,7 @@ struct stm32_uart
{
USART_TypeDef
*
uart_device
;
IRQn_Type
irq
;
#ifdef RT_SERIAL_USING_DMA
struct
stm32_uart_dma
{
/* dma stream */
...
...
@@ -81,9 +82,12 @@ struct stm32_uart
/* last receive index */
rt_size_t
last_recv_index
;
}
dma
;
#endif
/* RT_SERIAL_USING_DMA */
};
#ifdef RT_SERIAL_USING_DMA
static
void
DMA_Configuration
(
struct
rt_serial_device
*
serial
);
#endif
/* RT_SERIAL_USING_DMA */
static
rt_err_t
stm32_configure
(
struct
rt_serial_device
*
serial
,
struct
serial_configure
*
cfg
)
{
...
...
@@ -130,7 +134,6 @@ static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_c
static
rt_err_t
stm32_control
(
struct
rt_serial_device
*
serial
,
int
cmd
,
void
*
arg
)
{
struct
stm32_uart
*
uart
;
rt_uint32_t
ctrl_arg
=
(
rt_uint32_t
)(
arg
);
RT_ASSERT
(
serial
!=
RT_NULL
);
uart
=
(
struct
stm32_uart
*
)
serial
->
parent
.
user_data
;
...
...
@@ -149,11 +152,13 @@ static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *ar
/* enable interrupt */
USART_ITConfig
(
uart
->
uart_device
,
USART_IT_RXNE
,
ENABLE
);
break
;
#ifdef RT_SERIAL_USING_DMA
/* USART config */
case
RT_DEVICE_CTRL_CONFIG
:
if
(
ctrl_arg
==
RT_DEVICE_FLAG_DMA_RX
)
{
if
(
(
rt_uint32_t
)(
arg
)
==
RT_DEVICE_FLAG_DMA_RX
)
{
DMA_Configuration
(
serial
);
}
#endif
/* RT_SERIAL_USING_DMA */
}
return
RT_EOK
;
...
...
@@ -190,6 +195,7 @@ static int stm32_getc(struct rt_serial_device *serial)
return
ch
;
}
#ifdef RT_SERIAL_USING_DMA
/**
* DMA initialize by DMA_InitStruct structure
*
...
...
@@ -278,6 +284,7 @@ static void dma_rx_done_isr(struct rt_serial_device *serial)
DMA_ClearFlag
(
uart
->
dma
.
rx_stream
,
uart
->
dma
.
rx_flag
);
}
}
#endif
/* RT_SERIAL_USING_DMA */
/**
* Uart common interrupt process. This need add to uart ISR.
...
...
@@ -296,10 +303,12 @@ static void uart_isr(struct rt_serial_device *serial)
/* clear interrupt */
USART_ClearITPendingBit
(
uart
->
uart_device
,
USART_IT_RXNE
);
}
#ifdef RT_SERIAL_USING_DMA
if
(
USART_GetITStatus
(
uart
->
uart_device
,
USART_IT_IDLE
)
!=
RESET
)
{
dma_uart_rx_idle_isr
(
serial
);
}
#endif
/* RT_SERIAL_USING_DMA */
if
(
USART_GetITStatus
(
uart
->
uart_device
,
USART_IT_TC
)
!=
RESET
)
{
/* clear interrupt */
...
...
@@ -325,6 +334,7 @@ static const struct rt_uart_ops stm32_uart_ops =
struct
stm32_uart
uart1
=
{
USART1
,
#ifdef RT_SERIAL_USING_DMA
USART1_IRQn
,
{
DMA2_Stream5
,
...
...
@@ -333,6 +343,7 @@ struct stm32_uart uart1 =
DMA2_Stream5_IRQn
,
0
,
},
#endif
/* RT_SERIAL_USING_DMA */
};
struct
rt_serial_device
serial1
;
...
...
@@ -347,6 +358,7 @@ void USART1_IRQHandler(void)
rt_interrupt_leave
();
}
#ifdef RT_SERIAL_USING_DMA
void
DMA2_Stream5_IRQHandler
(
void
)
{
/* enter interrupt */
rt_interrupt_enter
();
...
...
@@ -356,6 +368,8 @@ void DMA2_Stream5_IRQHandler(void) {
/* leave interrupt */
rt_interrupt_leave
();
}
#endif
/* RT_SERIAL_USING_DMA */
#endif
/* RT_USING_UART1 */
#if defined(RT_USING_UART2)
...
...
@@ -363,6 +377,7 @@ void DMA2_Stream5_IRQHandler(void) {
struct
stm32_uart
uart2
=
{
USART2
,
#ifdef RT_SERIAL_USING_DMA
USART2_IRQn
,
{
DMA1_Stream5
,
...
...
@@ -372,6 +387,7 @@ struct stm32_uart uart2 =
0
,
0
,
},
#endif
/* RT_SERIAL_USING_DMA */
};
struct
rt_serial_device
serial2
;
...
...
@@ -386,6 +402,7 @@ void USART2_IRQHandler(void)
rt_interrupt_leave
();
}
#ifdef RT_SERIAL_USING_DMA
void
DMA1_Stream5_IRQHandler
(
void
)
{
/* enter interrupt */
rt_interrupt_enter
();
...
...
@@ -395,6 +412,8 @@ void DMA1_Stream5_IRQHandler(void) {
/* leave interrupt */
rt_interrupt_leave
();
}
#endif
/* RT_SERIAL_USING_DMA */
#endif
/* RT_USING_UART2 */
#if defined(RT_USING_UART3)
...
...
@@ -402,6 +421,7 @@ void DMA1_Stream5_IRQHandler(void) {
struct
stm32_uart
uart3
=
{
USART3
,
#ifdef RT_SERIAL_USING_DMA
USART3_IRQn
,
{
DMA1_Stream1
,
...
...
@@ -411,6 +431,7 @@ struct stm32_uart uart3 =
0
,
0
,
},
#endif
/* RT_SERIAL_USING_DMA */
};
struct
rt_serial_device
serial3
;
...
...
@@ -425,6 +446,7 @@ void USART3_IRQHandler(void)
rt_interrupt_leave
();
}
#ifdef RT_SERIAL_USING_DMA
void
DMA1_Stream1_IRQHandler
(
void
)
{
/* enter interrupt */
rt_interrupt_enter
();
...
...
@@ -434,6 +456,8 @@ void DMA1_Stream1_IRQHandler(void) {
/* leave interrupt */
rt_interrupt_leave
();
}
#endif
/* RT_SERIAL_USING_DMA */
#endif
/* RT_USING_UART3 */
#if defined(RT_USING_UART4)
...
...
@@ -441,6 +465,7 @@ void DMA1_Stream1_IRQHandler(void) {
struct
stm32_uart
uart4
=
{
UART4
,
#ifdef RT_SERIAL_USING_DMA
UART4_IRQn
,
{
DMA1_Stream2
,
...
...
@@ -450,6 +475,7 @@ struct stm32_uart uart4 =
0
,
0
,
},
#endif
/* RT_SERIAL_USING_DMA */
};
struct
rt_serial_device
serial4
;
...
...
@@ -464,6 +490,7 @@ void UART4_IRQHandler(void)
rt_interrupt_leave
();
}
#ifdef RT_SERIAL_USING_DMA
void
DMA1_Stream2_IRQHandler
(
void
)
{
/* enter interrupt */
rt_interrupt_enter
();
...
...
@@ -473,6 +500,8 @@ void DMA1_Stream2_IRQHandler(void) {
/* leave interrupt */
rt_interrupt_leave
();
}
#endif
/* RT_SERIAL_USING_DMA */
#endif
/* RT_USING_UART4 */
#if defined(RT_USING_UART5)
...
...
@@ -480,6 +509,7 @@ void DMA1_Stream2_IRQHandler(void) {
struct
stm32_uart
uart5
=
{
UART5
,
#ifdef RT_SERIAL_USING_DMA
UART5_IRQn
,
{
DMA1_Stream0
,
...
...
@@ -489,6 +519,7 @@ struct stm32_uart uart5 =
0
,
0
,
},
#endif
/* RT_SERIAL_USING_DMA */
};
struct
rt_serial_device
serial5
;
...
...
@@ -503,6 +534,7 @@ void UART5_IRQHandler(void)
rt_interrupt_leave
();
}
#ifdef RT_SERIAL_USING_DMA
void
DMA1_Stream0_IRQHandler
(
void
)
{
/* enter interrupt */
rt_interrupt_enter
();
...
...
@@ -512,6 +544,8 @@ void DMA1_Stream0_IRQHandler(void) {
/* leave interrupt */
rt_interrupt_leave
();
}
#endif
/* RT_SERIAL_USING_DMA */
#endif
/* RT_USING_UART5 */
static
void
RCC_Configuration
(
void
)
...
...
@@ -626,6 +660,7 @@ static void NVIC_Configuration(struct stm32_uart *uart)
NVIC_Init
(
&
NVIC_InitStructure
);
}
#ifdef RT_SERIAL_USING_DMA
static
void
DMA_Configuration
(
struct
rt_serial_device
*
serial
)
{
struct
stm32_uart
*
uart
=
(
struct
stm32_uart
*
)
serial
->
parent
.
user_data
;
struct
rt_serial_rx_fifo
*
rx_fifo
=
(
struct
rt_serial_rx_fifo
*
)
serial
->
serial_rx
;
...
...
@@ -653,6 +688,7 @@ static void DMA_Configuration(struct rt_serial_device *serial) {
NVIC_InitStructure
.
NVIC_IRQChannelCmd
=
ENABLE
;
NVIC_Init
(
&
NVIC_InitStructure
);
}
#endif
/* RT_SERIAL_USING_DMA */
int
stm32_hw_usart_init
(
void
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录