[rtduino] 对接STM32F412 NUCLEO (#6461)

This commit is contained in:
Man, Jianting (Meco) 2022-09-25 22:38:35 -04:00 committed by GitHub
parent 1c2d05d545
commit c7a9481831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 990 additions and 206 deletions

View File

@ -71,7 +71,7 @@ RT-Thread online packages --->
| D7 | PE6 | 普通IO |
| D8 | PB8 | 普通IO |
| D9 | PB9 | 普通IO |
| D10 | PB0 | 普通IO |
| D10 | PB0 | SPI片选/普通IO |
| D11 | PB5 | SPI1_MOSI/普通IO |
| D12 | PB4 | SPI1_MISO/普通IO |
| D13 | PD3 | SPI1_SCK/普通IO |
@ -169,3 +169,7 @@ SPI必须先调用begin才能使用其他函数
### 4.RTduino编译报错 "posix/xxx.h cannot find"
如果编译报错为 "posix/xxx.h cannot find"请更新rt-thread到最新版本从github仓库拉取最新的源码
## 7 参考资料
- [工程师笔记 | 使用RT-Thread的Arduino兼容层开发ES32应用程序](https://mp.weixin.qq.com/s/O693pgCLl1xOGxE9O7zaHA)

View File

@ -5,7 +5,6 @@
*
* Change Logs:
* Date Author Notes
* 2021-12-10 Meco Man first version
* 2022-07-07 shiwa Adapt ES32F369x
*/
#include <Arduino.h>
@ -14,7 +13,7 @@
#include "pins_arduino.h"
/*
{Arduino Pin, RT-Thread Pin [, Device Name(PWM or ADC), Channel]}
{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).
@ -22,8 +21,8 @@
*/
const pin_map_t pin_map_table[]=
{
{D0/*, GET_PIN(E,3)*/}, /* UART2_RX */
{D1/*, GET_PIN(E,2)*/}, /* UART2_TX */
{D0, GET_PIN(E,3), "uart2"}, /* UART2-RX */
{D1, GET_PIN(E,2), "uart2"}, /* UART2-TX */
{D2, GET_PIN(E,4)}, /* GPIO0 */
{D3, GET_PIN(A,2),"pwm2",3}, /* PWM2 GP32C4T0 CH3 */
{D4, GET_PIN(E,5)}, /* GPIO1 */
@ -33,13 +32,13 @@ const pin_map_t pin_map_table[]=
{D8, GET_PIN(B,8)}, /* GPIO3 */
{D9, GET_PIN(B,9)}, /* GPIO4 */
{D10, GET_PIN(B,0)}, /* GPIO5 */
{D11/*, GET_PIN(B,5)*/}, /* SPI0_MOSI */
{D12/*, GET_PIN(B,4)*/}, /* SPI0_MISO */
{D13/*, GET_PIN(D,3)*/}, /* SPI0_SCK */
{D10, GET_PIN(B,0)}, /* GPIO5, SS */
{D11, GET_PIN(B,5), "spi0"}, /* SPI0-MOSI */
{D12, GET_PIN(B,4), "spi0"}, /* SPI0-MISO */
{D13, GET_PIN(D,3), "spi0"}, /* SPI0-SCK */
{D14/*, GET_PIN(B,7)*/}, /* I2C0_SDA */
{D15/*, GET_PIN(B,6)*/}, /* I2C0_SCL */
{D14, GET_PIN(B,7), "i2c0"}, /* I2C0-SDA */
{D15, GET_PIN(B,6), "i2c0"}, /* I2C0-SCL */
{D16, GET_PIN(C,8)}, /* LED4 */
{D17, GET_PIN(C,12)}, /* LED5 */

View File

@ -5,7 +5,6 @@
*
* Change Logs:
* Date Author Notes
* 2021-12-10 Meco Man first version
* 2022-07-07 shiwa Adapt ES32F369x
*/
@ -51,6 +50,7 @@
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c0"
#define SS D10
#define RTDUINO_DEFAULT_SPI_BUS_NAME "spi0"
#define LED_BUILTIN D16

View File

@ -13,7 +13,7 @@ menu "Hardware Drivers Config"
menu "Onboard Peripheral Drivers"
config BSP_USING_ARDUINO
bool "Support Arduino"
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_GPIO
select BSP_USING_UART2

View File

@ -72,6 +72,28 @@ extern "C" {
#endif /* PWM5_CONFIG */
#endif /* BSP_USING_PWM5 */
#ifdef BSP_USING_PWM6
#ifndef PWM6_CONFIG
#define PWM6_CONFIG \
{ \
.tim_handle.Instance = TIM6, \
.name = "pwm6", \
.channel = 0 \
}
#endif /* PWM6_CONFIG */
#endif /* BSP_USING_PWM6 */
#ifdef BSP_USING_PWM7
#ifndef PWM7_CONFIG
#define PWM7_CONFIG \
{ \
.tim_handle.Instance = TIM7, \
.name = "pwm7", \
.channel = 0 \
}
#endif /* PWM7_CONFIG */
#endif /* BSP_USING_PWM7 */
#ifdef BSP_USING_PWM8
#ifndef PWM8_CONFIG
#define PWM8_CONFIG \
@ -94,6 +116,28 @@ extern "C" {
#endif /* PWM9_CONFIG */
#endif /* BSP_USING_PWM9 */
#ifdef BSP_USING_PWM10
#ifndef PWM10_CONFIG
#define PWM10_CONFIG \
{ \
.tim_handle.Instance = TIM10, \
.name = "pwm10", \
.channel = 0 \
}
#endif /* PWM10_CONFIG */
#endif /* BSP_USING_PWM10 */
#ifdef BSP_USING_PWM11
#ifndef PWM11_CONFIG
#define PWM11_CONFIG \
{ \
.tim_handle.Instance = TIM11, \
.name = "pwm11", \
.channel = 0 \
}
#endif /* PWM11_CONFIG */
#endif /* BSP_USING_PWM11 */
#ifdef BSP_USING_PWM12
#ifndef PWM12_CONFIG
#define PWM12_CONFIG \
@ -105,6 +149,28 @@ extern "C" {
#endif /* PWM12_CONFIG */
#endif /* BSP_USING_PWM12 */
#ifdef BSP_USING_PWM13
#ifndef PWM13_CONFIG
#define PWM13_CONFIG \
{ \
.tim_handle.Instance = TIM13, \
.name = "pwm13", \
.channel = 0 \
}
#endif /* PWM13_CONFIG */
#endif /* BSP_USING_PWM13 */
#ifdef BSP_USING_PWM14
#ifndef PWM14_CONFIG
#define PWM14_CONFIG \
{ \
.tim_handle.Instance = TIM14, \
.name = "pwm14", \
.channel = 0 \
}
#endif /* PWM14_CONFIG */
#endif /* BSP_USING_PWM14 */
#ifdef __cplusplus
}
#endif

View File

@ -180,17 +180,17 @@ static void pclkx_doubler_get(rt_uint32_t *pclk1_doubler, rt_uint32_t *pclk2_dou
}
if (RCC_ClkInitStruct.APB2_Div != RCC_APB2_DIV1)
{
*pclk2_doubler = 2;
*pclk2_doubler = 2;
}
#else
if (RCC_ClkInitStruct.APB1CLKDivider != RCC_HCLK_DIV1)
{
*pclk1_doubler = 2;
*pclk1_doubler = 2;
}
#if !defined(SOC_SERIES_STM32F0) && !defined(SOC_SERIES_STM32G0)
#if !(defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32G0))
if (RCC_ClkInitStruct.APB2CLKDivider != RCC_HCLK_DIV1)
{
*pclk2_doubler = 2;
*pclk2_doubler = 2;
}
#endif
#endif
@ -213,9 +213,7 @@ static rt_uint64_t tim_clock_get(TIM_HandleTypeDef *htim)
if (0)
#endif
{
#if !defined(SOC_SERIES_STM32F0) && !defined(SOC_SERIES_STM32G0)
tim_clock = (rt_uint32_t)(HAL_RCC_GetPCLK2Freq() * pclk2_doubler);
#endif
}
else
{
@ -631,6 +629,15 @@ static void pwm_get_channel(void)
#ifdef BSP_USING_PWM12_CH2
stm32_pwm_obj[PWM12_INDEX].channel |= 1 << 1;
#endif
#ifdef BSP_USING_PWM13_CH1
stm32_pwm_obj[PWM13_INDEX].channel |= 1 << 0;
#endif
#ifdef BSP_USING_PWM14_CH1
stm32_pwm_obj[PWM14_INDEX].channel |= 1 << 0;
#endif
#ifdef BSP_USING_PWM15_CH1
stm32_pwm_obj[PWM15_INDEX].channel |= 1 << 0;
#endif
#ifdef BSP_USING_PWM16_CH1
stm32_pwm_obj[PWM16_INDEX].channel |= 1 << 0;
#endif

View File

@ -57,7 +57,7 @@ Hardware Drivers Config --->
> 参考资料
>
> 【1】[STM32 Nucleo板官方手册](https://www.st.com/resource/en/user_manual/um1724-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf)
> 【1】[STM32 Nucleo-64板官方手册](https://www.st.com/resource/en/user_manual/um1724-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf)
## 3 通信

View File

@ -37,7 +37,7 @@ const pin_map_t pin_map_table[]=
{D13, GET_PIN(A,5)}, /* LED_BUILTIN */
{D14, GET_PIN(B,9), "i2c1"}, /* I2C-SDA (Wire) */
{D15, GET_PIN(B,8), "i2c1"}, /* I2C-SCL (Wire) */
{D16, GET_PIN(C,13)},
{D16, GET_PIN(C,13)}, /* USER KEY */
{A0, GET_PIN(A,0), "adc1", 0}, /* ADC */
{A1, GET_PIN(A,1), "adc1", 1}, /* ADC */
{A2, GET_PIN(A,4), "adc1", 4}, /* ADC */

View File

@ -40,7 +40,7 @@
#define F_CPU 48000000L /* CPU:48MHz */
#define LED_BUITIN D13 /* Default Built-in LED */
#define LED_BUILTIN D13 /* Default Built-in LED */
/* i2c1 - PB9-SDA PB8-SCL */
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"

File diff suppressed because one or more lines are too long

View File

@ -50,14 +50,14 @@ Mcu.PinsNb=30
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F072RBTx
MxCube.Version=6.5.0
MxDb.Version=DB.6.0.50
MxCube.Version=6.6.1
MxDb.Version=DB.6.0.60
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:false
PA0.Locked=true
PA0.Mode=IN0
PA0.Signal=ADC_IN0
@ -165,7 +165,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=MDK-ARM V5
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
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_ADC_Init-ADC-false-HAL-true,5-MX_TIM2_Init-TIM2-false-HAL-true,6-MX_TIM3_Init-TIM3-false-HAL-true,7-MX_TIM16_Init-TIM16-false-HAL-true,8-MX_TIM17_Init-TIM17-false-HAL-true
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_ADC_Init-ADC-false-HAL-true,5-MX_TIM2_Init-TIM2-false-HAL-true,6-MX_TIM3_Init-TIM3-false-HAL-true,7-MX_TIM16_Init-TIM16-false-HAL-true,8-MX_TIM17_Init-TIM17-false-HAL-true,9-MX_TIM7_Init-TIM7-false-HAL-true
RCC.AHBFreq_Value=48000000
RCC.APB1Freq_Value=48000000
RCC.APB1TimFreq_Value=48000000

View File

@ -15,7 +15,7 @@ menu "Onboard Peripheral Drivers"
default y
config BSP_USING_ARDUINO
bool "Support Arduino"
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART
select BSP_USING_GPIO

View File

@ -16,7 +16,7 @@ menu "Onboard Peripheral Drivers"
default y
config BSP_USING_ARDUINO
bool "Support Arduino"
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART
select BSP_USING_UART2

View File

@ -22,8 +22,8 @@ Hardware Drivers Config --->
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
| ----------- | --------- | ---- | --------------------------------------- |
| 0 (D0) | PA3 | | Serial2-Rx默认被RT-Thread的UART设备框架uart2接管 |
| 1 (D1) | PA2 | | Serial2-Tx默认被RT-Thread的UART设备框架uart2接管 |
| 0 (D0) | PA3 | | Serial2-Rx默认被RT-Thread的UART设备框架uart2接管 |
| 1 (D1) | PA2 | | Serial2-Tx默认被RT-Thread的UART设备框架uart2接管 |
| 2 (D2) | PA10 | 是 | |
| 3 (D3) | PB3 | 是 | PWM2-CH2默认被RT-Thread的PWM设备框架pwm2接管 |
| 4 (D4) | PB5 | 是 | |
@ -35,10 +35,10 @@ Hardware Drivers Config --->
| 10 (D10) | PB6 | 是 | PWM4-CH1默认被RT-Thread的PWM设备框架pwm4接管 |
| 11 (D11) | PA7 | 是 | PWM1-CH1N默认被RT-Thread的PWM设备框架pwm1接管 |
| 12 (D12) | PA6 | 是 | |
| 13 (D13) | PA5 | 是 | 板载LED |
| 13 (D13) | PA5 | 是 | 板载LED |
| 14 (D14) | PB9 | 是 | I2C-SDA默认被RT-Thread的I2C设备框架i2c1总线接管 |
| 15 (D15) | PB8 | 是 | I2C-SCL默认被RT-Thread的I2C设备框架i2c1总线接管 |
| 16 (D16) | PC13 | 是 | 板载用户按键(左侧蓝色) |
| 16 (D16) | PC13 | 是 | 板载用户按键(左侧蓝色) |
| A0 | PA0 | 是 | ADC1-CH0默认被RT-Thread的ADC设备框架adc1接管 |
| A1 | PA1 | 是 | ADC1-CH1默认被RT-Thread的ADC设备框架adc1接管 |
| A2 | PA4 | 是 | ADC1-CH4默认被RT-Thread的ADC设备框架adc1接管 |
@ -57,7 +57,7 @@ Hardware Drivers Config --->
> 参考资料
>
> 【1】[STM32 Nucleo板官方手册](https://www.st.com/resource/en/user_manual/um1724-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf)
> 【1】[STM32 Nucleo-64板官方手册](https://www.st.com/resource/en/user_manual/um1724-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf)
## 3 通信

View File

@ -37,7 +37,7 @@ const pin_map_t pin_map_table[]=
{D13, GET_PIN(A,5)}, /* LED_BUILTIN */
{D14, GET_PIN(B,9), "i2c1"}, /* I2C-SDA (Wire) */
{D15, GET_PIN(B,8), "i2c1"}, /* I2C-SCL (Wire) */
{D16, GET_PIN(C,13)},
{D16, GET_PIN(C,13)}, /* USER KEY */
{A0, GET_PIN(A,0), "adc1", 0}, /* ADC */
{A1, GET_PIN(A,1), "adc1", 1}, /* ADC */
{A2, GET_PIN(A,4), "adc1", 4}, /* ADC */

View File

@ -15,7 +15,7 @@ menu "Onboard Peripheral Drivers"
default y
config BSP_USING_ARDUINO
bool "Support Arduino"
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART
select BSP_USING_GPIO

View File

@ -1,12 +1,18 @@
import rtconfig
import os
from building import *
cwd = GetCurrentDir()
CPPPATH = [cwd, str(Dir('#'))]
src = Split("""
main.c
""")
CPPPATH = [cwd]
src = ['main.c']
if GetDepend(['PKG_USING_RTDUINO']) and not GetDepend(['RTDUINO_NO_SETUP_LOOP']):
src += ['arduino_main.cpp']
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
list = os.listdir(cwd)
for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
group = group + SConscript(os.path.join(item, 'SConscript'))
Return('group')

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-09-21 Meco Man first version
*/
#include <Arduino.h>
void setup(void)
{
/* put your setup code here, to run once: */
pinMode(LED_BUILTIN, OUTPUT);
}
void loop(void)
{
/* put your main code here, to run repeatedly: */
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
delay(100);
}

View File

@ -0,0 +1,75 @@
# STM32F412 Nucleo开发板的Arduino生态兼容说明
## 1 RTduino - RT-Thread的Arduino生态兼容层
STM32F412 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 --->
[*] Support Arduino
```
## 2 Arduino引脚排布
![nucleo-f412-pinout](nucleo-f412-pinout.png)
该BSP遵照Arduino UNO板的引脚排列方式。详见 `pins_arduino.c`
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
| ----------- | --------- | ---- | -------------------------------------- |
| 0 (D0) | PG9 | 是 | Serial-Rx默认被RT-Thread的UART设备框架uart3接管 |
| 1 (D1) | PG14 | 是 | Serial-tx默认被RT-Thread的UART设备框架uart3接管 |
| 2 (D2) | PF15 | 是 | |
| 3 (D3) | PE13 | 是 | PWM定时器1发生 |
| 4 (D4) | PF14 | 是 | |
| 5 (D5) | PE11 | 是 | PWM定时器1发生 |
| 6 (D6) | PE9 | 是 | PWM定时器1发生 |
| 7 (D7) | PF13 | 是 | |
| 8 (D8) | PF12 | 是 | |
| 9 (D9) | PD15 | 是 | PWM定时器4发生 |
| 10 (D10) | PD14 | 是 | PWM定时器4发生 |
| 11 (D11) | PA7 | 是 | PWM定时器14发生 |
| 12 (D12) | PA6 | 是 | |
| 13 (D13) | PA5 | 是 | |
| 14 (D14) | PB9 | 是 | 默认为I2C1-SDA被RT-Thread的I2C设备框架i2c1总线接管 |
| 15 (D15) | PB8 | 是 | 默认为I2C1-SCL被RT-Thread的I2C设备框架i2c1总线接管 |
| 16 (D16) | PC13 | 是 | 板载用户按键(左侧蓝色) |
| 17 (D17) | PB0 | 是 | 板载用户LED1 (LED_BUILTIN) |
| 18 (D18) | PB7 | 是 | 板载用户LED2 |
| 19 (D19) | PB14 | 是 | 板载用户LED3 |
| A0 | PA3 | 是 | ADC |
| A1 | PC0 | 是 | ADC |
| A2 | PC3 | 是 | ADC |
| A3 | PC1 | 是 | ADC |
| A4 | PC4 | 是 | ADC |
| A5 | PC5 | 是 | ADC |
| A6 | -- | | 芯片内部参考电压 ADC |
| A7 | -- | | 芯片内部温度 ADC |
> 注意:
>
> 1. 驱动舵机和analogWrite函数要选择不同定时器发生的PWM信号引脚由于STM32的定时器4个通道需要保持相同的频率如果采用相同的定时器发生的PWM分别驱动舵机和analogWrite可能会导致舵机失效。
> 2. Nucleo板的Arduino接口中AVDD即AREF默认是与VDD相连的如果需要扩展板提供外部参考电压需要将SB57锡桥挑开。
> 参考资料
>
> 【1】[STM32 Nucleo-144板官方手册](https://www.st.com/resource/en/user_manual/um1974-stm32-nucleo144-boards-mb1137-stmicroelectronics.pdf)
## 3 通信
### 3.1 I2C总线
I2C总线是板上丝印的 `SCL/D15``SDA/D14` 引脚这两个引脚默认是被RT-Thread I2C设备框架接管的直接引用`#include <Wire.h>`Arduino官方I2C头文件即可使用。
### 3.2 SPI总线
目前本BSP不支持使用Arduino的SPI功能。
### 3.3 串口
本BSP通过 `Serial.` 方法调用 `uart3` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-09-21 Meco Man first version
*/
#include <Arduino.h>
#include <board.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(G,9), "uart3"}, /* Serial-xx */
{D1, GET_PIN(G,14), "uart3"}, /* Serial-xx */
{D2, GET_PIN(F,15)},
{D3, GET_PIN(E,13), "pwm1", 3}, /* PWM */
{D4, GET_PIN(F,14)},
{D5, GET_PIN(E,11), "pwm1", 2}, /* PWM */
{D6, GET_PIN(E,9), "pwm1", 1}, /* PWM */
{D7, GET_PIN(F,13)},
{D8, GET_PIN(F,12)},
{D9, GET_PIN(D,15), "pwm4", 4}, /* PWM */
{D10, GET_PIN(D,14), "pwm4", 3}, /* PWM */
{D11, GET_PIN(A,7), "pwm14", 1}, /* PWM */
{D12, GET_PIN(A,6)},
{D13, GET_PIN(A,5)},
{D14, GET_PIN(B,9), "i2c1"}, /* I2C-SDA (Wire) */
{D15, GET_PIN(B,8), "i2c1"}, /* I2C-SCL (Wire) */
{D16, GET_PIN(C,13)}, /* USER KEY */
{D17, GET_PIN(B,0)}, /* LED_BUILTIN, USER LED1 */
{D18, GET_PIN(B,7)}, /* USER LED2 */
{D19, GET_PIN(B,14)}, /* USER LED3 */
{A0, GET_PIN(A,3), "adc1", 3}, /* ADC */
{A1, GET_PIN(C,0), "adc1", 10}, /* ADC */
{A2, GET_PIN(C,3), "adc1", 13}, /* ADC */
{A3, GET_PIN(C,1), "adc1", 11}, /* ADC */
{A4, GET_PIN(C,4), "adc1", 14}, /* ADC */
{A5, GET_PIN(C,5), "adc1", 15}, /* ADC */
{A6, RT_NULL, "adc1", 17}, /* ADC, On-Chip: internal reference voltage, ADC_CHANNEL_VREFINT */
{A7, RT_NULL, "adc1", 16}, /* ADC, On-Chip: internal temperature sensor, ADC_CHANNEL_TEMPSENSOR */
};

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-09-21 Meco Man 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 D16 (16)
#define D17 (17)
#define D18 (18)
#define D19 (19)
#define A0 (20)
#define A1 (21)
#define A2 (22)
#define A3 (23)
#define A4 (24)
#define A5 (25)
#define A6 (26)
#define A7 (27)
#define F_CPU 96000000L /* CPU:96MHz */
#define LED_BUILTIN D17 /* Default Built-in LED */
/* i2c1 : PB9-SDA PB8-SCL */
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
#endif /* Pins_Arduino_h */

View File

@ -12,19 +12,19 @@
#include <rtdevice.h>
#include <board.h>
/* defined the LED0 pin: PB7 */
#define LED0_PIN GET_PIN(B, 7)
/* defined the USER LED2 pin: PB7 */
#define LED2_PIN GET_PIN(B, 7)
int main(void)
{
/* set LED0 pin mode to output */
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
rt_pin_mode(LED2_PIN, PIN_MODE_OUTPUT);
while (1)
{
rt_pin_write(LED0_PIN, PIN_HIGH);
rt_pin_write(LED2_PIN, PIN_HIGH);
rt_thread_mdelay(500);
rt_pin_write(LED0_PIN, PIN_LOW);
rt_pin_write(LED2_PIN, PIN_LOW);
rt_thread_mdelay(500);
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,53 +1,81 @@
#MicroXplorer Configuration settings - do not modify
ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_3
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master
ADC1.NbrOfConversionFlag=1
ADC1.Rank-0\#ChannelRegularConversion=1
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES
ADC1.master=1
File.Version=6
KeepUserPlacement=true
Mcu.CPN=STM32F412ZGT6
Mcu.Family=STM32F4
Mcu.IP0=NVIC
Mcu.IP1=RCC
Mcu.IP2=SYS
Mcu.IP3=USART3
Mcu.IP4=USB_OTG_FS
Mcu.IPNb=5
Mcu.IP0=ADC1
Mcu.IP1=NVIC
Mcu.IP2=RCC
Mcu.IP3=SYS
Mcu.IP4=TIM1
Mcu.IP5=TIM4
Mcu.IP6=TIM14
Mcu.IP7=USART3
Mcu.IP8=USB_OTG_FS
Mcu.IPNb=9
Mcu.Name=STM32F412Z(E-G)Tx
Mcu.Package=LQFP144
Mcu.Pin0=PC13
Mcu.Pin1=PC14-OSC32_IN
Mcu.Pin10=PC9
Mcu.Pin11=PA8
Mcu.Pin12=PA9
Mcu.Pin13=PA10
Mcu.Pin14=PA11
Mcu.Pin15=PA12
Mcu.Pin16=PA13
Mcu.Pin17=PA14
Mcu.Pin18=PB3
Mcu.Pin19=PB7
Mcu.Pin10=PC4
Mcu.Pin11=PC5
Mcu.Pin12=PE9
Mcu.Pin13=PE11
Mcu.Pin14=PE13
Mcu.Pin15=PB14
Mcu.Pin16=PD8
Mcu.Pin17=PD9
Mcu.Pin18=PD14
Mcu.Pin19=PD15
Mcu.Pin2=PC15-OSC32_OUT
Mcu.Pin20=VP_SYS_VS_Systick
Mcu.Pin20=PG6
Mcu.Pin21=PG7
Mcu.Pin22=PC9
Mcu.Pin23=PA8
Mcu.Pin24=PA9
Mcu.Pin25=PA10
Mcu.Pin26=PA11
Mcu.Pin27=PA12
Mcu.Pin28=PA13
Mcu.Pin29=PA14
Mcu.Pin3=PH0 - OSC_IN
Mcu.Pin30=PB3
Mcu.Pin31=PB7
Mcu.Pin32=VP_ADC1_TempSens_Input
Mcu.Pin33=VP_ADC1_Vref_Input
Mcu.Pin34=VP_SYS_VS_Systick
Mcu.Pin35=VP_TIM1_VS_ClockSourceINT
Mcu.Pin36=VP_TIM4_VS_ClockSourceINT
Mcu.Pin37=VP_TIM14_VS_ClockSourceINT
Mcu.Pin4=PH1 - OSC_OUT
Mcu.Pin5=PB14
Mcu.Pin6=PD8
Mcu.Pin7=PD9
Mcu.Pin8=PG6
Mcu.Pin9=PG7
Mcu.PinsNb=21
Mcu.Pin5=PC0
Mcu.Pin6=PC1
Mcu.Pin7=PC3
Mcu.Pin8=PA3
Mcu.Pin9=PA7
Mcu.PinsNb=38
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F412ZGTx
MxCube.Version=5.0.0
MxDb.Version=DB.5.0.0
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:true\:false
MxCube.Version=6.6.1
MxDb.Version=DB.6.0.60
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:true\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:true\:false
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:false
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
PA10.GPIOParameters=GPIO_Label
PA10.GPIO_Label=USB_ID
PA10.Locked=true
@ -72,6 +100,10 @@ PA14.GPIO_Label=TCK
PA14.Locked=true
PA14.Mode=Serial_Wire
PA14.Signal=SYS_JTCK-SWCLK
PA3.Locked=true
PA3.Signal=ADCx_IN3
PA7.Locked=true
PA7.Signal=S_TIM14_CH1
PA8.GPIOParameters=GPIO_Label
PA8.GPIO_Label=USB_SOF [TP1]
PA8.Locked=true
@ -92,6 +124,10 @@ PB7.GPIOParameters=GPIO_Label
PB7.GPIO_Label=LD2 [Blue]
PB7.Locked=true
PB7.Signal=GPIO_Output
PC0.Locked=true
PC0.Signal=ADCx_IN10
PC1.Locked=true
PC1.Signal=ADCx_IN11
PC13.GPIOParameters=GPIO_Label
PC13.GPIO_Label=USER_Btn [B1]
PC13.Locked=true
@ -102,18 +138,20 @@ PC14-OSC32_IN.Signal=RCC_OSC32_IN
PC15-OSC32_OUT.Locked=true
PC15-OSC32_OUT.Mode=LSE-External-Oscillator
PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
PC3.Locked=true
PC3.Signal=ADCx_IN13
PC4.Locked=true
PC4.Signal=ADCx_IN14
PC5.Locked=true
PC5.Signal=ADCx_IN15
PC9.GPIOParameters=GPIO_Label
PC9.GPIO_Label=LD1 [Green]
PC9.Locked=true
PC9.Signal=GPIO_Output
PCC.Checker=false
PCC.Line=STM32F412
PCC.MCU=STM32F412Z(E-G)Tx
PCC.PartNumber=STM32F412ZGTx
PCC.Seq0=0
PCC.Series=STM32F4
PCC.Temperature=25
PCC.Vdd=null
PD14.Locked=true
PD14.Signal=S_TIM4_CH3
PD15.Locked=true
PD15.Signal=S_TIM4_CH4
PD8.GPIOParameters=GPIO_Label
PD8.GPIO_Label=STLK_RX [STM32F103CBT6_PA3]
PD8.Locked=true
@ -124,6 +162,12 @@ PD9.GPIO_Label=STLK_TX [STM32F103CBT6_PA2]
PD9.Locked=true
PD9.Mode=Asynchronous
PD9.Signal=USART3_RX
PE11.Locked=true
PE11.Signal=S_TIM1_CH2
PE13.Locked=true
PE13.Signal=S_TIM1_CH3
PE9.Locked=true
PE9.Signal=S_TIM1_CH1
PG6.GPIOParameters=GPIO_Label
PG6.GPIO_Label=USB_PowerSwitchOn [STMPS2151STR_EN]
PG6.Locked=true
@ -140,7 +184,7 @@ PH0\ -\ OSC_IN.Signal=RCC_OSC_IN
PH1\ -\ OSC_OUT.Mode=HSE-External-Clock-Source
PH1\ -\ OSC_OUT.Signal=RCC_OSC_OUT
PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=false
ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
@ -149,7 +193,7 @@ ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32F412ZGTx
ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.23.0
ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.27.1
ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200
@ -162,11 +206,12 @@ ProjectManager.PreviousToolchain=
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=CubeMX_Config.ioc
ProjectManager.ProjectName=CubeMX_Config
ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=MDK-ARM V5
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART3_UART_Init-USART3-false-HAL-true,4-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART3_UART_Init-USART3-false-HAL-true,4-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,5-MX_ADC1_Init-ADC1-false-HAL-true,6-MX_TIM1_Init-TIM1-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,8-MX_TIM14_Init-TIM14-false-HAL-true
RCC.48MHZClocksFreq_Value=24000000
RCC.ADC12outputFreq_Value=72000000
RCC.ADC34outputFreq_Value=72000000
@ -244,13 +289,56 @@ RCC.VCOOutput2Freq_Value=8000000
RCC.VCOOutputFreq_Value=384000000
RCC.VcooutputI2S=48000000
RCC.WatchDogFreq_Value=32000
SH.ADCx_IN10.0=ADC1_IN10,IN10
SH.ADCx_IN10.ConfNb=1
SH.ADCx_IN11.0=ADC1_IN11,IN11
SH.ADCx_IN11.ConfNb=1
SH.ADCx_IN13.0=ADC1_IN13,IN13
SH.ADCx_IN13.ConfNb=1
SH.ADCx_IN14.0=ADC1_IN14,IN14
SH.ADCx_IN14.ConfNb=1
SH.ADCx_IN15.0=ADC1_IN15,IN15
SH.ADCx_IN15.ConfNb=1
SH.ADCx_IN3.0=ADC1_IN3,IN3
SH.ADCx_IN3.ConfNb=1
SH.GPXTI13.0=GPIO_EXTI13
SH.GPXTI13.ConfNb=1
SH.S_TIM14_CH1.0=TIM14_CH1,PWM Generation1 CH1
SH.S_TIM14_CH1.ConfNb=1
SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1
SH.S_TIM1_CH1.ConfNb=1
SH.S_TIM1_CH2.0=TIM1_CH2,PWM Generation2 CH2
SH.S_TIM1_CH2.ConfNb=1
SH.S_TIM1_CH3.0=TIM1_CH3,PWM Generation3 CH3
SH.S_TIM1_CH3.ConfNb=1
SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3
SH.S_TIM4_CH3.ConfNb=1
SH.S_TIM4_CH4.0=TIM4_CH4,PWM Generation4 CH4
SH.S_TIM4_CH4.ConfNb=1
TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM1.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM1.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM1.IPParameters=Channel-PWM Generation3 CH3,Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1
TIM14.Channel=TIM_CHANNEL_1
TIM14.IPParameters=Channel
TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM4.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM4.IPParameters=Channel-PWM Generation4 CH4,Channel-PWM Generation3 CH3
USART3.IPParameters=VirtualMode
USART3.VirtualMode=VM_ASYNC
USB_OTG_FS.IPParameters=VirtualMode
USB_OTG_FS.VirtualMode=Device_Only
VP_ADC1_TempSens_Input.Mode=IN-TempSens
VP_ADC1_TempSens_Input.Signal=ADC1_TempSens_Input
VP_ADC1_Vref_Input.Mode=IN-Vrefint
VP_ADC1_Vref_Input.Signal=ADC1_Vref_Input
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_TIM14_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM14_VS_ClockSourceINT.Signal=TIM14_VS_ClockSourceINT
VP_TIM1_VS_ClockSourceINT.Mode=Internal
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
VP_TIM4_VS_ClockSourceINT.Mode=Internal
VP_TIM4_VS_ClockSourceINT.Signal=TIM4_VS_ClockSourceINT
board=NUCLEO-F412ZG
boardIOC=true

View File

@ -70,6 +70,8 @@ extern "C" {
/* USER CODE END EM */
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
@ -121,5 +123,3 @@ void Error_Handler(void);
#endif
#endif /* __MAIN_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,36 +1,24 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f4xx_hal_conf.h
* @brief HAL configuration file.
* @file stm32f4xx_hal_conf_template.h
* @author MCD Application Team
* @brief HAL configuration template file.
* This file should be copied to the application folder and renamed
* to stm32f4xx_hal_conf.h.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
* Copyright (c) 2017 STMicroelectronics.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_HAL_CONF_H
@ -45,14 +33,15 @@
/* ########################## Module Selection ############################## */
/**
* @brief This is the list of modules to be used in the HAL driver
* @brief This is the list of modules to be used in the HAL driver
*/
#define HAL_MODULE_ENABLED
#define HAL_MODULE_ENABLED
/* #define HAL_ADC_MODULE_ENABLED */
#define HAL_ADC_MODULE_ENABLED
/* #define HAL_CRYP_MODULE_ENABLED */
/* #define HAL_CAN_MODULE_ENABLED */
/* #define HAL_CRC_MODULE_ENABLED */
/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
/* #define HAL_CRYP_MODULE_ENABLED */
/* #define HAL_DAC_MODULE_ENABLED */
/* #define HAL_DCMI_MODULE_ENABLED */
@ -74,11 +63,12 @@
/* #define HAL_SD_MODULE_ENABLED */
/* #define HAL_MMC_MODULE_ENABLED */
/* #define HAL_SPI_MODULE_ENABLED */
/* #define HAL_TIM_MODULE_ENABLED */
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
/* #define HAL_USART_MODULE_ENABLED */
/* #define HAL_IRDA_MODULE_ENABLED */
/* #define HAL_SMARTCARD_MODULE_ENABLED */
/* #define HAL_SMBUS_MODULE_ENABLED */
/* #define HAL_WWDG_MODULE_ENABLED */
#define HAL_PCD_MODULE_ENABLED
/* #define HAL_HCD_MODULE_ENABLED */
@ -87,11 +77,12 @@
/* #define HAL_QSPI_MODULE_ENABLED */
/* #define HAL_CEC_MODULE_ENABLED */
/* #define HAL_FMPI2C_MODULE_ENABLED */
/* #define HAL_FMPSMBUS_MODULE_ENABLED */
/* #define HAL_SPDIFRX_MODULE_ENABLED */
/* #define HAL_DFSDM_MODULE_ENABLED */
/* #define HAL_LPTIM_MODULE_ENABLED */
/* #define HAL_EXTI_MODULE_ENABLED */
#define HAL_GPIO_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
@ -102,20 +93,20 @@
/**
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
#if !defined (HSE_VALUE)
#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */
/**
* @brief Internal High Speed oscillator (HSI) value.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSI is used as system clock source, directly or through the PLL).
* (when HSI is used as system clock source, directly or through the PLL).
*/
#if !defined (HSI_VALUE)
#define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
@ -124,8 +115,8 @@
/**
* @brief Internal Low Speed oscillator (LSI) value.
*/
#if !defined (LSI_VALUE)
#define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
#if !defined (LSI_VALUE)
#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations
in voltage and temperature.*/
@ -133,20 +124,20 @@
* @brief External Low Speed oscillator (LSE) value.
*/
#if !defined (LSE_VALUE)
#define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */
#endif /* LSE_VALUE */
#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */
/**
* @brief External clock source for I2S peripheral
* This value is used by the I2S HAL module to compute the I2S clock source
* frequency, this source is inserted directly through I2S_CKIN pad.
* This value is used by the I2S HAL module to compute the I2S clock source
* frequency, this source is inserted directly through I2S_CKIN pad.
*/
#if !defined (EXTERNAL_CLOCK_VALUE)
#define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/
#endif /* EXTERNAL_CLOCK_VALUE */
/* Tip: To avoid modifying this file each time you need to use different HSE,
@ -156,16 +147,56 @@
/**
* @brief This is the HAL system configuration section
*/
#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
#define USE_RTOS 0U
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority */
#define USE_RTOS 0U
#define PREFETCH_ENABLE 1U
#define INSTRUCTION_CACHE_ENABLE 1U
#define DATA_CACHE_ENABLE 1U
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
/* ########################## Assert Selection ############################## */
/**
* @brief Uncomment the line below to expanse the "assert_param" macro in the
* @brief Uncomment the line below to expanse the "assert_param" macro in the
* HAL drivers code
*/
/* #define USE_FULL_ASSERT 1U */
@ -182,29 +213,29 @@
#define MAC_ADDR4 0U
#define MAC_ADDR5 0U
/* Definition of the Ethernet driver buffers size and count */
/* Definition of the Ethernet driver buffers size and count */
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
/* Section 2: PHY configuration section */
/* DP83848_PHY_ADDRESS Address*/
/* DP83848_PHY_ADDRESS Address*/
#define DP83848_PHY_ADDRESS 0x01U
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
#define PHY_RESET_DELAY ((uint32_t)0x000000FFU)
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
#define PHY_RESET_DELAY 0x000000FFU
/* PHY Configuration delay */
#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU)
#define PHY_CONFIG_DELAY 0x00000FFFU
#define PHY_READ_TO ((uint32_t)0x0000FFFFU)
#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU)
#define PHY_READ_TO 0x0000FFFFU
#define PHY_WRITE_TO 0x0000FFFFU
/* Section 3: Common PHY Registers */
#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */
#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */
#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
@ -219,7 +250,7 @@
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
/* Section 4: Extended PHY Registers */
#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
@ -237,25 +268,25 @@
/* Includes ------------------------------------------------------------------*/
/**
* @brief Include module's header file
* @brief Include module's header file
*/
#ifdef HAL_RCC_MODULE_ENABLED
#include "stm32f4xx_hal_rcc.h"
#endif /* HAL_RCC_MODULE_ENABLED */
#ifdef HAL_EXTI_MODULE_ENABLED
#include "stm32f4xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */
#ifdef HAL_GPIO_MODULE_ENABLED
#include "stm32f4xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */
#ifdef HAL_EXTI_MODULE_ENABLED
#include "stm32f4xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */
#ifdef HAL_DMA_MODULE_ENABLED
#include "stm32f4xx_hal_dma.h"
#endif /* HAL_DMA_MODULE_ENABLED */
#ifdef HAL_CORTEX_MODULE_ENABLED
#include "stm32f4xx_hal_cortex.h"
#endif /* HAL_CORTEX_MODULE_ENABLED */
@ -268,12 +299,16 @@
#include "stm32f4xx_hal_can.h"
#endif /* HAL_CAN_MODULE_ENABLED */
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
#include "stm32f4xx_hal_can_legacy.h"
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
#ifdef HAL_CRC_MODULE_ENABLED
#include "stm32f4xx_hal_crc.h"
#endif /* HAL_CRC_MODULE_ENABLED */
#ifdef HAL_CRYP_MODULE_ENABLED
#include "stm32f4xx_hal_cryp.h"
#include "stm32f4xx_hal_cryp.h"
#endif /* HAL_CRYP_MODULE_ENABLED */
#ifdef HAL_DMA2D_MODULE_ENABLED
@ -295,7 +330,7 @@
#ifdef HAL_FLASH_MODULE_ENABLED
#include "stm32f4xx_hal_flash.h"
#endif /* HAL_FLASH_MODULE_ENABLED */
#ifdef HAL_SRAM_MODULE_ENABLED
#include "stm32f4xx_hal_sram.h"
#endif /* HAL_SRAM_MODULE_ENABLED */
@ -310,11 +345,11 @@
#ifdef HAL_PCCARD_MODULE_ENABLED
#include "stm32f4xx_hal_pccard.h"
#endif /* HAL_PCCARD_MODULE_ENABLED */
#endif /* HAL_PCCARD_MODULE_ENABLED */
#ifdef HAL_SDRAM_MODULE_ENABLED
#include "stm32f4xx_hal_sdram.h"
#endif /* HAL_SDRAM_MODULE_ENABLED */
#endif /* HAL_SDRAM_MODULE_ENABLED */
#ifdef HAL_HASH_MODULE_ENABLED
#include "stm32f4xx_hal_hash.h"
@ -324,6 +359,10 @@
#include "stm32f4xx_hal_i2c.h"
#endif /* HAL_I2C_MODULE_ENABLED */
#ifdef HAL_SMBUS_MODULE_ENABLED
#include "stm32f4xx_hal_smbus.h"
#endif /* HAL_SMBUS_MODULE_ENABLED */
#ifdef HAL_I2S_MODULE_ENABLED
#include "stm32f4xx_hal_i2s.h"
#endif /* HAL_I2S_MODULE_ENABLED */
@ -356,10 +395,6 @@
#include "stm32f4xx_hal_sd.h"
#endif /* HAL_SD_MODULE_ENABLED */
#ifdef HAL_MMC_MODULE_ENABLED
#include "stm32f4xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */
#ifdef HAL_SPI_MODULE_ENABLED
#include "stm32f4xx_hal_spi.h"
#endif /* HAL_SPI_MODULE_ENABLED */
@ -395,7 +430,7 @@
#ifdef HAL_HCD_MODULE_ENABLED
#include "stm32f4xx_hal_hcd.h"
#endif /* HAL_HCD_MODULE_ENABLED */
#ifdef HAL_DSI_MODULE_ENABLED
#include "stm32f4xx_hal_dsi.h"
#endif /* HAL_DSI_MODULE_ENABLED */
@ -412,6 +447,10 @@
#include "stm32f4xx_hal_fmpi2c.h"
#endif /* HAL_FMPI2C_MODULE_ENABLED */
#ifdef HAL_FMPSMBUS_MODULE_ENABLED
#include "stm32f4xx_hal_fmpsmbus.h"
#endif /* HAL_FMPSMBUS_MODULE_ENABLED */
#ifdef HAL_SPDIFRX_MODULE_ENABLED
#include "stm32f4xx_hal_spdifrx.h"
#endif /* HAL_SPDIFRX_MODULE_ENABLED */
@ -423,14 +462,18 @@
#ifdef HAL_LPTIM_MODULE_ENABLED
#include "stm32f4xx_hal_lptim.h"
#endif /* HAL_LPTIM_MODULE_ENABLED */
#ifdef HAL_MMC_MODULE_ENABLED
#include "stm32f4xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function
* @param expr If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
@ -439,13 +482,10 @@
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
#endif /* USE_FULL_ASSERT */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F4xx_HAL_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -39,7 +39,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#endif
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
@ -80,5 +80,3 @@ void SysTick_Handler(void);
#endif
#endif /* __STM32F4xx_IT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -78,7 +78,9 @@
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
/**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
@ -97,6 +99,245 @@ 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};
if(hadc->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspInit 0 */
/* USER CODE END ADC1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_ADC1_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**ADC1 GPIO Configuration
PC0 ------> ADC1_IN10
PC1 ------> ADC1_IN11
PC3 ------> ADC1_IN13
PA3 ------> ADC1_IN3
PC4 ------> ADC1_IN14
PC5 ------> ADC1_IN15
*/
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4
|GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &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_ADC1_CLK_DISABLE();
/**ADC1 GPIO Configuration
PC0 ------> ADC1_IN10
PC1 ------> ADC1_IN11
PC3 ------> ADC1_IN13
PA3 ------> ADC1_IN3
PC4 ------> ADC1_IN14
PC5 ------> ADC1_IN15
*/
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4
|GPIO_PIN_5);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_3);
/* 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==TIM4)
{
/* USER CODE BEGIN TIM4_MspInit 0 */
/* USER CODE END TIM4_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM4_CLK_ENABLE();
/* USER CODE BEGIN TIM4_MspInit 1 */
/* USER CODE END TIM4_MspInit 1 */
}
else if(htim_base->Instance==TIM14)
{
/* USER CODE BEGIN TIM14_MspInit 0 */
/* USER CODE END TIM14_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM14_CLK_ENABLE();
/* USER CODE BEGIN TIM14_MspInit 1 */
/* USER CODE END TIM14_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_GPIOE_CLK_ENABLE();
/**TIM1 GPIO Configuration
PE9 ------> TIM1_CH1
PE11 ------> TIM1_CH2
PE13 ------> TIM1_CH3
*/
GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/* USER CODE BEGIN TIM1_MspPostInit 1 */
/* USER CODE END TIM1_MspPostInit 1 */
}
else if(htim->Instance==TIM4)
{
/* USER CODE BEGIN TIM4_MspPostInit 0 */
/* USER CODE END TIM4_MspPostInit 0 */
__HAL_RCC_GPIOD_CLK_ENABLE();
/**TIM4 GPIO Configuration
PD14 ------> TIM4_CH3
PD15 ------> TIM4_CH4
*/
GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM4;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/* USER CODE BEGIN TIM4_MspPostInit 1 */
/* USER CODE END TIM4_MspPostInit 1 */
}
else if(htim->Instance==TIM14)
{
/* USER CODE BEGIN TIM14_MspPostInit 0 */
/* USER CODE END TIM14_MspPostInit 0 */
__HAL_RCC_GPIOA_CLK_ENABLE();
/**TIM14 GPIO Configuration
PA7 ------> TIM14_CH1
*/
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_AF9_TIM14;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USER CODE BEGIN TIM14_MspPostInit 1 */
/* USER CODE END TIM14_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==TIM4)
{
/* USER CODE BEGIN TIM4_MspDeInit 0 */
/* USER CODE END TIM4_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM4_CLK_DISABLE();
/* USER CODE BEGIN TIM4_MspDeInit 1 */
/* USER CODE END TIM4_MspDeInit 1 */
}
else if(htim_base->Instance==TIM14)
{
/* USER CODE BEGIN TIM14_MspDeInit 0 */
/* USER CODE END TIM14_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM14_CLK_DISABLE();
/* USER CODE BEGIN TIM14_MspDeInit 1 */
/* USER CODE END TIM14_MspDeInit 1 */
}
}
/**
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example
@ -105,7 +346,6 @@ void HAL_MspInit(void)
*/
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(huart->Instance==USART3)
{
@ -122,7 +362,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
*/
GPIO_InitStruct.Pin = STLK_RX_Pin|STLK_TX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
@ -140,10 +380,8 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
{
if(huart->Instance==USART3)
{
/* USER CODE BEGIN USART3_MspDeInit 0 */
@ -173,14 +411,23 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
*/
void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
if(hpcd->Instance==USB_OTG_FS)
{
/* USER CODE BEGIN USB_OTG_FS_MspInit 0 */
/* USER CODE END USB_OTG_FS_MspInit 0 */
/** Initializes the peripherals clock
*/
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CLK48;
PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48CLKSOURCE_PLLQ;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
__HAL_RCC_GPIOA_CLK_ENABLE();
/**USB_OTG_FS GPIO Configuration
PA8 ------> USB_OTG_FS_SOF
@ -210,10 +457,8 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
* @param hpcd: PCD handle pointer
* @retval None
*/
void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
{
if(hpcd->Instance==USB_OTG_FS)
{
/* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */
@ -240,5 +485,3 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -71,12 +71,13 @@
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/******************************************************************************/
/* Cortex-M4 Processor Interruption and Exception Handlers */
/* Cortex-M4 Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
@ -214,4 +215,3 @@ void SysTick_Handler(void)
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -16,6 +16,29 @@ menu "Onboard Peripheral Drivers"
select BSP_USING_UART3
default y
config BSP_USING_ARDUINO
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART
select BSP_USING_GPIO
select BSP_USING_ADC
select BSP_USING_ADC1
select BSP_USING_PWM
select BSP_USING_PWM14
select BSP_USING_PWM4
select BSP_USING_PWM1
select BSP_USING_PWM1_CH3
select BSP_USING_PWM1_CH2
select BSP_USING_PWM1_CH1
select BSP_USING_PWM4_CH4
select BSP_USING_PWM4_CH3
select BSP_USING_PWM14_CH1
select BSP_USING_I2C
select BSP_USING_I2C1
imply RTDUINO_USING_SERVO
imply RTDUINO_USING_WIRE
default n
endmenu
menu "On-chip Peripheral Drivers"
@ -47,6 +70,86 @@ 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_CH1
bool "Enable PWM1 channel1"
default n
config BSP_USING_PWM1_CH2
bool "Enable PWM1 channel2"
default n
config BSP_USING_PWM1_CH3
bool "Enable PWM1 channel3"
default n
endif
menuconfig BSP_USING_PWM4
bool "Enable timer4 output PWM"
default n
if BSP_USING_PWM4
config BSP_USING_PWM4_CH3
bool "Enable PWM3 channel3"
default n
config BSP_USING_PWM4_CH4
bool "Enable PWM4 channel4"
default n
endif
menuconfig BSP_USING_PWM14
bool "Enable timer14 output PWM"
default n
if BSP_USING_PWM14
config BSP_USING_PWM14_CH1
bool "Enable PWM14 channel1"
default n
endif
endif
menuconfig BSP_USING_I2C
bool "Enable I2C BUS"
default n
select RT_USING_I2C
select RT_USING_I2C_BITOPS
select RT_USING_PIN
if BSP_USING_I2C
config BSP_USING_I2C1
bool "Enable I2C1 Bus (User I2C)"
default n
if BSP_USING_I2C1
comment "Notice: PB9 --> 25; PB8 --> 24"
config BSP_I2C1_SCL_PIN
int "i2c1 SCL pin number"
range 1 176
default 24
config BSP_I2C1_SDA_PIN
int "i2c1 SDA pin number"
range 1 176
default 25
endif
endif
config BSP_USING_ON_CHIP_FLASH
bool "Enable on-chip FLASH"
default n

View File

@ -47,6 +47,14 @@ SECTIONS
__rt_init_end = .;
. = ALIGN(4);
PROVIDE(__ctors_start__ = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE(__ctors_end__ = .);
. = ALIGN(4);
_etext = .;
} > ROM = 0

View File

@ -1,4 +1,4 @@
# STM32F69 Discovery开发板的Arduino生态兼容说明
# STM32F469 Discovery开发板的Arduino生态兼容说明
## 1 RTduino - RT-Thread的Arduino生态兼容层
@ -22,8 +22,8 @@ Hardware Drivers Config --->
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
| --------------- | ------------- | ------ | ------------------------------------------------------------ |
| 0 (D0) | -- | | 该引脚在UNO板中为串口RX引脚不可当做普通IO |
| 1 (D1) | -- | | 该引脚在UNO板中为串口TX引脚不可当做普通IO |
| 0 (D0) | PG9 | 是 | Serial-Rx默认被RT-Thread的UART设备框架uart6接管 |
| 1 (D1) | PG14 | 是 | Serial-Tx默认被RT-Thread的UART设备框架uart6接管 |
| 2 (D2) | PG13 | 是 | |
| 3 (D3) | PA1 | 是 | PWM定时器2发生 |
| 4 (D4) | PG12 | 是 | |
@ -60,6 +60,17 @@ Hardware Drivers Config --->
>
> 【1】[STM32F469 Discovery官方资料](https://www.st.com/en/evaluation-tools/32f469idiscovery.html#documentation)
## 3 I2C总线
## 3 通信
### 3.1 I2C总线
STM32F469 Discovery板的I2C总线是板上丝印的 `SCL/D15``SDA/D14` 引脚这两个引脚是被RT-Thread I2C设备框架接管的不需要直接操控这两个引脚直接引用`#include <Wire.h>`Arduino官方I2C头文件即可使用。
### 3.2 SPI总线
目前本BSP不支持使用Arduino的SPI功能。
### 3.3 串口
本BSP通过 `Serial.` 方法调用 `uart2` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。

View File

@ -23,7 +23,7 @@ menu "Onboard Peripheral Drivers"
endif
config BSP_USING_ARDUINO
bool "Support Arduino"
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART
select BSP_USING_GPIO

View File

@ -57,7 +57,7 @@
#define F_CPU 80000000L /* CPU:80MHz */
#define LED_BUITIN D22 /* Default Built-in LED */
#define LED_BUILTIN D22 /* Default Built-in LED */
/*
* i2c1 - PC7-SDA PC6-SCL (User I2C)

View File

@ -20,7 +20,7 @@ menu "Onboard Peripheral Drivers"
default y
config BSP_USING_ARDUINO
bool "Support Arduino"
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART
select BSP_USING_GPIO