Chrispy
High-performance multichannel ADC sampling and audio recording.
Loading...
Searching...
No Matches
TimerConfig Struct Reference

Configuration for a hardware timer. More...

#include <Timer.h>

Public Member Functions

 TimerConfig (clk_t src_clock, clk_t desired_clock, Skew preference)
 Constructor for a timer config which initializes required variables for a configuration but does not perform any computation.
 
TimerRc compute (size_t nprescalers, pre_t *prescalers, clk_t max_compare, double max_error)
 Compute the first timer configuration satisfying the error constraint, or find the best possible timer configuration if given a max_error of 0.
 
void pprint ()
 Pretty print the timer configuration.
 

Data Fields

pre_t prescaler
 Prescaler value to use with timer.
 
clk_t compare
 Comparison value to trigger timer at.
 
clk_t src
 Input clock frequency (Hz).
 
clk_t desired
 Target clock frequency (Hz) given input.
 
Skew skew
 Preference for whether a lower/high clock rate.
 
clk_t actual
 Actual clock rate achieved.
 
double error
 Percentage error from desired clock rate.
 

Detailed Description

Configuration for a hardware timer.

Constructor & Destructor Documentation

◆ TimerConfig()

TimerConfig::TimerConfig ( clk_t  src_clock,
clk_t  desired_clock,
Skew  preference 
)
inline

Constructor for a timer config which initializes required variables for a configuration but does not perform any computation.

Parameters
src_clockInput clock frequency (Hz).
desired_clockDesired clock frequency (Hz).
preferencePreference for whether to err low or high when calculating parameters to get desired clock frequency.

Member Function Documentation

◆ compute()

enum TimerRc TimerConfig::compute ( size_t  nprescalers,
pre_t prescalers,
clk_t  max_compare,
double  max_error 
)

Compute the first timer configuration satisfying the error constraint, or find the best possible timer configuration if given a max_error of 0.

Parameters
nprescalersSize of prescaler array values,
prescalersArray of potential prescaler values.
max_compareUpper bound for timer compare value. Typically UINT8_MAX for 8-bit timers and UINT16_MAX for 16-bit timers.
max_errorUpper error bound for computation. Causes the first configuration satisfying the bound to be used. When set to 0.0, this will examine every potential option and end with the best one.
Returns
(TimerRc): Return code with Okay or the error which occured.

◆ pprint()

void TimerConfig::pprint ( )

Pretty print the timer configuration.

For debugging purposes only.

Field Documentation

◆ actual

clk_t TimerConfig::actual

Actual clock rate achieved.

◆ compare

clk_t TimerConfig::compare

Comparison value to trigger timer at.

◆ desired

clk_t TimerConfig::desired

Target clock frequency (Hz) given input.

◆ error

double TimerConfig::error

Percentage error from desired clock rate.

◆ prescaler

pre_t TimerConfig::prescaler

Prescaler value to use with timer.

◆ skew

Skew TimerConfig::skew

Preference for whether a lower/high clock rate.

◆ src

clk_t TimerConfig::src

Input clock frequency (Hz).


The documentation for this struct was generated from the following files: