diff --git a/SConstruct b/SConstruct index 798707ca..fbee7b6b 100644 --- a/SConstruct +++ b/SConstruct @@ -16,8 +16,10 @@ Usage: scons mode= mcu= (hse= / hsi=) [float=hard] [example f1md = STM32100 medium density series. f1mdvl = STM32100 medium density value line series. f4 = STM32F407/f417 series (maintained for backwards compatibility) + f401 = STM32F401 f405 = STM32F405 f407 = STM32F407 + f411 = STM32F411 f415 = STM32F417 f417 = STM32F417 f427 = STM32F427 @@ -184,9 +186,15 @@ elif mcu=="f1md": elif mcu=="f4" or mcu=="f407": setFlags("m4","F407") floatOpt() +elif mcu=="f401": + setFlags("m4","F401") + floatOpt() elif mcu=="f405": setFlags("m4","F405") floatOpt() +elif mcu=="f411": + setFlags("m4","F411") + floatOpt() elif mcu=="f415": setFlags("m4","F415") floatOpt() diff --git a/lib/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h b/lib/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h index cec0ffff..b07d82f9 100644 --- a/lib/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h +++ b/lib/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h @@ -327,9 +327,7 @@ typedef struct #if defined (STM32F40_41xxx) #define ADC_Channel_TempSensor ((uint8_t)ADC_Channel_16) -#endif /* STM32F40_41xxx */ - -#if defined (STM32F427_437xx) || defined (STM32F429_439xx) || defined (STM32F401xx) || defined (STM32F411xE) +#elif defined (STM32F427_437xx) || defined (STM32F429_439xx) || defined (STM32F401xx) || defined (STM32F411xE) #define ADC_Channel_TempSensor ((uint8_t)ADC_Channel_18) #endif /* STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F411xE */ diff --git a/lib/fwlib/f4/stdperiph/inc/stm32f4xx_dac.h b/lib/fwlib/f4/stdperiph/inc/stm32f4xx_dac.h index 2bfe5b53..172b856c 100644 --- a/lib/fwlib/f4/stdperiph/inc/stm32f4xx_dac.h +++ b/lib/fwlib/f4/stdperiph/inc/stm32f4xx_dac.h @@ -37,6 +37,8 @@ /* Includes ------------------------------------------------------------------*/ #include "fwlib/f4/cmsis/Device/ST/STM32F4xx/Include/stm32f4xx.h" +#if defined(STM32PLUS_F4_HAS_DCMI) + /** @addtogroup STM32F4xx_StdPeriph_Driver * @{ */ @@ -287,6 +289,8 @@ void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG); ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT); void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT); +#endif + #ifdef __cplusplus } #endif diff --git a/lib/fwlib/f4/stdperiph/inc/stm32f4xx_rng.h b/lib/fwlib/f4/stdperiph/inc/stm32f4xx_rng.h index 911740ce..01381773 100644 --- a/lib/fwlib/f4/stdperiph/inc/stm32f4xx_rng.h +++ b/lib/fwlib/f4/stdperiph/inc/stm32f4xx_rng.h @@ -37,6 +37,8 @@ /* Includes ------------------------------------------------------------------*/ #include "fwlib/f4/cmsis/Device/ST/STM32F4xx/Include/stm32f4xx.h" +#if defined(STM32PLUS_F4_HAS_RNG) + /** @addtogroup STM32F4xx_StdPeriph_Driver * @{ */ @@ -103,6 +105,8 @@ void RNG_ClearFlag(uint8_t RNG_FLAG); ITStatus RNG_GetITStatus(uint8_t RNG_IT); void RNG_ClearITPendingBit(uint8_t RNG_IT); +#endif + #ifdef __cplusplus } #endif diff --git a/lib/fwlib/f4/stdperiph/src/stm32f4xx_dac.c b/lib/fwlib/f4/stdperiph/src/stm32f4xx_dac.c index ad2f9816..68ee8da8 100644 --- a/lib/fwlib/f4/stdperiph/src/stm32f4xx_dac.c +++ b/lib/fwlib/f4/stdperiph/src/stm32f4xx_dac.c @@ -131,6 +131,8 @@ #include "fwlib/f4/stdperiph/inc/stm32f4xx_dac.h" #include "fwlib/f4/stdperiph/inc/stm32f4xx_rcc.h" +#if defined(STM32PLUS_F4_HAS_DCMI) + /** @addtogroup STM32F4xx_StdPeriph_Driver * @{ */ @@ -712,3 +714,5 @@ void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT) */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + +#endif diff --git a/lib/fwlib/f4/stdperiph/src/stm32f4xx_gpio.c b/lib/fwlib/f4/stdperiph/src/stm32f4xx_gpio.c index ab03cdd7..09cf4dd7 100644 --- a/lib/fwlib/f4/stdperiph/src/stm32f4xx_gpio.c +++ b/lib/fwlib/f4/stdperiph/src/stm32f4xx_gpio.c @@ -154,6 +154,7 @@ void GPIO_DeInit(GPIO_TypeDef* GPIOx) RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOE, ENABLE); RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOE, DISABLE); } +#if defined (STM32PLUS_F4_HAS_GPIOF_G_I) else if (GPIOx == GPIOF) { RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOF, ENABLE); @@ -175,9 +176,9 @@ void GPIO_DeInit(GPIO_TypeDef* GPIOx) RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOI, ENABLE); RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOI, DISABLE); } +#endif -#if defined(STM32PLUS_F427) || defined(STM32PLUS_F429) || defined(STM32PLUS_F437) || defined(STM32PLUS_F439) - +#if defined(STM32PLUS_F4_HAS_GPIOJ_K) else if (GPIOx == GPIOJ) { RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOJ, ENABLE); diff --git a/lib/fwlib/f4/stdperiph/src/stm32f4xx_rng.c b/lib/fwlib/f4/stdperiph/src/stm32f4xx_rng.c index 61aafc82..4f9d0b80 100644 --- a/lib/fwlib/f4/stdperiph/src/stm32f4xx_rng.c +++ b/lib/fwlib/f4/stdperiph/src/stm32f4xx_rng.c @@ -56,6 +56,8 @@ #include "fwlib/f4/stdperiph/inc/stm32f4xx_rng.h" #include "fwlib/f4/stdperiph/inc/stm32f4xx_rcc.h" +#if defined(STM32PLUS_F4_HAS_RNG) + /** @addtogroup STM32F4xx_StdPeriph_Driver * @{ */ @@ -393,5 +395,6 @@ void RNG_ClearITPendingBit(uint8_t RNG_IT) * @} */ - /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + +#endif diff --git a/lib/fwlib/f4/stdperiph/src/stm32f4xx_tim.c b/lib/fwlib/f4/stdperiph/src/stm32f4xx_tim.c index 6ed8fb42..75b255b2 100644 --- a/lib/fwlib/f4/stdperiph/src/stm32f4xx_tim.c +++ b/lib/fwlib/f4/stdperiph/src/stm32f4xx_tim.c @@ -227,6 +227,7 @@ void TIM_DeInit(TIM_TypeDef* TIMx) RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM5, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM5, DISABLE); } +#if defined (STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) else if (TIMx == TIM6) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM6, ENABLE); @@ -242,6 +243,7 @@ void TIM_DeInit(TIM_TypeDef* TIMx) RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, DISABLE); } +#endif else if (TIMx == TIM9) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM9, ENABLE); @@ -257,6 +259,7 @@ void TIM_DeInit(TIM_TypeDef* TIMx) RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM11, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM11, DISABLE); } +#if defined (STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) else if (TIMx == TIM12) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM12, ENABLE); @@ -275,6 +278,7 @@ void TIM_DeInit(TIM_TypeDef* TIMx) RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM14, DISABLE); } } +#endif } /** @@ -296,21 +300,27 @@ void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseIn tmpcr1 = TIMx->CR1; - if((TIMx == TIM1) || (TIMx == TIM8)|| - (TIMx == TIM2) || (TIMx == TIM3)|| - (TIMx == TIM4) || (TIMx == TIM5)) + if((TIMx == TIM1) || (TIMx == TIM2) || + (TIMx == TIM3) || (TIMx == TIM4) || + (TIMx == TIM5) +#if defined (STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) + || (TIMx == TIM8) +#endif + ) { /* Select the Counter Mode */ tmpcr1 &= (uint16_t)(~(TIM_CR1_DIR | TIM_CR1_CMS)); tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_CounterMode; } +#if defined (STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) if((TIMx != TIM6) && (TIMx != TIM7)) { /* Set the clock division */ tmpcr1 &= (uint16_t)(~TIM_CR1_CKD); tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_ClockDivision; } +#endif TIMx->CR1 = tmpcr1; @@ -320,8 +330,12 @@ void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseIn /* Set the Prescaler value */ TIMx->PSC = TIM_TimeBaseInitStruct->TIM_Prescaler; - if ((TIMx == TIM1) || (TIMx == TIM8)) - { + if ((TIMx == TIM1) +#if defined (STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) + || (TIMx == TIM8) +#endif + ) + { /* Set the Repetition Counter value */ TIMx->RCR = TIM_TimeBaseInitStruct->TIM_RepetitionCounter; } @@ -705,7 +719,11 @@ void TIM_OC1Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct) /* Set the Output State */ tmpccer |= TIM_OCInitStruct->TIM_OutputState; - if((TIMx == TIM1) || (TIMx == TIM8)) + if((TIMx == TIM1) +#if defined (STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) + || (TIMx == TIM8) +#endif + ) { assert_param(IS_TIM_OUTPUTN_STATE(TIM_OCInitStruct->TIM_OutputNState)); assert_param(IS_TIM_OCN_POLARITY(TIM_OCInitStruct->TIM_OCNPolarity)); @@ -787,7 +805,11 @@ void TIM_OC2Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct) /* Set the Output State */ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputState << 4); - if((TIMx == TIM1) || (TIMx == TIM8)) + if((TIMx == TIM1) +#if defined (STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) + || (TIMx == TIM8) +#endif + ) { assert_param(IS_TIM_OUTPUTN_STATE(TIM_OCInitStruct->TIM_OutputNState)); assert_param(IS_TIM_OCN_POLARITY(TIM_OCInitStruct->TIM_OCNPolarity)); @@ -867,7 +889,11 @@ void TIM_OC3Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct) /* Set the Output State */ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputState << 8); - if((TIMx == TIM1) || (TIMx == TIM8)) + if((TIMx == TIM1) +#if defined (STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) + || (TIMx == TIM8) +#endif + ) { assert_param(IS_TIM_OUTPUTN_STATE(TIM_OCInitStruct->TIM_OutputNState)); assert_param(IS_TIM_OCN_POLARITY(TIM_OCInitStruct->TIM_OCNPolarity)); @@ -948,7 +974,11 @@ void TIM_OC4Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct) /* Set the Output State */ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputState << 12); - if((TIMx == TIM1) || (TIMx == TIM8)) + if((TIMx == TIM1) +#if defined (STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) + || (TIMx == TIM8) +#endif + ) { assert_param(IS_TIM_OCIDLE_STATE(TIM_OCInitStruct->TIM_OCIdleState)); /* Reset the Output Compare IDLE State */ diff --git a/lib/fwlib/f4/stdperiph/src/stm32f4xx_usart.c b/lib/fwlib/f4/stdperiph/src/stm32f4xx_usart.c index 05cd2460..fa5f8576 100644 --- a/lib/fwlib/f4/stdperiph/src/stm32f4xx_usart.c +++ b/lib/fwlib/f4/stdperiph/src/stm32f4xx_usart.c @@ -199,6 +199,7 @@ void USART_DeInit(USART_TypeDef* USARTx) RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, DISABLE); } +#if defined(STM32PLUS_F4_HAS_USART3_4_5) else if (USARTx == USART3) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, ENABLE); @@ -214,6 +215,7 @@ void USART_DeInit(USART_TypeDef* USARTx) RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, DISABLE); } +#endif else if (USARTx == USART6) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART6, ENABLE); diff --git a/lib/include/adc/features/f4/AdcChannelGpioInitialiser.h b/lib/include/adc/features/f4/AdcChannelGpioInitialiser.h index 8c23b7f7..96089715 100644 --- a/lib/include/adc/features/f4/AdcChannelGpioInitialiser.h +++ b/lib/include/adc/features/f4/AdcChannelGpioInitialiser.h @@ -57,6 +57,7 @@ namespace stm32plus { case 15: port=GPIOC; pin=GPIO_Pin_5; break; } } +#if defined(STM32PLUS_F4_HAS_ADC2_3) else if(TAdcNumber==2) { switch(TChannelNumber) { case 0: port=GPIOA; pin=GPIO_Pin_0; break; @@ -97,7 +98,7 @@ namespace stm32plus { case 15: port=GPIOF; pin=GPIO_Pin_5; break; } } - +#endif // initialise the pin GpioPinInitialiser::initialise(port,pin); // this minimal overload is for analog input diff --git a/lib/include/config/adc.h b/lib/include/config/adc.h index 051a1d56..4f858504 100644 --- a/lib/include/config/adc.h +++ b/lib/include/config/adc.h @@ -51,8 +51,10 @@ #include "adc/f4/Adc.h" #include "adc/f4/AdcPeripheral.h" #include "adc/Adc1.h" +#if defined(STM32PLUS_F4_HAS_ADC2_3) #include "adc/Adc2.h" #include "adc/Adc3.h" +#endif #endif diff --git a/lib/include/config/dac.h b/lib/include/config/dac.h index 3742317d..c516685d 100644 --- a/lib/include/config/dac.h +++ b/lib/include/config/dac.h @@ -24,9 +24,11 @@ // peripheral includes -#include "dac/Dac.h" -#include "dac/DacPinInitialiser.h" -#include "dac/DacPeripheral.h" +#if defined(STM32PLUS_F4_HAS_DAC) + #include "dac/Dac.h" + #include "dac/DacPinInitialiser.h" + #include "dac/DacPeripheral.h" +#endif // feature includes diff --git a/lib/include/config/mcu_defines.h b/lib/include/config/mcu_defines.h index 7b096516..f45c9a1b 100644 --- a/lib/include/config/mcu_defines.h +++ b/lib/include/config/mcu_defines.h @@ -42,6 +42,13 @@ #elif defined(STM32PLUS_F0_42) #define STM32PLUS_F0 #define STM32F0XX + +#elif defined(STM32PLUS_F401) + #define STM32PLUS_F4 + #define STM32F401xx + #define STM32F401xC + #define STM32F401xE + #elif defined(STM32PLUS_F405) #define STM32PLUS_F4 #define STM32F405xx @@ -54,6 +61,7 @@ #define STM32PLUS_F4_HAS_OTG_HS #define STM32PLUS_F4_HAS_DAC #define STM32PLUS_F4_HAS_FSMC + #define STM32PLUS_F4_HAS_RNG #elif defined(STM32PLUS_F407) #define STM32PLUS_F4 @@ -69,6 +77,11 @@ #define STM32PLUS_F4_HAS_OTG_HS #define STM32PLUS_F4_HAS_DAC #define STM32PLUS_F4_HAS_FSMC + #define STM32PLUS_F4_HAS_RNG + +#elif defined(STM32PLUS_F411) + #define STM32PLUS_F4 + #define STM32F411xE #elif defined(STM32PLUS_F415) #define STM32PLUS_F4 @@ -83,6 +96,7 @@ #define STM32PLUS_F4_HAS_OTG_HS #define STM32PLUS_F4_HAS_DAC #define STM32PLUS_F4_HAS_FSMC + #define STM32PLUS_F4_HAS_RNG #elif defined(STM32PLUS_F417) #define STM32PLUS_F4 @@ -99,6 +113,7 @@ #define STM32PLUS_F4_HAS_OTG_HS #define STM32PLUS_F4_HAS_DAC #define STM32PLUS_F4_HAS_FSMC + #define STM32PLUS_F4_HAS_RNG #elif defined(STM32PLUS_F427) #define STM32PLUS_F4 @@ -117,6 +132,7 @@ #define STM32PLUS_F4_HAS_OTG_HS #define STM32PLUS_F4_HAS_DAC #define STM32PLUS_F4_HAS_FMC + #define STM32PLUS_F4_HAS_RNG #elif defined(STM32PLUS_F429) #define STM32PLUS_F4 @@ -136,6 +152,7 @@ #define STM32PLUS_F4_HAS_OTG_HS #define STM32PLUS_F4_HAS_DAC #define STM32PLUS_F4_HAS_FMC + #define STM32PLUS_F4_HAS_RNG #elif defined(STM32PLUS_F437) #define STM32PLUS_F4 @@ -155,6 +172,7 @@ #define STM32PLUS_F4_HAS_OTG_HS #define STM32PLUS_F4_HAS_DAC #define STM32PLUS_F4_HAS_FMC + #define STM32PLUS_F4_HAS_RNG #elif defined(STM32PLUS_F439) #define STM32PLUS_F4 @@ -175,6 +193,7 @@ #define STM32PLUS_F4_HAS_OTG_HS #define STM32PLUS_F4_HAS_DAC #define STM32PLUS_F4_HAS_FMC + #define STM32PLUS_F4_HAS_RNG #else #error "You must define an MCU type. See config/stm32plus.h" diff --git a/lib/include/config/rng.h b/lib/include/config/rng.h index 8d52d997..e24d6b76 100644 --- a/lib/include/config/rng.h +++ b/lib/include/config/rng.h @@ -24,12 +24,16 @@ #if defined(STM32PLUS_F4) +#if defined (STM32PLUS_F4_HAS_RNG) + #define USE_RNG_INTERRUPT #include "rng/f4/Rng.h" #include "rng/f4/RngEventSource.h" #include "rng/f4/features/RngInterruptFeature.h" +#endif + #elif defined(STM32PLUS_F1) #include "rng/f1/Well512.h" diff --git a/lib/include/config/usart.h b/lib/include/config/usart.h index a7cffb32..22d0db07 100644 --- a/lib/include/config/usart.h +++ b/lib/include/config/usart.h @@ -71,9 +71,11 @@ #define USE_USART1_INTERRUPT #define USE_USART2_INTERRUPT +#if !defined (STM32PLUS_F4) || defined(STM32PLUS_F4_HAS_USART3_4_5) #define USE_USART3_INTERRUPT #define USE_UART4_INTERRUPT #define USE_UART5_INTERRUPT +#endif // device specific includes diff --git a/lib/include/dma/features/PwmFadeTimerDmaFeature.h b/lib/include/dma/features/PwmFadeTimerDmaFeature.h index e114b4c0..a7e555d9 100644 --- a/lib/include/dma/features/PwmFadeTimerDmaFeature.h +++ b/lib/include/dma/features/PwmFadeTimerDmaFeature.h @@ -165,6 +165,7 @@ namespace stm32plus { template using Timer5Channel4UpdatePwmFadeTimerDmaFeature = PwmFadeTimerDmaFeature; +#if defined(STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) // TIM7 template @@ -192,9 +193,11 @@ namespace stm32plus { template using Timer8Channel4UpdatePwmFadeTimerDmaFeature = PwmFadeTimerDmaFeature; +#endif #endif +#if defined(STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) // TIM6 template @@ -208,4 +211,5 @@ namespace stm32plus { template using Timer6Channel4UpdatePwmFadeTimerDmaFeature = PwmFadeTimerDmaFeature; +#endif } diff --git a/lib/include/dma/features/f4/DmaPeripheralInfo.h b/lib/include/dma/features/f4/DmaPeripheralInfo.h index 6f10c2db..b278137c 100644 --- a/lib/include/dma/features/f4/DmaPeripheralInfo.h +++ b/lib/include/dma/features/f4/DmaPeripheralInfo.h @@ -103,9 +103,11 @@ namespace stm32plus { struct Usart1TxDmaPeripheralInfo : UsartDmaPeripheralInfo { enum { REGISTER_ADDRESS = USART1_BASE + __builtin_offsetof(USART_TypeDef,DR) }; }; struct Usart2TxDmaPeripheralInfo : UsartDmaPeripheralInfo { enum { REGISTER_ADDRESS = USART2_BASE + __builtin_offsetof(USART_TypeDef,DR) }; }; +#if defined (STM32PLUS_F4_HAS_USART3_4_5) struct Usart3TxDmaPeripheralInfo : UsartDmaPeripheralInfo { enum { REGISTER_ADDRESS = USART3_BASE + __builtin_offsetof(USART_TypeDef,DR) }; }; struct Uart4TxDmaPeripheralInfo : UsartDmaPeripheralInfo { enum { REGISTER_ADDRESS = UART4_BASE + __builtin_offsetof(USART_TypeDef,DR) }; }; struct Uart5TxDmaPeripheralInfo : UsartDmaPeripheralInfo { enum { REGISTER_ADDRESS = UART5_BASE + __builtin_offsetof(USART_TypeDef,DR) }; }; +#endif #if defined(STM32PLUS_F4) struct Usart6TxDmaPeripheralInfo : UsartDmaPeripheralInfo { enum { REGISTER_ADDRESS = USART6_BASE + __builtin_offsetof(USART_TypeDef,DR) }; }; diff --git a/lib/include/i2c/f4/I2C2Remap.h b/lib/include/i2c/f4/I2C2Remap.h index eb531672..3fad3583 100644 --- a/lib/include/i2c/f4/I2C2Remap.h +++ b/lib/include/i2c/f4/I2C2Remap.h @@ -15,7 +15,7 @@ namespace stm32plus { - +#if defined(STM32PLUS_F4_HAS_GPIOF_G_I) /* * Remap #1 pin package: * (SCL,SDA) = (PF1,PF0) @@ -45,7 +45,7 @@ namespace stm32plus { Features(static_cast(*this))... { } }; - +#endif /* * Remap #2 pin package: diff --git a/lib/include/timer/features/f4/Timer10GpioFeature.h b/lib/include/timer/features/f4/Timer10GpioFeature.h index e8fe7381..d888b953 100644 --- a/lib/include/timer/features/f4/Timer10GpioFeature.h +++ b/lib/include/timer/features/f4/Timer10GpioFeature.h @@ -19,10 +19,11 @@ namespace stm32plus { typedef gpio::PB8 TIM10_CH1_Pin; }; +#if defined (STM32PLUS_F4_HAS_GPIOF_G_I) struct TIM10_PinPackage_Remap_Full { typedef gpio::PF6 TIM10_CH1_Pin; }; - +#endif /** * Initialise GPIO pins for this timer GPIO mode @@ -64,11 +65,13 @@ namespace stm32plus { } }; +#if defined (STM32PLUS_F4_HAS_GPIOF_G_I) template class... Features> struct Timer10GpioFeature : TimerFeatureBase,Features... { Timer10GpioFeature(Timer& timer) : TimerFeatureBase(timer) { } }; +#endif /** * Custom structure to allow any pin mapping. diff --git a/lib/include/timer/features/f4/Timer11GpioFeature.h b/lib/include/timer/features/f4/Timer11GpioFeature.h index e553fe86..0d94208e 100644 --- a/lib/include/timer/features/f4/Timer11GpioFeature.h +++ b/lib/include/timer/features/f4/Timer11GpioFeature.h @@ -19,10 +19,11 @@ namespace stm32plus { typedef gpio::PB9 TIM11_CH1_Pin; }; +#if defined (STM32PLUS_F4_HAS_GPIOF_G_I) struct TIM11_PinPackage_Remap_Full { typedef gpio::PF7 TIM11_CH1_Pin; }; - +#endif /** * Initialise GPIO pins for this timer GPIO mode @@ -64,11 +65,13 @@ namespace stm32plus { } }; +#if defined(STM32PLUS_F4_HAS_GPIOF_G_I) template class... Features> struct Timer11GpioFeature : TimerFeatureBase,Features... { Timer11GpioFeature(Timer& timer) : TimerFeatureBase(timer) { } }; +#endif /** * Custom structure to allow any pin mapping. diff --git a/lib/include/timing/MicrosecondDelay.h b/lib/include/timing/MicrosecondDelay.h index 9d173fa6..fa2064a4 100644 --- a/lib/include/timing/MicrosecondDelay.h +++ b/lib/include/timing/MicrosecondDelay.h @@ -40,13 +40,13 @@ namespace stm32plus { static void delay(uint16_t us); }; - +#if defined (STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) /** * Use the basic timer TIM6 as a default for doing the microsecond delay. */ typedef MicrosecondDelayTemplate > MicrosecondDelay; - +#endif /** * Template static member initialisation diff --git a/lib/include/traits/f4/traits.h b/lib/include/traits/f4/traits.h index 3676c336..d46a0665 100644 --- a/lib/include/traits/f4/traits.h +++ b/lib/include/traits/f4/traits.h @@ -50,6 +50,7 @@ namespace stm32plus { typedef PeripheralTraits Adc3PeripheralTraits; #endif +#if defined(STM32PLUS_F4_HAS_CAN) template<> struct PeripheralTraits { enum { @@ -67,7 +68,9 @@ namespace stm32plus { }; }; typedef PeripheralTraits Can2PeripheralTraits; +#endif +#if defined(STM32PLUS_F4_HAS_DAC) template<> struct PeripheralTraits { enum { @@ -83,6 +86,7 @@ namespace stm32plus { }; }; typedef PeripheralTraits Dac1PeripheralTraits; +#endif template<> struct PeripheralTraits { diff --git a/lib/include/usart/f4/Usart3.h b/lib/include/usart/f4/Usart3.h index 09f30eb9..6fe0df1e 100644 --- a/lib/include/usart/f4/Usart3.h +++ b/lib/include/usart/f4/Usart3.h @@ -11,6 +11,7 @@ #error This class can only be used with the STM32F4 series #endif +#if defined (STM32PLUS_F4_HAS_USART3_4_5) namespace stm32plus { @@ -154,3 +155,5 @@ namespace stm32plus { } }; } + +#endif diff --git a/lib/include/usart/f4/Usart6.h b/lib/include/usart/f4/Usart6.h index 5e104b5e..344e935d 100644 --- a/lib/include/usart/f4/Usart6.h +++ b/lib/include/usart/f4/Usart6.h @@ -38,14 +38,18 @@ namespace stm32plus { enum { Port_TX=GPIOC_BASE, Port_RX=GPIOC_BASE, +#if defined(STM32PLUS_F4_HAS_GPIOF_G_I) Port_RTS=GPIOG_BASE, Port_CTS=GPIOC_BASE, +#endif Port_CK=GPIOC_BASE, Pin_TX=GPIO_Pin_6, Pin_RX=GPIO_Pin_7, +#if defined(STM32PLUS_F4_HAS_GPIOF_G_I) Pin_RTS=GPIO_Pin_8, Pin_CTS=GPIO_Pin_13, +#endif Pin_CK=GPIO_Pin_8 }; }; @@ -65,6 +69,7 @@ namespace stm32plus { } }; +#if defined(STM32PLUS_F4_HAS_GPIOF_G_I) /* * Remap #1: @@ -101,4 +106,6 @@ namespace stm32plus { Features(static_cast(*this))... { } }; +#endif + } diff --git a/lib/include/usart/features/f4/UsartInterruptFeature.h b/lib/include/usart/features/f4/UsartInterruptFeature.h index c5a4fa8a..08a50984 100644 --- a/lib/include/usart/features/f4/UsartInterruptFeature.h +++ b/lib/include/usart/features/f4/UsartInterruptFeature.h @@ -175,6 +175,7 @@ namespace stm32plus { Nvic::configureIrq(USART2_IRQn); } +#if defined (STM32PLUS_F4_HAS_USART3_4_5) /** * Enabler specialisation, Usart 3 */ @@ -204,7 +205,7 @@ namespace stm32plus { _forceLinkage=&UART5_IRQHandler; Nvic::configureIrq(UART5_IRQn); } - +#endif /** * Enabler specialisation, Usart 6 diff --git a/lib/src/adc/interrupts/f4/AdcInterruptHandler.cpp b/lib/src/adc/interrupts/f4/AdcInterruptHandler.cpp index d10b3de7..bc6939c8 100644 --- a/lib/src/adc/interrupts/f4/AdcInterruptHandler.cpp +++ b/lib/src/adc/interrupts/f4/AdcInterruptHandler.cpp @@ -25,15 +25,19 @@ extern "C" { void __attribute__ ((interrupt("IRQ"))) ADC_IRQHandler(void) { - uint16_t raised1,raised2,raised3; + uint16_t raised1; // ADC1 interrupts - the more likely to be a source. we'll prioritise these checks so // the most likely are checked first and optimise slightly by not repeatedly calling // the inefficient ADC_GetITStatus call raised1=ADC1->SR & (ADC_SR_EOC | ADC_SR_JEOC | ADC_SR_AWD | ADC_SR_OVR); + +#if defined(STM32PLUS_F4_HAS_ADC2_3) + uint16_t raised2,raised3; raised2=ADC2->SR & (ADC_SR_EOC | ADC_SR_JEOC | ADC_SR_AWD | ADC_SR_OVR); raised3=ADC3->SR & (ADC_SR_EOC | ADC_SR_JEOC | ADC_SR_AWD | ADC_SR_OVR); +#endif if((raised1 & ADC_SR_EOC)!=0 && (ADC1->CR1 & ADC_CR1_EOCIE)!=0) { AdcInterruptFeature::_adcInstance->AdcInterruptEventSender.raiseEvent(AdcEventType::EVENT_REGULAR_END_OF_CONVERSION,1); @@ -52,6 +56,7 @@ extern "C" { ADC_ClearITPendingBit(ADC1,ADC_IT_OVR); } +#if defined(STM32PLUS_F4_HAS_ADC2_3) // ADC2 interrupts else if((raised2 & ADC_SR_EOC)!=0 && (ADC2->CR1 & ADC_CR1_EOCIE)!=0) { @@ -89,7 +94,7 @@ extern "C" { AdcInterruptFeature::_adcInstance->AdcInterruptEventSender.raiseEvent(AdcEventType::EVENT_OVERFLOW,3); ADC_ClearITPendingBit(ADC3,ADC_IT_OVR); } - +#endif __DSB(); // prevent erroneous recall of this handler due to delayed memory write } diff --git a/lib/src/can/interrupts/f4/Can1InterruptHandler.cpp b/lib/src/can/interrupts/f4/Can1InterruptHandler.cpp index 5e102caa..373b81bc 100644 --- a/lib/src/can/interrupts/f4/Can1InterruptHandler.cpp +++ b/lib/src/can/interrupts/f4/Can1InterruptHandler.cpp @@ -8,6 +8,8 @@ #if defined(STM32PLUS_F4) +#if defined(STM32PLUS_F4_HAS_CAN) + #include "config/can.h" @@ -82,3 +84,5 @@ extern "C" { } #endif + +#endif diff --git a/lib/src/can/interrupts/f4/Can2InterruptHandler.cpp b/lib/src/can/interrupts/f4/Can2InterruptHandler.cpp index 687a23ba..c88ea039 100644 --- a/lib/src/can/interrupts/f4/Can2InterruptHandler.cpp +++ b/lib/src/can/interrupts/f4/Can2InterruptHandler.cpp @@ -8,6 +8,8 @@ #if defined(STM32PLUS_F4) +#if defined(STM32PLUS_F4_HAS_CAN) + #include "config/can.h" @@ -82,3 +84,5 @@ extern "C" { } #endif + +#endif diff --git a/lib/src/gpio/f4/GpioPinInitialiser.cpp b/lib/src/gpio/f4/GpioPinInitialiser.cpp index f8011211..438a8fdc 100644 --- a/lib/src/gpio/f4/GpioPinInitialiser.cpp +++ b/lib/src/gpio/f4/GpioPinInitialiser.cpp @@ -90,10 +90,12 @@ namespace stm32plus { port==GPIOC ? RCC_AHB1Periph_GPIOC : port==GPIOD ? RCC_AHB1Periph_GPIOD : port==GPIOE ? RCC_AHB1Periph_GPIOE : +#if defined (STM32PLUS_F4_HAS_GPIOF_G_I) port==GPIOF ? RCC_AHB1Periph_GPIOF : port==GPIOG ? RCC_AHB1Periph_GPIOG : - port==GPIOH ? RCC_AHB1Periph_GPIOH : - RCC_AHB1Periph_GPIOI + port==GPIOI ? RCC_AHB1Periph_GPIOI : +#endif + RCC_AHB1Periph_GPIOH ,ENABLE); // initialise diff --git a/lib/src/rng/f4/features/RngInterruptFeature.cpp b/lib/src/rng/f4/features/RngInterruptFeature.cpp index b78cf9b4..fd107612 100644 --- a/lib/src/rng/f4/features/RngInterruptFeature.cpp +++ b/lib/src/rng/f4/features/RngInterruptFeature.cpp @@ -10,6 +10,7 @@ #include "config/rng.h" +#if defined(STM32PLUS_F4_HAS_RNG) using namespace stm32plus; @@ -54,3 +55,4 @@ extern "C" { #endif #endif +#endif diff --git a/lib/src/timer/f4/Timer6InterruptHandler.cpp b/lib/src/timer/f4/Timer6InterruptHandler.cpp index b0eb1d21..d74f6823 100644 --- a/lib/src/timer/f4/Timer6InterruptHandler.cpp +++ b/lib/src/timer/f4/Timer6InterruptHandler.cpp @@ -8,7 +8,7 @@ #include "config/timer.h" -#if defined(STM32PLUS_F4) +#if defined(STM32PLUS_F4) && defined(STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) using namespace stm32plus; diff --git a/lib/src/timer/f4/Timer7InterruptHandler.cpp b/lib/src/timer/f4/Timer7InterruptHandler.cpp index 8035d86a..8885c556 100644 --- a/lib/src/timer/f4/Timer7InterruptHandler.cpp +++ b/lib/src/timer/f4/Timer7InterruptHandler.cpp @@ -8,7 +8,7 @@ #include "config/timer.h" -#if defined(STM32PLUS_F4) +#if defined(STM32PLUS_F4) && defined(STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) using namespace stm32plus; diff --git a/lib/src/timer/f4/Timer8_12_13_14InterruptHandlers.cpp b/lib/src/timer/f4/Timer8_12_13_14InterruptHandlers.cpp index 758bb09b..0316b8aa 100644 --- a/lib/src/timer/f4/Timer8_12_13_14InterruptHandlers.cpp +++ b/lib/src/timer/f4/Timer8_12_13_14InterruptHandlers.cpp @@ -7,7 +7,7 @@ #include "config/stm32plus.h" #include "config/timer.h" -#if defined(STM32PLUS_F4) +#if defined(STM32PLUS_F4) && defined(STM32PLUS_F4_HAS_TIM6_7_8_12_13_14) using namespace stm32plus;