Pārlūkot izejas kodu

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 pirms 6 gadiem
vecāks
revīzija
edbf0b4c0c
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
1 mainītis faili ar 11 papildinājumiem un 0 dzēšanām
  1. +11
    -0
      teensy4/delay.c

+ 11
- 0
teensy4/delay.c Parādīt failu

@@ -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;

Notiek ielāde…
Atcelt
Saglabāt