Browse Source

use nullptr, no default

teensy4-core
Frank 5 years ago
parent
commit
68bde513e6
No account linked to committer's email address
1 changed files with 15 additions and 9 deletions
  1. +15
    -9
      teensy4/IntervalTimer.cpp

+ 15
- 9
teensy4/IntervalTimer.cpp View File

#include "IntervalTimer.h" #include "IntervalTimer.h"
#include "debug/printf.h" #include "debug/printf.h"


static void dummy_funct(void);
static void pit_isr(void); static void pit_isr(void);


#define NUM_CHANNELS 4 #define NUM_CHANNELS 4
static void (*funct_table[4])(void) __attribute((aligned(32))) = {dummy_funct, dummy_funct, dummy_funct, dummy_funct};
static void (*funct_table[4])(void) __attribute((aligned(32))) = {nullptr, nullptr, nullptr, nullptr};
uint8_t IntervalTimer::nvic_priorites[4] = {255, 255, 255, 255}; uint8_t IntervalTimer::nvic_priorites[4] = {255, 255, 255, 255};




if (channel) { if (channel) {
int index = channel - IMXRT_PIT_CHANNELS; int index = channel - IMXRT_PIT_CHANNELS;
// TODO: disable IRQ_PIT, but only if all instances ended // TODO: disable IRQ_PIT, but only if all instances ended
funct_table[index] = dummy_funct;
funct_table[index] = nullptr;
channel->TCTRL = 0; channel->TCTRL = 0;
nvic_priorites[index] = 255; nvic_priorites[index] = 255;
uint8_t top_priority = 255; uint8_t top_priority = 255;
//FASTRUN //FASTRUN
static void pit_isr() static void pit_isr()
{ {
#if 0
for (int i=0; i < NUM_CHANNELS; i++) { for (int i=0; i < NUM_CHANNELS; i++) {
IMXRT_PIT_CHANNEL_t *channel = IMXRT_PIT_CHANNELS + i; IMXRT_PIT_CHANNEL_t *channel = IMXRT_PIT_CHANNELS + i;
if (channel->TFLG) {
if (funct_table[0] && channel->TFLG) {
channel->TFLG = 1; channel->TFLG = 1;
funct_table[i](); funct_table[i]();

} }
} }
#else
IMXRT_PIT_CHANNEL_t *channel= IMXRT_PIT_CHANNELS;
if (funct_table[0] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[0]();}
channel++;
if (funct_table[1] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[1]();}
channel++;
if (funct_table[2] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[2]();}
channel++;
if (funct_table[3] != nullptr && channel->TFLG) {channel->TFLG = 1;funct_table[3]();}
#endif
} }

static void dummy_funct(void)
{
}


Loading…
Cancel
Save