Browse Source

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 years ago
parent
commit
edbf0b4c0c
No account linked to committer's email address
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      teensy4/delay.c

+ 11
- 0
teensy4/delay.c View File

// TODO... // 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 micros(void)
{ {
uint32_t ccdelta, usec, smc; uint32_t ccdelta, usec, smc;

Loading…
Cancel
Save