Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
宁楠萍
rt-thread
提交
351dd923
R
rt-thread
项目概览
宁楠萍
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
351dd923
编写于
3月 11, 2015
作者:
U
unknown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bsp stm32f10x add uart4 drive
上级
a2fbc5f5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
82 addition
and
0 deletion
+82
-0
bsp/stm32f10x/drivers/usart.c
bsp/stm32f10x/drivers/usart.c
+82
-0
未找到文件。
bsp/stm32f10x/drivers/usart.c
浏览文件 @
351dd923
...
...
@@ -35,6 +35,12 @@
#define UART3_GPIO_RX GPIO_Pin_11
#define UART3_GPIO GPIOB
/* USART4 */
#define UART4_GPIO_TX GPIO_Pin_10
#define UART4_GPIO_RX GPIO_Pin_11
#define UART4_GPIO GPIOC
/* STM32 uart driver */
struct
stm32_uart
{
...
...
@@ -264,6 +270,45 @@ void USART3_IRQHandler(void)
}
#endif
/* RT_USING_UART3 */
#if defined(RT_USING_UART4)
/* UART4 device driver structure */
struct
stm32_uart
uart4
=
{
UART4
,
UART4_IRQn
,
};
struct
rt_serial_device
serial4
;
void
UART4_IRQHandler
(
void
)
{
struct
stm32_uart
*
uart
;
uart
=
&
uart4
;
/* enter interrupt */
rt_interrupt_enter
();
if
(
USART_GetITStatus
(
uart
->
uart_device
,
USART_IT_RXNE
)
!=
RESET
)
{
rt_hw_serial_isr
(
&
serial4
,
RT_SERIAL_EVENT_RX_IND
);
/* clear interrupt */
USART_ClearITPendingBit
(
uart
->
uart_device
,
USART_IT_RXNE
);
}
if
(
USART_GetITStatus
(
uart
->
uart_device
,
USART_IT_TC
)
!=
RESET
)
{
/* clear interrupt */
USART_ClearITPendingBit
(
uart
->
uart_device
,
USART_IT_TC
);
}
if
(
USART_GetFlagStatus
(
uart
->
uart_device
,
USART_FLAG_ORE
)
==
SET
)
{
stm32_getc
(
&
serial4
);
}
/* leave interrupt */
rt_interrupt_leave
();
}
#endif
/* RT_USING_UART3 */
static
void
RCC_Configuration
(
void
)
{
#if defined(RT_USING_UART1)
...
...
@@ -286,6 +331,14 @@ static void RCC_Configuration(void)
/* Enable UART clock */
RCC_APB1PeriphClockCmd
(
RCC_APB1Periph_USART3
,
ENABLE
);
#endif
/* RT_USING_UART3 */
#if defined(RT_USING_UART4)
/* Enable UART GPIO clocks */
RCC_APB2PeriphClockCmd
(
RCC_APB2Periph_GPIOC
,
ENABLE
);
/* Enable UART clock */
RCC_APB1PeriphClockCmd
(
RCC_APB1Periph_UART4
,
ENABLE
);
#endif
/* RT_USING_UART4 */
}
static
void
GPIO_Configuration
(
void
)
...
...
@@ -326,6 +379,18 @@ static void GPIO_Configuration(void)
GPIO_InitStructure
.
GPIO_Pin
=
UART3_GPIO_TX
;
GPIO_Init
(
UART3_GPIO
,
&
GPIO_InitStructure
);
#endif
/* RT_USING_UART3 */
#if defined(RT_USING_UART4)
/* Configure USART Rx/tx PIN */
GPIO_InitStructure
.
GPIO_Mode
=
GPIO_Mode_IN_FLOATING
;
GPIO_InitStructure
.
GPIO_Pin
=
UART4_GPIO_RX
;
GPIO_Init
(
UART4_GPIO
,
&
GPIO_InitStructure
);
GPIO_InitStructure
.
GPIO_Mode
=
GPIO_Mode_AF_PP
;
GPIO_InitStructure
.
GPIO_Pin
=
UART4_GPIO_TX
;
GPIO_Init
(
UART4_GPIO
,
&
GPIO_InitStructure
);
#endif
/* RT_USING_UART4 */
}
static
void
NVIC_Configuration
(
struct
stm32_uart
*
uart
)
...
...
@@ -393,4 +458,21 @@ void rt_hw_usart_init(void)
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
uart
);
#endif
/* RT_USING_UART3 */
#if defined(RT_USING_UART4)
uart
=
&
uart4
;
config
.
baud_rate
=
BAUD_RATE_115200
;
serial4
.
ops
=
&
stm32_uart_ops
;
serial4
.
config
=
config
;
NVIC_Configuration
(
&
uart4
);
/* register UART4 device */
rt_hw_serial_register
(
&
serial4
,
"uart4"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
uart
);
#endif
/* RT_USING_UART4 */
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录