Skip to content

Commit

Permalink
Tidy up util timer code - utilTimerInsertTask shouldn't be called fro…
Browse files Browse the repository at this point in the history
…m the IRQ so flag isn't needed (and wsn't volatile so probably wouldn't work anyway)
  • Loading branch information
gfwilliams committed Nov 18, 2024
1 parent 0300f65 commit 9d2f496
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/jstimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ volatile unsigned char utilTimerTasksTail = 0;

/// Is the utility timer actually running?
volatile bool utilTimerOn = false;

unsigned int utilTimerBit;
bool utilTimerInIRQ = false;
unsigned int utilTimerData;
uint16_t utilTimerReload0H, utilTimerReload0L, utilTimerReload1H, utilTimerReload1L;
/// When we rescheduled the timer, how far in the future were we meant to get called (in system time)?
int utilTimerPeriod;
/// The system time at which the util timer's period was last set
Expand Down Expand Up @@ -92,7 +87,6 @@ void jstUtilTimerInterruptHandler() {
/* Note: we're using 32 bit times here, even though the real time counter is 64 bit. We
* just make sure nothing is scheduled that far in the future */
if (utilTimerOn) {
utilTimerInIRQ = true;
// TODO: Keep UtilTimer running and then use the value from it
// to estimate how long utilTimerPeriod really was
// Subtract utilTimerPeriod from all timers' time
Expand Down Expand Up @@ -231,7 +225,6 @@ void jstUtilTimerInterruptHandler() {
utilTimerOn = false;
jshUtilTimerDisable();
}
utilTimerInIRQ = false;
} else {
// Nothing left to do - disable the timer
jshUtilTimerDisable();
Expand Down Expand Up @@ -275,7 +268,7 @@ void jstRestartUtilTimer() {
bool utilTimerInsertTask(UtilTimerTask *task, uint32_t *timerOffset) {
// check if queue is full or not
if (utilTimerIsFull()) return false;
if (!utilTimerInIRQ) jshInterruptOff();
jshInterruptOff();

// See above - keep times in sync
if (timerOffset)
Expand Down Expand Up @@ -319,7 +312,7 @@ bool utilTimerInsertTask(UtilTimerTask *task, uint32_t *timerOffset) {
utilTimerOn = true;
jstRestartUtilTimer();
}
if (!utilTimerInIRQ) jshInterruptOn();
jshInterruptOn();
return true;
}

Expand Down

0 comments on commit 9d2f496

Please sign in to comment.