From 9cc3cbece413a8407d748e3cbdaeb6eb81150346 Mon Sep 17 00:00:00 2001 From: Luca Date: Fri, 29 Aug 2025 22:51:31 -0700 Subject: [PATCH] Removed unused BUS field from RCC_Peripheral struct --- Core/Include/GPIO/SHAL_GPIO.h | 10 ++++++++++ Core/Include/GPIO/SHAL_GPIO_REG.h | 14 ++++++++++++++ Core/Include/SHAL.h | 2 +- Core/Include/Timer/Reg/SHAL_TIM_REG.h | 25 ++++++++----------------- Core/Src/main.cpp | 2 +- 5 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 Core/Include/GPIO/SHAL_GPIO.h create mode 100644 Core/Include/GPIO/SHAL_GPIO_REG.h diff --git a/Core/Include/GPIO/SHAL_GPIO.h b/Core/Include/GPIO/SHAL_GPIO.h new file mode 100644 index 0000000..1c243b3 --- /dev/null +++ b/Core/Include/GPIO/SHAL_GPIO.h @@ -0,0 +1,10 @@ +// +// Created by Luca on 8/29/2025. +// + +#ifndef SHMINGO_HAL_SHAL_GPIO_H +#define SHMINGO_HAL_SHAL_GPIO_H + + + +#endif //SHMINGO_HAL_SHAL_GPIO_H diff --git a/Core/Include/GPIO/SHAL_GPIO_REG.h b/Core/Include/GPIO/SHAL_GPIO_REG.h new file mode 100644 index 0000000..2534afb --- /dev/null +++ b/Core/Include/GPIO/SHAL_GPIO_REG.h @@ -0,0 +1,14 @@ +// +// Created by Luca on 8/29/2025. +// + +#ifndef SHMINGO_HAL_SHAL_GPIO_REG_H +#define SHMINGO_HAL_SHAL_GPIO_REG_H + +enum class GPIO_Key { + A0, + A1, + +}; + +#endif //SHMINGO_HAL_SHAL_GPIO_REG_H diff --git a/Core/Include/SHAL.h b/Core/Include/SHAL.h index daa09a7..d79a854 100644 --- a/Core/Include/SHAL.h +++ b/Core/Include/SHAL.h @@ -8,7 +8,7 @@ #ifndef SHAL_H #define SHAL_H -#include "Core/Include/Timer/SHAL_TIM.h" +#include "SHAL_TIM.h" #endif diff --git a/Core/Include/Timer/Reg/SHAL_TIM_REG.h b/Core/Include/Timer/Reg/SHAL_TIM_REG.h index 8295639..dd36c9d 100644 --- a/Core/Include/Timer/Reg/SHAL_TIM_REG.h +++ b/Core/Include/Timer/Reg/SHAL_TIM_REG.h @@ -5,16 +5,7 @@ #include #include - -enum class Bus { - AHB, - APB1, - APB2, - INVALID -}; - struct RCC_Peripheral { - Bus bus; volatile uint32_t* reg; uint32_t bitmask; }; @@ -35,17 +26,17 @@ enum class Timer_Key { //For STM32F072 //Get timer peripheral struct including bus register, enable mask, timer mask constexpr RCC_Peripheral getTimerRCC(Timer_Key t) { switch(t) { - case Timer_Key::S_TIM1: return {Bus::APB2, &RCC->APB2ENR, RCC_APB2ENR_TIM1EN}; - case Timer_Key::S_TIM2: return {Bus::APB1, &RCC->APB1ENR, RCC_APB1ENR_TIM2EN}; - case Timer_Key::S_TIM3: return {Bus::APB1, &RCC->APB1ENR, RCC_APB1ENR_TIM3EN}; - case Timer_Key::S_TIM14: return {Bus::APB1, &RCC->APB1ENR, RCC_APB1ENR_TIM14EN}; - case Timer_Key::S_TIM15: return {Bus::APB2, &RCC->APB2ENR, RCC_APB2ENR_TIM15EN}; - case Timer_Key::S_TIM16: return {Bus::APB2, &RCC->APB2ENR, RCC_APB2ENR_TIM16EN}; - case Timer_Key::S_TIM17: return {Bus::APB2, &RCC->APB2ENR, RCC_APB2ENR_TIM17EN}; + case Timer_Key::S_TIM1: return {&RCC->APB2ENR, RCC_APB2ENR_TIM1EN}; + case Timer_Key::S_TIM2: return {&RCC->APB1ENR, RCC_APB1ENR_TIM2EN}; + case Timer_Key::S_TIM3: return {&RCC->APB1ENR, RCC_APB1ENR_TIM3EN}; + case Timer_Key::S_TIM14: return {&RCC->APB1ENR, RCC_APB1ENR_TIM14EN}; + case Timer_Key::S_TIM15: return {&RCC->APB2ENR, RCC_APB2ENR_TIM15EN}; + case Timer_Key::S_TIM16: return {&RCC->APB2ENR, RCC_APB2ENR_TIM16EN}; + case Timer_Key::S_TIM17: return {&RCC->APB2ENR, RCC_APB2ENR_TIM17EN}; case Timer_Key::NUM_TIMERS: case Timer_Key::S_TIM_INVALID: assert(false); - return {Bus::INVALID, nullptr, 0};; //Unreachable + return {nullptr, 0};; //Unreachable } __builtin_unreachable(); diff --git a/Core/Src/main.cpp b/Core/Src/main.cpp index e0ccf4a..ff98056 100644 --- a/Core/Src/main.cpp +++ b/Core/Src/main.cpp @@ -19,7 +19,7 @@ int main() { Timer timer2 = getTimer(Timer_Key::S_TIM2); timer2.setPrescaler(8000 - 1); - timer2.setARR(500 - 1); + timer2.setARR(2000 - 1); timer2.setCallbackFunc(tim2Handler); timer2.start();