Browse Source

[arduino][stm32f427-robomaster-a] : 对接RTduino (#6767)

* [arduino][stm32f427-robomaster-a] : 对接RTduino

* Update README.md

* Update pins_arduino.c

Co-authored-by: Man, Jianting (Meco) <920369182@qq.com>
螺丝松掉的人 2 năm trước cách đây
mục cha
commit
eec9d4f595

+ 2 - 2
bsp/stm32/stm32f407-robomaster-c/applications/arduino_pinout/README.md

@@ -1,8 +1,8 @@
-# xxx 开发板的Arduino生态兼容说明
+# 大疆STM32F407 Robomaster C型开发板的Arduino生态兼容说明
 
 ## 1 RTduino - RT-Thread的Arduino生态兼容层
 
-stm32f407-robomaster-c 开发板已经完整适配了[RTduino软件包](https://github.com/RTduino/RTduino),即RT-Thread的Arduino生态兼容层。用户可以按照Arduino的编程习惯来操作该BSP,并且可以使用大量Arduino社区丰富的库,是对RT-Thread生态的极大增强。更多信息,请参见[RTduino软件包说明文档](https://github.com/RTduino/RTduino)。
+大疆STM32F407 Robomaster C型开发板已经完整适配了[RTduino软件包](https://github.com/RTduino/RTduino),即RT-Thread的Arduino生态兼容层。用户可以按照Arduino的编程习惯来操作该BSP,并且可以使用大量Arduino社区丰富的库,是对RT-Thread生态的极大增强。更多信息,请参见[RTduino软件包说明文档](https://github.com/RTduino/RTduino)。
 
 ### 1.1 如何开启针对本BSP的Arduino生态兼容层
 

+ 10 - 4
bsp/stm32/stm32f427-robomaster-a/applications/SConscript

@@ -1,12 +1,18 @@
-import rtconfig
 from building import *
+import os
 
 cwd     = GetCurrentDir()
 CPPPATH = [cwd]
-src     = Split("""
-main.c
-""")
+src     = Glob('*.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')

+ 24 - 0
bsp/stm32/stm32f427-robomaster-a/applications/arduino_main.cpp

@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2022-12-21     ChuShicheng  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);
+}

+ 69 - 0
bsp/stm32/stm32f427-robomaster-a/applications/arduino_pinout/README.md

@@ -0,0 +1,69 @@
+# 大疆STM32F427 Robomaster A型开发板的Arduino生态兼容说明
+
+## 1 RTduino - RT-Thread的Arduino生态兼容层
+
+大疆STM32F427 Robomaster A型开发板已经完整适配了[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)。
+
+![xxx-pinout](xxx-pinout.jpg)
+| Arduino引脚编号  | STM32引脚编号 | 5V容忍 | 备注  |
+| ------------------- | --------- | ---- | ------------------------------------------------------------------------- |
+| 0 (D0) | PF14 | 是/否 | 板载用户LED |
+| 1 (D1) | PD9 | 是/否 | Serial-RX,默认被RT-Thread的UART设备框架uart3接管 |
+| 2 (D2) | PD8 | 是/否 | Serial-TX,默认被RT-Thread的UART设备框架uart3接管 |
+| 3 (D3) | PG9 | 是/否 | Serial-RX,默认被RT-Thread的UART设备框架uart6接管 |
+| 4 (D4) | PG14 | 是/否 | Serial-TX,默认被RT-Thread的UART设备框架uart6接管 |
+| 5 (D5) | PE0 | 是/否 | Serial-RX,默认被RT-Thread的UART设备框架uart8接管 |
+| 6 (D6) | PE1 | 是/否 | Serial-TX,默认被RT-Thread的UART设备框架uart8接管 |
+| 7 (D7) | PE7 | 是/否 | Serial-RX,默认被RT-Thread的UART设备框架uart7接管 |
+| 8 (D8) | PE8 | 是/否 | Serial-TX,默认被RT-Thread的UART设备框架uart7接管 |
+| 9 (D9) | PH6 | 是/否 | 板载蜂鸣器,PWM12-CH1,默认被RT-Thread的PWM设备框架pwm12接管 |
+| 10 (D10) | PD12 | 是/否 | PWM4-CH1,默认被RT-Thread的PWM设备框架pwm4接管 |
+| 11 (D11) | PD13 | 是/否 | PWM4-CH2,默认被RT-Thread的PWM设备框架pwm4接管 |
+| 12 (D12) | PD14 | 是/否 | PWM4-CH3,默认被RT-Thread的PWM设备框架pwm4接管 |
+| 13 (D13) | PD15 | 是/否 | PWM4-CH4,默认被RT-Thread的PWM设备框架pwm4接管 |
+| 14 (D14) | PH10 | 是/否 | PWM5-CH1,默认被RT-Thread的PWM设备框架pwm5接管 |
+| 15 (D15) | PH11 | 是/否 | PWM5-CH2,默认被RT-Thread的PWM设备框架pwm5接管 |
+| 16 (D16) | PH12 | 是/否 | PWM5-CH3,默认被RT-Thread的PWM设备框架pwm5接管 |
+| 17 (D17) | PI0 | 是/否 | PWM5-CH4,默认被RT-Thread的PWM设备框架pwm5接管 |
+| 18 (D18) | PA0 | 是/否 | PWM2-CH1,默认被RT-Thread的PWM设备框架pwm2接管 |
+| 19 (D19) | PA1 | 是/否 | PWM2-CH2,默认被RT-Thread的PWM设备框架pwm2接管 |
+| 20 (D20) | PA2 | 是/否 | PWM2-CH3,默认被RT-Thread的PWM设备框架pwm2接管 |
+| 21 (D21) | PA3 | 是/否 | PWM2-CH4,默认被RT-Thread的PWM设备框架pwm2接管 |
+| 22 (D22) | PI5 | 是/否 | PWM8-CH1,默认被RT-Thread的PWM设备框架pwm8接管 |
+| 23 (D23) | PI6 | 是/否 | PWM8-CH2,默认被RT-Thread的PWM设备框架pwm8接管 |
+| 24 (D24) | PI7 | 是/否 | PWM8-CH3,默认被RT-Thread的PWM设备框架pwm8接管 |
+| 25 (D25) | PI2 | 是/否 | PWM8-CH4,默认被RT-Thread的PWM设备框架pwm8接管 |
+| 26 (D26) | PF1 | 是/否 |  |
+| 27 (D27) | PF0 | 是/否 |  |
+| 28 (D28) | PE4 | 是/否 | I2C1-SCL,默认被RT-Thread的I2C设备框架i2c1接管 |
+| 29 (D29) | PE5 | 是/否 | I2C1-SDA,默认被RT-Thread的I2C设备框架i2c1接管 |
+| 30 (D30) | PE6 | 是/否 |  |
+| 31 (D31) | PE12 | 是/否 |  |
+| 32 (D32) | PC2 | 是/否 |  |
+| 33 (D33) | PB0 | 是/否 |  |
+| 34 (D34) | PC3 | 是/否 |  |
+| 35 (D35) | PB1 | 是/否 |  |
+| 36 (D36) | PC4 | 是/否 |  |
+| 37 (D37) | PC0 | 是/否 |  |
+| 38 (D38) | PC5 | 是/否 |  |
+| 39 (D39) | PC1 | 是/否 |  |
+| 40 (D40) | PA5 | 是/否 |  |
+| 41 (D41) | PA4 | 是/否 |  |
+| 42 (D42) | PF10 | 是/否 |  |
+| 43 (D43) | PI9 | 是/否 |  |
+| 44 (A0) | -- |  | 芯片内部温度 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
+| 45 (A1) | -- |  | 芯片内部参考电压 ADC,默认被RT-Thread的ADC设备框架adc1接管 |

+ 9 - 0
bsp/stm32/stm32f427-robomaster-a/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')

+ 70 - 0
bsp/stm32/stm32f427-robomaster-a/applications/arduino_pinout/pins_arduino.c

@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2022-12-21     ChuShicheng  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(F,14)},                /* LED_BUILTIN */
+    {D1, GET_PIN(D,9), "uart3"},        /* Serial-RX */
+    {D2, GET_PIN(D,8), "uart3"},        /* Serial-TX */
+    {D3, GET_PIN(G,9), "uart6"},        /* Serial-RX */
+    {D4, GET_PIN(G,14), "uart6"},       /* Serial-TX */
+    {D5, GET_PIN(E,0), "uart8"},        /* Serial-RX */
+    {D6, GET_PIN(E,1), "uart8"},        /* Serial-TX */
+    {D7, GET_PIN(E,7), "uart7"},        /* Serial-RX */
+    {D8, GET_PIN(E,8), "uart7"},        /* Serial-TX */
+    {D9, GET_PIN(H,6), "pwm12", 1},     /* BSP: Buzzer, PWM */
+    {D10, GET_PIN(D,12), "pwm4", 1},    /* PWM */
+    {D11, GET_PIN(D,13), "pwm4", 2},    /* PWM */
+    {D12, GET_PIN(D,14), "pwm4", 3},    /* PWM */
+    {D13, GET_PIN(D,15), "pwm4", 4},    /* PWM */
+    {D14, GET_PIN(H,10), "pwm5", 1},    /* PWM */
+    {D15, GET_PIN(H,11), "pwm5", 2},    /* PWM */
+    {D16, GET_PIN(H,12), "pwm5", 3},    /* PWM */
+    {D17, GET_PIN(I,0), "pwm5", 4},     /* PWM */
+    {D18, GET_PIN(A,0), "pwm2", 1},     /* PWM */
+    {D19, GET_PIN(A,1), "pwm2", 2},     /* PWM */
+    {D20, GET_PIN(A,2), "pwm2", 3},     /* PWM */
+    {D21, GET_PIN(A,3), "pwm2", 4},     /* PWM */
+    {D22, GET_PIN(I,5), "pwm8", 1},     /* PWM */
+    {D23, GET_PIN(I,6), "pwm8", 2},     /* PWM */
+    {D24, GET_PIN(I,7), "pwm8", 3},     /* PWM */
+    {D25, GET_PIN(I,2), "pwm8", 4},     /* PWM */
+    {D26, GET_PIN(F,1)},
+    {D27, GET_PIN(F,0)},
+    {D28, GET_PIN(E,4), "i2c1"},        /* I2C-SCL (Wire) */
+    {D29, GET_PIN(E,5), "i2c1"},        /* I2C-SDA (Wire) */
+    {D30, GET_PIN(E,6)},
+    {D31, GET_PIN(E,12)},
+    {D32, GET_PIN(C,2)},
+    {D33, GET_PIN(B,0)},
+    {D34, GET_PIN(C,3)},
+    {D35, GET_PIN(B,1)},
+    {D36, GET_PIN(C,4)},
+    {D37, GET_PIN(C,0)},
+    {D38, GET_PIN(C,5)},
+    {D39, GET_PIN(C,1)},
+    {D40, GET_PIN(A,5)},
+    {D41, GET_PIN(A,4)},
+    {D42, GET_PIN(F,10)},
+    {D43, GET_PIN(I,9)},
+    {A0, RT_NULL, "adc1", 16},          /* ADC, On-Chip: internal temperature sensor, ADC_CHANNEL_TEMPSENSOR */
+    {A1, RT_NULL, "adc1", 17},          /* ADC, On-Chip: internal reference voltage, ADC_CHANNEL_VREFINT */
+};

+ 69 - 0
bsp/stm32/stm32f427-robomaster-a/applications/arduino_pinout/pins_arduino.h

@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2022-12-21     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 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 D29       (29)
+#define D30       (30)
+#define D31       (31)
+#define D32       (32)
+#define D33       (33)
+#define D34       (34)
+#define D35       (35)
+#define D36       (36)
+#define D37       (37)
+#define D38       (38)
+#define D39       (39)
+#define D40       (40)
+#define D41       (41)
+#define D42       (42)
+#define D43       (43)
+#define A0        (44)
+#define A1        (45)
+
+#define F_CPU          180000000L  /* CPU:180MHz */
+
+#define LED_BUILTIN     D0  /* Default Built-in LED */
+
+/* i2c1 : PE5-SDA PE4-SCL */
+#define RTDUINO_DEFAULT_IIC_BUS_NAME    "i2c1"
+
+#endif /* Pins_Arduino_h */

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 6
bsp/stm32/stm32f427-robomaster-a/board/CubeMX_Config/.mxproject


+ 132 - 68
bsp/stm32/stm32f427-robomaster-a/board/CubeMX_Config/CubeMX_Config.ioc

@@ -1,94 +1,125 @@
 #MicroXplorer Configuration settings - do not modify
+ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_TEMPSENSOR
+ADC1.IPParameters=Rank-0\#ChannelRegularConversion,master,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag
+ADC1.NbrOfConversionFlag=1
+ADC1.Rank-0\#ChannelRegularConversion=1
+ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES
+ADC1.master=1
+CAD.formats=
+CAD.pinconfig=
+CAD.provider=
 CAN1.CalculateTimeQuantum=355.55555555555554
 CAN1.IPParameters=CalculateTimeQuantum
 CAN2.CalculateTimeQuantum=355.55555555555554
 CAN2.IPParameters=CalculateTimeQuantum
 File.Version=6
 KeepUserPlacement=true
+Mcu.CPN=STM32F427IIH6
 Mcu.Family=STM32F4
-Mcu.IP0=CAN1
-Mcu.IP1=CAN2
-Mcu.IP10=UART7
-Mcu.IP11=UART8
-Mcu.IP12=USART1
-Mcu.IP13=USART3
-Mcu.IP14=USART6
-Mcu.IP2=NVIC
-Mcu.IP3=RCC
-Mcu.IP4=SDIO
-Mcu.IP5=SPI5
-Mcu.IP6=SYS
-Mcu.IP7=TIM4
-Mcu.IP8=TIM5
-Mcu.IP9=TIM12
-Mcu.IPNb=15
+Mcu.IP0=ADC1
+Mcu.IP1=CAN1
+Mcu.IP10=TIM5
+Mcu.IP11=TIM8
+Mcu.IP12=TIM12
+Mcu.IP13=UART7
+Mcu.IP14=UART8
+Mcu.IP15=USART1
+Mcu.IP16=USART3
+Mcu.IP17=USART6
+Mcu.IP2=CAN2
+Mcu.IP3=NVIC
+Mcu.IP4=RCC
+Mcu.IP5=SDIO
+Mcu.IP6=SPI5
+Mcu.IP7=SYS
+Mcu.IP8=TIM2
+Mcu.IP9=TIM4
+Mcu.IPNb=18
 Mcu.Name=STM32F427I(G-I)Hx
 Mcu.Package=UFBGA176
 Mcu.Pin0=PE1
 Mcu.Pin1=PE0
 Mcu.Pin10=PC10
-Mcu.Pin11=PG9
-Mcu.Pin12=PD1
-Mcu.Pin13=PD2
-Mcu.Pin14=PI0
-Mcu.Pin15=PC9
-Mcu.Pin16=PH0/OSC_IN
-Mcu.Pin17=PC8
-Mcu.Pin18=PH1/OSC_OUT
-Mcu.Pin19=PF7
+Mcu.Pin11=PI7
+Mcu.Pin12=PI6
+Mcu.Pin13=PI5
+Mcu.Pin14=PG9
+Mcu.Pin15=PD1
+Mcu.Pin16=PI2
+Mcu.Pin17=PD2
+Mcu.Pin18=PI0
+Mcu.Pin19=PC9
 Mcu.Pin2=PG14
-Mcu.Pin20=PF6
-Mcu.Pin21=PH12
-Mcu.Pin22=PF9
-Mcu.Pin23=PF8
-Mcu.Pin24=PH11
-Mcu.Pin25=PH10
-Mcu.Pin26=PD15
-Mcu.Pin27=PH6
-Mcu.Pin28=PD14
-Mcu.Pin29=PD13
+Mcu.Pin20=PH0/OSC_IN
+Mcu.Pin21=PC8
+Mcu.Pin22=PH1/OSC_OUT
+Mcu.Pin23=PF7
+Mcu.Pin24=PF6
+Mcu.Pin25=PH12
+Mcu.Pin26=PF9
+Mcu.Pin27=PF8
+Mcu.Pin28=PH11
+Mcu.Pin29=PH10
 Mcu.Pin3=PC12
-Mcu.Pin30=PD12
-Mcu.Pin31=PE8
-Mcu.Pin32=PE11
-Mcu.Pin33=PB12
-Mcu.Pin34=PB13
-Mcu.Pin35=PD9
-Mcu.Pin36=PD8
-Mcu.Pin37=PF14
-Mcu.Pin38=PE7
-Mcu.Pin39=VP_SYS_VS_Systick
+Mcu.Pin30=PD15
+Mcu.Pin31=PH6
+Mcu.Pin32=PD14
+Mcu.Pin33=PD13
+Mcu.Pin34=PA1
+Mcu.Pin35=PA0/WKUP
+Mcu.Pin36=PD12
+Mcu.Pin37=PA2
+Mcu.Pin38=PE8
+Mcu.Pin39=PE11
 Mcu.Pin4=PA14
-Mcu.Pin40=VP_TIM4_VS_ClockSourceINT
-Mcu.Pin41=VP_TIM5_VS_ClockSourceINT
-Mcu.Pin42=VP_TIM12_VS_ClockSourceINT
+Mcu.Pin40=PB12
+Mcu.Pin41=PB13
+Mcu.Pin42=PD9
+Mcu.Pin43=PD8
+Mcu.Pin44=PA3
+Mcu.Pin45=PF14
+Mcu.Pin46=PE7
+Mcu.Pin47=VP_ADC1_TempSens_Input
+Mcu.Pin48=VP_ADC1_Vref_Input
+Mcu.Pin49=VP_SYS_VS_Systick
 Mcu.Pin5=PA13
+Mcu.Pin50=VP_TIM2_VS_ClockSourceINT
+Mcu.Pin51=VP_TIM4_VS_ClockSourceINT
+Mcu.Pin52=VP_TIM5_VS_ClockSourceINT
+Mcu.Pin53=VP_TIM8_VS_ClockSourceINT
+Mcu.Pin54=VP_TIM12_VS_ClockSourceINT
 Mcu.Pin6=PB7
 Mcu.Pin7=PB6
 Mcu.Pin8=PD0
 Mcu.Pin9=PC11
-Mcu.PinsNb=43
+Mcu.PinsNb=55
 Mcu.ThirdPartyNb=0
 Mcu.UserConstants=
 Mcu.UserName=STM32F427IIHx
 MxCube.Version=5.4.0
 MxDb.Version=DB.5.0.40
-NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
-NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
+NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
+NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
 NVIC.ForceEnableDMAVector=true
-NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
-NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false
-NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false
-NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
+NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
+NVIC.MemoryManagement_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.PriorityGroup=NVIC_PRIORITYGROUP_4
-NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
-NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
-NVIC.USART6_IRQn=true\:0\:0\:false\:false\:true\:true\:true
-NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
+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.USART6_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
+NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
+PA0/WKUP.Locked=true
+PA0/WKUP.Signal=S_TIM2_CH1_ETR
+PA1.Locked=true
+PA1.Signal=S_TIM2_CH2
 PA13.Mode=Serial_Wire
 PA13.Signal=SYS_JTMS-SWDIO
 PA14.Mode=Serial_Wire
 PA14.Signal=SYS_JTCK-SWCLK
+PA2.Signal=S_TIM2_CH3
+PA3.Signal=S_TIM2_CH4
 PB12.Locked=true
 PB12.Mode=Slave
 PB12.Signal=CAN2_RX
@@ -110,14 +141,6 @@ PC8.Mode=SD_4_bits_Wide_bus
 PC8.Signal=SDIO_D0
 PC9.Mode=SD_4_bits_Wide_bus
 PC9.Signal=SDIO_D1
-PCC.Checker=false
-PCC.Line=STM32F427/437
-PCC.MCU=STM32F427I(G-I)Hx
-PCC.PartNumber=STM32F427IIHx
-PCC.Seq0=0
-PCC.Series=STM32F4
-PCC.Temperature=25
-PCC.Vdd=3.3
 PD0.Locked=true
 PD0.Mode=Master
 PD0.Signal=CAN1_RX
@@ -184,6 +207,12 @@ PH12.Signal=S_TIM5_CH3
 PH6.Signal=S_TIM12_CH1
 PI0.Locked=true
 PI0.Signal=S_TIM5_CH4
+PI2.Signal=S_TIM8_CH4
+PI5.Locked=true
+PI5.Signal=S_TIM8_CH1
+PI6.Locked=true
+PI6.Signal=S_TIM8_CH2
+PI7.Signal=S_TIM8_CH3
 PinOutPanel.CurrentBGAView=Top
 PinOutPanel.RotationAngle=0
 ProjectManager.AskForMigrate=true
@@ -208,11 +237,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-true,3-MX_SPI5_Init-SPI5-false-HAL-true,4-MX_USART6_UART_Init-USART6-false-HAL-true,5-MX_CAN1_Init-CAN1-false-HAL-true,6-MX_CAN2_Init-CAN2-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,8-MX_TIM5_Init-TIM5-false-HAL-true,9-MX_TIM12_Init-TIM12-false-HAL-true,10-MX_UART7_Init-UART7-false-HAL-true,11-MX_UART8_Init-UART8-false-HAL-true,12-MX_USART1_UART_Init-USART1-false-HAL-true,13-MX_USART3_UART_Init-USART3-false-HAL-true
+ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-true,3-MX_SPI5_Init-SPI5-false-HAL-true,4-MX_USART6_UART_Init-USART6-false-HAL-true,5-MX_CAN1_Init-CAN1-false-HAL-true,6-MX_CAN2_Init-CAN2-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,8-MX_TIM5_Init-TIM5-false-HAL-true,9-MX_TIM12_Init-TIM12-false-HAL-true,10-MX_UART7_Init-UART7-false-HAL-true,11-MX_UART8_Init-UART8-false-HAL-true,12-MX_USART1_UART_Init-USART1-false-HAL-true,13-MX_USART3_UART_Init-USART3-false-HAL-true,14-MX_SDIO_SD_Init-SDIO-false-HAL-true
 RCC.48MHZClocksFreq_Value=45000000
 RCC.AHBFreq_Value=180000000
 RCC.APB1CLKDivider=RCC_HCLK_DIV4
@@ -254,6 +284,14 @@ RCC.VcooutputI2S=192000000
 RCC.VcooutputI2SQ=192000000
 SH.S_TIM12_CH1.0=TIM12_CH1,PWM Generation1 CH1
 SH.S_TIM12_CH1.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
+SH.S_TIM2_CH2.ConfNb=1
+SH.S_TIM2_CH3.0=TIM2_CH3,PWM Generation3 CH3
+SH.S_TIM2_CH3.ConfNb=1
+SH.S_TIM2_CH4.0=TIM2_CH4,PWM Generation4 CH4
+SH.S_TIM2_CH4.ConfNb=1
 SH.S_TIM4_CH1.0=TIM4_CH1,PWM Generation1 CH1
 SH.S_TIM4_CH1.ConfNb=1
 SH.S_TIM4_CH2.0=TIM4_CH2,PWM Generation2 CH2
@@ -270,6 +308,14 @@ SH.S_TIM5_CH3.0=TIM5_CH3,PWM Generation3 CH3
 SH.S_TIM5_CH3.ConfNb=1
 SH.S_TIM5_CH4.0=TIM5_CH4,PWM Generation4 CH4
 SH.S_TIM5_CH4.ConfNb=1
+SH.S_TIM8_CH1.0=TIM8_CH1,PWM Generation1 CH1
+SH.S_TIM8_CH1.ConfNb=1
+SH.S_TIM8_CH2.0=TIM8_CH2,PWM Generation2 CH2
+SH.S_TIM8_CH2.ConfNb=1
+SH.S_TIM8_CH3.0=TIM8_CH3,PWM Generation3 CH3
+SH.S_TIM8_CH3.ConfNb=1
+SH.S_TIM8_CH4.0=TIM8_CH4,PWM Generation4 CH4
+SH.S_TIM8_CH4.ConfNb=1
 SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128
 SPI5.CalculateBaudRate=703.125 KBits/s
 SPI5.Direction=SPI_DIRECTION_2LINES
@@ -278,6 +324,11 @@ SPI5.Mode=SPI_MODE_MASTER
 SPI5.VirtualType=VM_MASTER
 TIM12.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
 TIM12.IPParameters=Channel-PWM Generation1 CH1
+TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
+TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
+TIM2.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
+TIM2.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
+TIM2.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
 TIM4.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
 TIM4.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
 TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
@@ -288,6 +339,11 @@ TIM5.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
 TIM5.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
 TIM5.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
 TIM5.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
+TIM8.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
+TIM8.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
+TIM8.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
+TIM8.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
+TIM8.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
 UART7.IPParameters=VirtualMode
 UART7.VirtualMode=Asynchronous
 UART8.IPParameters=VirtualMode
@@ -298,12 +354,20 @@ USART3.IPParameters=VirtualMode
 USART3.VirtualMode=VM_ASYNC
 USART6.IPParameters=VirtualMode
 USART6.VirtualMode=VM_ASYNC
+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_TIM12_VS_ClockSourceINT.Mode=Internal
 VP_TIM12_VS_ClockSourceINT.Signal=TIM12_VS_ClockSourceINT
+VP_TIM2_VS_ClockSourceINT.Mode=Internal
+VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
 VP_TIM4_VS_ClockSourceINT.Mode=Internal
 VP_TIM4_VS_ClockSourceINT.Signal=TIM4_VS_ClockSourceINT
 VP_TIM5_VS_ClockSourceINT.Mode=Internal
 VP_TIM5_VS_ClockSourceINT.Signal=TIM5_VS_ClockSourceINT
+VP_TIM8_VS_ClockSourceINT.Mode=Internal
+VP_TIM8_VS_ClockSourceINT.Signal=TIM8_VS_ClockSourceINT
 board=Imu

+ 31 - 32
bsp/stm32/stm32f427-robomaster-a/board/CubeMX_Config/Inc/stm32f4xx_hal_conf.h

@@ -2,7 +2,7 @@
   ******************************************************************************
   * @file    stm32f4xx_hal_conf_template.h
   * @author  MCD Application Team
-  * @brief   HAL configuration template file. 
+  * @brief   HAL configuration template file.
   *          This file should be copied to the application folder and renamed
   *          to stm32f4xx_hal_conf.h.
   ******************************************************************************
@@ -17,7 +17,7 @@
   *                        opensource.org/licenses/BSD-3-Clause
   *
   ******************************************************************************
-  */ 
+  */
 
 /* Define to prevent recursive inclusion -------------------------------------*/
 #ifndef __STM32F4xx_HAL_CONF_H
@@ -32,11 +32,11 @@
 
 /* ########################## 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   */
@@ -90,9 +90,9 @@
 /**
   * @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) 
+#if !defined  (HSE_VALUE)
   #define HSE_VALUE    ((uint32_t)12000000U) /*!< Value of the External oscillator in Hz */
 #endif /* HSE_VALUE */
 
@@ -103,7 +103,7 @@
 /**
   * @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*/
@@ -112,7 +112,7 @@
 /**
   * @brief Internal Low Speed oscillator (LSI) value.
   */
-#if !defined  (LSI_VALUE) 
+#if !defined  (LSI_VALUE)
  #define LSI_VALUE  ((uint32_t)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
@@ -130,8 +130,8 @@
 
 /**
   * @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*/
@@ -144,16 +144,16 @@
 /**
   * @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		      ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define  TICK_INT_PRIORITY            ((uint32_t)0U)   /*!< tick interrupt priority */
+#define  USE_RTOS                     0U
 #define  PREFETCH_ENABLE              1U
 #define  INSTRUCTION_CACHE_ENABLE     1U
 #define  DATA_CACHE_ENABLE            1U
 
 /* ########################## 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 */
@@ -170,7 +170,7 @@
 #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  */
@@ -178,9 +178,9 @@
 
 /* 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*/ 
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
 #define PHY_RESET_DELAY                 ((uint32_t)0x000000FFU)
 /* PHY Configuration delay */
 #define PHY_CONFIG_DELAY                ((uint32_t)0x00000FFFU)
@@ -192,7 +192,7 @@
 
 #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 */
@@ -207,7 +207,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                      */
 
@@ -225,7 +225,7 @@
 
 /* Includes ------------------------------------------------------------------*/
 /**
-  * @brief Include module's header file 
+  * @brief Include module's header file
   */
 
 #ifdef HAL_RCC_MODULE_ENABLED
@@ -243,7 +243,7 @@
 #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 */
@@ -261,7 +261,7 @@
 #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_SMBUS_MODULE_ENABLED
@@ -287,7 +287,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 */
@@ -302,11 +302,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"
@@ -387,7 +387,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 */
@@ -415,14 +415,14 @@
 #ifdef HAL_LPTIM_MODULE_ENABLED
  #include "stm32f4xx_hal_lptim.h"
 #endif /* HAL_LPTIM_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
   *         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
   */
@@ -431,13 +431,12 @@
   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****/

+ 1 - 1
bsp/stm32/stm32f427-robomaster-a/board/CubeMX_Config/Inc/stm32f4xx_it.h

@@ -39,7 +39,7 @@
 
 #ifdef __cplusplus
  extern "C" {
-#endif 
+#endif
 
 /* Private includes ----------------------------------------------------------*/
 /* USER CODE BEGIN Includes */

+ 140 - 4
bsp/stm32/stm32f427-robomaster-a/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c

@@ -80,7 +80,7 @@
 /* USER CODE END 0 */
 
 void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
-                                                            /**
+                                                                                                    /**
   * Initializes the Global MSP.
   */
 void HAL_MspInit(void)
@@ -99,6 +99,50 @@ 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)
+{
+  if(hadc->Instance==ADC1)
+  {
+  /* USER CODE BEGIN ADC1_MspInit 0 */
+
+  /* USER CODE END ADC1_MspInit 0 */
+    /* Peripheral clock enable */
+    __HAL_RCC_ADC1_CLK_ENABLE();
+  /* 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();
+  /* USER CODE BEGIN ADC1_MspDeInit 1 */
+
+  /* USER CODE END ADC1_MspDeInit 1 */
+  }
+
+}
+
 static uint32_t HAL_RCC_CAN1_CLK_ENABLED=0;
 
 /**
@@ -382,7 +426,18 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
 */
 void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
 {
-  if(htim_base->Instance==TIM4)
+  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==TIM4)
   {
   /* USER CODE BEGIN TIM4_MspInit 0 */
 
@@ -404,6 +459,17 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
 
   /* USER CODE END TIM5_MspInit 1 */
   }
+  else if(htim_base->Instance==TIM8)
+  {
+  /* USER CODE BEGIN TIM8_MspInit 0 */
+
+  /* USER CODE END TIM8_MspInit 0 */
+    /* Peripheral clock enable */
+    __HAL_RCC_TIM8_CLK_ENABLE();
+  /* USER CODE BEGIN TIM8_MspInit 1 */
+
+  /* USER CODE END TIM8_MspInit 1 */
+  }
   else if(htim_base->Instance==TIM12)
   {
   /* USER CODE BEGIN TIM12_MspInit 0 */
@@ -421,11 +487,35 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
 void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
 {
   GPIO_InitTypeDef GPIO_InitStruct = {0};
-  if(htim->Instance==TIM4)
+  if(htim->Instance==TIM2)
+  {
+  /* USER CODE BEGIN TIM2_MspPostInit 0 */
+
+  /* USER CODE END TIM2_MspPostInit 0 */
+    __HAL_RCC_GPIOA_CLK_ENABLE();
+    /**TIM2 GPIO Configuration
+    PA1     ------> TIM2_CH2
+    PA0/WKUP     ------> TIM2_CH1
+    PA2     ------> TIM2_CH3
+    PA3     ------> TIM2_CH4
+    */
+    GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3;
+    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(GPIOA, &GPIO_InitStruct);
+
+  /* USER CODE BEGIN TIM2_MspPostInit 1 */
+
+  /* USER CODE END TIM2_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
     PD15     ------> TIM4_CH4
@@ -476,6 +566,30 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
 
   /* USER CODE END TIM5_MspPostInit 1 */
   }
+  else if(htim->Instance==TIM8)
+  {
+  /* USER CODE BEGIN TIM8_MspPostInit 0 */
+
+  /* USER CODE END TIM8_MspPostInit 0 */
+
+    __HAL_RCC_GPIOI_CLK_ENABLE();
+    /**TIM8 GPIO Configuration
+    PI7     ------> TIM8_CH3
+    PI6     ------> TIM8_CH2
+    PI5     ------> TIM8_CH1
+    PI2     ------> TIM8_CH4
+    */
+    GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_2;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_NOPULL;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+    GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
+    HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
+
+  /* USER CODE BEGIN TIM8_MspPostInit 1 */
+
+  /* USER CODE END TIM8_MspPostInit 1 */
+  }
   else if(htim->Instance==TIM12)
   {
   /* USER CODE BEGIN TIM12_MspPostInit 0 */
@@ -507,7 +621,18 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
 */
 void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
 {
-  if(htim_base->Instance==TIM4)
+  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==TIM4)
   {
   /* USER CODE BEGIN TIM4_MspDeInit 0 */
 
@@ -529,6 +654,17 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
 
   /* USER CODE END TIM5_MspDeInit 1 */
   }
+  else if(htim_base->Instance==TIM8)
+  {
+  /* USER CODE BEGIN TIM8_MspDeInit 0 */
+
+  /* USER CODE END TIM8_MspDeInit 0 */
+    /* Peripheral clock disable */
+    __HAL_RCC_TIM8_CLK_DISABLE();
+  /* USER CODE BEGIN TIM8_MspDeInit 1 */
+
+  /* USER CODE END TIM8_MspDeInit 1 */
+  }
   else if(htim_base->Instance==TIM12)
   {
   /* USER CODE BEGIN TIM12_MspDeInit 0 */

+ 1 - 1
bsp/stm32/stm32f427-robomaster-a/board/CubeMX_Config/Src/stm32f4xx_it.c

@@ -77,7 +77,7 @@ extern UART_HandleTypeDef huart6;
 /* 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.

+ 107 - 0
bsp/stm32/stm32f427-robomaster-a/board/Kconfig

@@ -14,6 +14,43 @@ menu "Onboard Peripheral Drivers"
         select RT_USING_DFS
         select RT_USING_DFS_ELMFAT
         default n
+    
+    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_PWM2
+        select BSP_USING_PWM2_CH1
+        select BSP_USING_PWM2_CH2
+        select BSP_USING_PWM2_CH3
+        select BSP_USING_PWM2_CH4
+        select BSP_USING_PWM4
+        select BSP_USING_PWM4_CH1
+        select BSP_USING_PWM4_CH2
+        select BSP_USING_PWM4_CH3
+        select BSP_USING_PWM4_CH4
+        select BSP_USING_PWM5
+        select BSP_USING_PWM5_CH1
+        select BSP_USING_PWM5_CH2
+        select BSP_USING_PWM5_CH3
+        select BSP_USING_PWM5_CH4
+        select BSP_USING_PWM8
+        select BSP_USING_PWM8_CH1
+        select BSP_USING_PWM8_CH2
+        select BSP_USING_PWM8_CH3
+        select BSP_USING_PWM8_CH4
+        select BSP_USING_PWM12
+        select BSP_USING_PWM12_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"
@@ -88,6 +125,40 @@ menu "On-chip Peripheral Drivers"
         select RT_USING_DFS
         default n
 
+    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_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: PE4 --> 68; PE5 --> 69" 
+                    config BSP_I2C1_SCL_PIN
+                        int "i2c1 SCL pin number"
+                        range 1 176
+                        default 68
+                    config BSP_I2C1_SDA_PIN
+                        int "i2c1 SDA pin number"
+                        range 1 176
+                        default 69
+                endif
+        endif
+
     menuconfig BSP_USING_PWM
         bool "Enable PWM"
         default n
@@ -137,6 +208,42 @@ menu "On-chip Peripheral Drivers"
                         bool "Enable PWM5 channel4"
                         default n
                 endif
+
+            menuconfig BSP_USING_PWM2
+                bool "Enable timer2 output PWM"
+                default n
+                if BSP_USING_PWM2
+                    config BSP_USING_PWM2_CH1
+                        bool "Enable PWM2 channel1"
+                        default n
+                    config BSP_USING_PWM2_CH2
+                        bool "Enable PWM2 channel2"
+                        default n
+                    config BSP_USING_PWM2_CH3
+                        bool "Enable PWM2 channel3"
+                        default n
+                    config BSP_USING_PWM2_CH4
+                        bool "Enable PWM2 channel4"
+                        default n
+                endif
+            
+            menuconfig BSP_USING_PWM8
+                bool "Enable timer8 output PWM"
+                default n
+                if BSP_USING_PWM8
+                    config BSP_USING_PWM8_CH1
+                        bool "Enable PWM8 channel1"
+                        default n
+                    config BSP_USING_PWM8_CH2
+                        bool "Enable PWM8 channel2"
+                        default n
+                    config BSP_USING_PWM8_CH3
+                        bool "Enable PWM8 channel3"
+                        default n
+                    config BSP_USING_PWM8_CH4
+                        bool "Enable PWM8 channel4"
+                        default n
+                endif
         endif
 
     source "../libraries/HAL_Drivers/Kconfig"    

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác