Removed unused BUS field from RCC_Peripheral struct
This commit is contained in:
10
Core/Include/GPIO/SHAL_GPIO.h
Normal file
10
Core/Include/GPIO/SHAL_GPIO.h
Normal file
@@ -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
|
||||||
14
Core/Include/GPIO/SHAL_GPIO_REG.h
Normal file
14
Core/Include/GPIO/SHAL_GPIO_REG.h
Normal file
@@ -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
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#ifndef SHAL_H
|
#ifndef SHAL_H
|
||||||
#define SHAL_H
|
#define SHAL_H
|
||||||
|
|
||||||
#include "Core/Include/Timer/SHAL_TIM.h"
|
#include "SHAL_TIM.h"
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,16 +5,7 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stm32f072xb.h>
|
#include <stm32f072xb.h>
|
||||||
|
|
||||||
|
|
||||||
enum class Bus {
|
|
||||||
AHB,
|
|
||||||
APB1,
|
|
||||||
APB2,
|
|
||||||
INVALID
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RCC_Peripheral {
|
struct RCC_Peripheral {
|
||||||
Bus bus;
|
|
||||||
volatile uint32_t* reg;
|
volatile uint32_t* reg;
|
||||||
uint32_t bitmask;
|
uint32_t bitmask;
|
||||||
};
|
};
|
||||||
@@ -35,17 +26,17 @@ enum class Timer_Key { //For STM32F072
|
|||||||
//Get timer peripheral struct including bus register, enable mask, timer mask
|
//Get timer peripheral struct including bus register, enable mask, timer mask
|
||||||
constexpr RCC_Peripheral getTimerRCC(Timer_Key t) {
|
constexpr RCC_Peripheral getTimerRCC(Timer_Key t) {
|
||||||
switch(t) {
|
switch(t) {
|
||||||
case Timer_Key::S_TIM1: return {Bus::APB2, &RCC->APB2ENR, RCC_APB2ENR_TIM1EN};
|
case Timer_Key::S_TIM1: return {&RCC->APB2ENR, RCC_APB2ENR_TIM1EN};
|
||||||
case Timer_Key::S_TIM2: return {Bus::APB1, &RCC->APB1ENR, RCC_APB1ENR_TIM2EN};
|
case Timer_Key::S_TIM2: return {&RCC->APB1ENR, RCC_APB1ENR_TIM2EN};
|
||||||
case Timer_Key::S_TIM3: return {Bus::APB1, &RCC->APB1ENR, RCC_APB1ENR_TIM3EN};
|
case Timer_Key::S_TIM3: return {&RCC->APB1ENR, RCC_APB1ENR_TIM3EN};
|
||||||
case Timer_Key::S_TIM14: return {Bus::APB1, &RCC->APB1ENR, RCC_APB1ENR_TIM14EN};
|
case Timer_Key::S_TIM14: return {&RCC->APB1ENR, RCC_APB1ENR_TIM14EN};
|
||||||
case Timer_Key::S_TIM15: return {Bus::APB2, &RCC->APB2ENR, RCC_APB2ENR_TIM15EN};
|
case Timer_Key::S_TIM15: return {&RCC->APB2ENR, RCC_APB2ENR_TIM15EN};
|
||||||
case Timer_Key::S_TIM16: return {Bus::APB2, &RCC->APB2ENR, RCC_APB2ENR_TIM16EN};
|
case Timer_Key::S_TIM16: return {&RCC->APB2ENR, RCC_APB2ENR_TIM16EN};
|
||||||
case Timer_Key::S_TIM17: return {Bus::APB2, &RCC->APB2ENR, RCC_APB2ENR_TIM17EN};
|
case Timer_Key::S_TIM17: return {&RCC->APB2ENR, RCC_APB2ENR_TIM17EN};
|
||||||
case Timer_Key::NUM_TIMERS:
|
case Timer_Key::NUM_TIMERS:
|
||||||
case Timer_Key::S_TIM_INVALID:
|
case Timer_Key::S_TIM_INVALID:
|
||||||
assert(false);
|
assert(false);
|
||||||
return {Bus::INVALID, nullptr, 0};; //Unreachable
|
return {nullptr, 0};; //Unreachable
|
||||||
}
|
}
|
||||||
|
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ int main() {
|
|||||||
Timer timer2 = getTimer(Timer_Key::S_TIM2);
|
Timer timer2 = getTimer(Timer_Key::S_TIM2);
|
||||||
|
|
||||||
timer2.setPrescaler(8000 - 1);
|
timer2.setPrescaler(8000 - 1);
|
||||||
timer2.setARR(500 - 1);
|
timer2.setARR(2000 - 1);
|
||||||
timer2.setCallbackFunc(tim2Handler);
|
timer2.setCallbackFunc(tim2Handler);
|
||||||
timer2.start();
|
timer2.start();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user