Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Time-Keeping #257

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

Implement Time-Keeping #257

wants to merge 13 commits into from

Conversation

Cryptjar
Copy link

@Cryptjar Cryptjar commented Apr 18, 2022

This PR adds:

  • TimingCircuit trait to abstract over various hardware timers that are eligible for time-keeping.
  • attach_timing_circuit_interrupt macro, which allows attaching timer interrupts in a somewhat generic manor.
  • Timepiece trait and impl_timepiece macro, that users will use to "prepare" a hardware timer (i.e. a TimingCircuit) for the time-keeping facilities (i.e. the Choronometer). "Preparing" means here that the user defines the configuration (e.g. hardware, resolution) and the macro will attach a corresponding timer interrupt handler.
  • Choronometer, a struct that wraps a Timepiece (which in turn wraps a TimingCircuit), initializes the corresponding hardware timer, and implements the embedded_time::Clock trait with microseconds precision.
  • StaticChronometer a statically accessible embedded_time::Clock implementation that yields milliseconds precision.

For a quick peek, see the uno-time example

TODOs:

  • implement TimingCircuit on all eligible hardware Timers
  • add an Arduino Mega example
  • decide on what names to use
  • polish docs

Fixes #256

@djdisodo djdisodo mentioned this pull request Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time-Keeping Library
1 participant