circuitpython/ports/nrf/modules/machine
Martin Fischer 15574cd665 nrf: Add support for time.ticks_xxx functions using RTC1.
This commit adds time.ticks_ms/us support using RTC1 as the timebase.  It
also adds the time.ticks_add/diff helper functions.  This feature can be
enabled using MICROPY_PY_TIME_TICKS.  If disabled the system uses the
legacy sleep methods and does not have any ticks functions.

In addition support for MICROPY_EVENT_POLL_HOOK was added to the
time.sleep_ms(x) function, making this function more power efficient and
allows support for select.poll/asyncio.  To support this, the RTC's CCR0
was used to schedule a ~1msec event to wakeup the CPU.

Some important notes about the RTC timebase:

- Since the granularity of RTC1's ticks are approx 30usec, time.ticks_us is
not perfect, does not have 1us resolution, but is otherwise quite usable.
For tighter measurments the ticker's 1MHz counter should be used.

- time.ticks_ms(x) should *not* be called in an IRQ with higher prio than
the RTC overflow irq (3).  If so it introduces a race condition and
possibly leads to wrong tick calculations.

See #6171 and #6202.
2020-07-08 23:47:02 +10:00
..
adc.c nrf: Update to work with nrfx v2.0.0, to match TinyUSB. 2020-05-15 15:06:02 +10:00
adc.h nrf/adc: Allow for external use of new and value read function. 2018-07-18 17:12:26 +10:00
i2c.c nrf: Update to work with nrfx v2.0.0, to match TinyUSB. 2020-05-15 15:06:02 +10:00
i2c.h nrf: Replace custom-HAL with nrfx-HAL 2018-07-18 17:12:26 +10:00
modmachine.c nrf: Use MICROPY_HW_ENABLE_RNG instead of MICROPY_PY_RANDOM_HW_RNG. 2020-02-18 12:43:16 +11:00
modmachine.h nrf/modmachine: Rename machine.sleep to machine.lightsleep. 2019-01-30 14:15:38 +11:00
pin.c nrf: Update to work with nrfx v2.0.0, to match TinyUSB. 2020-05-15 15:06:02 +10:00
pin.h nrf: Remove port member from Pin object 2018-07-18 17:12:26 +10:00
pwm.c nrf: Update to work with nrfx v2.0.0, to match TinyUSB. 2020-05-15 15:06:02 +10:00
pwm.h nrf: Replace custom-HAL with nrfx-HAL 2018-07-18 17:12:26 +10:00
rtcounter.c nrf: Add support for time.ticks_xxx functions using RTC1. 2020-07-08 23:47:02 +10:00
rtcounter.h nrf: Replace custom-HAL with nrfx-HAL 2018-07-18 17:12:26 +10:00
spi.c all: Use MP_ERROR_TEXT for all error messages. 2020-04-05 15:02:06 +10:00
spi.h nrf/spi: Allow for external use of new and transfer function. 2018-07-18 17:12:26 +10:00
temp.c nrf: Update to work with nrfx v2.0.0, to match TinyUSB. 2020-05-15 15:06:02 +10:00
temp.h nrf: Add new port to Nordic nRF5x MCUs. 2018-07-18 17:12:25 +10:00
timer.c all: Use MP_ERROR_TEXT for all error messages. 2020-04-05 15:02:06 +10:00
timer.h nrf: Replace custom-HAL with nrfx-HAL 2018-07-18 17:12:26 +10:00
uart.c nrf: Update to work with nrfx v2.0.0, to match TinyUSB. 2020-05-15 15:06:02 +10:00
uart.h nrf: Move pyb module to boards module 2018-07-18 17:12:26 +10:00