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

@@ -152,6 +152,7 @@ void IntervalTimer::start_PIT(uint32_t newValue) {
*PIT_TCTRL = 0;
*PIT_LDVAL = newValue;
*PIT_TCTRL = 3;
NVIC_SET_PRIORITY(IRQ_PIT_CH, nvic_priority);
NVIC_ENABLE_IRQ(IRQ_PIT_CH);

}

+ 6
- 1
teensy3/IntervalTimer.h View File

@@ -46,10 +46,11 @@ class IntervalTimer {
reg PIT_LDVAL;
reg PIT_TCTRL;
uint8_t IRQ_PIT_CH;
uint8_t nvic_priority;
ISR myISR;
bool beginCycles(ISR newISR, uint32_t cycles);
public:
IntervalTimer() { status = TIMER_OFF; }
IntervalTimer() { status = TIMER_OFF; nvic_priority = 128; }
~IntervalTimer() { end(); }
bool begin(ISR newISR, unsigned int newPeriod) {
if (newPeriod == 0 || newPeriod > MAX_PERIOD) return false;
@@ -76,6 +77,10 @@ class IntervalTimer {
return begin(newISR, (float)newPeriod);
}
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];
};


Loading…
Cancel
Save