You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
KED/env/csl/stm32f042/Src/imp_interrupt.c

97 lines
1.3 KiB

#include "interrupt.h"
static void defaultHandler(){};
// pointers to dedicated interrupt handlers
void intInit(
intType_t intType
intHandler_t handler,
uint8_t priority)
{
NVIC_SetPriority(interruptTypeIndexList[intType], priority);
// TODO: add index ceck!
intHandlerList[intType] = (uint32_t)handler;
}
void intEnableAll()
{
__enable_irq();
}
void intDissableAll()
{
__disable_irq();
}
void intEnable(
intType_t intType)
{
NVIC_EnableIRQ();
}
void intDissable(
intType_t intType)
{
}
// Interrupt service routines
void TIM2_IRQHandler()
{
if(TIM2->SR & TIM_SR_UIF) {
// clear flag
TIM2-> SR &= ~TIM_SR_UIF;
//TODO: call handler here
(intHandler_t)(intHandlerList[TIM2_UPDATE])();
}
if(TIM->SR & TIM_SR_CC1IF) {
TIM2-> SR &= ~TIM_SR_CC12IF;
}
if(TIM->SR & TIM_SR_CC12IF) {
TIM2-> SR &= ~TIM_SR_CC12IF;
}
if(TIM->SR & TIM_SR_CC3IF) {
TIM2-> SR &= ~TIM_SR_CC3IF;
}
if(TIM->SR & TIM_SR_CC4IF) {
TIM2-> SR &= ~TIM_SR_CC4IF;
}
if(TIM->SR & TIM_SR_TIF) {
TIM2-> SR &= ~TIM_SR_TIF;
}
if(TIM->SR & TIM_SR_CC1OF) {
TIM2-> SR &= ~TIM_SR_CC1OF;
}
if(TIM->SR & TIM_SR_CC2OF) {
TIM2-> SR &= ~TIM_SR_CC2OF;
}
if(TIM->SR & TIM_SR_CC3OF) {
TIM2-> SR &= ~TIM_SR_CC3OF;
}
if(TIM->SR & TIM_SR_CC4OF) {
TIM2-> SR &= ~TIM_SR_CC4OF;
}
}