4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-19 12:13:36 +08:00

[bsp][stm32]: add stm32h503 rtduino (#8448)

This commit is contained in:
Shicheng Chu 2023-12-29 19:46:28 +08:00 committed by GitHub
parent 7c4749eb1b
commit be2119e0f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 1242 additions and 39 deletions

View File

@ -2,8 +2,8 @@ from building import *
import os
cwd = GetCurrentDir()
CPPPATH = [cwd]
src = Glob('*.c')
CPPPATH = [cwd]
if GetDepend(['PKG_USING_RTDUINO']) and not GetDepend(['RTDUINO_NO_SETUP_LOOP']):
src += ['arduino_main.cpp']

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-12-29 ChuShicheng first version
*/
#include <Arduino.h>
void setup(void)
{
/* put your setup code here, to run once: */
Serial2.begin();
}
void loop(void)
{
/* put your main code here, to run repeatedly: */
Serial2.println("Hello Arduino!");
delay(800);
}

View File

@ -0,0 +1,49 @@
# stm32h503-st-nucleo 开发板的Arduino生态兼容说明
## 1 RTduino - RT-Thread的Arduino生态兼容层
stm32h503-st-nucleo 开发板已经完整适配了[RTduino软件包](https://github.com/RTduino/RTduino)即RT-Thread的Arduino生态兼容层。用户可以按照Arduino的编程习惯来操作该BSP并且可以使用大量Arduino社区丰富的库是对RT-Thread生态的极大增强。更多信息请参见[RTduino软件包说明文档](https://github.com/RTduino/RTduino)。
### 1.1 如何开启针对本BSP的Arduino生态兼容层
Env 工具下敲入 menuconfig 命令,或者 RT-Thread Studio IDE 下选择 RT-Thread Settings
```Kconfig
Hardware Drivers Config --->
Onboard Peripheral Drivers --->
[*] Compatible with Arduino Ecosystem (RTduino)
```
## 2 Arduino引脚排布
更多引脚布局相关信息参见 [pins_arduino.c](pins_arduino.c) 和 [pins_arduino.h](pins_arduino.h)。
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
| ------------------- | --------- | ---- | ------------------------------------------------------------------------- |
| 0 (D0) | GET_PIN(B, 15) | 是 | Serial2-RX,默认被RT-Thread的UART设备框架uart1接管 |
| 1 (D1) | GET_PIN(B, 14) | 是 | Serial2-TX,默认被RT-Thread的UART设备框架uart1接管 |
| 2 (D2) | GET_PIN(A, 10) | 是 | |
| 3 (D3) | GET_PIN(B, 3) | 是 | |
| 4 (D4) | GET_PIN(B, 5) | 是 | |
| 5 (D5) | GET_PIN(B, 4) | 是 | PWM1-CH2,默认被RT-Thread的PWM设备框架pwm1接管 |
| 6 (D6) | GET_PIN(B, 10) | 是 | PWM2-CH3,默认被RT-Thread的PWM设备框架pwm2接管 |
| 7 (D7) | GET_PIN(A, 8) | 是 | |
| 8 (D8) | GET_PIN(C, 7) | 是 | |
| 9 (D9) | GET_PIN(C, 6) | 是 | PWM3-CH1,默认被RT-Thread的PWM设备框架pwm3接管 |
| 10 (D10) | GET_PIN(C, 9) | 是 | PWM3-CH4,默认被RT-Thread的PWM设备框架pwm3接管 |
| 11 (D11) | GET_PIN(A, 7) | 是 | PWM3-CH2,默认被RT-Thread的PWM设备框架pwm3接管 |
| 12 (D12) | GET_PIN(A, 6) | 是 | |
| 13 (D13) | GET_PIN(A, 5) | 是 | 板载用户LED |
| 14 (D14) | GET_PIN(B, 7) | 是 | I2C1-SDA,默认被RT-Thread的I2C设备框架i2c1接管 |
| 15 (D15) | GET_PIN(B, 6) | 是 | I2C1-SCL,默认被RT-Thread的I2C设备框架i2c1接管 |
| 16 (A0) | GET_PIN(A, 0) | 是 | ADC1-CH0,默认被RT-Thread的ADC设备框架adc1接管 |
| 17 (A1) | GET_PIN(A, 1) | 是 | ADC1-CH1,默认被RT-Thread的ADC设备框架adc1接管 |
| 18 (A2) | GET_PIN(A, 2) | 是 | ADC1-CH14,默认被RT-Thread的ADC设备框架adc1接管 |
| 19 (A3) | GET_PIN(B, 0) | 是 | ADC1-CH9,默认被RT-Thread的ADC设备框架adc1接管 |
| 20 (A4) | GET_PIN(C, 1) | 是 | ADC1-CH11,默认被RT-Thread的ADC设备框架adc1接管 |
| 21 (A5) | GET_PIN(C, 0) | 是 | ADC1-CH10,默认被RT-Thread的ADC设备框架adc1接管 |
> 注意:
>
> 1. xxxxxxxxx
> 2. xxxxxxxxx

View File

@ -0,0 +1,9 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c') + Glob('*.cpp')
inc = [cwd]
group = DefineGroup('RTduino', src, depend = ['PKG_USING_RTDUINO'], CPPPATH = inc)
Return('group')

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-12-25 ChuShicheng first version
*/
#include <Arduino.h>
#include "pins_arduino.h"
/*
* {Arduino Pin, RT-Thread Pin [, Device Name, Channel]}
* [] means optional
* Digital pins must NOT give the device name and channel.
* Analog pins MUST give the device name and channel(ADC, PWM or DAC).
* Arduino Pin must keep in sequence.
*/
const pin_map_t pin_map_table[]=
{
{D0, GET_PIN(B, 15), "uart1"}, /* Serial-RX */
{D1, GET_PIN(B, 14), "uart1"}, /* Serial-TX */
{D2, GET_PIN(A, 10)},
{D3, GET_PIN(B, 3)},
{D4, GET_PIN(B, 5)},
{D5, GET_PIN(B, 4), "pwm1", 2}, /* PWM */
{D6, GET_PIN(B, 10), "pwm2", 3}, /* PWM */
{D7, GET_PIN(A, 8)},
{D8, GET_PIN(C, 7)},
{D9, GET_PIN(C, 6), "pwm3", 1}, /* PWM */
{D10, GET_PIN(C, 9), "pwm3", 4}, /* PWM */
{D11, GET_PIN(A, 7), "pwm3", 2}, /* PWM */
{D12, GET_PIN(A, 6)},
{D13, GET_PIN(A, 5)},
{D14, GET_PIN(B, 7), "i2c1"}, /* I2C-SDA (Wire) */
{D15, GET_PIN(B, 6), "i2c1"}, /* I2C-SCL (Wire) */
{A0, GET_PIN(A, 0), "adc1", 0}, /* ADC */
{A1, GET_PIN(A, 1), "adc1", 1}, /* ADC */
{A2, GET_PIN(A, 2), "adc1", 14}, /* ADC */
{A3, GET_PIN(B, 0), "adc1", 9}, /* ADC */
{A4, GET_PIN(C, 1), "adc1", 11}, /* ADC */
{A5, GET_PIN(C, 0), "adc1", 10}, /* ADC */
};

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-12-29 ChuShicheng first version
*/
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
/* pins alias. Must keep in sequence */
#define D0 (0)
#define D1 (1)
#define D2 (2)
#define D3 (3)
#define D4 (4)
#define D5 (5)
#define D6 (6)
#define D7 (7)
#define D8 (8)
#define D9 (9)
#define D10 (10)
#define D11 (11)
#define D12 (12)
#define D13 (13)
#define D14 (14)
#define D15 (15)
#define A0 (16)
#define A1 (17)
#define A2 (18)
#define A3 (19)
#define A4 (20)
#define A5 (21)
#define RTDUINO_PIN_MAX_LIMIT A5 /* pin number max limit check */
#define F_CPU 250000000L /* CPU:250MHz */
#define LED_BUILTIN D13 /* Default Built-in LED */
/* i2c1 : PB.7-SDA PB.6-SCL */
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
/* Serial2(uart1) : PB.14-TX PB.15-RX */
#define RTDUINO_SERIAL2_DEVICE_NAME "uart1"
#endif /* Pins_Arduino_h */

View File

@ -13,7 +13,7 @@
#include <board.h>
/* defined the LED1 pin: PB0 */
#define LED1_PIN GET_PIN(B, 0)
#define LED1_PIN GET_PIN(A, 5)
int main(void)
{

View File

@ -0,0 +1,294 @@
{
"author": "ChuShicheng",
"board_name": "stm32h503-st-nucleo",
"childseries": "STM32H7",
"codedemo": "Hello Arduino",
"frequency": "250",
"i2c": "i2c1",
"ledpin": "D13",
"pininfos": [
{
"allow5v": true,
"arduino": "D0",
"channel": "",
"function": "UART",
"iomap": "RX",
"name": "uart1",
"notes": "/* Serial-RX */",
"rtthread": "",
"rttpin": "15",
"rttport": "B"
},
{
"allow5v": true,
"arduino": "D1",
"channel": "",
"function": "UART",
"iomap": "TX",
"name": "uart1",
"notes": "/* Serial-TX */",
"rtthread": "",
"rttpin": "14",
"rttport": "B"
},
{
"allow5v": true,
"arduino": "D2",
"channel": "",
"function": "GPIO",
"iomap": "",
"name": "",
"notes": "",
"rtthread": "",
"rttpin": "10",
"rttport": "A"
},
{
"allow5v": true,
"arduino": "D3",
"channel": "",
"function": "GPIO",
"iomap": "",
"name": "",
"notes": "",
"rtthread": "",
"rttpin": "3",
"rttport": "B"
},
{
"allow5v": true,
"arduino": "D4",
"channel": "",
"function": "GPIO",
"iomap": "",
"name": "",
"notes": "",
"rtthread": "",
"rttpin": "5",
"rttport": "B"
},
{
"allow5v": true,
"arduino": "D5",
"channel": "2",
"function": "PWM",
"iomap": "",
"name": "pwm1",
"notes": "/* PWM */",
"rtthread": "",
"rttpin": "4",
"rttport": "B"
},
{
"allow5v": true,
"arduino": "D6",
"channel": "3",
"function": "PWM",
"iomap": "",
"name": "pwm2",
"notes": "/* PWM */",
"rtthread": "",
"rttpin": "10",
"rttport": "B"
},
{
"allow5v": true,
"arduino": "D7",
"channel": "",
"function": "GPIO",
"iomap": "",
"name": "",
"notes": "",
"rtthread": "",
"rttpin": "8",
"rttport": "A"
},
{
"allow5v": true,
"arduino": "D8",
"channel": "",
"function": "GPIO",
"iomap": "",
"name": "",
"notes": "",
"rtthread": "",
"rttpin": "7",
"rttport": "C"
},
{
"allow5v": true,
"arduino": "D9",
"channel": "1",
"function": "PWM",
"iomap": "",
"name": "pwm3",
"notes": "/* PWM */",
"rtthread": "",
"rttpin": "6",
"rttport": "C"
},
{
"allow5v": true,
"arduino": "D10",
"channel": "4",
"function": "PWM",
"iomap": "",
"name": "pwm3",
"notes": "/* PWM */",
"rtthread": "",
"rttpin": "9",
"rttport": "C"
},
{
"allow5v": true,
"arduino": "D11",
"channel": "2",
"function": "PWM",
"iomap": "",
"name": "pwm3",
"notes": "/* PWM */",
"rtthread": "",
"rttpin": "7",
"rttport": "A"
},
{
"allow5v": true,
"arduino": "D12",
"channel": "",
"function": "GPIO",
"iomap": "",
"name": "",
"notes": "",
"rtthread": "",
"rttpin": "6",
"rttport": "A"
},
{
"allow5v": true,
"arduino": "D13",
"channel": "",
"function": "GPIO",
"iomap": "",
"name": "",
"notes": "",
"rtthread": "",
"rttpin": "5",
"rttport": "A"
},
{
"allow5v": true,
"arduino": "D14",
"channel": "",
"function": "I2C",
"iomap": "SDA",
"name": "i2c1",
"notes": "/* I2C-SDA (Wire) */",
"rtthread": "",
"rttpin": "7",
"rttport": "B"
},
{
"allow5v": true,
"arduino": "D15",
"channel": "",
"function": "I2C",
"iomap": "SCL",
"name": "i2c1",
"notes": "/* I2C-SCL (Wire) */",
"rtthread": "",
"rttpin": "6",
"rttport": "B"
},
{
"allow5v": true,
"arduino": "A0",
"channel": "0",
"function": "ADC",
"iomap": "",
"name": "adc1",
"notes": "/* ADC */",
"rtthread": "",
"rttpin": "0",
"rttport": "A"
},
{
"allow5v": true,
"arduino": "A1",
"channel": "1",
"function": "ADC",
"iomap": "",
"name": "adc1",
"notes": "/* ADC */",
"rtthread": "",
"rttpin": "1",
"rttport": "A"
},
{
"allow5v": true,
"arduino": "A2",
"channel": "14",
"function": "ADC",
"iomap": "",
"name": "adc1",
"notes": "/* ADC */",
"rtthread": "",
"rttpin": "2",
"rttport": "A"
},
{
"allow5v": true,
"arduino": "A3",
"channel": "9",
"function": "ADC",
"iomap": "",
"name": "adc1",
"notes": "/* ADC */",
"rtthread": "",
"rttpin": "0",
"rttport": "B"
},
{
"allow5v": true,
"arduino": "A4",
"channel": "11",
"function": "ADC",
"iomap": "",
"name": "adc1",
"notes": "/* ADC */",
"rtthread": "",
"rttpin": "1",
"rttport": "C"
},
{
"allow5v": true,
"arduino": "A5",
"channel": "10",
"function": "ADC",
"iomap": "",
"name": "adc1",
"notes": "/* ADC */",
"rtthread": "",
"rttpin": "0",
"rttport": "C"
}
],
"pinmap_image": "",
"project_name": "stm32h503-st-nucleo-rtduino",
"project_path": "D:/RT-Thread/rt-thread/bsp/stm32/stm32h503-st-nucleo/applications",
"pwmtospi": {
"miso_pin": "",
"miso_port": "",
"mosi_pin": "",
"mosi_port": "",
"sck_pin": "",
"sck_port": "",
"spi_name": ""
},
"serial1": "",
"serial2": "uart1",
"serial3": "",
"series": "STM32",
"spi": "",
"spiss": "D0",
"timer": ""
}

View File

@ -0,0 +1 @@
CONFIG_BSP_USING_ARDUINO=y

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,17 @@
#MicroXplorer Configuration settings - do not modify
ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_0
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,MonitoredBy-0\#ChannelRegularConversion,NbrOfConversionFlag,master
ADC1.MonitoredBy-0\#ChannelRegularConversion=__NULL
ADC1.NbrOfConversionFlag=1
ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE
ADC1.Rank-0\#ChannelRegularConversion=1
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_2CYCLES_5
ADC1.master=1
CAD.formats=
CAD.pinconfig=
CAD.provider=
File.Version=6
GPIO.groupedBy=
GPIO.groupedBy=Group By Peripherals
KeepUserPlacement=false
MMTAppReg1.MEMORYMAP.AP=RW_priv_only
MMTAppReg1.MEMORYMAP.AppRegionName=RAM
@ -38,44 +46,64 @@ MMTAppRegionsCount=3
MMTConfigApplied=false
Mcu.CPN=STM32H503RBT6
Mcu.Family=STM32H5
Mcu.IP0=CORTEX_M33_NS
Mcu.IP1=DEBUG
Mcu.IP10=USB
Mcu.IP2=ICACHE
Mcu.IP3=MEMORYMAP
Mcu.IP4=NVIC
Mcu.IP5=PWR
Mcu.IP6=RCC
Mcu.IP7=SYS
Mcu.IP8=USART1
Mcu.IP9=USART3
Mcu.IPNb=11
Mcu.IP0=ADC1
Mcu.IP1=CORTEX_M33_NS
Mcu.IP10=TIM2
Mcu.IP11=TIM3
Mcu.IP12=USART1
Mcu.IP13=USART3
Mcu.IP14=USB
Mcu.IP2=DEBUG
Mcu.IP3=ICACHE
Mcu.IP4=MEMORYMAP
Mcu.IP5=NVIC
Mcu.IP6=PWR
Mcu.IP7=RCC
Mcu.IP8=SYS
Mcu.IP9=TIM1
Mcu.IPNb=15
Mcu.Name=STM32H503RBTx
Mcu.Package=LQFP64
Mcu.Pin0=PC13
Mcu.Pin1=PC14-OSC32_IN(OSC32_IN)
Mcu.Pin10=PA9
Mcu.Pin11=PA11
Mcu.Pin12=PA12
Mcu.Pin13=PA13(JTMS/SWDIO)
Mcu.Pin14=PA14(JTCK/SWCLK)
Mcu.Pin15=PA15(JTDI)
Mcu.Pin16=PC10
Mcu.Pin17=PD2
Mcu.Pin18=PB3(JTDO/TRACESWO)
Mcu.Pin19=VP_ICACHE_VS_ICACHE
Mcu.Pin10=PA3
Mcu.Pin11=PA4
Mcu.Pin12=PA5
Mcu.Pin13=PA7
Mcu.Pin14=PB0
Mcu.Pin15=PB10
Mcu.Pin16=PB14
Mcu.Pin17=PB15
Mcu.Pin18=PC6
Mcu.Pin19=PC9
Mcu.Pin2=PC15-OSC32_OUT(OSC32_OUT)
Mcu.Pin20=VP_PWR_VS_SECSignals
Mcu.Pin21=VP_SYS_VS_Systick
Mcu.Pin22=VP_MEMORYMAP_VS_MEMORYMAP
Mcu.Pin20=PA9
Mcu.Pin21=PA11
Mcu.Pin22=PA12
Mcu.Pin23=PA13(JTMS/SWDIO)
Mcu.Pin24=PA14(JTCK/SWCLK)
Mcu.Pin25=PA15(JTDI)
Mcu.Pin26=PC10
Mcu.Pin27=PD2
Mcu.Pin28=PB3(JTDO/TRACESWO)
Mcu.Pin29=PB4(NJTRST)
Mcu.Pin3=PH0-OSC_IN(PH0)
Mcu.Pin30=PB6
Mcu.Pin31=PB7
Mcu.Pin32=VP_ICACHE_VS_ICACHE
Mcu.Pin33=VP_PWR_VS_SECSignals
Mcu.Pin34=VP_SYS_VS_Systick
Mcu.Pin35=VP_TIM1_VS_ClockSourceINT
Mcu.Pin36=VP_TIM2_VS_ClockSourceINT
Mcu.Pin37=VP_TIM3_VS_ClockSourceINT
Mcu.Pin38=VP_MEMORYMAP_VS_MEMORYMAP
Mcu.Pin4=PH1-OSC_OUT(PH1)
Mcu.Pin5=PA3
Mcu.Pin6=PA4
Mcu.Pin7=PA5
Mcu.Pin8=PB14
Mcu.Pin9=PB15
Mcu.PinsNb=23
Mcu.Pin5=PC0
Mcu.Pin6=PC1
Mcu.Pin7=PA0
Mcu.Pin8=PA1
Mcu.Pin9=PA2
Mcu.PinsNb=39
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32H503RBTx
@ -92,6 +120,8 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA0.Signal=ADCx_INP0
PA1.Signal=ADCx_INP1
PA11.GPIOParameters=GPIO_Label
PA11.GPIO_Label=USB_FS_DN
PA11.Locked=true
@ -117,6 +147,7 @@ PA15(JTDI).GPIO_Label=T_JTDI
PA15(JTDI).Locked=true
PA15(JTDI).Mode=JTAG_4_pins
PA15(JTDI).Signal=DEBUG_JTDI
PA2.Signal=ADCx_INP14
PA3.GPIOParameters=GPIO_Label
PA3.GPIO_Label=T_VCP_RX
PA3.Locked=true
@ -131,10 +162,15 @@ PA5.GPIOParameters=GPIO_Label
PA5.GPIO_Label=USER_LED
PA5.Locked=true
PA5.Signal=GPIO_Output
PA7.Locked=true
PA7.Signal=S_TIM3_CH2
PA9.GPIOParameters=GPIO_Label
PA9.GPIO_Label=USB_FS_VBUS
PA9.Locked=true
PA9.Signal=GPIO_Input
PB0.Signal=ADCx_INP9
PB10.Locked=true
PB10.Signal=S_TIM2_CH3
PB14.GPIOParameters=GPIO_Label
PB14.GPIO_Label=ARD_D1_TX
PB14.Locked=true
@ -150,6 +186,14 @@ PB3(JTDO/TRACESWO).GPIO_Label=T_SWO
PB3(JTDO/TRACESWO).Locked=true
PB3(JTDO/TRACESWO).Mode=JTAG_4_pins
PB3(JTDO/TRACESWO).Signal=DEBUG_JTDO-SWO
PB4(NJTRST).Locked=true
PB4(NJTRST).Signal=S_TIM1_CH2
PB6.Locked=true
PB6.Signal=I2C1_SCL
PB7.Locked=true
PB7.Signal=I2C1_SDA
PC0.Signal=ADCx_INP10
PC1.Signal=ADCx_INP11
PC10.GPIOParameters=GPIO_Label
PC10.GPIO_Label=USB_FS_PWR_EN
PC10.Locked=true
@ -162,6 +206,10 @@ PC14-OSC32_IN(OSC32_IN).Mode=LSE-External-Oscillator
PC14-OSC32_IN(OSC32_IN).Signal=RCC_OSC32_IN
PC15-OSC32_OUT(OSC32_OUT).Mode=LSE-External-Oscillator
PC15-OSC32_OUT(OSC32_OUT).Signal=RCC_OSC32_OUT
PC6.Locked=true
PC6.Signal=S_TIM3_CH1
PC9.Locked=true
PC9.Signal=S_TIM3_CH4
PD2.GPIOParameters=GPIO_Label
PD2.GPIO_Label=USB_FS_OVCR
PD2.Locked=true
@ -201,7 +249,7 @@ ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ICACHE_Init-ICACHE-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_USART3_UART_Init-USART3-false-HAL-true,6-MX_USB_PCD_Init-USB-false-HAL-true,7-MX_MEMORYMAP_Init-MEMORYMAP-false-HAL-true,0-MX_CORTEX_M33_NS_Init-CORTEX_M33_NS-false-HAL-true,0-MX_PWR_Init-PWR-false-HAL-true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ICACHE_Init-ICACHE-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_USART3_UART_Init-USART3-false-HAL-true,6-MX_USB_PCD_Init-USB-false-HAL-true,7-MX_MEMORYMAP_Init-MEMORYMAP-false-HAL-true,8-MX_ADC1_Init-ADC1-false-HAL-true,9-MX_I2C1_Init-I2C1-false-HAL-true,10-MX_TIM1_Init-TIM1-false-HAL-true,11-MX_TIM2_Init-TIM2-false-HAL-true,12-MX_TIM3_Init-TIM3-false-HAL-true,0-MX_CORTEX_M33_NS_Init-CORTEX_M33_NS-false-HAL-true,0-MX_PWR_Init-PWR-false-HAL-true
RCC.ADCFreq_Value=250000000
RCC.AHBFreq_Value=250000000
RCC.APB1Freq_Value=250000000
@ -258,10 +306,40 @@ RCC.VCOInput2Freq_Value=4000000
RCC.VCOInputFreq_Value=2000000
RCC.VCOOutputFreq_Value=500000000
RCC.VCOPLL2OutputFreq_Value=516000000
SH.ADCx_INP0.0=ADC1_INP0,IN0-Single-Ended
SH.ADCx_INP0.ConfNb=1
SH.ADCx_INP1.0=ADC1_INP1,IN1-Single-Ended
SH.ADCx_INP1.ConfNb=1
SH.ADCx_INP10.0=ADC1_INP10,IN10-Single-Ended
SH.ADCx_INP10.ConfNb=1
SH.ADCx_INP11.0=ADC1_INP11,IN11-Single-Ended
SH.ADCx_INP11.ConfNb=1
SH.ADCx_INP14.0=ADC1_INP14,IN14-Single-Ended
SH.ADCx_INP14.ConfNb=1
SH.ADCx_INP9.0=ADC1_INP9,IN9-Single-Ended
SH.ADCx_INP9.ConfNb=1
SH.GPXTI13.0=GPIO_EXTI13
SH.GPXTI13.ConfNb=1
SH.GPXTI2.0=GPIO_EXTI2
SH.GPXTI2.ConfNb=1
SH.S_TIM1_CH2.0=TIM1_CH2,PWM Generation2 CH2
SH.S_TIM1_CH2.ConfNb=1
SH.S_TIM2_CH3.0=TIM2_CH3,PWM Generation3 CH3
SH.S_TIM2_CH3.ConfNb=1
SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1
SH.S_TIM3_CH1.ConfNb=1
SH.S_TIM3_CH2.0=TIM3_CH2,PWM Generation2 CH2
SH.S_TIM3_CH2.ConfNb=1
SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4
SH.S_TIM3_CH4.ConfNb=1
TIM1.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM1.IPParameters=Channel-PWM Generation2 CH2
TIM2.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM2.IPParameters=Channel-PWM Generation3 CH3
TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM3.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation4 CH4
USART1.IPParameters=VirtualMode
USART1.VirtualMode=VM_ASYNC
USART3.IPParameters=VirtualMode
@ -276,5 +354,11 @@ VP_PWR_VS_SECSignals.Mode=Security/Privilege
VP_PWR_VS_SECSignals.Signal=PWR_VS_SECSignals
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_TIM1_VS_ClockSourceINT.Mode=Internal
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
VP_TIM2_VS_ClockSourceINT.Mode=Internal
VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
VP_TIM3_VS_ClockSourceINT.Mode=Internal
VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
board=NUCLEO-H503RB
boardIOC=true

View File

@ -49,6 +49,8 @@ extern "C" {
/* USER CODE END EM */
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

View File

@ -41,7 +41,7 @@
#define HAL_MODULE_ENABLED
/*#define HAL_ADC_MODULE_ENABLED */
#define HAL_ADC_MODULE_ENABLED
/*#define HAL_CEC_MODULE_ENABLED */
/*#define HAL_COMP_MODULE_ENABLED */
/*#define HAL_CORDIC_MODULE_ENABLED */
@ -79,7 +79,7 @@
/*#define HAL_SMBUS_MODULE_ENABLED */
/*#define HAL_SPI_MODULE_ENABLED */
/*#define HAL_SRAM_MODULE_ENABLED */
/*#define HAL_TIM_MODULE_ENABLED */
#define HAL_TIM_MODULE_ENABLED
/*#define HAL_RAMCFG_MODULE_ENABLED */
#define HAL_UART_MODULE_ENABLED
/*#define HAL_USART_MODULE_ENABLED */

View File

@ -40,6 +40,11 @@
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;
TIM_HandleTypeDef htim1;
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim3;
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart3;
@ -58,6 +63,10 @@ static void MX_USART1_UART_Init(void);
static void MX_USART3_UART_Init(void);
static void MX_USB_PCD_Init(void);
static void MX_MEMORYMAP_Init(void);
static void MX_ADC1_Init(void);
static void MX_TIM1_Init(void);
static void MX_TIM2_Init(void);
static void MX_TIM3_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
@ -100,6 +109,10 @@ int main(void)
MX_USART3_UART_Init();
MX_USB_PCD_Init();
MX_MEMORYMAP_Init();
MX_ADC1_Init();
MX_TIM1_Init();
MX_TIM2_Init();
MX_TIM3_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
@ -168,6 +181,65 @@ void SystemClock_Config(void)
}
}
/**
* @brief ADC1 Initialization Function
* @param None
* @retval None
*/
static void MX_ADC1_Init(void)
{
/* USER CODE BEGIN ADC1_Init 0 */
/* USER CODE END ADC1_Init 0 */
ADC_ChannelConfTypeDef sConfig = {0};
/* USER CODE BEGIN ADC1_Init 1 */
/* USER CODE END ADC1_Init 1 */
/** Common config
*/
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV2;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.SamplingMode = ADC_SAMPLING_MODE_NORMAL;
hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc1.Init.OversamplingMode = DISABLE;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_0;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC1_Init 2 */
/* USER CODE END ADC1_Init 2 */
}
/**
* @brief ICACHE Initialization Function
* @param None
@ -217,6 +289,214 @@ static void MX_MEMORYMAP_Init(void)
}
/**
* @brief TIM1 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM1_Init(void)
{
/* USER CODE BEGIN TIM1_Init 0 */
/* USER CODE END TIM1_Init 0 */
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_OC_InitTypeDef sConfigOC = {0};
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
/* USER CODE BEGIN TIM1_Init 1 */
/* USER CODE END TIM1_Init 1 */
htim1.Instance = TIM1;
htim1.Init.Prescaler = 0;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 65535;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
sBreakDeadTimeConfig.DeadTime = 0;
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
sBreakDeadTimeConfig.BreakFilter = 0;
sBreakDeadTimeConfig.BreakAFMode = TIM_BREAK_AFMODE_INPUT;
sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
sBreakDeadTimeConfig.Break2Filter = 0;
sBreakDeadTimeConfig.Break2AFMode = TIM_BREAK_AFMODE_INPUT;
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM1_Init 2 */
/* USER CODE END TIM1_Init 2 */
HAL_TIM_MspPostInit(&htim1);
}
/**
* @brief TIM2 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM2_Init(void)
{
/* USER CODE BEGIN TIM2_Init 0 */
/* USER CODE END TIM2_Init 0 */
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_OC_InitTypeDef sConfigOC = {0};
/* USER CODE BEGIN TIM2_Init 1 */
/* USER CODE END TIM2_Init 1 */
htim2.Instance = TIM2;
htim2.Init.Prescaler = 0;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
htim2.Init.Period = 4.294967295E9;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_Init(&htim2) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM2_Init 2 */
/* USER CODE END TIM2_Init 2 */
HAL_TIM_MspPostInit(&htim2);
}
/**
* @brief TIM3 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM3_Init(void)
{
/* USER CODE BEGIN TIM3_Init 0 */
/* USER CODE END TIM3_Init 0 */
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_OC_InitTypeDef sConfigOC = {0};
/* USER CODE BEGIN TIM3_Init 1 */
/* USER CODE END TIM3_Init 1 */
htim3.Instance = TIM3;
htim3.Init.Prescaler = 0;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 65535;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM3_Init 2 */
/* USER CODE END TIM3_Init 2 */
HAL_TIM_MspPostInit(&htim3);
}
/**
* @brief USART1 Initialization Function
* @param None
@ -405,6 +685,14 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(USB_FS_OVCR_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : PB6 PB7 */
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}

View File

@ -58,7 +58,9 @@
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
/**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
@ -74,6 +76,269 @@ void HAL_MspInit(void)
/* USER CODE END MspInit 1 */
}
/**
* @brief ADC MSP Initialization
* This function configures the hardware resources used in this example
* @param hadc: ADC handle pointer
* @retval None
*/
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
if(hadc->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspInit 0 */
/* USER CODE END ADC1_MspInit 0 */
/** Initializes the peripherals clock
*/
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADCDAC;
PeriphClkInitStruct.AdcDacClockSelection = RCC_ADCDACCLKSOURCE_HCLK;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
/* Peripheral clock enable */
__HAL_RCC_ADC_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/**ADC1 GPIO Configuration
PC0 ------> ADC1_INP10
PC1 ------> ADC1_INP11
PA0 ------> ADC1_INP0
PA1 ------> ADC1_INP1
PA2 ------> ADC1_INP14
PB0 ------> ADC1_INP9
*/
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN ADC1_MspInit 1 */
/* USER CODE END ADC1_MspInit 1 */
}
}
/**
* @brief ADC MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hadc: ADC handle pointer
* @retval None
*/
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
{
if(hadc->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspDeInit 0 */
/* USER CODE END ADC1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_ADC_CLK_DISABLE();
/**ADC1 GPIO Configuration
PC0 ------> ADC1_INP10
PC1 ------> ADC1_INP11
PA0 ------> ADC1_INP0
PA1 ------> ADC1_INP1
PA2 ------> ADC1_INP14
PB0 ------> ADC1_INP9
*/
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_1);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0);
/* USER CODE BEGIN ADC1_MspDeInit 1 */
/* USER CODE END ADC1_MspDeInit 1 */
}
}
/**
* @brief TIM_Base MSP Initialization
* This function configures the hardware resources used in this example
* @param htim_base: TIM_Base handle pointer
* @retval None
*/
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspInit 0 */
/* USER CODE END TIM1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM1_CLK_ENABLE();
/* USER CODE BEGIN TIM1_MspInit 1 */
/* USER CODE END TIM1_MspInit 1 */
}
else if(htim_base->Instance==TIM2)
{
/* USER CODE BEGIN TIM2_MspInit 0 */
/* USER CODE END TIM2_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM2_CLK_ENABLE();
/* USER CODE BEGIN TIM2_MspInit 1 */
/* USER CODE END TIM2_MspInit 1 */
}
else if(htim_base->Instance==TIM3)
{
/* USER CODE BEGIN TIM3_MspInit 0 */
/* USER CODE END TIM3_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM3_CLK_ENABLE();
/* USER CODE BEGIN TIM3_MspInit 1 */
/* USER CODE END TIM3_MspInit 1 */
}
}
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(htim->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspPostInit 0 */
/* USER CODE END TIM1_MspPostInit 0 */
__HAL_RCC_GPIOB_CLK_ENABLE();
/**TIM1 GPIO Configuration
PB4(NJTRST) ------> TIM1_CH2
*/
GPIO_InitStruct.Pin = GPIO_PIN_4;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF14_TIM1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN TIM1_MspPostInit 1 */
/* USER CODE END TIM1_MspPostInit 1 */
}
else if(htim->Instance==TIM2)
{
/* USER CODE BEGIN TIM2_MspPostInit 0 */
/* USER CODE END TIM2_MspPostInit 0 */
__HAL_RCC_GPIOB_CLK_ENABLE();
/**TIM2 GPIO Configuration
PB10 ------> TIM2_CH3
*/
GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN TIM2_MspPostInit 1 */
/* USER CODE END TIM2_MspPostInit 1 */
}
else if(htim->Instance==TIM3)
{
/* USER CODE BEGIN TIM3_MspPostInit 0 */
/* USER CODE END TIM3_MspPostInit 0 */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/**TIM3 GPIO Configuration
PA7 ------> TIM3_CH2
PC6 ------> TIM3_CH1
PC9 ------> TIM3_CH4
*/
GPIO_InitStruct.Pin = GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* USER CODE BEGIN TIM3_MspPostInit 1 */
/* USER CODE END TIM3_MspPostInit 1 */
}
}
/**
* @brief TIM_Base MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param htim_base: TIM_Base handle pointer
* @retval None
*/
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspDeInit 0 */
/* USER CODE END TIM1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM1_CLK_DISABLE();
/* USER CODE BEGIN TIM1_MspDeInit 1 */
/* USER CODE END TIM1_MspDeInit 1 */
}
else if(htim_base->Instance==TIM2)
{
/* USER CODE BEGIN TIM2_MspDeInit 0 */
/* USER CODE END TIM2_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM2_CLK_DISABLE();
/* USER CODE BEGIN TIM2_MspDeInit 1 */
/* USER CODE END TIM2_MspDeInit 1 */
}
else if(htim_base->Instance==TIM3)
{
/* USER CODE BEGIN TIM3_MspDeInit 0 */
/* USER CODE END TIM3_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM3_CLK_DISABLE();
/* USER CODE BEGIN TIM3_MspDeInit 1 */
/* USER CODE END TIM3_MspDeInit 1 */
}
}
/**
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example

View File

@ -7,6 +7,33 @@ config SOC_STM32H503RB
select RT_USING_USER_MAIN
default y
menu "Onboard Peripheral Drivers"
config BSP_USING_ARDUINO
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART
select BSP_USING_UART1
select BSP_USING_GPIO
# select BSP_USING_ADC
# select BSP_USING_ADC1
# select BSP_USING_PWM
# select BSP_USING_PWM1
# select BSP_USING_PWM1_CH2
# select BSP_USING_PWM2
# select BSP_USING_PWM2_CH3
# select BSP_USING_PWM3
# select BSP_USING_PWM3_CH1
# select BSP_USING_PWM3_CH2
# select BSP_USING_PWM3_CH4
# select BSP_USING_I2C
# select BSP_USING_I2C2
# imply RTDUINO_USING_SERVO
imply RTDUINO_USING_WIRE
default n
endmenu
menu "On-chip Peripheral Drivers"
config BSP_USING_GPIO
@ -56,6 +83,71 @@ menu "On-chip Peripheral Drivers"
default n
endif
menuconfig BSP_USING_ADC
bool "Enable ADC"
default n
select RT_USING_ADC
if BSP_USING_ADC
config BSP_USING_ADC1
bool "Enable ADC1"
default n
endif
menuconfig BSP_USING_PWM
bool "Enable PWM"
default n
select RT_USING_PWM
if BSP_USING_PWM
menuconfig BSP_USING_PWM1
bool "Enable timer1 output PWM"
default n
if BSP_USING_PWM1
config BSP_USING_PWM1_CH2
bool "Enable PWM1 channel2"
default n
endif
menuconfig BSP_USING_PWM2
bool "Enable timer2 output PWM"
default n
if BSP_USING_PWM2
config BSP_USING_PWM2_CH3
bool "Enable PWM2 channel3"
default n
endif
menuconfig BSP_USING_PWM3
bool "Enable timer3 output PWM"
default n
if BSP_USING_PWM3
config BSP_USING_PWM3_CH1
bool "Enable PWM3 channel1"
default n
config BSP_USING_PWM3_CH2
bool "Enable PWM3 channel2"
default n
config BSP_USING_PWM3_CH4
bool "Enable PWM3 channel4"
default n
endif
endif
menuconfig BSP_USING_I2C1
bool "Enable I2C1 BUS (software simulation)"
default n
select RT_USING_I2C
select RT_USING_I2C_BITOPS
select RT_USING_PIN
if BSP_USING_I2C1
config BSP_I2C1_SCL_PIN
int "i2c1 scl pin number (PB.6)"
default 22
config BSP_I2C1_SDA_PIN
int "i2c1 sda pin number (PB.7)"
default 23
endif
source "$BSP_DIR/../libraries/HAL_Drivers/drivers/Kconfig"
endmenu