mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
[stm32][nucleo-f072] add arduino support (#5650)
* [stm32][nucleo-f072] add arduino gpio support * 完善stm32f401nucleo的基本配置 * 修改led引脚描述 * 潘多拉增加arduino引脚别名 * [ARDUINO]STM32L072RB 增加ADC A0-A5的引脚配置 * add pwm
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
src = ['main.c']
|
||||
|
||||
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')
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
inc = [cwd]
|
||||
|
||||
group = DefineGroup('Arduino', src, depend = ['RT_USING_ARDUINO'], CPPPATH = inc)
|
||||
|
||||
Return('group')
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-12-10 Meco Man first version
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <board.h>
|
||||
#include "pins_arduino.h"
|
||||
|
||||
const pin_map_t pin_map_table[]=
|
||||
{
|
||||
/*
|
||||
{Arduino Pin, RT-Thread Pin [, Device Name(PWM or ADC), Channel]}
|
||||
[] means optional
|
||||
Digital pins must NOT give the device name and channel.
|
||||
Analog pins MUST give the device name and channel(ADC or PWM).
|
||||
*/
|
||||
{0, GET_PIN(A,3)}, /* D0, RX */
|
||||
{1, GET_PIN(A,2)}, /* D1, TX */
|
||||
{2, GET_PIN(A,10)}, /* D2 */
|
||||
{3, GET_PIN(B,3), "pwm2", 2}, /* D3, PWM */
|
||||
{4, GET_PIN(B,5)}, /* D4 */
|
||||
{5, GET_PIN(B,4), "pwm3", 1}, /* D5, PWM */
|
||||
{6, GET_PIN(B,10), "pwm2", 3}, /* D6, PWM */
|
||||
{7, GET_PIN(A,8)}, /* D7 */
|
||||
{8, GET_PIN(A,9)}, /* D8 */
|
||||
{9, GET_PIN(C,7), "pwm3", 2}, /* D9, PWM */
|
||||
{10, GET_PIN(B,6)}, /* D10 */
|
||||
{11, GET_PIN(A,7)}, /* D11 */
|
||||
{12, GET_PIN(A,6)}, /* D12 */
|
||||
{13, GET_PIN(A,5)}, /* D13 */
|
||||
{14, GET_PIN(B,9)}, /* D14 */
|
||||
{15, GET_PIN(B,8)}, /* D15 */
|
||||
{16, GET_PIN(A,0), "adc1", 0}, /* A0 */
|
||||
{17, GET_PIN(A,1), "adc1", 1}, /* A1 */
|
||||
{18, GET_PIN(A,4), "adc1", 4}, /* A2 */
|
||||
{19, GET_PIN(B,0), "adc1", 8}, /* A3 */
|
||||
{20, GET_PIN(C,1), "adc1", 11}, /* A4 */
|
||||
{21, GET_PIN(C,0), "adc1", 10} /* A5 */
|
||||
};
|
||||
|
||||
/* initialization for BSP; maybe a blank function */
|
||||
void initVariant(void)
|
||||
{
|
||||
/* Nothing needs to initialize for this BSP */
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-12-10 Meco Man first version
|
||||
*/
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#define LED_BUILTIN 13 /* Built-in LED */
|
||||
|
||||
#define ARDUINO_PWM_HZ 500 /* Arduino UNO's PWM is around 500Hz */
|
||||
|
||||
#define ARDUINO_PINOUT_ADC_MAX 6 /* Arduino UNO has 6 ADC pins */
|
||||
#define ARDUINO_PINOUT_PWM_MAX 5 /* Arduino UNO has 5 PWM pins */
|
||||
|
||||
#define ARDUINO_DEFAULT_IIC_BUS_NAME "i2c4"
|
||||
|
||||
/* pins alias */
|
||||
#define D0 (0)
|
||||
#define D1 (1)
|
||||
#define D2 (2)
|
||||
#define D3 (3)
|
||||
#define D4 (4)
|
||||
#define D5 (5)
|
||||
#define D6 (6)
|
||||
#define D7 (7)
|
||||
#define D8 (8)
|
||||
#define D9 (9)
|
||||
#define D10 (10)
|
||||
#define D11 (11)
|
||||
#define D12 (12)
|
||||
#define D13 (13)
|
||||
#define D14 (14)
|
||||
#define D15 (15)
|
||||
#define A0 (16)
|
||||
#define A1 (17)
|
||||
#define A2 (18)
|
||||
#define A3 (19)
|
||||
#define A4 (20)
|
||||
#define A5 (21)
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
|
||||
/* defined the LED2 pin: PA5 */
|
||||
/* defined the LED2 (user LED) pin: PA5 */
|
||||
#define LED2_PIN GET_PIN(A, 5)
|
||||
|
||||
int main(void)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,36 +1,59 @@
|
||||
#MicroXplorer Configuration settings - do not modify
|
||||
File.Version=6
|
||||
KeepUserPlacement=true
|
||||
Mcu.CPN=STM32F072RBT6
|
||||
Mcu.Family=STM32F0
|
||||
Mcu.IP0=NVIC
|
||||
Mcu.IP1=RCC
|
||||
Mcu.IP2=SYS
|
||||
Mcu.IP3=USART2
|
||||
Mcu.IPNb=4
|
||||
Mcu.IP0=ADC
|
||||
Mcu.IP1=NVIC
|
||||
Mcu.IP2=RCC
|
||||
Mcu.IP3=SYS
|
||||
Mcu.IP4=TIM2
|
||||
Mcu.IP5=TIM3
|
||||
Mcu.IP6=USART2
|
||||
Mcu.IPNb=7
|
||||
Mcu.Name=STM32F072R(8-B)Tx
|
||||
Mcu.Package=LQFP64
|
||||
Mcu.Pin0=PC13
|
||||
Mcu.Pin1=PC14-OSC32_IN
|
||||
Mcu.Pin10=VP_SYS_VS_Systick
|
||||
Mcu.Pin10=PA3
|
||||
Mcu.Pin11=PA4
|
||||
Mcu.Pin12=PA5
|
||||
Mcu.Pin13=PB0
|
||||
Mcu.Pin14=PB10
|
||||
Mcu.Pin15=PC7
|
||||
Mcu.Pin16=PA13
|
||||
Mcu.Pin17=PA14
|
||||
Mcu.Pin18=PB3
|
||||
Mcu.Pin19=PB4
|
||||
Mcu.Pin2=PC15-OSC32_OUT
|
||||
Mcu.Pin20=VP_SYS_VS_Systick
|
||||
Mcu.Pin21=VP_TIM2_VS_ClockSourceINT
|
||||
Mcu.Pin22=VP_TIM3_VS_ClockSourceINT
|
||||
Mcu.Pin3=PF0-OSC_IN
|
||||
Mcu.Pin4=PF1-OSC_OUT
|
||||
Mcu.Pin5=PA2
|
||||
Mcu.Pin6=PA3
|
||||
Mcu.Pin7=PA5
|
||||
Mcu.Pin8=PA13
|
||||
Mcu.Pin9=PA14
|
||||
Mcu.PinsNb=11
|
||||
Mcu.Pin5=PC0
|
||||
Mcu.Pin6=PC1
|
||||
Mcu.Pin7=PA0
|
||||
Mcu.Pin8=PA1
|
||||
Mcu.Pin9=PA2
|
||||
Mcu.PinsNb=23
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F072RBTx
|
||||
MxCube.Version=5.2.0
|
||||
MxDb.Version=DB.5.0.20
|
||||
NVIC.HardFault_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.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true\:true
|
||||
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.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
|
||||
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true
|
||||
PA0.Locked=true
|
||||
PA0.Mode=IN0
|
||||
PA0.Signal=ADC_IN0
|
||||
PA1.Locked=true
|
||||
PA1.Mode=IN1
|
||||
PA1.Signal=ADC_IN1
|
||||
PA13.GPIOParameters=GPIO_Label
|
||||
PA13.GPIO_Label=TMS
|
||||
PA13.Locked=true
|
||||
@@ -57,6 +80,9 @@ PA3.GPIO_Speed=GPIO_SPEED_FREQ_LOW
|
||||
PA3.Locked=true
|
||||
PA3.Mode=Asynchronous
|
||||
PA3.Signal=USART2_RX
|
||||
PA4.Locked=true
|
||||
PA4.Mode=IN4
|
||||
PA4.Signal=ADC_IN4
|
||||
PA5.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label,GPIO_Mode
|
||||
PA5.GPIO_Label=LD2 [Green Led]
|
||||
PA5.GPIO_Mode=GPIO_MODE_OUTPUT_PP
|
||||
@@ -64,6 +90,21 @@ PA5.GPIO_PuPd=GPIO_NOPULL
|
||||
PA5.GPIO_Speed=GPIO_SPEED_FREQ_LOW
|
||||
PA5.Locked=true
|
||||
PA5.Signal=GPIO_Output
|
||||
PB0.Locked=true
|
||||
PB0.Mode=IN8
|
||||
PB0.Signal=ADC_IN8
|
||||
PB10.Locked=true
|
||||
PB10.Signal=S_TIM2_CH3
|
||||
PB3.Locked=true
|
||||
PB3.Signal=S_TIM2_CH2
|
||||
PB4.Locked=true
|
||||
PB4.Signal=S_TIM3_CH1
|
||||
PC0.Locked=true
|
||||
PC0.Mode=IN10
|
||||
PC0.Signal=ADC_IN10
|
||||
PC1.Locked=true
|
||||
PC1.Mode=IN11
|
||||
PC1.Signal=ADC_IN11
|
||||
PC13.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
|
||||
PC13.GPIO_Label=B1 [Blue PushButton]
|
||||
PC13.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
|
||||
@@ -75,14 +116,8 @@ 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
|
||||
PCC.Checker=false
|
||||
PCC.Line=STM32F0x2
|
||||
PCC.MCU=STM32F072R(8-B)Tx
|
||||
PCC.PartNumber=STM32F072RBTx
|
||||
PCC.Seq0=0
|
||||
PCC.Series=STM32F0
|
||||
PCC.Temperature=25
|
||||
PCC.Vdd=3.6
|
||||
PC7.Locked=true
|
||||
PC7.Signal=S_TIM3_CH2
|
||||
PF0-OSC_IN.Locked=true
|
||||
PF0-OSC_IN.Signal=RCC_OSC_IN
|
||||
PF1-OSC_OUT.Locked=true
|
||||
@@ -110,11 +145,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_USART2_UART_Init-USART2-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
|
||||
RCC.AHBFreq_Value=48000000
|
||||
RCC.APB1Freq_Value=48000000
|
||||
RCC.APB1TimFreq_Value=48000000
|
||||
@@ -139,10 +175,28 @@ RCC.USART1Freq_Value=48000000
|
||||
RCC.USART2Freq_Value=48000000
|
||||
SH.GPXTI13.0=GPIO_EXTI13
|
||||
SH.GPXTI13.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_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
|
||||
TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
|
||||
TIM2.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
|
||||
TIM2.IPParameters=Channel-PWM Generation3 CH3,Channel-PWM Generation2 CH2
|
||||
TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
|
||||
TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
|
||||
TIM3.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1
|
||||
USART2.IPParameters=VirtualMode,VirtualMode-Asynchronous
|
||||
USART2.VirtualMode=VM_ASYNC
|
||||
USART2.VirtualMode-Asynchronous=VM_ASYNC
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||
VP_TIM2_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
|
||||
VP_TIM3_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
|
||||
board=NUCLEO-F072RB
|
||||
boardIOC=true
|
||||
|
||||
@@ -70,6 +70,8 @@ extern "C" {
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void Error_Handler(void);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
|
||||
* <h2><center>© COPYRIGHT(c) 2022 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@@ -30,7 +30,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F0xx_HAL_CONF_H
|
||||
@@ -45,10 +45,10 @@
|
||||
|
||||
/* ########################## 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_ADC_MODULE_ENABLED */
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
/*#define HAL_CRYP_MODULE_ENABLED */
|
||||
/*#define HAL_CAN_MODULE_ENABLED */
|
||||
/*#define HAL_CEC_MODULE_ENABLED */
|
||||
@@ -64,7 +64,7 @@
|
||||
/*#define HAL_RNG_MODULE_ENABLED */
|
||||
/*#define HAL_RTC_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 */
|
||||
@@ -85,15 +85,15 @@
|
||||
/**
|
||||
* @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)8000000) /*!< Value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
/**
|
||||
* @brief In the following line adjust the External High Speed oscillator (HSE) Startup
|
||||
* Timeout value
|
||||
* @brief In the following line adjust the External High Speed oscillator (HSE) Startup
|
||||
* Timeout value
|
||||
*/
|
||||
#if !defined (HSE_STARTUP_TIMEOUT)
|
||||
#define HSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for HSE start up, in ms */
|
||||
@@ -102,24 +102,24 @@
|
||||
/**
|
||||
* @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)8000000) /*!< Value of the Internal oscillator in Hz*/
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/**
|
||||
* @brief In the following line adjust the Internal High Speed oscillator (HSI) Startup
|
||||
* Timeout value
|
||||
* @brief In the following line adjust the Internal High Speed oscillator (HSI) Startup
|
||||
* Timeout value
|
||||
*/
|
||||
#if !defined (HSI_STARTUP_TIMEOUT)
|
||||
#if !defined (HSI_STARTUP_TIMEOUT)
|
||||
#define HSI_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSI start up */
|
||||
#endif /* HSI_STARTUP_TIMEOUT */
|
||||
#endif /* HSI_STARTUP_TIMEOUT */
|
||||
|
||||
/**
|
||||
* @brief Internal High Speed oscillator for ADC (HSI14) value.
|
||||
*/
|
||||
#if !defined (HSI14_VALUE)
|
||||
#if !defined (HSI14_VALUE)
|
||||
#define HSI14_VALUE ((uint32_t)14000000) /*!< Value of the Internal High Speed oscillator for ADC in Hz.
|
||||
The real value may vary depending on the variations
|
||||
in voltage and temperature. */
|
||||
@@ -128,7 +128,7 @@
|
||||
/**
|
||||
* @brief Internal High Speed oscillator for USB (HSI48) value.
|
||||
*/
|
||||
#if !defined (HSI48_VALUE)
|
||||
#if !defined (HSI48_VALUE)
|
||||
#define HSI48_VALUE ((uint32_t)48000000) /*!< Value of the Internal High Speed oscillator for USB in Hz.
|
||||
The real value may vary depending on the variations
|
||||
in voltage and temperature. */
|
||||
@@ -137,8 +137,8 @@
|
||||
/**
|
||||
* @brief Internal Low Speed oscillator (LSI) value.
|
||||
*/
|
||||
#if !defined (LSI_VALUE)
|
||||
#define LSI_VALUE ((uint32_t)40000)
|
||||
#if !defined (LSI_VALUE)
|
||||
#define LSI_VALUE ((uint32_t)40000)
|
||||
#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. */
|
||||
@@ -147,7 +147,7 @@
|
||||
*/
|
||||
#if !defined (LSE_VALUE)
|
||||
#define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */
|
||||
#endif /* LSE_VALUE */
|
||||
#endif /* LSE_VALUE */
|
||||
|
||||
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
|
||||
@@ -159,18 +159,18 @@
|
||||
/* ########################### System Configuration ######################### */
|
||||
/**
|
||||
* @brief This is the HAL system configuration section
|
||||
*/
|
||||
#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
|
||||
#define TICK_INT_PRIORITY ((uint32_t)0) /*!< tick interrupt priority (lowest by default) */
|
||||
*/
|
||||
#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
|
||||
#define TICK_INT_PRIORITY ((uint32_t)0) /*!< tick interrupt priority (lowest by default) */
|
||||
/* Warning: Must be set to higher priority for HAL_Delay() */
|
||||
/* and HAL_GetTick() usage under interrupt context */
|
||||
#define USE_RTOS 0
|
||||
#define PREFETCH_ENABLE 1
|
||||
#define USE_RTOS 0
|
||||
#define PREFETCH_ENABLE 1
|
||||
#define INSTRUCTION_CACHE_ENABLE 0
|
||||
#define DATA_CACHE_ENABLE 0
|
||||
/* ########################## 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 */
|
||||
@@ -186,7 +186,7 @@
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Include module's header file
|
||||
* @brief Include module's header file
|
||||
*/
|
||||
|
||||
#ifdef HAL_RCC_MODULE_ENABLED
|
||||
@@ -303,7 +303,7 @@
|
||||
* @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
|
||||
*/
|
||||
@@ -312,8 +312,8 @@
|
||||
void assert_failed(char* file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0U)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -77,7 +77,7 @@
|
||||
/* USER CODE END EV */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M0 Processor Interruption and Exception Handlers */
|
||||
/* Cortex-M0 Processor Interruption and Exception Handlers */
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @brief This function handles Non maskable interrupt.
|
||||
|
||||
@@ -8,6 +8,27 @@ config SOC_STM32F072RB
|
||||
default y
|
||||
|
||||
menu "Onboard Peripheral Drivers"
|
||||
config BSP_USING_STLINK_TO_USART
|
||||
bool "Enable STLINK TO USART (uart2)"
|
||||
select BSP_USING_UART
|
||||
select BSP_USING_UART2
|
||||
default y
|
||||
|
||||
config BSP_USING_ARDUINO
|
||||
bool "Support Arduino"
|
||||
select RT_USING_ARDUINO
|
||||
select RT_USING_PIN
|
||||
select BSP_USING_ADC
|
||||
select BSP_USING_ADC1
|
||||
select BSP_USING_PWM
|
||||
select BSP_USING_PWM2
|
||||
select BSP_USING_PWM2_CH2
|
||||
select BSP_USING_PWM2_CH3
|
||||
select BSP_USING_PWM3
|
||||
select BSP_USING_PWM3_CH1
|
||||
select BSP_USING_PWM3_CH2
|
||||
select BSP_USING_I2C
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -34,13 +55,68 @@ menu "On-chip Peripheral Drivers"
|
||||
|
||||
config BSP_USING_UART2
|
||||
bool "Enable UART2"
|
||||
default y
|
||||
default n
|
||||
|
||||
config BSP_UART2_RX_USING_DMA
|
||||
bool "Enable UART2 RX DMA"
|
||||
depends on BSP_USING_UART2 && RT_SERIAL_USING_DMA
|
||||
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_PWM2
|
||||
bool "Enable timer2 output pwm"
|
||||
default n
|
||||
if BSP_USING_PWM2
|
||||
config BSP_USING_PWM2_CH2
|
||||
bool "Enable PWM2 channel2"
|
||||
default n
|
||||
|
||||
config BSP_USING_PWM2_CH3
|
||||
bool "Enable PWM2 channel3"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_PWM3
|
||||
bool "Enable timer3 output pwm"
|
||||
default n
|
||||
if BSP_USING_PWM3
|
||||
config BSP_USING_PWM3_CH1
|
||||
bool "Enable PWM3 channel1"
|
||||
default n
|
||||
|
||||
config BSP_USING_PWM3_CH2
|
||||
bool "Enable PWM3 channel2"
|
||||
default n
|
||||
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
|
||||
|
||||
endif
|
||||
|
||||
source "../libraries/HAL_Drivers/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ST-LINKIII-KEIL_SWO</Key>
|
||||
<Name>-U066DFF555355755087081621 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("") -D00(00000000) -L00(0) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F0xx_128 -FS08000000 -FL020000</Name>
|
||||
<Name>-U0668FF544949878667154127 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F0xx_128_2K -FS08000000 -FL020000 -FP0($$Device:STM32F072RBTx$CMSIS\Flash\STM32F0xx_128_2K.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
@@ -178,7 +178,6 @@
|
||||
<pMultCmdsp></pMultCmdsp>
|
||||
<DebugDescription>
|
||||
<Enable>1</Enable>
|
||||
<EnableFlashSeq>0</EnableFlashSeq>
|
||||
<EnableLog>0</EnableLog>
|
||||
<Protocol>2</Protocol>
|
||||
<DbgClock>10000000</DbgClock>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F072RBTx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F0xx_DFP.2.0.0</PackID>
|
||||
<PackID>Keil.STM32F0xx_DFP.2.1.1</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x00004000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M0") CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
@@ -184,7 +184,6 @@
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import rtconfig
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
CPPPATH = [cwd, str(Dir('#'))]
|
||||
src = Split("""
|
||||
main.c
|
||||
""")
|
||||
CPPPATH = [cwd]
|
||||
src = ['main.c']
|
||||
|
||||
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')
|
||||
|
||||
@@ -12,19 +12,19 @@
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
|
||||
/* defined the LED0 pin: PB1 */
|
||||
#define LED0_PIN GET_PIN(A, 5)
|
||||
/* defined the LD2 (user LED) pin: PB1 */
|
||||
#define LED2_PIN GET_PIN(A, 5)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@ config SOC_STM32F401RE
|
||||
default y
|
||||
|
||||
menu "Onboard Peripheral Drivers"
|
||||
config BSP_USING_STLINK_TO_USART
|
||||
bool "Enable STLINK TO USART (uart2)"
|
||||
select BSP_USING_UART
|
||||
select BSP_USING_UART2
|
||||
default y
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -20,12 +25,12 @@ menu "On-chip Peripheral Drivers"
|
||||
|
||||
menuconfig BSP_USING_UART
|
||||
bool "Enable UART"
|
||||
default y
|
||||
default n
|
||||
select RT_USING_SERIAL
|
||||
if BSP_USING_UART
|
||||
config BSP_USING_UART2
|
||||
bool "Enable UART2"
|
||||
default y
|
||||
default n
|
||||
|
||||
config BSP_UART2_RX_USING_DMA
|
||||
bool "Enable UART2 RX DMA"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <board.h>
|
||||
#include "pins_arduino.h"
|
||||
|
||||
const pin_map_t pin_map_table[ARDUINO_PINOUT_PIN_MAX]=
|
||||
const pin_map_t pin_map_table[]=
|
||||
{
|
||||
/*
|
||||
{Arduino Pin, RT-Thread Pin [, Device Name(PWM or ADC), Channel]}
|
||||
@@ -34,11 +34,11 @@ const pin_map_t pin_map_table[ARDUINO_PINOUT_PIN_MAX]=
|
||||
{12, GET_PIN(B,2)}, /* D12, BSP: BEEP */
|
||||
{13, GET_PIN(E,8)}, /* D13, LED_BUILTIN, BSP: GREEN-LED */
|
||||
{14, GET_PIN(C,2), "adc1", 3}, /* D14, A0 */
|
||||
{15}, /* D15, A1 */
|
||||
{16}, /* D16, A2 */
|
||||
{17}, /* D17, A3 */
|
||||
{18}, /* D18, A4 */
|
||||
{19} /* D19, A5 */
|
||||
{15}, /* A1 */
|
||||
{16}, /* A2 */
|
||||
{17}, /* A3 */
|
||||
{18}, /* A4 */
|
||||
{19} /* A5 */
|
||||
};
|
||||
|
||||
/* initialization for BSP; maybe a blank function */
|
||||
|
||||
@@ -14,12 +14,25 @@
|
||||
|
||||
#define ARDUINO_PWM_HZ 500 /* Arduino UNO's PWM is around 500Hz */
|
||||
|
||||
#define ARDUINO_PINOUT_PIN_MAX 20 /* Arduino UNO has 20 pins in total*/
|
||||
#define ARDUINO_PINOUT_ADC_MAX 6 /* Arduino UNO has 6 ADC pins */
|
||||
#define ARDUINO_PINOUT_PWM_MAX 5 /* Arduino UNO has 5 PWM pins */
|
||||
|
||||
#define ARDUINO_DEFAULT_IIC_BUS_NAME "i2c4"
|
||||
|
||||
#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 A0 (14)
|
||||
#define A1 (15)
|
||||
#define A2 (16)
|
||||
|
||||
@@ -8,6 +8,7 @@ ADC1.SamplingTime-15\#ChannelRegularConversion=ADC_SAMPLETIME_2CYCLES_5
|
||||
ADC1.master=1
|
||||
File.Version=6
|
||||
KeepUserPlacement=false
|
||||
Mcu.CPN=STM32L475VET6
|
||||
Mcu.Family=STM32L4
|
||||
Mcu.IP0=ADC1
|
||||
Mcu.IP1=DAC1
|
||||
@@ -98,18 +99,18 @@ Mcu.UserConstants=
|
||||
Mcu.UserName=STM32L475VETx
|
||||
MxCube.Version=6.4.0
|
||||
MxDb.Version=DB.6.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\:true
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
|
||||
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.OTG_FS_IRQn=true\:0\:0\:false\:false\:true\:true\:true
|
||||
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
|
||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
|
||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
|
||||
NVIC.OTG_FS_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
|
||||
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.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
|
||||
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
|
||||
PA10.GPIOParameters=GPIO_PuPd
|
||||
PA10.GPIO_PuPd=GPIO_PULLUP
|
||||
PA10.Mode=Asynchronous
|
||||
|
||||
Reference in New Issue
Block a user