Skip to content

Commit 3b23b29

Browse files
committed
[bsp]stm32f103keysking:add uart3
1 parent 524ae34 commit 3b23b29

File tree

6 files changed

+74
-14
lines changed

6 files changed

+74
-14
lines changed

bsp/stm32/stm32f103-keysking-learning/.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,7 @@ CONFIG_BSP_USING_GPIO=y
13891389
CONFIG_BSP_USING_UART=y
13901390
CONFIG_BSP_STM32_UART_V1_TX_TIMEOUT=2000
13911391
CONFIG_BSP_USING_UART2=y
1392+
CONFIG_BSP_USING_UART3=y
13921393
# CONFIG_BSP_USING_UDID is not set
13931394
# end of On-chip Peripheral Drivers
13941395

bsp/stm32/stm32f103-keysking-learning/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ Keysking学习板是B站UP主Keysking推出的一块基于ARM Cortex-M3内核的
4141

4242
本BSP目前对外设的支持情况如下:
4343

44-
| 板载外设 | 支持情况 | 备注 |
45-
| -------- |:--------:| ------- |
46-
| USB转串口 | 支持 | UART2 |
47-
| **片上外设** | **支持情况** | **备注** |
48-
| GPIO | 支持 | |
49-
| UART | 支持 | UART1,2 |
44+
| 板载外设 | 支持情况 | 备注 |
45+
| -------- |:--------:| ----------- |
46+
| USB转串口 | 支持 | UART2 |
47+
| **片上外设** | **支持情况** | **备注** |
48+
| GPIO | 支持 | |
49+
| UART | 支持 | UART2,3 |
5050

5151
## 使用说明
5252

@@ -121,3 +121,5 @@ STM32F103C8T6的Flash在官方文档中的大小是64KB,但是其实该芯片
121121
维护人:
122122

123123
* qianjiuyuan, 邮箱:<[email protected]>
124+
125+

bsp/stm32/stm32f103-keysking-learning/board/CubeMX_Config/CubeMX_Config.ioc

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ Mcu.IP0=NVIC
1111
Mcu.IP1=RCC
1212
Mcu.IP2=SYS
1313
Mcu.IP3=USART2
14-
Mcu.IPNb=4
14+
Mcu.IP4=USART3
15+
Mcu.IPNb=5
1516
Mcu.Name=STM32F103C(8-B)Tx
1617
Mcu.Package=LQFP48
1718
Mcu.Pin0=PC14-OSC32_IN
1819
Mcu.Pin1=PC15-OSC32_OUT
20+
Mcu.Pin10=VP_SYS_VS_Systick
1921
Mcu.Pin2=PD0-OSC_IN
2022
Mcu.Pin3=PD1-OSC_OUT
2123
Mcu.Pin4=PA2
2224
Mcu.Pin5=PA3
23-
Mcu.Pin6=PA13
24-
Mcu.Pin7=PA14
25-
Mcu.Pin8=VP_SYS_VS_Systick
26-
Mcu.PinsNb=9
25+
Mcu.Pin6=PB10
26+
Mcu.Pin7=PB11
27+
Mcu.Pin8=PA13
28+
Mcu.Pin9=PA14
29+
Mcu.PinsNb=11
2730
Mcu.ThirdPartyNb=0
2831
Mcu.UserConstants=
2932
Mcu.UserName=STM32F103C8Tx
@@ -52,6 +55,10 @@ PA3.GPIOParameters=GPIO_PuPd
5255
PA3.GPIO_PuPd=GPIO_PULLUP
5356
PA3.Mode=Asynchronous
5457
PA3.Signal=USART2_RX
58+
PB10.Mode=Asynchronous
59+
PB10.Signal=USART3_TX
60+
PB11.Mode=Asynchronous
61+
PB11.Signal=USART3_RX
5562
PC14-OSC32_IN.Mode=LSE-External-Oscillator
5663
PC14-OSC32_IN.Signal=RCC_OSC32_IN
5764
PC15-OSC32_OUT.Mode=LSE-External-Oscillator
@@ -91,7 +98,7 @@ ProjectManager.ToolChainLocation=
9198
ProjectManager.UAScriptAfterPath=
9299
ProjectManager.UAScriptBeforePath=
93100
ProjectManager.UnderRoot=false
94-
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true
101+
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_USART3_UART_Init-USART3-false-HAL-true
95102
RCC.ADCFreqValue=12000000
96103
RCC.ADCPresc=RCC_ADCPCLK2_DIV6
97104
RCC.AHBFreq_Value=72000000
@@ -117,6 +124,8 @@ RCC.USBPrescaler=RCC_USBCLKSOURCE_PLL_DIV1_5
117124
RCC.VCOOutput2Freq_Value=8000000
118125
USART2.IPParameters=VirtualMode
119126
USART2.VirtualMode=VM_ASYNC
127+
USART3.IPParameters=VirtualMode
128+
USART3.VirtualMode=VM_ASYNC
120129
VP_SYS_VS_Systick.Mode=SysTick
121130
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
122131
board=custom

bsp/stm32/stm32f103-keysking-learning/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/* USER CODE END Header */
2121

2222
/* Includes ------------------------------------------------------------------*/
23-
// #include "main.h"
23+
#include "main.h"
2424
/* USER CODE BEGIN Includes */
2525
#include <drv_common.h>
2626
/* USER CODE END Includes */
@@ -117,6 +117,33 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
117117

118118
/* USER CODE END USART2_MspInit 1 */
119119
}
120+
else if(huart->Instance==USART3)
121+
{
122+
/* USER CODE BEGIN USART3_MspInit 0 */
123+
124+
/* USER CODE END USART3_MspInit 0 */
125+
/* Peripheral clock enable */
126+
__HAL_RCC_USART3_CLK_ENABLE();
127+
128+
__HAL_RCC_GPIOB_CLK_ENABLE();
129+
/**USART3 GPIO Configuration
130+
PB10 ------> USART3_TX
131+
PB11 ------> USART3_RX
132+
*/
133+
GPIO_InitStruct.Pin = GPIO_PIN_10;
134+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
135+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
136+
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
137+
138+
GPIO_InitStruct.Pin = GPIO_PIN_11;
139+
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
140+
GPIO_InitStruct.Pull = GPIO_NOPULL;
141+
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
142+
143+
/* USER CODE BEGIN USART3_MspInit 1 */
144+
145+
/* USER CODE END USART3_MspInit 1 */
146+
}
120147

121148
}
122149

@@ -146,6 +173,24 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
146173

147174
/* USER CODE END USART2_MspDeInit 1 */
148175
}
176+
else if(huart->Instance==USART3)
177+
{
178+
/* USER CODE BEGIN USART3_MspDeInit 0 */
179+
180+
/* USER CODE END USART3_MspDeInit 0 */
181+
/* Peripheral clock disable */
182+
__HAL_RCC_USART3_CLK_DISABLE();
183+
184+
/**USART3 GPIO Configuration
185+
PB10 ------> USART3_TX
186+
PB11 ------> USART3_RX
187+
*/
188+
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
189+
190+
/* USER CODE BEGIN USART3_MspDeInit 1 */
191+
192+
/* USER CODE END USART3_MspDeInit 1 */
193+
}
149194

150195
}
151196

bsp/stm32/stm32f103-keysking-learning/board/Kconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ menu "On-chip Peripheral Drivers"
2323
select RT_USING_SERIAL
2424

2525
if BSP_USING_UART
26-
2726
config BSP_STM32_UART_V1_TX_TIMEOUT
2827
int "UART TX timeout"
2928
default 2000
3029
depends on RT_USING_SERIAL_V1
3130
config BSP_USING_UART2
3231
bool "Enable UART2"
3332
default y
33+
config BSP_USING_UART3
34+
bool "Enable UART3"
35+
default y
3436

3537
#config BSP_UART2_RX_USING_DMA
3638
# bool "Enable UART2 RX DMA"

bsp/stm32/stm32f103-keysking-learning/rtconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@
411411
#define BSP_USING_UART
412412
#define BSP_STM32_UART_V1_TX_TIMEOUT 2000
413413
#define BSP_USING_UART2
414+
#define BSP_USING_UART3
414415
/* end of On-chip Peripheral Drivers */
415416

416417
/* Board extended module Drivers */

0 commit comments

Comments
 (0)