瀏覽代碼

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 年之前
父節點
當前提交
edbf0b4c0c
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 11 行新增0 行删除
  1. +11
    -0
      teensy4/delay.c

+ 11
- 0
teensy4/delay.c 查看文件

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