[Ardunio] stm32-blue-pill对接RTdunio软件包 (#6241)

按照pinout布局图重新设计Arduino引脚布局和功能
- 目前PB0(D12, PWM)和PA15(D5,PWM)测试不通过
参考:https://github.com/stm32duino/Arduino_Core_STM32/issues/1082#issuecomment-634027716
This commit is contained in:
liYang~ 2022-08-08 22:00:03 +08:00 committed by GitHub
parent 8da744a750
commit 40f5e1d1ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 202 additions and 285 deletions

View File

@ -20,55 +20,43 @@ Hardware Drivers Config --->
该BSP遵照Arduino UNO板的引脚排列方式并扩展增加了Blue-pill自身的板载资源功能引脚。详见 `pins_arduino.c`
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
| --------------- | ------------- | ------ | ------------------------------------------------------------ |
| 0 (D0) | -- | | 该引脚在UNO板中为串口RX引脚不可当做普通IO |
| 1 (D1) | -- | | 该引脚在UNO板中为串口TX引脚不可当做普通IO |
| 2 (D2) | PB9 | 是 | I2C1-SDA被RT-Thread的I2C设备框架i2c1总线接管不可当做普通IO |
| 3 (D3) | PB8 | 是 | I2C1_SCL被RT-Thread的I2C设备框架i2c1总线接管不可当做普通IO |
| 4 (D4) | PB7 | 是 | |
| 5 (D5) | PB6 | 是 | |
| 6 (D6) | PB5 | 否 | PWM3-CH2定时器3发生 |
| 7 (D7) | PB4 | 是 | PWM3-CH1定时器3发生 |
| 8 (D8) | PB3 | 是 | PWM2-CH2定时器2发生 |
| 9 (D9) | PA15 | 是 | PWM2-CH1定时器2发生 |
| 10 (D10) | PA12 | 是 | USB-DB不可当做普通IO |
| 11 (D11) | PA11 | 是 | USB-DM不可当做普通IO |
| 12 (D12) | PA10 | 是 | UART1-RX被RT-Thread的UART设备框架uart1接管不可当做普通IO |
| 13 (D13) | PA9 | 是 | UART1-RX被RT-Thread的UART设备框架uart1接管不可当做普通IO |
| 14 (D14) | PA8 | 是 | PWM1-CH1定时器1发生 |
| 15 (D15) | PB15 | 是 | |
| 16 (D16) | PB14 | 是 | |
| 17 (D17) | PB13 | 是 | PWM1-CH1N定时器1发生 |
| 18 (D18) | PB12 | 是 | |
| 19 (D19) | PC13 | 否 | 板载LED默认引脚 |
| 20 (D20) | PC14 | 否 | |
| 21 (D21) | PC15 | 否 | |
| 22 (D22) | PA2 | 否 | UART2-TX被RT-Thread的UART设备框架uart2接管不可当做普通IO |
| 23 (D23) | PA3 | 否 | UART2-RX被RT-Thread的UART设备框架uart2接管不可当做普通IO |
| 24 (D24) | PA5 | 否 | SPI-SCK SPI功能尚未完全实现目前仅作普通IO使用 |
| 25 (D25) | PA6 | 否 | SPI-MISOSPI功能尚未完全实现目前仅作普通IO使用 |
| 26 (D26) | PA7 | 否 | SPI-MOSISPI功能尚未完全实现目前仅作普通IO使用 |
| 27 (D27) | PB10 | 是 | UART3-TX被RT-Thread的UART设备框架uart3接管不可当做普通IO |
| 28 (D28) | PB11 | 是 | UART3-RX被RT-Thread的UART设备框架uart3接管不可当做普通IO |
| A0 | PA0 | 否 | ADC |
| A1 | PA1 | 否 | ADC |
| A2 | PA4 | 否 | ADC |
| A3 | PB0 | 否 | ADC |
| A4 | PB1 | 否 | ADC |
| A5 | -- | | 芯片内部参考电压 ADC |
| A6 | -- | | 芯片内部温度 ADC |
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
| ----------- | --------- | ---- | -------------------------------------------- |
| 0 (D0) | PB7 | 是 | |
| 1 (D1) | PB6 | 是 | |
| 2 (D2) | PB5 | 否 | PWM3-CH2定时器3发生 |
| 3 (D3) | PB4 | 是 | PWM3-CH1定时器3发生 |
| 4 (D4) | PB3 | 是 | PWM2-CH2定时器2发生 |
| 5 (D5) | PA15 | 是 | PWM2-CH1定时器2发生 |
| 6 (D6) | PA8 | 是 | |
| 7 (D7) | PB12 | 是 | |
| 8 (D8) | PC13 | 否 | |
| 9 (D9) | PC14 | 否 | |
| 10 (D10) | PC15 | 否 | |
| 11 (D11) | PA0 | 否 | |
| 12 (D12) | PB0 | 否 | PWM3-CH3定时器3发生 |
| 13 (D13) | PB1 | 否 | PWM3-CH4定时器3发生 |
| A0 | PA1 | 否 | ADC1-CH1 |
| A1 | PA4 | 否 | ADC1-CH4 |
| A2 | PA5 | 否 | ADC1-CH5 |
| A3 | PA6 | 否 | ADC1-CH6 |
| A4 | PA7 | 否 | ADC1-CH7 |
| A5 | -- | | 芯片内部参考电压 ADC |
| A6 | -- | | 芯片内部温度 ADC |
| -- | PB9 | 是 | I2C-SDA被RT-Thread的I2C设备框架i2c1总线接管不可当做普通IO |
| -- | PB8 | 是 | I2C-SCL被RT-Thread的I2C设备框架i2c1总线接管不可当做普通IO |
| -- | PA12 | 是 | USB-DP被TinyUSB接管不可当做普通IO |
| -- | PA11 | 是 | USB-DM被TinyUSB接管不可当做普通IO |
| -- | PA10 | 是 | UART1-RX被RT-Thread的UART设备框架uart1接管不可当做普通IO |
| -- | PA9 | 是 | UART1-TX被RT-Thread的UART设备框架uart1接管不可当做普通IO |
| -- | PA2 | 否 | UART2-TX被RT-Thread的UART设备框架uart2接管不可当做普通IO |
| -- | PA3 | 否 | UART2-RX被RT-Thread的UART设备框架uart2接管不可当做普通IO |
| -- | PB10 | 是 | UART3-TX被RT-Thread的UART设备框架uart3接管不可当做普通IO |
| -- | PB11 | 是 | UART3-RX被RT-Thread的UART设备框架uart3接管不可当做普通IO |
| -- | PB15 | 是 | SPI-MOSISPI功能尚未完全实现 |
| -- | PB14 | 是 | SPI-MISOSPI功能尚未完全实现 |
| -- | PB13 | 是 | SPI-SCK SPI功能尚未完全实现 |
> 注意:
>
>
> 1. 驱动舵机和analogWrite函数要选择不同定时器发生的PWM信号引脚由于STM32的定时器4个通道需要保持相同的频率如果采用相同的定时器发生的PWM分别驱动舵机和analogWrite可能会导致舵机失效。
> 4. D10引脚是PWM反相位引脚(也就是常说的互补输出引脚CHxN)。但是这里不用考虑到占空比互补问题CHx-20%CHxN-80%),直接正常使用即可。
> 4. STM32的PA15引脚默认作为JTAG下载使用但是如果采用SWD调试时PA15(D9)可以作为普通的IO口使用但是需要设置一些寄存器。
> 参考资料
>
> 1. 暂无
## 3 I2C总线
STM32F103 Blue-Pill板的I2C总线是板上丝印的 `SCL/D3``SDA/D2` 引脚这两个引脚是被RT-Thread I2C设备框架接管的不需要直接操控这两个引脚直接引用`#include <Wire.h>`Arduino官方I2C头文件即可使用。

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -20,42 +20,34 @@
*/
const pin_map_t pin_map_table[]=
{
{D0}, /* RX */
{D1}, /* TX */
{D2}, /* I2C1-SDA */
{D3}, /* I2C1-SCL */
{D4, GET_PIN(B,7)},
{D5, GET_PIN(B,6)},
{D6, GET_PIN(B,5), "pwm3", 2},/* PWM */
{D7, GET_PIN(B,4), "pwm3", 1}, /* PWM */
{D8, GET_PIN(B,3), "pwm2", 2}, /* PWM */
{D9, GET_PIN(A,15), "pwm2", 1}, /* PWM */
{D10}, /* USB-DP */
{D11}, /* USB-DM */
{D12}, /* UART1-RX */
{D13}, /* UART1-TX */
{D14, GET_PIN(A,8), "pwm1", 1}, /* PWM */
{D15, GET_PIN(B,15)},
{D16, GET_PIN(B,14)},
{D17, GET_PIN(B,13), "pwm1", -1}, /* PWM */
{D18, GET_PIN(B,12)},
{D19, GET_PIN(C,13)}, /* user led1 */
{D20, GET_PIN(C,14)},
{D21, GET_PIN(C,15)},
{D22}, /* UART2-TX */
{D23}, /* UART2-RX */
/* The connection of RTdunio SPI has not been completed, *
* and it can only be used as a common GPIO at present. */
{D24, GET_PIN(A,5)}, /* SPI-SCK */
{D25, GET_PIN(A,6)}, /* SPI-MISO */
{D26, GET_PIN(A,7)}, /* SPI-MOSI */
{D27}, /* UART3-TX */
{D28}, /* UART3-RX */
{A0, GET_PIN(A,0), "adc1", 0}, /* ADC */
{A1, GET_PIN(A,1), "adc1", 1}, /* ADC */
{A2, GET_PIN(A,4), "adc1", 4}, /* ADC */
{A3, GET_PIN(B,0), "adc1", 8}, /* ADC */
{A4, GET_PIN(B,1), "adc1", 9}, /* ADC */
{D0, GET_PIN(B,7)},
{D1, GET_PIN(B,6)},
{D2, GET_PIN(B,5), "pwm3", 2},/* PWM */
{D3, GET_PIN(B,4), "pwm3", 1}, /* PWM */
{D4, GET_PIN(B,3), "pwm2", 2}, /* PWM */
{D5, GET_PIN(A,15), "pwm2", 1}, /* PWM */
{D6, GET_PIN(A,8)},
{D7, GET_PIN(B,12)},
{D8, GET_PIN(C,13)}, /* LED_BUILTIN */
{D9, GET_PIN(C,14)},
{D10, GET_PIN(C,15)},
{D11, GET_PIN(A,0)},
{D12, GET_PIN(B,0), "pwm3", 3}, /* PWM */
{D13, GET_PIN(B,1), "pwm3", 4}, /* PWM */
{A0, GET_PIN(A,1), "adc1", 1}, /* ADC */
{A1, GET_PIN(A,4), "adc1", 4}, /* ADC */
{A2, GET_PIN(A,5), "adc1", 5}, /* ADC */
{A3, GET_PIN(A,6), "adc1", 6}, /* ADC */
{A4, GET_PIN(A,7), "adc1", 7}, /* ADC */
{A5, RT_NULL, "adc1", 17}, /* ADC, On-Chip: internal reference voltage, ADC_CHANNEL_VREFINT */
{A6, RT_NULL, "adc1", 16} /* ADC, On-Chip: internal temperature sensor, ADC_CHANNEL_TEMPSENSOR */
};
/*
* Before RTdunio is used, you can do some necessary initialization through this function
*/
void initVariant()
{
/* JTAG-DP Disabled and SW-DP enabled */
__HAL_RCC_AFIO_CLK_ENABLE();
__HAL_AFIO_REMAP_SWJ_NOJTAG();
}

View File

@ -26,34 +26,26 @@
#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 D20 (20)
#define D21 (21)
#define D22 (22)
#define D23 (23)
#define D24 (24)
#define D25 (25)
#define D26 (26)
#define D27 (27)
#define D28 (28)
#define A0 (29)
#define A1 (30)
#define A2 (31)
#define A3 (32)
#define A4 (33)
#define A5 (34)
#define A6 (35)
#define A0 (14)
#define A1 (15)
#define A2 (16)
#define A3 (17)
#define A4 (18)
#define A5 (19)
#define A6 (20)
#define F_CPU 72000000L /* CPU: 72MHz */
#define LED_BUILTIN D19 /* Default Built-in LED */
#define LED_BUILTIN D8 /* Default Built-in LED */
/*
* i2c1 - PB9-SDA PB8-SCL
*/
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
/*
* uart2 - PA2-TX PA3-RX
* uart3 - PB10-TX PB11-RX
*/
#define RTDUINO_SERIAL2_DEVICE_NAME "uart2"
#define RTDUINO_SERIAL3_DEVICE_NAME "uart3"

View File

@ -11,30 +11,29 @@ Mcu.CPN=STM32F103C8T6
Mcu.Family=STM32F1
Mcu.IP0=ADC1
Mcu.IP1=NVIC
Mcu.IP10=USART2
Mcu.IP11=USART3
Mcu.IP12=USB
Mcu.IP10=USART3
Mcu.IP11=USB
Mcu.IP2=RCC
Mcu.IP3=RTC
Mcu.IP4=SPI1
Mcu.IP4=SPI2
Mcu.IP5=SYS
Mcu.IP6=TIM1
Mcu.IP7=TIM2
Mcu.IP8=TIM3
Mcu.IP9=USART1
Mcu.IPNb=13
Mcu.IP6=TIM2
Mcu.IP7=TIM3
Mcu.IP8=USART1
Mcu.IP9=USART2
Mcu.IPNb=12
Mcu.Name=STM32F103C(8-B)Tx
Mcu.Package=LQFP48
Mcu.Pin0=PC14-OSC32_IN
Mcu.Pin1=PC15-OSC32_OUT
Mcu.Pin10=PA6
Mcu.Pin11=PA7
Mcu.Pin12=PB0
Mcu.Pin13=PB1
Mcu.Pin14=PB10
Mcu.Pin15=PB11
Mcu.Pin16=PB13
Mcu.Pin17=PA8
Mcu.Pin10=PA7
Mcu.Pin11=PB0
Mcu.Pin12=PB1
Mcu.Pin13=PB10
Mcu.Pin14=PB11
Mcu.Pin15=PB13
Mcu.Pin16=PB14
Mcu.Pin17=PB15
Mcu.Pin18=PA9
Mcu.Pin19=PA10
Mcu.Pin2=PD0-OSC_IN
@ -51,16 +50,15 @@ Mcu.Pin29=VP_ADC1_Vref_Input
Mcu.Pin3=PD1-OSC_OUT
Mcu.Pin30=VP_RTC_VS_RTC_Activate
Mcu.Pin31=VP_SYS_VS_Systick
Mcu.Pin32=VP_TIM1_VS_ClockSourceINT
Mcu.Pin33=VP_TIM2_VS_ClockSourceINT
Mcu.Pin34=VP_TIM3_VS_ClockSourceINT
Mcu.Pin4=PA0-WKUP
Mcu.Pin5=PA1
Mcu.Pin6=PA2
Mcu.Pin7=PA3
Mcu.Pin8=PA4
Mcu.Pin9=PA5
Mcu.PinsNb=35
Mcu.Pin32=VP_TIM2_VS_ClockSourceINT
Mcu.Pin33=VP_TIM3_VS_ClockSourceINT
Mcu.Pin4=PA1
Mcu.Pin5=PA2
Mcu.Pin6=PA3
Mcu.Pin7=PA4
Mcu.Pin8=PA5
Mcu.Pin9=PA6
Mcu.PinsNb=34
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F103C8Tx
@ -77,8 +75,6 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA0-WKUP.Locked=true
PA0-WKUP.Signal=ADCx_IN0
PA1.Signal=ADCx_IN1
PA10.GPIOParameters=GPIO_PuPd
PA10.GPIO_PuPd=GPIO_PULLUP
@ -104,28 +100,30 @@ PA3.Mode=Asynchronous
PA3.Signal=USART2_RX
PA4.Locked=true
PA4.Signal=ADCx_IN4
PA5.Mode=Full_Duplex_Master
PA5.Signal=SPI1_SCK
PA6.Mode=Full_Duplex_Master
PA6.Signal=SPI1_MISO
PA7.Mode=Full_Duplex_Master
PA7.Signal=SPI1_MOSI
PA8.Signal=S_TIM1_CH1
PA5.Locked=true
PA5.Signal=ADCx_IN5
PA6.Locked=true
PA6.Signal=ADCx_IN6
PA7.Locked=true
PA7.Signal=ADCx_IN7
PA9.GPIOParameters=GPIO_PuPd
PA9.GPIO_PuPd=GPIO_PULLUP
PA9.Mode=Asynchronous
PA9.Signal=USART1_TX
PB0.Locked=true
PB0.Signal=ADCx_IN8
PB0.Signal=S_TIM3_CH3
PB1.Locked=true
PB1.Signal=ADCx_IN9
PB1.Signal=S_TIM3_CH4
PB10.Mode=Asynchronous
PB10.Signal=USART3_TX
PB11.Mode=Asynchronous
PB11.Signal=USART3_RX
PB13.Locked=true
PB13.Mode=PWM Generation1 CH1 CH1N
PB13.Signal=TIM1_CH1N
PB13.Mode=Full_Duplex_Master
PB13.Signal=SPI2_SCK
PB14.Mode=Full_Duplex_Master
PB14.Signal=SPI2_MISO
PB15.Mode=Full_Duplex_Master
PB15.Signal=SPI2_MOSI
PB3.Signal=S_TIM2_CH2
PB4.Signal=S_TIM3_CH1
PB5.Signal=S_TIM3_CH2
@ -189,18 +187,16 @@ RCC.TimSysFreq_Value=72000000
RCC.USBFreq_Value=48000000
RCC.USBPrescaler=RCC_USBCLKSOURCE_PLL_DIV1_5
RCC.VCOOutput2Freq_Value=8000000
SH.ADCx_IN0.0=ADC1_IN0,IN0
SH.ADCx_IN0.ConfNb=1
SH.ADCx_IN1.0=ADC1_IN1,IN1
SH.ADCx_IN1.ConfNb=1
SH.ADCx_IN4.0=ADC1_IN4,IN4
SH.ADCx_IN4.ConfNb=1
SH.ADCx_IN8.0=ADC1_IN8,IN8
SH.ADCx_IN8.ConfNb=1
SH.ADCx_IN9.0=ADC1_IN9,IN9
SH.ADCx_IN9.ConfNb=1
SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1 CH1N
SH.S_TIM1_CH1.ConfNb=1
SH.ADCx_IN5.0=ADC1_IN5,IN5
SH.ADCx_IN5.ConfNb=1
SH.ADCx_IN6.0=ADC1_IN6,IN6
SH.ADCx_IN6.ConfNb=1
SH.ADCx_IN7.0=ADC1_IN7,IN7
SH.ADCx_IN7.ConfNb=1
SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1
SH.S_TIM2_CH1_ETR.ConfNb=1
SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2
@ -209,20 +205,23 @@ 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
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_8
SPI1.CalculateBaudRate=9.0 MBits/s
SPI1.Direction=SPI_DIRECTION_2LINES
SPI1.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate
SPI1.Mode=SPI_MODE_MASTER
SPI1.VirtualType=VM_MASTER
TIM1.Channel-PWM\ Generation1\ CH1\ CH1N=TIM_CHANNEL_1
TIM1.IPParameters=Channel-PWM Generation1 CH1 CH1N
SH.S_TIM3_CH3.0=TIM3_CH3,PWM Generation3 CH3
SH.S_TIM3_CH3.ConfNb=1
SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4
SH.S_TIM3_CH4.ConfNb=1
SPI2.CalculateBaudRate=18.0 MBits/s
SPI2.Direction=SPI_DIRECTION_2LINES
SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
SPI2.Mode=SPI_MODE_MASTER
SPI2.VirtualType=VM_MASTER
TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM2.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2
TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM3.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2
TIM3.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM3.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
USART1.IPParameters=VirtualMode
USART1.VirtualMode=VM_ASYNC
USART2.IPParameters=VirtualMode
@ -237,8 +236,6 @@ VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
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

View File

@ -60,7 +60,7 @@
/* USER CODE END 0 */
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
/**
/**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
@ -101,22 +101,18 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
__HAL_RCC_ADC1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/**ADC1 GPIO Configuration
PA0-WKUP ------> ADC1_IN0
PA1 ------> ADC1_IN1
PA4 ------> ADC1_IN4
PB0 ------> ADC1_IN8
PB1 ------> ADC1_IN9
PA5 ------> ADC1_IN5
PA6 ------> ADC1_IN6
PA7 ------> ADC1_IN7
*/
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4;
GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6
|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN ADC1_MspInit 1 */
/* USER CODE END ADC1_MspInit 1 */
@ -141,15 +137,14 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
__HAL_RCC_ADC1_CLK_DISABLE();
/**ADC1 GPIO Configuration
PA0-WKUP ------> ADC1_IN0
PA1 ------> ADC1_IN1
PA4 ------> ADC1_IN4
PB0 ------> ADC1_IN8
PB1 ------> ADC1_IN9
PA5 ------> ADC1_IN5
PA6 ------> ADC1_IN6
PA7 ------> ADC1_IN7
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0|GPIO_PIN_1);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6
|GPIO_PIN_7);
/* USER CODE BEGIN ADC1_MspDeInit 1 */
@ -214,33 +209,33 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hspi->Instance==SPI1)
if(hspi->Instance==SPI2)
{
/* USER CODE BEGIN SPI1_MspInit 0 */
/* USER CODE BEGIN SPI2_MspInit 0 */
/* USER CODE END SPI1_MspInit 0 */
/* USER CODE END SPI2_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_SPI1_CLK_ENABLE();
__HAL_RCC_SPI2_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PA6 ------> SPI1_MISO
PA7 ------> SPI1_MOSI
__HAL_RCC_GPIOB_CLK_ENABLE();
/**SPI2 GPIO Configuration
PB13 ------> SPI2_SCK
PB14 ------> SPI2_MISO
PB15 ------> SPI2_MOSI
*/
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Pin = GPIO_PIN_14;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN SPI1_MspInit 1 */
/* USER CODE BEGIN SPI2_MspInit 1 */
/* USER CODE END SPI1_MspInit 1 */
/* USER CODE END SPI2_MspInit 1 */
}
}
@ -253,24 +248,24 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
*/
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
{
if(hspi->Instance==SPI1)
if(hspi->Instance==SPI2)
{
/* USER CODE BEGIN SPI1_MspDeInit 0 */
/* USER CODE BEGIN SPI2_MspDeInit 0 */
/* USER CODE END SPI1_MspDeInit 0 */
/* USER CODE END SPI2_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_SPI1_CLK_DISABLE();
__HAL_RCC_SPI2_CLK_DISABLE();
/**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PA6 ------> SPI1_MISO
PA7 ------> SPI1_MOSI
/**SPI2 GPIO Configuration
PB13 ------> SPI2_SCK
PB14 ------> SPI2_MISO
PB15 ------> SPI2_MOSI
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
/* USER CODE BEGIN SPI1_MspDeInit 1 */
/* USER CODE BEGIN SPI2_MspDeInit 1 */
/* USER CODE END SPI1_MspDeInit 1 */
/* USER CODE END SPI2_MspDeInit 1 */
}
}
@ -283,18 +278,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
*/
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)
if(htim_base->Instance==TIM2)
{
/* USER CODE BEGIN TIM2_MspInit 0 */
@ -322,37 +306,11 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
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();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**TIM1 GPIO Configuration
PB13 ------> TIM1_CH1N
PA8 ------> TIM1_CH1
*/
GPIO_InitStruct.Pin = GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USER CODE BEGIN TIM1_MspPostInit 1 */
/* USER CODE END TIM1_MspPostInit 1 */
}
else if(htim->Instance==TIM2)
if(htim->Instance==TIM2)
{
/* USER CODE BEGIN TIM2_MspPostInit 0 */
/* USER CODE END TIM2_MspPostInit 0 */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/**TIM2 GPIO Configuration
@ -383,10 +341,12 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
__HAL_RCC_GPIOB_CLK_ENABLE();
/**TIM3 GPIO Configuration
PB0 ------> TIM3_CH3
PB1 ------> TIM3_CH4
PB4 ------> TIM3_CH1
PB5 ------> TIM3_CH2
*/
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
@ -407,18 +367,7 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
*/
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)
if(htim_base->Instance==TIM2)
{
/* USER CODE BEGIN TIM2_MspDeInit 0 */

View File

@ -15,7 +15,7 @@ menu "Onboard Peripheral Drivers"
select BSP_USING_UART1
default y
config BSP_USING_ARDUINO
config BSP_USING_ARDUINO
bool "Support Arduino"
select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART
@ -25,14 +25,14 @@ menu "Onboard Peripheral Drivers"
select BSP_USING_ADC
select BSP_USING_ADC1
select BSP_USING_PWM
select BSP_USING_PWM1
select BSP_USING_PWM1_CH1
select BSP_USING_PWM2
select BSP_USING_PWM2_CH1
select BSP_USING_PWM2_CH2
select BSP_USING_PWM3
select BSP_USING_PWM3_CH1
select BSP_USING_PWM3_CH2
select BSP_USING_PWM3_CH3
select BSP_USING_PWM3_CH4
select BSP_USING_I2C
select BSP_USING_I2C1
imply RTDUINO_USING_SERVO
@ -105,15 +105,6 @@ menu "On-chip Peripheral Drivers"
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
endif
menuconfig BSP_USING_PWM2
bool "Enable timer2 output PWM"
default n
@ -138,6 +129,14 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_PWM3_CH2
bool "Enable PWM3 channel2"
default n
config BSP_USING_PWM3_CH3
bool "Enable PWM3 channel3"
default n
config BSP_USING_PWM3_CH4
bool "Enable PWM3 channel4"
default n
endif
endif
@ -163,19 +162,19 @@ menu "On-chip Peripheral Drivers"
default n
select RT_USING_SPI
if BSP_USING_SPI
config BSP_USING_SPI1
bool "Enable SPI1 BUS"
config BSP_USING_SPI2
bool "Enable SPI2 BUS"
default n
config BSP_SPI1_TX_USING_DMA
bool "Enable SPI1 TX DMA"
depends on BSP_USING_SPI1
config BSP_SPI2_TX_USING_DMA
bool "Enable SPI2 TX DMA"
depends on BSP_USING_SPI2
default n
config BSP_SPI1_RX_USING_DMA
bool "Enable SPI1 RX DMA"
depends on BSP_USING_SPI1
select BSP_SPI1_TX_USING_DMA
config BSP_SPI2_RX_USING_DMA
bool "Enable SPI2 RX DMA"
depends on BSP_USING_SPI2
select BSP_SPI2_TX_USING_DMA
default n
endif

View File

@ -35,7 +35,7 @@ Hardware Drivers Config --->
| 10 (D10) | PH6 | 是 | PWM定时器12发生 |
| 11 (D11) | PB15 | 是 | PWM定时器12发生 |
| 12 (D12) | PB14 | 是 | |
| 13 (D13) | PD3 | 是 | RTduino LED |
| 13 (D13) | PD3 | 是 | LED_BUILTIN |
| 14 (D14) | PB9 | 是 | I2C1-SDA被RT-Thread的I2C设备框架i2c1总线接管不可当做普通IO |
| 15 (D15) | PB8 | 是 | I2C1_SCL被RT-Thread的I2C设备框架i2c1总线接管不可当做普通IO |
| 16 (D16) | PA0 | 是 | Discovery板载用户按键蓝色 |

View File

@ -33,7 +33,7 @@ const pin_map_t pin_map_table[]=
{D10, GET_PIN(H,6),"pwm12", 1}, /* PWM */
{D11, GET_PIN(B,15),"pwm12", 2}, /* PWM */
{D12, GET_PIN(B,14)},
{D13, GET_PIN(D,3)},
{D13, GET_PIN(D,3)}, /* LED_BUILTIN */
{D14}, /* I2C1-SDA */
{D15}, /* I2C1-SCL */
{D16, GET_PIN(A,0)}, /* user button */