nrf-rs / nrf51-hal

A Rust embedded-hal impl crate for the Nordic nrf51 series of microcontrollers
BSD Zero Clause License
19 stars 13 forks source link

Drivers for the TIMER and RTC peripherals #19

Closed mattheww closed 5 years ago

mattheww commented 5 years ago

Includes standalone modules for the TIMER and RTC peripherals exposing most but not all of their functionality (the main missing feature is the TIMERs' counter mode).

Provides new implementations of the embedded-hal CountDown and Delay traits based on these modules.

These support using all three TIMERs, or either RTC, at any frequency supported by the hardware.

Includes backwards-compatible timer::Timer and delay::Delay types.

The approach is loosely based on PR #12 but the implementation is new, with the 'driver' code separated from the countdown/delay support, and no macros.

The hardware restriction to no more than 16-bit mode for TIMER1 and TIMER2 is enforced statically.

There are usage examples in the rustdoc and in test_timer.rs and test_countdown.rs on the mattheww/microbit timer-test-examples branch (which is based on the droogmic/microbit timer-rtc branch).