Browse Source

Add IntervalTimer.priority()

teensy4-core
PaulStoffregen 10 years ago
parent
commit
7765518d85
2 changed files with 7 additions and 1 deletions
  1. +1
    -0
      teensy3/IntervalTimer.cpp
  2. +6
    -1
      teensy3/IntervalTimer.h

+ 1
- 0
teensy3/IntervalTimer.cpp View File

*PIT_TCTRL = 0; *PIT_TCTRL = 0;
*PIT_LDVAL = newValue; *PIT_LDVAL = newValue;
*PIT_TCTRL = 3; *PIT_TCTRL = 3;
NVIC_SET_PRIORITY(IRQ_PIT_CH, nvic_priority);
NVIC_ENABLE_IRQ(IRQ_PIT_CH); NVIC_ENABLE_IRQ(IRQ_PIT_CH);


} }

+ 6
- 1
teensy3/IntervalTimer.h View File

reg PIT_LDVAL; reg PIT_LDVAL;
reg PIT_TCTRL; reg PIT_TCTRL;
uint8_t IRQ_PIT_CH; uint8_t IRQ_PIT_CH;
uint8_t nvic_priority;
ISR myISR; ISR myISR;
bool beginCycles(ISR newISR, uint32_t cycles); bool beginCycles(ISR newISR, uint32_t cycles);
public: public:
IntervalTimer() { status = TIMER_OFF; }
IntervalTimer() { status = TIMER_OFF; nvic_priority = 128; }
~IntervalTimer() { end(); } ~IntervalTimer() { end(); }
bool begin(ISR newISR, unsigned int newPeriod) { bool begin(ISR newISR, unsigned int newPeriod) {
if (newPeriod == 0 || newPeriod > MAX_PERIOD) return false; if (newPeriod == 0 || newPeriod > MAX_PERIOD) return false;
return begin(newISR, (float)newPeriod); return begin(newISR, (float)newPeriod);
} }
void end(); void end();
void priority(uint8_t n) {
nvic_priority = n;
if (PIT_enabled) NVIC_SET_PRIORITY(IRQ_PIT_CH, n);
}
static ISR PIT_ISR[NUM_PIT]; static ISR PIT_ISR[NUM_PIT];
}; };



Loading…
Cancel
Save