MPyATE_Firmware/src/app_periodic_tasks.c
Yilin Sun c52e1a865a
All checks were successful
continuous-integration/drone/push Build is passing
Added GPIO interface.
Signed-off-by: Yilin Sun <imi415@imi.moe>
2023-05-29 23:38:52 +08:00

38 lines
841 B
C

/* Board */
#include "clock_config.h"
/* SDK drivers */
#include "fsl_mrt.h"
/* App */
#include "app_gpio.h"
#include "app_periodic_tasks.h"
#define APP_PERIODIC_RATE 1000
void app_periodic_tasks_init(void) {
CLOCK_EnableClock(kCLOCK_Mrt);
mrt_config_t mrt_cfg = {
.enableMultiTask = false,
};
MRT_Init(MRT0, &mrt_cfg);
MRT_SetupChannelMode(MRT0, kMRT_Channel_0, kMRT_RepeatMode);
MRT_EnableInterrupts(MRT0, kMRT_Channel_0, kMRT_TimerInterruptEnable);
EnableIRQ(MRT0_IRQn);
NVIC_SetPriority(MRT0_IRQn, 2);
MRT_StartTimer(MRT0, kMRT_Channel_0, (CLOCK_GetCoreSysClkFreq() / APP_PERIODIC_RATE));
}
static void app_periodic_task(void) {
app_gpio_update();
}
void MRT0_IRQHandler(void) {
app_periodic_task();
MRT_ClearStatusFlags(MRT0, kMRT_Channel_0, kMRT_TimerInterruptFlag);
}