瀏覽代碼

Add IntervalTimer.priority()

teensy4-core
PaulStoffregen 10 年之前
父節點
當前提交
7765518d85
共有 2 個文件被更改,包括 7 次插入1 次删除
  1. +1
    -0
      teensy3/IntervalTimer.cpp
  2. +6
    -1
      teensy3/IntervalTimer.h

+ 1
- 0
teensy3/IntervalTimer.cpp 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存