Made some minor chnages to HANDLE_INT_FLAG macro, The fact that Interrups are not functioning correcly after a soft reset is known, chnages in the satrup and to the hardware may alter this behaviour

master
kerem yollu 2 years ago
parent 68de79e685
commit bbb2fefe71

@ -86,9 +86,7 @@ typedef enum {
}intrType_t;
//static uint32_t intHandlerList[intTypeEND]={0};
extern volatile void (*intHandlerArray[intTypeEND])();
extern const uint8_t interruptTypeIndexList[intTypeEND];
#ifdef __cplusplus

@ -8,6 +8,7 @@
#define CLEAR_REG(REG) ((REG) = (0x0))
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
#define READ_REG(REG) ((REG))
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
// FLASH->ACR = (((FLASH->ACR) & (~(FLASH_ACR_LATENCY))) | 0)
#define SYS_CLK 8000000
@ -18,6 +19,7 @@ void setupInit()
setupBus();
setupMemory();
setupClock();
__disable_irq();
setupPower();
delayInitMs(SYS_CLK, 1000);
}

@ -87,12 +87,12 @@ void intInit(
intHandlerArray[intType] = handler;
}
void intEnableAll()
void intEnableGlobal()
{
__enable_irq();
}
void intDisableAll()
void intDisableGlobal()
{
__disable_irq();
}

@ -38,12 +38,12 @@ static const uint32_t DIER_list[41] = {
TIM_DIER_CC1IE,// timer 14
TIM_DIER_CC1IE,
TIM_DIER_UIE,
TIM_DIER_CC1IE,// tiemr 16
TIM_DIER_CC1IE,// timer 16
TIM_DIER_BIE,
TIM_DIER_COMIE,
TIM_DIER_CC1IE,
TIM_DIER_UIE,
TIM_DIER_CC1IE,// tiemr 17
TIM_DIER_CC1IE,// timer 17
TIM_DIER_BIE,
TIM_DIER_COMIE,
TIM_DIER_CC1IE,
@ -91,7 +91,6 @@ void timerSetCountDirection(timerNo_t timer, timerCountDirection_t direction)
{
if(direction == upCounting)
{
BASE->CR1 &=~ TIM_CR1_DIR;
return;
}
@ -347,6 +346,7 @@ void TIM2_IRQHandler()
HANDLE_INT_FLAG(TIM2->SR,TIM_SR_CC4OF,TIM2_CAPTURECOMAPRE_4);
}
void TIM3_IRQHandler()
{
HANDLE_INT_FLAG(TIM3->SR,TIM_SR_UIF,TIM3_UPDATE);

@ -185,5 +185,3 @@ SECTIONS
.ARM.attributes 0 : { *(.ARM.attributes) }
}

@ -0,0 +1,42 @@
#include "delay.h"
#include "pin.h"
#include "deviceSetup.h"
#include "interrupt.h"
#include "timer.h"
void blinkiTask()
{
pinToggle(pinB3);
}
void declareInterrupts()
{
intDisableGlobal();
timerInitCounter(timer_2,(8E6/16E3)-1, 5000-1, upCounting);
timerEnableInterrupt(timer_2,TIM2_UPDATE);
timerStart(timer_2);
intInit(TIM2_UPDATE, blinkiTask, 1);
intEnable(TIM2_UPDATE);
intEnableGlobal();
}
int main(int argc, char *argv[])
{
uint8_t i = 0;
pinConfig(pinA0, input, def_stage, pullDown, def_speed);
pinConfig(pinB3, output, pushPull, def_res, def_speed);
pinWrite(pinB3, 0);
declareInterrupts();
while(1);
return 1;
}

@ -0,0 +1,15 @@
#ifndef MAIN_H
#define MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#ifdef __cplusplus
}
#endif
#endif /* MAIN_H */

@ -0,0 +1,21 @@
#Declareing header directory for the project
#To add a new directory
# -> list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
# list() = List declaration "DON'T CHANGE"
# PROJECT_HEADERS_DIR = Variable containing the listed direcotries "DON'T CHANCE
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
#list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/headers)
#Declaring sources directory for the project
#To add a new directory
# -> list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
# list() = List declaration "DON'T CHANGE"
# PROJECT_SOURCES_DIR = Variable containing the listed direcotries "DON'T CHANCE
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
#list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/src)
#list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/sensors)
#Declaring sources to be compiled for the project.
#CMake will look in each previsouly declarec sources directory until to find this files.
set(PROJECT_SOURCES_DIR_LIST)

@ -24,13 +24,23 @@ extern "C" {
#include <stdlib.h>
#include "hwd_interrupt.h"
#define HANDLE_INT_FLAG(flagReg, flagMask, intType) \
if ((flagReg) & (flagMask)) { \
(flagReg) &= ~(flagMask); \
if(intHandlerArray[(intType)]){ \
intHandlerArray[(intType)](); \
} \
}
/* OLD VERSION : Why did we need the do whlie loop ?
#define HANDLE_INT_FLAG(flagReg, flagMask, intType) \
do {if ((flagReg) & (flagMask)) { \
(flagReg) &= ~(flagMask); \
if(intHandlerArray[(intType)] == NULL){ continue;} \
intHandlerArray[(intType)](); \
}} while (0)
*/
/*! interrupt callback type for the handler */
typedef void (*intHandler_t)(void);
@ -65,7 +75,7 @@ void intInit(
* Enables all interrupts globally.
*
*/
void intEnableAll();
void intEnableGlobal();
/**
* @brief Disable all Interrups
@ -73,7 +83,7 @@ void intEnableAll();
* Dissables all interrupts globally exept the non maskable ones given by the architecture of the
* MCU.
*/
void intDisableAll();
void intDisableGlobal();
/**
* @brief Enable one interrupt type

Loading…
Cancel
Save