working on structure of interrupt. still errors when compiling

interrupts
polymurph 3 years ago
parent 15c0f36e11
commit 2a5aeb61e8

@ -26,6 +26,8 @@ extern "C" {
#include "stm32f042x6.h" #include "stm32f042x6.h"
#include <stdint.h> #include <stdint.h>
#include "interrupt.h"
#define PACKAGE_LQFP32 1 #define PACKAGE_LQFP32 1
#define MAX_USART_CHANNEL_COUNT 2 #define MAX_USART_CHANNEL_COUNT 2
@ -297,6 +299,40 @@ static const uint8_t i2cBus_Rst_bitPos[MAX_I2C_CHANNEL_COUNT] = {
}; };
// Interrupts
/*! interrupt types. These act as indexes for the */
typedef enum {
TIM2_UPDATE,
TIM2_COUNTERCOMPARE_1,
TIM2_COUNTERCOMPARE_2,
TIM2_COUNTERCOMPARE_3,
TIM2_COUNTERCOMPARE_4,
TIM2_TRIGGER,
TIM2_CAPTURECOMPARE_1,
TIM2_CAPTURECOMPARE_2,
TIM2_CAPTURECOMPARE_3,
TIM2_CAPTURECOMAPRE_4,
intTypeEND
}intType_t;
intHandler_t intHandlerList[intTypeEND] = NULL;
static const uint8_t interruptTypeIndexList[intTypeEND] =
{
TIM2_IRQn,
TIM2_IRQn,
TIM2_IRQn,
TIM2_IRQn,
TIM2_IRQn,
TIM2_IRQn,
TIM2_IRQn,
TIM2_IRQn,
TIM2_IRQn,
TIM2_IRQn
};
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -1,12 +1,17 @@
#include "interrupt.h" #include "interrupt.h"
static void defaultHandler(){};
// pointers to dedicated interrupt handlers
void intInit( void intInit(
intType_t intType intType_t intType
intHandler_t handler, intHandler_t handler,
uint8_t priority) uint8_t priority)
{ {
NVIC_SetPriority(, priority); NVIC_SetPriority(interruptTypeIndexList[intType], priority);
// TODO: add index ceck!
intHandlerList[intType] = handler;
} }
void intEnableAll() void intEnableAll()
@ -35,10 +40,47 @@ void intDissable(
void TIM2_IRQHandler() void TIM2_IRQHandler()
{ {
if(TIM2->SR & TIM_SR_UIF) { if(TIM2->SR & TIM_SR_UIF) {
// clear flag // clear flag
TIM2-> SR &= ~TIM_SR_UIF; TIM2-> SR &= ~TIM_SR_UIF;
//TODO: call handler here //TODO: call handler here
} }
if(TIM->SR & TIM_SR_CC1IF) {
}
if(TIM->SR & TIM_SR_CC12IF) {
}
if(TIM->SR & TIM_SR_CC3IF) {
}
if(TIM->SR & TIM_SR_CC4IF) {
}
if(TIM->SR & TIM_SR_TIF) {
}
if(TIM->SR & TIM_SR_CC1OF) {
}
if(TIM->SR & TIM_SR_CC2OF) {
}
if(TIM->SR & TIM_SR_CC3OF) {
}
if(TIM->SR & TIM_SR_CC4OF) {
}
} }

@ -28,11 +28,6 @@ extern "C" {
typedef void (*intHandler_t)(void); typedef void (*intHandler_t)(void);
// TODO: showe this into hardware description // TODO: showe this into hardware description
/*! interrupt types*/
typedef enum {
}intType_t;
/** /**
* @brief Initialize Interrupt * @brief Initialize Interrupt
* *

Loading…
Cancel
Save