working on adding timer interrupt enable/dissable feature which sets the DIER register internaly

master
polymurph 2 years ago
parent 42ef82eb87
commit 6d0ffa4045

@ -12,6 +12,50 @@
intHandlerArray[(intType)]();\
}} while (0)
static const uint32_t DIER_list[TIM16_UPDATE - TIM1_BREAK] = {
TIM_DIER_BIE,// timer 1
TIM_DIER_UIE,
TIM_DIER_TIE,
TIM_DIER_COMIE,
TIM_DIER_CC1IE,
TIM_DIER_CC2IE,
TIM_DIER_CC3IE,
TIM_DIER_CC4IE,
TIM_DIER_UIE,// timer 2
TIM_DIER_CC1IE,
TIM_DIER_CC2IE,
TIM_DIER_CC3IE,
TIM_DIER_CC4IE,
TIM_DIER_TIE,
TIM_DIER_CC1IE,
TIM_DIER_CC2IE,
TIM_DIER_CC3IE,
TIM_DIER_CC4IE,
TIM_DIER_UIE, // timer 3
TIM_DIER_CC1IE,
TIM_DIER_CC2IE,
TIM_DIER_CC3IE,
TIM_DIER_CC4IE,
TIM_DIER_TIE,
TIM_DIER_CC1IE,
TIM_DIER_CC2IE,
TIM_DIER_CC3IE,
TIM_DIER_CC4IE,
TIM_DIER_CC1IE,// timer 14
TIM_DIER_CC1IE,
TIM_DIER_UIE,
TIM_DIER_CC1IE,// tiemr 16
TIM_DIER_BIE,
TIM_DIER_COMIE,
TIM_DIER_CC1IE,
TIM_DIER_UIE,
TIM_DIER_CC1IE,// tiemr 17
TIM_DIER_BIE,
TIM_DIER_COMIE,
TIM_DIER_CC1IE,
TIM_DIER_UIE
}
void timerReset(timerNo_t timer)
{
if(timerBus_No[timer]==1)
@ -251,12 +295,32 @@ uint32_t timerGetCount(timerNo_t timer)
return BASE->CNT;
}
void timerEnableInterrupt(
timerNo_t timer,
intrType_t timerInterrupt)
{
// check for the correct interrupt index
if(timerInterrupt < TIM1_BREAK) return;
if(timerInterrupt >TIM17_UPDATE) return;
// set the corresponding bit in the corresponding timers DIER register
BASE->DIER |= DIER_list[timerInterrupt - TIM1_BREAK];
}
void timerDissableInterrupt(
timerNo_t timer,
intrType_t timerInterrupt)
{
// check for the correct interrupt index
if(timerInterrupt < TIM1_BREAK) return;
if(timerInterrupt >TIM17_UPDATE) return;
// set the corresponding bit in the corresponding timers DIER register
BASE->DIER &= ~DIER_list[timerInterrupt - TIM1_BREAK];
}
void timerThrowError(timerError_t error)
{
while(1);
}
// Interrupt service routines
void TIM1_BRK_UP_TRG_COM_IRQHandler()
@ -277,23 +341,7 @@ void TIM1_CC_IRQHandler()
void TIM2_IRQHandler()
{
/*
if(TIM2->SR & TIM_SR_UIF) {
TIM2->SR &= ~TIM_SR_UIF;
if(intHandlerArray[TIM2_UPDATE] == NULL) return;
//pinToggle(pinB3);
intHandlerArray[TIM2_UPDATE]();
// debug info: not working here!
//((intHandler_t)(intHandlerList[TIM2_UPDATE]))();
}
*/
HANDLE_INT_FLAG(TIM2->SR,TIM_SR_UIF,TIM2_UPDATE);
/*
HANDLE_INT_FLAG(TIM2->SR,TIM_SR_CC1IF,TIM2_COUNTERCOMPARE_1);
HANDLE_INT_FLAG(TIM2->SR,TIM_SR_CC2IF,TIM2_COUNTERCOMPARE_2);
HANDLE_INT_FLAG(TIM2->SR,TIM_SR_CC3IF,TIM2_COUNTERCOMPARE_3);
@ -303,7 +351,6 @@ void TIM2_IRQHandler()
HANDLE_INT_FLAG(TIM2->SR,TIM_SR_CC2OF,TIM2_CAPTURECOMPARE_2);
HANDLE_INT_FLAG(TIM2->SR,TIM_SR_CC3OF,TIM2_CAPTURECOMPARE_3);
HANDLE_INT_FLAG(TIM2->SR,TIM_SR_CC4OF,TIM2_CAPTURECOMAPRE_4);
*/
}
void TIM3_IRQHandler()

@ -23,6 +23,7 @@ extern "C" {
#endif
#include "hwd_timer.h"
#include "interrupt.h"
#include "pin.h"
/*! Emun of possible Timer Errors */
@ -227,8 +228,15 @@ void timerStop(timerNo_t timer);
uint32_t timerGetCount(timerNo_t timer);
void timerThrowError(timerError_t error);
void timerEnableInterrupt(
timerNo_t timer,
intrType_t timerInterrupt);
void timerDissableInterrupt(
timerNo_t timer,
intrType_t timerInterrupt);
void timerThrowError(timerError_t error);
#ifdef __cplusplus
}
#endif

Loading…
Cancel
Save