From be2119e0f58119edc868530021edd7eeafc2a683 Mon Sep 17 00:00:00 2001 From: Shicheng Chu <1468559561@qq.com> Date: Fri, 29 Dec 2023 19:46:28 +0800 Subject: [PATCH] [bsp][stm32]: add stm32h503 rtduino (#8448) --- .../applications/SConscript | 2 +- .../applications/arduino_main.cpp | 24 ++ .../applications/arduino_pinout/README.md | 49 +++ .../applications/arduino_pinout/SConscript | 9 + .../arduino_pinout/pins_arduino.c | 45 +++ .../arduino_pinout/pins_arduino.h | 50 +++ .../stm32h503-st-nucleo/applications/main.c | 2 +- .../stm32h503-st-nucleo-rtduino.rdpg | 294 ++++++++++++++++++ .../attachconfig/rtduino.attach | 1 + .../board/CubeMX_Config/.mxproject | 2 +- .../board/CubeMX_Config/CubeMX_Config.ioc | 150 +++++++-- .../board/CubeMX_Config/Inc/main.h | 2 + .../CubeMX_Config/Inc/stm32h5xx_hal_conf.h | 4 +- .../board/CubeMX_Config/Src/main.c | 288 +++++++++++++++++ .../CubeMX_Config/Src/stm32h5xx_hal_msp.c | 267 +++++++++++++++- bsp/stm32/stm32h503-st-nucleo/board/Kconfig | 92 ++++++ 16 files changed, 1242 insertions(+), 39 deletions(-) create mode 100644 bsp/stm32/stm32h503-st-nucleo/applications/arduino_main.cpp create mode 100644 bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/README.md create mode 100644 bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/SConscript create mode 100644 bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/pins_arduino.c create mode 100644 bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/pins_arduino.h create mode 100644 bsp/stm32/stm32h503-st-nucleo/applications/stm32h503-st-nucleo-rtduino.rdpg create mode 100644 bsp/stm32/stm32h503-st-nucleo/attachconfig/rtduino.attach diff --git a/bsp/stm32/stm32h503-st-nucleo/applications/SConscript b/bsp/stm32/stm32h503-st-nucleo/applications/SConscript index e1c7fa5996..03feb2016a 100644 --- a/bsp/stm32/stm32h503-st-nucleo/applications/SConscript +++ b/bsp/stm32/stm32h503-st-nucleo/applications/SConscript @@ -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'] diff --git a/bsp/stm32/stm32h503-st-nucleo/applications/arduino_main.cpp b/bsp/stm32/stm32h503-st-nucleo/applications/arduino_main.cpp new file mode 100644 index 0000000000..a41c414cfc --- /dev/null +++ b/bsp/stm32/stm32h503-st-nucleo/applications/arduino_main.cpp @@ -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 + +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); +} diff --git a/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/README.md b/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/README.md new file mode 100644 index 0000000000..832bb4c1dd --- /dev/null +++ b/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/README.md @@ -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 diff --git a/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/SConscript b/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/SConscript new file mode 100644 index 0000000000..2539929027 --- /dev/null +++ b/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/SConscript @@ -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') diff --git a/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/pins_arduino.c b/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/pins_arduino.c new file mode 100644 index 0000000000..1983a9545e --- /dev/null +++ b/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/pins_arduino.c @@ -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 +#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 */ +}; diff --git a/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/pins_arduino.h b/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/pins_arduino.h new file mode 100644 index 0000000000..54e749704c --- /dev/null +++ b/bsp/stm32/stm32h503-st-nucleo/applications/arduino_pinout/pins_arduino.h @@ -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 */ diff --git a/bsp/stm32/stm32h503-st-nucleo/applications/main.c b/bsp/stm32/stm32h503-st-nucleo/applications/main.c index 2bdc394fe3..0b3f1a4ea2 100644 --- a/bsp/stm32/stm32h503-st-nucleo/applications/main.c +++ b/bsp/stm32/stm32h503-st-nucleo/applications/main.c @@ -13,7 +13,7 @@ #include /* defined the LED1 pin: PB0 */ -#define LED1_PIN GET_PIN(B, 0) +#define LED1_PIN GET_PIN(A, 5) int main(void) { diff --git a/bsp/stm32/stm32h503-st-nucleo/applications/stm32h503-st-nucleo-rtduino.rdpg b/bsp/stm32/stm32h503-st-nucleo/applications/stm32h503-st-nucleo-rtduino.rdpg new file mode 100644 index 0000000000..5b1a8808f5 --- /dev/null +++ b/bsp/stm32/stm32h503-st-nucleo/applications/stm32h503-st-nucleo-rtduino.rdpg @@ -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": "" +} diff --git a/bsp/stm32/stm32h503-st-nucleo/attachconfig/rtduino.attach b/bsp/stm32/stm32h503-st-nucleo/attachconfig/rtduino.attach new file mode 100644 index 0000000000..a3e7cd6cb2 --- /dev/null +++ b/bsp/stm32/stm32h503-st-nucleo/attachconfig/rtduino.attach @@ -0,0 +1 @@ +CONFIG_BSP_USING_ARDUINO=y diff --git a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/.mxproject b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/.mxproject index 0b468cb87b..8384e95c12 100644 --- a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/.mxproject +++ b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/.mxproject @@ -1,5 +1,5 @@ [PreviousLibFiles] -LibFiles=Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_cortex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_bus.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_rcc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_crs.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_system.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_utils.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_gpio.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_dma.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_dmamux.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_pwr.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_cortex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_def.h;Drivers\STM32H5xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_exti.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_exti.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_icache.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pcd.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pcd_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_usb.h;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_cortex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_rcc.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_rcc_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_flash.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_flash_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_gpio.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_dma.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_dma_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_pwr.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_pwr_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_exti.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_icache.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_uart.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_uart_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_pcd.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_pcd_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_ll_usb.c;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_cortex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_bus.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_rcc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_crs.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_system.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_utils.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_gpio.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_dma.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_dmamux.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_pwr.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_cortex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_def.h;Drivers\STM32H5xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_exti.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_exti.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_icache.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pcd.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pcd_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_usb.h;Drivers\CMSIS\Device\ST\STM32H5xx\Include\stm32h503xx.h;Drivers\CMSIS\Device\ST\STM32H5xx\Include\stm32h5xx.h;Drivers\CMSIS\Device\ST\STM32H5xx\Include\system_stm32h5xx.h;Drivers\CMSIS\Device\ST\STM32H5xx\Source\Templates\system_stm32h5xx.c; +LibFiles=Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_adc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_adc_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_adc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_bus.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_rcc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_crs.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_system.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_utils.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_gpio.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_dma.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_dmamux.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_pwr.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_cortex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_cortex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_def.h;Drivers\STM32H5xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_exti.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_exti.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_icache.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pcd.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pcd_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_usb.h;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_adc.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_adc_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_dma.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_dma_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_rcc.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_rcc_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_flash.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_flash_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_gpio.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_pwr.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_pwr_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_cortex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_exti.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_icache.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_tim.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_tim_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_uart.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_uart_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_pcd.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_hal_pcd_ex.c;Drivers\STM32H5xx_HAL_Driver\Src\stm32h5xx_ll_usb.c;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_adc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_adc_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_adc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_bus.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_rcc.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_crs.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_system.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_utils.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_gpio.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_dma.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_dmamux.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_pwr.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_cortex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_cortex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_def.h;Drivers\STM32H5xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_exti.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_exti.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_icache.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pcd.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pcd_ex.h;Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_ll_usb.h;Drivers\CMSIS\Device\ST\STM32H5xx\Include\stm32h503xx.h;Drivers\CMSIS\Device\ST\STM32H5xx\Include\stm32h5xx.h;Drivers\CMSIS\Device\ST\STM32H5xx\Include\system_stm32h5xx.h;Drivers\CMSIS\Device\ST\STM32H5xx\Source\Templates\system_stm32h5xx.c; [] SourceFiles=;; diff --git a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/CubeMX_Config.ioc b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/CubeMX_Config.ioc index eb8c0fbe14..4153cf5bb4 100644 --- a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/CubeMX_Config.ioc +++ b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/CubeMX_Config.ioc @@ -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 diff --git a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Inc/main.h b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Inc/main.h index e5f7d0d6e1..b55233af8d 100644 --- a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Inc/main.h +++ b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Inc/main.h @@ -49,6 +49,8 @@ extern "C" { /* USER CODE END EM */ +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + /* Exported functions prototypes ---------------------------------------------*/ void Error_Handler(void); diff --git a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Inc/stm32h5xx_hal_conf.h b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Inc/stm32h5xx_hal_conf.h index e78fe91f52..2d9fac7225 100644 --- a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Inc/stm32h5xx_hal_conf.h +++ b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Inc/stm32h5xx_hal_conf.h @@ -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 */ diff --git a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Src/main.c b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Src/main.c index 4525fd8e44..a7b6f6cde1 100644 --- a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Src/main.c +++ b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Src/main.c @@ -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 */ } diff --git a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Src/stm32h5xx_hal_msp.c b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Src/stm32h5xx_hal_msp.c index f1a3e4c194..a7194d0419 100644 --- a/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Src/stm32h5xx_hal_msp.c +++ b/bsp/stm32/stm32h503-st-nucleo/board/CubeMX_Config/Src/stm32h5xx_hal_msp.c @@ -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 diff --git a/bsp/stm32/stm32h503-st-nucleo/board/Kconfig b/bsp/stm32/stm32h503-st-nucleo/board/Kconfig index 7bf05a78e6..f2e4ede561 100644 --- a/bsp/stm32/stm32h503-st-nucleo/board/Kconfig +++ b/bsp/stm32/stm32h503-st-nucleo/board/Kconfig @@ -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