[][src]Trait kernel::hil::time::Counter

pub trait Counter<'a>: Time {
    fn set_overflow_client(&'a self, client: &'a dyn OverflowClient);
fn start(&self) -> ReturnCode;
fn stop(&self) -> ReturnCode;
fn reset(&self) -> ReturnCode;
fn is_running(&self) -> bool; }

Represents a free-running hardware counter that can be started and stopped.

Required methods

fn set_overflow_client(&'a self, client: &'a dyn OverflowClient)

Specify the callback for when the counter overflows its maximum value (defined by Ticks). If there was a previously registered callback this call replaces it.

fn start(&self) -> ReturnCode

Starts the free-running hardware counter. Valid ReturnCode values are:

  • ReturnCode::SUCCESS: the counter is now running
  • ReturnCode::EOFF: underlying clocks or other hardware resources are not on, such that the counter cannot start.
  • ReturnCode::FAIL: unidentified failure, counter is not running. After a successful call to start, is_running MUST return true.

fn stop(&self) -> ReturnCode

Stops the free-running hardware counter. Valid ReturnCode values are:

  • ReturnCode::SUCCESS: the counter is now stopped. No further overflow callbacks will be invoked.
  • ReturnCode::EBUSY: the counter is in use in a way that means it cannot be stopped and is busy.
  • ReturnCode::FAIL: unidentified failure, counter is running. After a successful call to stop, is_running MUST return false.

fn reset(&self) -> ReturnCode

Resets the counter to 0. This may introduce jitter on the counter. Resetting the counter has no effect on any pending overflow callbacks. If a client needs to reset and clear pending callbacks it should call stop before reset. Valid ReturnCode values are:

  • ReturnCode::SUCCESS: the counter was reset to 0.
  • ReturnCode::FAIL: the counter was not reset to 0.

fn is_running(&self) -> bool

Returns whether the counter is currently running.

Loading content...

Implementors

Loading content...