diff --git a/SHAL/Include/Core/SHAL_CORE.h b/SHAL/Include/Core/SHAL_CORE.h index fc358f0..243fb8f 100644 --- a/SHAL/Include/Core/SHAL_CORE.h +++ b/SHAL/Include/Core/SHAL_CORE.h @@ -1,16 +1,63 @@ -// -// Created by Luca on 8/29/2025. -// - +/** + ****************************************************************************** + * @file SHAL_CORE.h + * @author Luca Lizaranzu + * @brief Defines universal macros and objects used across all STM32 families + * Includes for ST Microelectronics pre-made C headers for STM32 device families + ****************************************************************************** + */ #ifndef SHMINGO_HAL_SHAL_CORE_H #define SHMINGO_HAL_SHAL_CORE_H #include +//Universal structs and defines --------------------------- struct SHAL_Peripheral { volatile uint32_t* reg; uint32_t bitmask; }; + +//--------------------------------------------------------- + + +#if defined(STM32F030x6) +#include "stm32f030x6.h" +#elif defined(STM32F030x8) +#include "stm32f030x8.h" +#elif defined(STM32F031x6) +#include "stm32f031x6.h" +#elif defined(STM32F038xx) +#include "stm32f038xx.h" +#elif defined(STM32F042x6) +#include "stm32f042x6.h" +#elif defined(STM32F048xx) +#include "stm32f048xx.h" +#elif defined(STM32F051x8) +#include "stm32f051x8.h" +#elif defined(STM32F058xx) +#include "stm32f058xx.h" +#elif defined(STM32F070x6) +#include "stm32f070x6.h" +#elif defined(STM32F070xB) +#include "stm32f070xb.h" +#elif defined(STM32F071xB) +#include "stm32f071xb.h" +#elif defined(STM32F072xB) +#include "stm32f072xb.h" +#include "SHAL_TIM_REG_F072xB.h" +#elif defined(STM32F078xx) +#include "stm32f078xx.h" +#elif defined(STM32F091xC) + #include "stm32f091xc.h" +#elif defined(STM32F098xx) + #include "stm32f098xx.h" +#elif defined(STM32F030xC) + #include "stm32f030xc.h" +#else + #error "Please select first the target STM32F0xx device used in your application (in stm32f0xx.h file)" +#endif + + #endif //SHMINGO_HAL_SHAL_CORE_H diff --git a/SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_REG.h b/SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_REG_F072xB.h similarity index 88% rename from SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_REG.h rename to SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_REG_F072xB.h index 6842176..bbe5554 100644 --- a/SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_REG.h +++ b/SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_REG_F072xB.h @@ -1,3 +1,11 @@ +/** + ****************************************************************************** + * @file SHAL_TIM_REG.h + * @author Luca Lizaranzu + * @brief Defines universal macros and objects used across all STM32 families + ****************************************************************************** + */ + #ifndef SHAL_TIM_REG_H #define SHAL_TIM_REG_H diff --git a/SHAL/Include/Peripheral/Timer/SHAL_TIM.h b/SHAL/Include/Peripheral/Timer/SHAL_TIM.h index a1022b8..5267c43 100644 --- a/SHAL/Include/Peripheral/Timer/SHAL_TIM.h +++ b/SHAL/Include/Peripheral/Timer/SHAL_TIM.h @@ -1,7 +1,15 @@ +/** + ****************************************************************************** + * @file SHAL_TIM.h + * @author Luca Lizaranzu + * @brief Declarations of timer related objects + ****************************************************************************** + */ + #ifndef SHAL_TIM_H #define SHAL_TIM_H -#include "SHAL_TIM_REG.h" +#include "SHAL_TIM_REG_F072xB.h" #include "SHAL_TIM_CALLBACK.h" #include diff --git a/SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_CALLBACK.h b/SHAL/Include/Peripheral/Timer/SHAL_TIM_CALLBACK.h similarity index 67% rename from SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_CALLBACK.h rename to SHAL/Include/Peripheral/Timer/SHAL_TIM_CALLBACK.h index 1938d99..a8dc4b1 100644 --- a/SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_CALLBACK.h +++ b/SHAL/Include/Peripheral/Timer/SHAL_TIM_CALLBACK.h @@ -1,11 +1,16 @@ -// -// Created by Luca on 8/28/2025. -// +/** + ****************************************************************************** + * @file SHAL.h + * @author Luca Lizaranzu + * @brief Utilities for creating and populating the timer IRQ callback table + * globally, see usage in SHAL_TIM.h. Created in use for singleton timer abstractions + ****************************************************************************** + */ #ifndef SHMINGO_HAL_SHAL_TIM_CALLBACK_H #define SHMINGO_HAL_SHAL_TIM_CALLBACK_H -#include "SHAL_TIM_REG.h" +#include "SHAL/Include/Core/SHAL_CORE.h" #define DEFINE_TIMER_IRQ(key, irq_handler) \ extern "C" void irq_handler(void) { \ diff --git a/SHAL/Src/main.cpp b/SHAL/Src/main.cpp index ff98056..e0ccf4a 100644 --- a/SHAL/Src/main.cpp +++ b/SHAL/Src/main.cpp @@ -19,7 +19,7 @@ int main() { Timer timer2 = getTimer(Timer_Key::S_TIM2); timer2.setPrescaler(8000 - 1); - timer2.setARR(2000 - 1); + timer2.setARR(500 - 1); timer2.setCallbackFunc(tim2Handler); timer2.start();