Sfoglia il codice sorgente

Confirm no systick_isr() interruption

This saves a cycle - and checks both values to avoid _isr change of either value based on code/execution
teensy4-core
Defragster 6 anni fa
parent
commit
edbf0b4c0c
Nessun account collegato all'indirizzo email del committer
1 ha cambiato i file con 11 aggiunte e 0 eliminazioni
  1. +11
    -0
      teensy4/delay.c

+ 11
- 0
teensy4/delay.c Vedi File

@@ -62,6 +62,17 @@ void delay(uint32_t msec)
// TODO...
}

uint32_t micros(void)
{
uint32_t ccdelta, usec, smc, scc;
do {
smc = systick_millis_count;
scc = systick_cycle_count;
} while ( smc != systick_millis_count || scc != systick_cycle_count ); // repeat if systick_isr
ccdelta = ARM_DWT_CYCCNT - scc;
usec = 1000*smc + (ccdelta/(F_CPU_ACTUAL/1000000));
return usec;
}
uint32_t micros(void)
{
uint32_t ccdelta, usec, smc;

Loading…
Annulla
Salva