Chrispy
High-performance multichannel ADC sampling and audio recording.
Loading...
Searching...
No Matches
Timer.h File Reference
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  TimerConfig
 Configuration for a hardware timer. More...
 

Typedefs

typedef uint32_t clk_t
 
typedef uint16_t pre_t
 
typedef int32_t ssize_t
 

Enumerations

enum struct  TimerRc : uint8_t {
  Okay , ImpossibleClock , ZeroDiv , ErrorRange ,
  TooLow , TooHigh
}
 Possible return codes when trying to compute the best timer configuration. More...
 
enum struct  Skew : uint8_t { Low , High , None }
 Preference for how the computed timer configuration should skew if it cannot get the precise value. More...
 

Functions

const char * error_str (TimerRc rc)
 Retrieve a string description of a timer return code.
 
TimerRc activate_t1 (TimerConfig &cfg)
 Activate the 16-bit timer 1 on ATMEGA2560 with a given configuration.
 
void deactivate_t1 ()
 Deactivate 16-bit timer 1 on ATMEGA2560.
 

Typedef Documentation

◆ clk_t

typedef uint32_t clk_t

◆ pre_t

typedef uint16_t pre_t

◆ ssize_t

typedef int32_t ssize_t

Enumeration Type Documentation

◆ Skew

enum struct Skew : uint8_t
strong

Preference for how the computed timer configuration should skew if it cannot get the precise value.

Enumerator
Low 
High 
None 

◆ TimerRc

enum struct TimerRc : uint8_t
strong

Possible return codes when trying to compute the best timer configuration.

Enumerator
Okay 
ImpossibleClock 
ZeroDiv 
ErrorRange 
TooLow 
TooHigh 

Function Documentation

◆ activate_t1()

TimerRc activate_t1 ( TimerConfig cfg)

Activate the 16-bit timer 1 on ATMEGA2560 with a given configuration.

Parameters
cfgComputed timer configuration with desired clock frequency.
Returns
(TimerRc): Return code from operation.

◆ deactivate_t1()

void deactivate_t1 ( )

Deactivate 16-bit timer 1 on ATMEGA2560.

◆ error_str()

const char * error_str ( TimerRc  rc)

Retrieve a string description of a timer return code.

Parameters
rcReturn code to get its string for.
Returns
(const char*): Static string for return code.