zephyr/drivers/timer
Andy Ross 0baf72e1c7 drivers/timer/nrf_rtc_timer: Fix round-up for rapid tick rates
When the tick rate was less than MIN_DELAY, bumping a "too soon"
expiration by just one tick may not be enough and we could
theoretically miss the counter.

Instead, eliminate the MIN_DELAY computation and write to the spec:
NRF guarantees that the RTC will generate an interrupt for a
comparator value two cycles in the future.  And further, we can test
at the set point to see if we "just missed" the interrupt (i.e. zero
cycles delay) and flag a synchronous interrupt.  So we only need to
miss a requested interrupt now for the special case of exactly one
cycle in the future, and then we're only late by one cycle.  That's
optimal.

Also fixes an off-by-one in the next cycle computation.  By API
convention, an ticks argument of one or less means "at the next tick"
and not "right now".  So we need to add one to the target cycle to
avoid incorrectly triggering a synchronous interrupt.  This was a
non-issue when a tick is longer than a hardware cycle but is needed
now.

Also handles the edge case with zero latency interrupts (which are
unmaskable) which might mess up timing.  This was always a problem,
but we're more sensitive now and it's comparatively more likely to
occur.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-07-02 22:52:29 -04:00
..
altera_avalon_timer_hal.c include: move system timer headers to include/drivers/timer/ 2019-06-25 15:27:00 -04:00
apic_timer.c drivers: apic_timer: fix include of system_timer.h 2019-06-27 10:51:32 -07:00
arcv2_timer0.c include: move system timer headers to include/drivers/timer/ 2019-06-25 15:27:00 -04:00
CMakeLists.txt drivers/timer/apic_timer.c: new local APIC timer for TICKLESS_KERNEL 2019-06-27 07:20:54 -04:00
cortex_m_systick.c include: move system timer headers to include/drivers/timer/ 2019-06-25 15:27:00 -04:00
hpet.c include: move system timer headers to include/drivers/timer/ 2019-06-25 15:27:00 -04:00
Kconfig kernel/timeout: Remove "clock_always_on", replace with "SLOPPY_IDLE" 2019-06-28 14:24:56 -07:00
legacy_api.h license: cleanup: add SPDX Apache-2.0 license identifier 2019-04-07 08:45:22 -04:00
litex_timer.c include: move system timer headers to include/drivers/timer/ 2019-06-25 15:27:00 -04:00
loapic_timer.c arch/x86: eliminate include/arch/x86/irq_controller.h 2019-07-02 19:30:00 -04:00
native_posix_timer.c include: move system timer headers to include/drivers/timer/ 2019-06-25 15:27:00 -04:00
nrf_rtc_timer.c drivers/timer/nrf_rtc_timer: Fix round-up for rapid tick rates 2019-07-02 22:52:29 -04:00
riscv_machine_timer.c include: move system timer headers to include/drivers/timer/ 2019-06-25 15:27:00 -04:00
rv32m1_lptmr_timer.c cleanup: include/: move misc/util.h to sys/util.h 2019-06-27 22:55:49 -04:00
sam0_rtc_timer.c cleanup: include/: move clock_control.h to drivers/clock_control.h 2019-06-27 22:55:49 -04:00
sys_clock_init.c include: move system timer headers to include/drivers/timer/ 2019-06-25 15:27:00 -04:00
xtensa_sys_timer.c include: move system timer headers to include/drivers/timer/ 2019-06-25 15:27:00 -04:00