TimerCounter Class Reference
|
yasimavr
|
Generic model of a Counter. More...
#include <sim_timer.h>
Public Types | |
| enum | TickSource { Tick_Stopped = 0 , Tick_Timer , Tick_External } |
| Tick source mode. More... | |
| enum | SlopeMode { Slope_Up = 0 , Slope_Down , Slope_Double } |
| Counter direction mode. More... | |
| enum | EventType { Event_Max = 0x01 , Event_Top = 0x02 , Event_Bottom = 0x04 , Event_Compare = 0x08 } |
| Event type flags used when signaling. More... | |
| enum | SignalId { Signal_Event , Signal_CompMatch } |
| Signal Ids raised by this object. More... | |
Public Member Functions | |
| TimerCounter (long wrap, size_t comp_count) | |
| void | init (CycleManager &cycle_manager, Logger &logger) |
| void | reset () |
| void | reschedule () |
| void | update () |
| Force update of the internal prescaler. | |
| long | wrap () const |
| Getter for the wrapping value. | |
| void | set_tick_source (TickSource src) |
| TickSource | tick_source () const |
| Getter for the tick source mode. | |
| void | tick () |
| void | set_top (long top) |
| long | top () const |
| Getter for the TOP value. | |
| void | set_slope_mode (SlopeMode mode) |
| SlopeMode | slope_mode () const |
| Getter for the slope mode. | |
| void | set_counter (long value) |
| long | counter () const |
| Getter for the current counter value. | |
| void | set_comp_value (size_t index, long value) |
| long | comp_value (size_t index) const |
| Getter for a compare value. | |
| void | set_comp_enabled (size_t index, bool enable) |
| bool | comp_enabled (size_t index) const |
| Getter for a compare value enable. | |
| bool | countdown () const |
| Getter for the current counting direction. | |
| void | set_countdown (bool down) |
| Signal & | signal () |
| Getter for the counting signal. | |
| SignalHook & | ext_tick_hook () |
| Getter for the external signal hook used for tick source. | |
| PrescaledTimer & | prescaler () |
| Getter for the internal prescaler. | |
Detailed Description
Generic model of a Counter.
Implementation of a clock cycle counter, used by peripherals such as TCx, WDT, RTC. Features :
- 2 'tick' sources: internal (using a PrescaledTimer object) or external via a signal hook
- Up/down counting and dual slope
- Arbitrary number of compare channels
- Signalling on top, bottom, max and compare value
Member Enumeration Documentation
◆ EventType
Event type flags used when signaling.
- See also
- Signal_Event
◆ SignalId
◆ SlopeMode
◆ TickSource
Constructor & Destructor Documentation
◆ TimerCounter()
| TimerCounter::TimerCounter | ( | long | wrap, |
| size_t | comp_count | ||
| ) |
Constructor
- Parameters
-
wrap Wrapping value for the counter. For example, a 16-bits counter wrap is 0x10000. comp_count number of compare channels
Member Function Documentation
◆ comp_enabled()
|
inline |
Getter for a compare value enable.
◆ comp_value()
|
inline |
Getter for a compare value.
◆ countdown()
|
inline |
Getter for the current counting direction.
◆ counter()
|
inline |
Getter for the current counter value.
◆ ext_tick_hook()
|
inline |
Getter for the external signal hook used for tick source.
◆ init()
| void TimerCounter::init | ( | CycleManager & | cycle_manager, |
| Logger & | logger | ||
| ) |
Initialise the counter
◆ prescaler()
|
inline |
Getter for the internal prescaler.
◆ reschedule()
| void TimerCounter::reschedule | ( | ) |
Reschedule the counter, this should be called after changing the configuration
◆ reset()
| void TimerCounter::reset | ( | ) |
Reset the counter
◆ set_comp_enabled()
| void TimerCounter::set_comp_enabled | ( | size_t | index, |
| bool | enable | ||
| ) |
Enable or disable a compare channel
◆ set_comp_value()
| void TimerCounter::set_comp_value | ( | size_t | index, |
| long | value | ||
| ) |
Change a compare channel value
◆ set_countdown()
| void TimerCounter::set_countdown | ( | bool | down | ) |
Set the counting up or down. Changes the slope mode accordingly except if the slope mode is Dual.
◆ set_counter()
| void TimerCounter::set_counter | ( | long | value | ) |
Change the counter current value
◆ set_slope_mode()
| void TimerCounter::set_slope_mode | ( | SlopeMode | mode | ) |
Change the slope mode
◆ set_tick_source()
| void TimerCounter::set_tick_source | ( | TickSource | src | ) |
Change the tick source
◆ set_top()
| void TimerCounter::set_top | ( | long | top | ) |
Change the TOP value
◆ signal()
|
inline |
Getter for the counting signal.
◆ slope_mode()
|
inline |
Getter for the slope mode.
◆ tick()
| void TimerCounter::tick | ( | ) |
Progress the counter by one unit. Has no effect if if the source is set to Stopped.
◆ tick_source()
|
inline |
Getter for the tick source mode.
◆ top()
|
inline |
Getter for the TOP value.
◆ update()
|
inline |
Force update of the internal prescaler.
◆ wrap()
|
inline |
Getter for the wrapping value.
The documentation for this class was generated from the following files:
Generated by