Changed directory structure to eventually support multi-MCU family support
This commit is contained in:
26
SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_CALLBACK.h
Normal file
26
SHAL/Include/Peripheral/Timer/Reg/SHAL_TIM_CALLBACK.h
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Luca on 8/28/2025.
|
||||
//
|
||||
|
||||
#ifndef SHMINGO_HAL_SHAL_TIM_CALLBACK_H
|
||||
#define SHMINGO_HAL_SHAL_TIM_CALLBACK_H
|
||||
|
||||
#include "SHAL_TIM_REG.h"
|
||||
|
||||
#define DEFINE_TIMER_IRQ(key, irq_handler) \
|
||||
extern "C" void irq_handler(void) { \
|
||||
auto tim_reg = getTimerRegister(key); \
|
||||
if (tim_reg->SR & TIM_SR_UIF) { \
|
||||
tim_reg->SR &= ~TIM_SR_UIF; /* clear flag */ \
|
||||
auto cb = timer_callbacks[static_cast<int>(key)]; \
|
||||
if (cb) cb(); \
|
||||
}; \
|
||||
};
|
||||
|
||||
typedef void (*TimerCallback)(); //Typedef for callback function
|
||||
|
||||
[[maybe_unused]] static TimerCallback timer_callbacks[static_cast<int>(Timer_Key::NUM_TIMERS)] = {nullptr}; //Timer IRQ Callback table
|
||||
|
||||
void registerTimerCallback(Timer_Key key, TimerCallback callback);
|
||||
|
||||
#endif //SHMINGO_HAL_SHAL_TIM_CALLBACK_H
|
||||
Reference in New Issue
Block a user