Changed SHAL_Peripheral to take in a void* of any peripheral struct, and added SHAL_Peripheral_Register for individual registers
This commit is contained in:
@@ -29,8 +29,8 @@ enum class Timer_Key { //For STM32F072
|
||||
};
|
||||
|
||||
|
||||
//Get timer peripheral struct including bus register, enable mask, timer mask
|
||||
constexpr SHAL_Peripheral getTimerRCC(Timer_Key t) {
|
||||
//Get TIMER_KEY peripheral struct including bus register, enable mask, TIMER_KEY mask
|
||||
constexpr SHAL_Peripheral_Register getTimerRCC(Timer_Key t) {
|
||||
switch(t) {
|
||||
case Timer_Key::S_TIM1: return {&RCC->APB2ENR, RCC_APB2ENR_TIM1EN_Pos};
|
||||
case Timer_Key::S_TIM2: return {&RCC->APB1ENR, RCC_APB1ENR_TIM2EN_Pos};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* @file SHAL_TIM.h
|
||||
* @author Luca Lizaranzu
|
||||
* @brief Declarations of timer related objects
|
||||
* @brief Declarations of TIMER_KEY related objects
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
@@ -33,9 +33,9 @@ public:
|
||||
//Enable interrupts
|
||||
void enableInterrupt();
|
||||
|
||||
//Set timer IRQ callback function
|
||||
//Set TIMER_KEY IRQ callback function
|
||||
void setCallbackFunc(TimerCallback callback){
|
||||
registerTimerCallback(timer, callback);
|
||||
registerTimerCallback(TIMER_KEY, callback);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -43,8 +43,7 @@ private:
|
||||
explicit Timer(Timer_Key t);
|
||||
Timer();
|
||||
|
||||
Timer_Key timer;
|
||||
volatile TIM_TypeDef* timer_reg;
|
||||
Timer_Key TIMER_KEY;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
******************************************************************************
|
||||
* @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
|
||||
* @brief Utilities for creating and populating the TIMER_KEY IRQ callback table
|
||||
* globally, see usage in SHAL_TIM.h. Created in use for singleton TIMER_KEY abstractions
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user