浏览代码

Add delayNanoseconds()

This makes sense now, and would be useful for shorter wait-times. Could be used for PulseIn etc.  where we need defined very short delays.
main
Frank 5 年前
父节点
当前提交
acc3eeb91b
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. +7
    -0
      teensy4/core_pins.h

+ 7
- 0
teensy4/core_pins.h 查看文件

@@ -692,6 +692,13 @@ static inline void delayMicroseconds(uint32_t usec)
while (ARM_DWT_CYCCNT - begin < cycles) ; // wait
}

static inline void delayNanoseconds(uint32_t) __attribute__((always_inline, unused));
static inline void delayNanoseconds(uint32_t nsec)
{
uint32_t begin = ARM_DWT_CYCCNT;
uint32_t cycles = ((uint64_t)F_CPU_ACTUAL * nsec) / 1000000000UL;
while (ARM_DWT_CYCCNT - begin < cycles) ; // wait
}


unsigned long rtc_get(void);

正在加载...
取消
保存