Merge pull request #2868 from yangjie11/dma

[bsp][stm32/libraries/HAL_Drivers] F0 系列支持SPI,并修复DMA中断函数重复定义
This commit is contained in:
Bernard Xiong 2019-07-27 22:28:22 +08:00 committed by GitHub
commit 3d3051dc1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 161 additions and 72 deletions

View File

@ -26,6 +26,18 @@ extern "C" {
#define UART1_RX_DMA_RCC RCC_AHBENR_DMA1EN #define UART1_RX_DMA_RCC RCC_AHBENR_DMA1EN
#define UART1_RX_DMA_INSTANCE DMA1_Channel3 #define UART1_RX_DMA_INSTANCE DMA1_Channel3
#define UART1_RX_DMA_IRQ DMA1_Ch2_3_DMA2_Ch1_2_IRQn #define UART1_RX_DMA_IRQ DMA1_Ch2_3_DMA2_Ch1_2_IRQn
#elif defined(BSP_SPI1_RX_USING_DMA) && !defined(SPI1_RX_DMA_INSTANCE)
#define SPI1_DMA_RX_TX_IRQHandler DMA1_Ch2_3_DMA2_Ch1_2_IRQHandler
#define SPI1_RX_DMA_RCC RCC_AHBENR_DMA1EN
#define SPI1_RX_DMA_INSTANCE DMA1_Channel2
#define SPI1_RX_DMA_IRQ DMA1_Ch2_3_DMA2_Ch1_2_IRQn
#endif
#if defined(BSP_SPI1_TX_USING_DMA) && !defined(SPI1_TX_DMA_INSTANCE)
#define SPI1_DMA_RX_TX_IRQHandler DMA1_Ch2_3_DMA2_Ch1_2_IRQHandler
#define SPI1_TX_DMA_RCC RCC_AHBENR_DMA1EN
#define SPI1_TX_DMA_INSTANCE DMA1_Channel3
#define SPI1_TX_DMA_IRQ DMA1_Ch2_3_DMA2_Ch1_2_IRQn
#endif #endif
/* DMA1 channel2-3 DMA2 channel1-2 */ /* DMA1 channel2-3 DMA2 channel1-2 */

View File

@ -6,6 +6,7 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2018-11-06 SummerGift first version * 2018-11-06 SummerGift first version
* 2019-01-05 SummerGift modify DMA support
*/ */
#ifndef __SPI_CONFIG_H__ #ifndef __SPI_CONFIG_H__
@ -18,21 +19,68 @@ extern "C" {
#endif #endif
#ifdef BSP_USING_SPI1 #ifdef BSP_USING_SPI1
#define SPI1_BUS_CONFIG \ #ifndef SPI1_BUS_CONFIG
{ \ #define SPI1_BUS_CONFIG \
.Instance = SPI1, \ { \
.bus_name = "spi1", \ .Instance = SPI1, \
.dma_rx.dma_rcc = RCC_AHBENR_DMA1EN, \ .bus_name = "spi1", \
.dma_tx.dma_rcc = RCC_AHBENR_DMA1EN, \
.dma_rx.Instance = DMA1_Channel2, \
.dma_rx.dma_irq = DMA1_Ch2_3_DMA2_Ch1_2_IRQn, \
.dma_tx.Instance = DMA1_Channel3, \
.dma_tx.dma_irq = DMA1_Ch2_3_DMA2_Ch1_2_IRQn, \
} }
#endif /* SPI1_BUS_CONFIG */
#endif /* BSP_USING_SPI1 */
#define SPI1_DMA_RX_IRQHandler DMA1_Ch2_3_DMA2_Ch1_2_IRQHandler #ifdef BSP_SPI1_TX_USING_DMA
#define SPI1_DMA_TX_IRQHandler DMA1_Ch2_3_DMA2_Ch1_2_IRQHandler #ifndef SPI1_TX_DMA_CONFIG
#endif #define SPI1_TX_DMA_CONFIG \
{ \
.dma_rcc = SPI1_TX_DMA_RCC, \
.Instance = SPI1_TX_DMA_INSTANCE, \
.dma_irq = SPI1_TX_DMA_IRQ, \
}
#endif /* SPI1_TX_DMA_CONFIG */
#endif /* BSP_SPI1_TX_USING_DMA */
#ifdef BSP_SPI1_RX_USING_DMA
#ifndef SPI1_RX_DMA_CONFIG
#define SPI1_RX_DMA_CONFIG \
{ \
.dma_rcc = SPI1_RX_DMA_RCC, \
.Instance = SPI1_RX_DMA_INSTANCE, \
.dma_irq = SPI1_RX_DMA_IRQ, \
}
#endif /* SPI1_RX_DMA_CONFIG */
#endif /* BSP_SPI1_RX_USING_DMA */
#ifdef BSP_USING_SPI2
#ifndef SPI2_BUS_CONFIG
#define SPI2_BUS_CONFIG \
{ \
.Instance = SPI2, \
.bus_name = "spi2", \
}
#endif /* SPI2_BUS_CONFIG */
#endif /* BSP_USING_SPI2 */
#ifdef BSP_SPI2_TX_USING_DMA
#ifndef SPI2_TX_DMA_CONFIG
#define SPI2_TX_DMA_CONFIG \
{ \
.dma_rcc = SPI2_TX_DMA_RCC, \
.Instance = SPI2_TX_DMA_INSTANCE, \
.dma_irq = SPI2_TX_DMA_IRQ, \
}
#endif /* SPI2_TX_DMA_CONFIG */
#endif /* BSP_SPI2_TX_USING_DMA */
#ifdef BSP_SPI2_RX_USING_DMA
#ifndef SPI2_RX_DMA_CONFIG
#define SPI2_RX_DMA_CONFIG \
{ \
.dma_rcc = SPI2_RX_DMA_RCC, \
.Instance = SPI2_RX_DMA_INSTANCE, \
.dma_irq = SPI2_RX_DMA_IRQ, \
}
#endif /* SPI2_RX_DMA_CONFIG */
#endif /* BSP_SPI2_RX_USING_DMA */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -203,7 +203,7 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
spi_handle->Init.TIMode = SPI_TIMODE_DISABLE; spi_handle->Init.TIMode = SPI_TIMODE_DISABLE;
spi_handle->Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; spi_handle->Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
spi_handle->State = HAL_SPI_STATE_RESET; spi_handle->State = HAL_SPI_STATE_RESET;
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32G0) #if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32G0) || defined(SOC_SERIES_STM32F0)
spi_handle->Init.NSSPMode = SPI_NSS_PULSE_DISABLE; spi_handle->Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
#endif #endif
@ -409,7 +409,7 @@ static int rt_hw_spi_bus_init(void)
{ {
rt_uint32_t tmpreg = 0x00U; rt_uint32_t tmpreg = 0x00U;
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32G0) #if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32G0) || defined(SOC_SERIES_STM32F0)
/* enable DMA clock && Delay after an RCC peripheral clock enabling*/ /* enable DMA clock && Delay after an RCC peripheral clock enabling*/
SET_BIT(RCC->AHBENR, spi_config[i].dma_rx->dma_rcc); SET_BIT(RCC->AHBENR, spi_config[i].dma_rx->dma_rcc);
tmpreg = READ_BIT(RCC->AHBENR, spi_config[i].dma_rx->dma_rcc); tmpreg = READ_BIT(RCC->AHBENR, spi_config[i].dma_rx->dma_rcc);
@ -447,10 +447,10 @@ static int rt_hw_spi_bus_init(void)
{ {
rt_uint32_t tmpreg = 0x00U; rt_uint32_t tmpreg = 0x00U;
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32G0) #if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32G0) || defined(SOC_SERIES_STM32F0)
/* enable DMA clock && Delay after an RCC peripheral clock enabling*/ /* enable DMA clock && Delay after an RCC peripheral clock enabling*/
SET_BIT(RCC->AHBENR, spi_config[i].dma_rx->dma_rcc); SET_BIT(RCC->AHBENR, spi_config[i].dma_tx->dma_rcc);
tmpreg = READ_BIT(RCC->AHBENR, spi_config[i].dma_rx->dma_rcc); tmpreg = READ_BIT(RCC->AHBENR, spi_config[i].dma_tx->dma_rcc);
#elif defined(SOC_SERIES_STM32F2) || defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4) #elif defined(SOC_SERIES_STM32F2) || defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4)
SET_BIT(RCC->AHB1ENR, spi_config[i].dma_tx->dma_rcc); SET_BIT(RCC->AHB1ENR, spi_config[i].dma_tx->dma_rcc);
/* Delay after an RCC peripheral clock enabling */ /* Delay after an RCC peripheral clock enabling */
@ -861,6 +861,30 @@ static void stm32_get_dma_info(void)
#endif #endif
} }
#if defined(SOC_SERIES_STM32F0)
void SPI1_DMA_RX_TX_IRQHandler(void)
{
#if defined(BSP_USING_SPI1) && defined(BSP_SPI1_TX_USING_DMA)
SPI1_DMA_TX_IRQHandler();
#endif
#if defined(BSP_USING_SPI1) && defined(BSP_SPI1_RX_USING_DMA)
SPI1_DMA_RX_IRQHandler();
#endif
}
void SPI2_DMA_RX_TX_IRQHandler(void)
{
#if defined(BSP_USING_SPI2) && defined(BSP_SPI2_TX_USING_DMA)
SPI2_DMA_TX_IRQHandler();
#endif
#if defined(BSP_USING_SPI2) && defined(BSP_SPI2_RX_USING_DMA)
SPI2_DMA_RX_IRQHandler();
#endif
}
#endif /* SOC_SERIES_STM32F0 */
int rt_hw_spi_init(void) int rt_hw_spi_init(void)
{ {
stm32_get_dma_info(); stm32_get_dma_info();

View File

@ -12,14 +12,24 @@
#include <rtdevice.h> #include <rtdevice.h>
#include <board.h> #include <board.h>
/* defined the LED2 pin: PA5 */
#define LED2_PIN GET_PIN(A, 5)
int main(void) int main(void)
{ {
int count = 1; int count = 1;
/* set LED2 pin mode to output */
rt_pin_mode(LED2_PIN, PIN_MODE_OUTPUT);
while (count++) while (count++)
{ {
rt_pin_write(LED2_PIN, PIN_HIGH);
rt_thread_mdelay(500);
rt_pin_write(LED2_PIN, PIN_LOW);
rt_thread_mdelay(500); rt_thread_mdelay(500);
} }
return RT_EOK; return RT_EOK;
} }

View File

@ -1,7 +1,7 @@
[PreviousGenFiles] [PreviousGenFiles]
HeaderPath=D:/BspFramework/rt-thread/bsp/stm32/stm32f091-nucleo/board/CubeMX_Config/Inc HeaderPath=E:/rt-thread_f/bsp/stm32/stm32f091-st-nucleo/board/CubeMX_Config/Inc
HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h;stm32f0xx_it.h;stm32f0xx_hal_conf.h; HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h;stm32f0xx_it.h;stm32f0xx_hal_conf.h;
SourcePath=D:/BspFramework/rt-thread/bsp/stm32/stm32f091-nucleo/board/CubeMX_Config/Src SourcePath=E:/rt-thread_f/bsp/stm32/stm32f091-st-nucleo/board/CubeMX_Config/Src
SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c;stm32f0xx_it.c;stm32f0xx_hal_msp.c; SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c;stm32f0xx_it.c;stm32f0xx_hal_msp.c;
[PreviousLibFiles] [PreviousLibFiles]
@ -17,4 +17,5 @@ SourceFiles=;;
[PreviousUsedIarFiles] [PreviousUsedIarFiles]
SourceFiles=..\Src\main.c;..\Src\stm32f0xx_it.c;..\Src\stm32f0xx_hal_msp.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_adc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_adc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_iwdg.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rtc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rtc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_usart.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c;../\Src/system_stm32f0xx.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_adc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_adc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_iwdg.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rtc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rtc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_usart.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c;../\Src/system_stm32f0xx.c;../Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/system_stm32f0xx.c;null; SourceFiles=..\Src\main.c;..\Src\stm32f0xx_it.c;..\Src\stm32f0xx_hal_msp.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_adc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_adc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_iwdg.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rtc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rtc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_usart.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c;../\Src/system_stm32f0xx.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_adc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_adc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_iwdg.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rtc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rtc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_usart.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c;../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c;../\Src/system_stm32f0xx.c;../Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/system_stm32f0xx.c;null;
HeaderPath=..\Drivers\STM32F0xx_HAL_Driver\Inc;..\Drivers\STM32F0xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F0xx\Include;..\Drivers\CMSIS\Include;..\Inc; HeaderPath=..\Drivers\STM32F0xx_HAL_Driver\Inc;..\Drivers\STM32F0xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F0xx\Include;..\Drivers\CMSIS\Include;..\Inc;
CDefines=USE_HAL_DRIVER;STM32F091xC;USE_HAL_DRIVER;STM32F091xC;

View File

@ -20,10 +20,10 @@ Mcu.Name=STM32F091R(B-C)Tx
Mcu.Package=LQFP64 Mcu.Package=LQFP64
Mcu.Pin0=PC14OSC32_IN Mcu.Pin0=PC14OSC32_IN
Mcu.Pin1=PC15OSC32_OUT Mcu.Pin1=PC15OSC32_OUT
Mcu.Pin10=PA9 Mcu.Pin10=PA10
Mcu.Pin11=PA10 Mcu.Pin11=PA13
Mcu.Pin12=PA13 Mcu.Pin12=PA14
Mcu.Pin13=PA14 Mcu.Pin13=PB3
Mcu.Pin14=VP_IWDG_VS_IWDG Mcu.Pin14=VP_IWDG_VS_IWDG
Mcu.Pin15=VP_RTC_VS_RTC_Activate Mcu.Pin15=VP_RTC_VS_RTC_Activate
Mcu.Pin16=VP_SYS_VS_Systick Mcu.Pin16=VP_SYS_VS_Systick
@ -34,22 +34,22 @@ Mcu.Pin2=PA0
Mcu.Pin20=VP_TIM17_VS_ClockSourceINT Mcu.Pin20=VP_TIM17_VS_ClockSourceINT
Mcu.Pin3=PA2 Mcu.Pin3=PA2
Mcu.Pin4=PA3 Mcu.Pin4=PA3
Mcu.Pin5=PA5 Mcu.Pin5=PA6
Mcu.Pin6=PA6 Mcu.Pin6=PA7
Mcu.Pin7=PA7 Mcu.Pin7=PB11
Mcu.Pin8=PB11 Mcu.Pin8=PA8
Mcu.Pin9=PA8 Mcu.Pin9=PA9
Mcu.PinsNb=21 Mcu.PinsNb=21
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F091RCTx Mcu.UserName=STM32F091RCTx
MxCube.Version=5.0.0 MxCube.Version=5.3.0
MxDb.Version=DB.5.0.0 MxDb.Version=DB.5.0.30
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
PA0.Mode=IN0 PA0.Mode=IN0
PA0.Signal=ADC_IN0 PA0.Signal=ADC_IN0
PA10.Mode=Synchronous PA10.Mode=Synchronous
@ -62,8 +62,6 @@ PA2.Mode=Asynchronous
PA2.Signal=USART2_TX PA2.Signal=USART2_TX
PA3.Mode=Asynchronous PA3.Mode=Asynchronous
PA3.Signal=USART2_RX PA3.Signal=USART2_RX
PA5.Mode=Full_Duplex_Master
PA5.Signal=SPI1_SCK
PA6.Mode=Full_Duplex_Master PA6.Mode=Full_Duplex_Master
PA6.Signal=SPI1_MISO PA6.Signal=SPI1_MISO
PA7.Mode=Full_Duplex_Master PA7.Mode=Full_Duplex_Master
@ -73,6 +71,9 @@ PA8.Signal=USART1_CK
PA9.Mode=Synchronous PA9.Mode=Synchronous
PA9.Signal=USART1_TX PA9.Signal=USART1_TX
PB11.Signal=S_TIM2_CH4 PB11.Signal=S_TIM2_CH4
PB3.Locked=true
PB3.Mode=Full_Duplex_Master
PB3.Signal=SPI1_SCK
PC14OSC32_IN.Mode=LSE-External-Oscillator PC14OSC32_IN.Mode=LSE-External-Oscillator
PC14OSC32_IN.Signal=RCC_OSC32_IN PC14OSC32_IN.Signal=RCC_OSC32_IN
PC15OSC32_OUT.Mode=LSE-External-Oscillator PC15OSC32_OUT.Mode=LSE-External-Oscillator
@ -95,7 +96,7 @@ ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32F091RCTx ProjectManager.DeviceId=STM32F091RCTx
ProjectManager.FirmwarePackage=STM32Cube FW_F0 V1.9.0 ProjectManager.FirmwarePackage=STM32Cube FW_F0 V1.10.1
ProjectManager.FreePins=false ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200 ProjectManager.HeapSize=0x200

View File

@ -5,7 +5,7 @@
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; COPYRIGHT(c) 2018 STMicroelectronics</center></h2> * <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:

View File

@ -116,6 +116,7 @@ int main(void)
/* USER CODE END 1 */ /* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/ /* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
@ -171,11 +172,11 @@ void SystemClock_Config(void)
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/**Configure LSE Drive Capability /** Configure LSE Drive Capability
*/ */
HAL_PWR_EnableBkUpAccess(); HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH); __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH);
/**Initializes the CPU, AHB and APB busses clocks /** Initializes the CPU, AHB and APB busses clocks
*/ */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI14 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI14
|RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_LSE; |RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_LSE;
@ -193,7 +194,7 @@ void SystemClock_Config(void)
{ {
Error_Handler(); Error_Handler();
} }
/**Initializes the CPU, AHB and APB busses clocks /** Initializes the CPU, AHB and APB busses clocks
*/ */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1; |RCC_CLOCKTYPE_PCLK1;
@ -233,7 +234,7 @@ static void MX_ADC_Init(void)
/* USER CODE BEGIN ADC_Init 1 */ /* USER CODE BEGIN ADC_Init 1 */
/* USER CODE END ADC_Init 1 */ /* USER CODE END ADC_Init 1 */
/**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
*/ */
hadc.Instance = ADC1; hadc.Instance = ADC1;
hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
@ -253,7 +254,7 @@ static void MX_ADC_Init(void)
{ {
Error_Handler(); Error_Handler();
} }
/**Configure for the selected ADC regular channel to be converted. /** Configure for the selected ADC regular channel to be converted.
*/ */
sConfig.Channel = ADC_CHANNEL_0; sConfig.Channel = ADC_CHANNEL_0;
sConfig.Rank = ADC_RANK_CHANNEL_NUMBER; sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
@ -312,7 +313,7 @@ static void MX_RTC_Init(void)
/* USER CODE BEGIN RTC_Init 1 */ /* USER CODE BEGIN RTC_Init 1 */
/* USER CODE END RTC_Init 1 */ /* USER CODE END RTC_Init 1 */
/**Initialize RTC Only /** Initialize RTC Only
*/ */
hrtc.Instance = RTC; hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24; hrtc.Init.HourFormat = RTC_HOURFORMAT_24;

View File

@ -107,7 +107,6 @@ void HAL_MspInit(void)
*/ */
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hadc->Instance==ADC1) if(hadc->Instance==ADC1)
{ {
@ -139,10 +138,8 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
* @param hadc: ADC handle pointer * @param hadc: ADC handle pointer
* @retval None * @retval None
*/ */
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
{ {
if(hadc->Instance==ADC1) if(hadc->Instance==ADC1)
{ {
/* USER CODE BEGIN ADC1_MspDeInit 0 */ /* USER CODE BEGIN ADC1_MspDeInit 0 */
@ -171,7 +168,6 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
*/ */
void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
{ {
if(hrtc->Instance==RTC) if(hrtc->Instance==RTC)
{ {
/* USER CODE BEGIN RTC_MspInit 0 */ /* USER CODE BEGIN RTC_MspInit 0 */
@ -192,10 +188,8 @@ void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
* @param hrtc: RTC handle pointer * @param hrtc: RTC handle pointer
* @retval None * @retval None
*/ */
void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
{ {
if(hrtc->Instance==RTC) if(hrtc->Instance==RTC)
{ {
/* USER CODE BEGIN RTC_MspDeInit 0 */ /* USER CODE BEGIN RTC_MspDeInit 0 */
@ -218,7 +212,6 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
*/ */
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hspi->Instance==SPI1) if(hspi->Instance==SPI1)
{ {
@ -229,18 +222,26 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
__HAL_RCC_SPI1_CLK_ENABLE(); __HAL_RCC_SPI1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/**SPI1 GPIO Configuration /**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PA6 ------> SPI1_MISO PA6 ------> SPI1_MISO
PA7 ------> SPI1_MOSI PA7 ------> SPI1_MOSI
PB3 ------> SPI1_SCK
*/ */
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF0_SPI1; GPIO_InitStruct.Alternate = GPIO_AF0_SPI1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF0_SPI1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN SPI1_MspInit 1 */ /* USER CODE BEGIN SPI1_MspInit 1 */
/* USER CODE END SPI1_MspInit 1 */ /* USER CODE END SPI1_MspInit 1 */
@ -254,10 +255,8 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
* @param hspi: SPI handle pointer * @param hspi: SPI handle pointer
* @retval None * @retval None
*/ */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
{ {
if(hspi->Instance==SPI1) if(hspi->Instance==SPI1)
{ {
/* USER CODE BEGIN SPI1_MspDeInit 0 */ /* USER CODE BEGIN SPI1_MspDeInit 0 */
@ -267,11 +266,13 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
__HAL_RCC_SPI1_CLK_DISABLE(); __HAL_RCC_SPI1_CLK_DISABLE();
/**SPI1 GPIO Configuration /**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PA6 ------> SPI1_MISO PA6 ------> SPI1_MISO
PA7 ------> SPI1_MOSI PA7 ------> SPI1_MOSI
PB3 ------> SPI1_SCK
*/ */
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); HAL_GPIO_DeInit(GPIOA, GPIO_PIN_6|GPIO_PIN_7);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3);
/* USER CODE BEGIN SPI1_MspDeInit 1 */ /* USER CODE BEGIN SPI1_MspDeInit 1 */
@ -288,7 +289,6 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
*/ */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{ {
if(htim_base->Instance==TIM2) if(htim_base->Instance==TIM2)
{ {
/* USER CODE BEGIN TIM2_MspInit 0 */ /* USER CODE BEGIN TIM2_MspInit 0 */
@ -338,7 +338,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(htim->Instance==TIM2) if(htim->Instance==TIM2)
{ {
@ -369,10 +368,8 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
* @param htim_base: TIM_Base handle pointer * @param htim_base: TIM_Base handle pointer
* @retval None * @retval None
*/ */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{ {
if(htim_base->Instance==TIM2) if(htim_base->Instance==TIM2)
{ {
/* USER CODE BEGIN TIM2_MspDeInit 0 */ /* USER CODE BEGIN TIM2_MspDeInit 0 */
@ -428,7 +425,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
*/ */
void HAL_USART_MspInit(USART_HandleTypeDef* husart) void HAL_USART_MspInit(USART_HandleTypeDef* husart)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(husart->Instance==USART1) if(husart->Instance==USART1)
{ {
@ -466,7 +462,6 @@ void HAL_USART_MspInit(USART_HandleTypeDef* husart)
*/ */
void HAL_UART_MspInit(UART_HandleTypeDef* huart) void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
if(huart->Instance==USART2) if(huart->Instance==USART2)
{ {
@ -501,10 +496,8 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
* @param husart: USART handle pointer * @param husart: USART handle pointer
* @retval None * @retval None
*/ */
void HAL_USART_MspDeInit(USART_HandleTypeDef* husart) void HAL_USART_MspDeInit(USART_HandleTypeDef* husart)
{ {
if(husart->Instance==USART1) if(husart->Instance==USART1)
{ {
/* USER CODE BEGIN USART1_MspDeInit 0 */ /* USER CODE BEGIN USART1_MspDeInit 0 */
@ -533,10 +526,8 @@ void HAL_USART_MspDeInit(USART_HandleTypeDef* husart)
* @param huart: UART handle pointer * @param huart: UART handle pointer
* @retval None * @retval None
*/ */
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
{ {
if(huart->Instance==USART2) if(huart->Instance==USART2)
{ {
/* USER CODE BEGIN USART2_MspDeInit 0 */ /* USER CODE BEGIN USART2_MspDeInit 0 */

View File

@ -71,6 +71,7 @@
/* USER CODE END 0 */ /* USER CODE END 0 */
/* External variables --------------------------------------------------------*/ /* External variables --------------------------------------------------------*/
/* USER CODE BEGIN EV */ /* USER CODE BEGIN EV */
/* USER CODE END EV */ /* USER CODE END EV */