Trait kernel::hil::time::Counter

source ·
pub trait Counter<'a>: Time {
    // Required methods
    fn set_overflow_client(&self, client: &'a dyn OverflowClient);
    fn start(&self) -> Result<(), ErrorCode>;
    fn stop(&self) -> Result<(), ErrorCode>;
    fn reset(&self) -> Result<(), ErrorCode>;
    fn is_running(&self) -> bool;
}
Expand description

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

Required Methods§

source

fn set_overflow_client(&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.

source

fn start(&self) -> Result<(), ErrorCode>

Starts the free-running hardware counter. Valid Result<(), ErrorCode> values are:

  • Ok(()): the counter is now running
  • Err(ErrorCode::OFF): underlying clocks or other hardware resources are not on, such that the counter cannot start.
  • Err(ErrorCode::FAIL): unidentified failure, counter is not running. After a successful call to start, is_running MUST return true.
source

fn stop(&self) -> Result<(), ErrorCode>

Stops the free-running hardware counter. Valid Result<(), ErrorCode> values are:

  • Ok(()): the counter is now stopped. No further overflow callbacks will be invoked.
  • Err(ErrorCode::BUSY): the counter is in use in a way that means it cannot be stopped and is busy.
  • Err(ErrorCode::FAIL): unidentified failure, counter is running. After a successful call to stop, is_running MUST return false.
source

fn reset(&self) -> Result<(), ErrorCode>

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 Result<(), ErrorCode> values are:

  • Ok(()): the counter was reset to 0.
  • Err(ErrorCode::FAIL): the counter was not reset to 0.
source

fn is_running(&self) -> bool

Returns whether the counter is currently running.

Implementors§