Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
168b8502
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,发现更多精彩内容 >>
提交
168b8502
编写于
12月 20, 2018
作者:
N
nongxiaoming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][stm32h743-nucleo] add the usart3 driver and use for console.
上级
574abc8a
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
643 addition
and
1296 deletion
+643
-1296
bsp/stm32h743-nucleo/drivers/drv_usart.c
bsp/stm32h743-nucleo/drivers/drv_usart.c
+93
-1
bsp/stm32h743-nucleo/project.uvoptx
bsp/stm32h743-nucleo/project.uvoptx
+361
-885
bsp/stm32h743-nucleo/project.uvprojx
bsp/stm32h743-nucleo/project.uvprojx
+188
-409
bsp/stm32h743-nucleo/rtconfig.h
bsp/stm32h743-nucleo/rtconfig.h
+1
-1
未找到文件。
bsp/stm32h743-nucleo/drivers/drv_usart.c
浏览文件 @
168b8502
...
@@ -30,6 +30,22 @@
...
@@ -30,6 +30,22 @@
#define USART1_RX_GPIO_PORT GPIOB
#define USART1_RX_GPIO_PORT GPIOB
#define USART1_RX_AF GPIO_AF7_USART1
#define USART1_RX_AF GPIO_AF7_USART1
/* Definition for USART3 clock resources */
#define USART3_CLK_ENABLE() __USART3_CLK_ENABLE()
#define USART3_RX_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE()
#define USART3_TX_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE()
#define USART3_FORCE_RESET() __USART3_FORCE_RESET()
#define USART3_RELEASE_RESET() __USART3_RELEASE_RESET()
/* Definition for USARTx Pins */
#define USART3_TX_PIN GPIO_PIN_8
#define USART3_TX_GPIO_PORT GPIOD
#define USART3_TX_AF GPIO_AF7_USART3
#define USART3_RX_PIN GPIO_PIN_9
#define USART3_RX_GPIO_PORT GPIOD
#define USART3_RX_AF GPIO_AF7_USART3
/* STM32 uart driver */
/* STM32 uart driver */
struct
stm32_uart
struct
stm32_uart
{
{
...
@@ -195,8 +211,33 @@ void USART1_IRQHandler(void)
...
@@ -195,8 +211,33 @@ void USART1_IRQHandler(void)
/* leave interrupt */
/* leave interrupt */
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
#endif
/* RT_USING_UART1 */
#endif
/* RT_USING_UART3 */
#if defined(RT_USING_UART3)
/* UART1 device driver structure */
static
struct
stm32_uart
uart3
;
struct
rt_serial_device
serial3
;
void
USART3_IRQHandler
(
void
)
{
struct
stm32_uart
*
uart
;
uart
=
&
uart3
;
/* enter interrupt */
rt_interrupt_enter
();
/* UART in mode Receiver ---------------------------------------------------*/
if
((
__HAL_UART_GET_IT
(
&
uart
->
UartHandle
,
UART_IT_RXNE
)
!=
RESET
)
&&
(
__HAL_UART_GET_IT_SOURCE
(
&
uart
->
UartHandle
,
UART_IT_RXNE
)
!=
RESET
))
{
rt_hw_serial_isr
(
&
serial3
,
RT_SERIAL_EVENT_RX_IND
);
/* Clear RXNE interrupt flag */
__HAL_UART_SEND_REQ
(
&
uart
->
UartHandle
,
UART_RXDATA_FLUSH_REQUEST
);
}
/* leave interrupt */
rt_interrupt_leave
();
}
#endif
/* RT_USING_UART3 */
/**
/**
* @brief UART MSP Initialization
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example:
* This function configures the hardware resources used in this example:
...
@@ -233,6 +274,31 @@ void HAL_UART_MspInit(UART_HandleTypeDef *huart)
...
@@ -233,6 +274,31 @@ void HAL_UART_MspInit(UART_HandleTypeDef *huart)
/* NVIC for USART */
/* NVIC for USART */
HAL_NVIC_SetPriority
(
USART1_IRQn
,
0
,
1
);
HAL_NVIC_SetPriority
(
USART1_IRQn
,
0
,
1
);
HAL_NVIC_EnableIRQ
(
USART1_IRQn
);
HAL_NVIC_EnableIRQ
(
USART1_IRQn
);
}
if
(
huart
->
Instance
==
USART3
)
{
/* Enable GPIO TX/RX clock */
USART3_TX_GPIO_CLK_ENABLE
();
USART3_RX_GPIO_CLK_ENABLE
();
/* Enable USARTx clock */
USART3_CLK_ENABLE
();
/* UART TX GPIO pin configuration */
GPIO_InitStruct
.
Pin
=
USART3_TX_PIN
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_PULLUP
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_VERY_HIGH
;
GPIO_InitStruct
.
Alternate
=
USART3_TX_AF
;
HAL_GPIO_Init
(
USART3_TX_GPIO_PORT
,
&
GPIO_InitStruct
);
/* UART RX GPIO pin configuration */
GPIO_InitStruct
.
Pin
=
USART3_RX_PIN
;
GPIO_InitStruct
.
Alternate
=
USART3_RX_AF
;
HAL_GPIO_Init
(
USART3_RX_GPIO_PORT
,
&
GPIO_InitStruct
);
/* NVIC for USART */
HAL_NVIC_SetPriority
(
USART3_IRQn
,
0
,
1
);
HAL_NVIC_EnableIRQ
(
USART3_IRQn
);
}
}
}
}
...
@@ -260,6 +326,21 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
...
@@ -260,6 +326,21 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
/* Disable the NVIC for UART */
/* Disable the NVIC for UART */
HAL_NVIC_DisableIRQ
(
USART1_IRQn
);
HAL_NVIC_DisableIRQ
(
USART1_IRQn
);
}
if
(
huart
->
Instance
==
USART3
)
{
/* Reset peripherals */
USART3_FORCE_RESET
();
USART3_RELEASE_RESET
();
/* Disable peripherals and GPIO Clocks */
/* Configure UART Tx as alternate function */
HAL_GPIO_DeInit
(
USART3_TX_GPIO_PORT
,
USART3_TX_PIN
);
/* Configure UART Rx as alternate function */
HAL_GPIO_DeInit
(
USART3_RX_GPIO_PORT
,
USART3_RX_PIN
);
/* Disable the NVIC for UART */
HAL_NVIC_DisableIRQ
(
USART3_IRQn
);
}
}
}
}
...
@@ -280,7 +361,18 @@ int stm32_hw_usart_init(void)
...
@@ -280,7 +361,18 @@ int stm32_hw_usart_init(void)
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
uart
);
uart
);
#endif
/* RT_USING_UART1 */
#endif
/* RT_USING_UART1 */
#ifdef RT_USING_UART3
uart
=
&
uart3
;
uart
->
UartHandle
.
Instance
=
USART3
;
serial3
.
ops
=
&
stm32_uart_ops
;
serial3
.
config
=
config
;
/* register UART3 device */
rt_hw_serial_register
(
&
serial3
,
"uart3"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
uart
);
#endif
/* RT_USING_UART3 */
return
0
;
return
0
;
}
}
INIT_BOARD_EXPORT
(
stm32_hw_usart_init
);
INIT_BOARD_EXPORT
(
stm32_hw_usart_init
);
bsp/stm32h743-nucleo/project.uvoptx
浏览文件 @
168b8502
此差异已折叠。
点击以展开。
bsp/stm32h743-nucleo/project.uvprojx
浏览文件 @
168b8502
此差异已折叠。
点击以展开。
bsp/stm32h743-nucleo/rtconfig.h
浏览文件 @
168b8502
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
/* RT_USING_INTERRUPT_INFO is not set */
/* RT_USING_INTERRUPT_INFO is not set */
#define RT_USING_CONSOLE
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart
1
"
#define RT_CONSOLE_DEVICE_NAME "uart
3
"
/* RT-Thread Components */
/* RT-Thread Components */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录