24#ifndef __YASIMAVR_IO_TIMER_H__
25#define __YASIMAVR_IO_TIMER_H__
27#include "../core/sim_cycle_timer.h"
28#include "../core/sim_signal.h"
29#include "../core/sim_device.h"
74 void set_prescaler(
unsigned long ps_max,
unsigned long ps_factor);
76 unsigned long prescaler_factor()
const;
82 void set_paused(
bool paused);
105 unsigned long m_ps_max;
106 unsigned long m_ps_factor;
119 std::vector<PrescaledTimer*> m_chained_timers;
224 void set_tick_source(TickSource src);
225 TickSource tick_source()
const;
229 void set_top(
long top);
232 void set_slope_mode(SlopeMode mode);
233 SlopeMode slope_mode()
const;
235 void set_counter(
long value);
236 long counter()
const;
238 void set_comp_value(
size_t index,
long value);
239 long comp_value(
size_t index)
const;
241 void set_comp_enabled(
size_t index,
bool enable);
242 bool comp_enabled(
size_t index)
const;
244 bool countdown()
const;
245 void set_countdown(
bool down);
260 bool enabled =
false;
261 bool is_next_event =
false;
277 std::vector<CompareUnit> m_cmp;
281 uint8_t m_next_event_type;
289 long delay_to_event();
293 long ticks_to_event(
long event);
294 void process_ticks(
long ticks,
bool event_reached);
339 return m_cmp[index].value;
345 return m_cmp[index].enabled;
Definition sim_signal.h:227
Definition sim_cycle_timer.h:134
Definition sim_cycle_timer.h:41
virtual cycle_count_t next(cycle_count_t when)=0
Callback from the cycle loop.
Definition sim_signal.h:137
Definition sim_logger.h:91
Generic model of a Timer with prescaling.
Definition sim_timer.h:63
void update()
Definition sim_timer.cpp:152
unsigned long prescaler_factor() const
Getter for ps_factor.
Definition sim_timer.h:134
PrescaledTimer(const PrescaledTimer &)=delete
PrescaledTimer & operator=(const PrescaledTimer &)=delete
Signal & signal()
Getter for the signal raised with counter updates.
Definition sim_timer.h:146
cycle_count_t timer_delay() const
Getter for timer_delay.
Definition sim_timer.h:140
Definition sim_signal.h:55
Signalling framework class.
Definition sim_signal.h:97
Generic model of a Counter.
Definition sim_timer.h:164
long counter() const
Getter for the current counter value.
Definition sim_timer.h:331
TickSource
Tick source mode.
Definition sim_timer.h:169
@ Tick_External
External signal hook used as tick source.
Definition sim_timer.h:175
@ Tick_Timer
Internal prescaled timer used as tick source.
Definition sim_timer.h:173
Signal & signal()
Getter for the counting signal.
Definition sim_timer.h:355
bool countdown() const
Getter for the current counting direction.
Definition sim_timer.h:349
SignalHook & ext_tick_hook()
Getter for the external signal hook used for tick source.
Definition sim_timer.h:361
PrescaledTimer & prescaler()
Getter for the internal prescaler.
Definition sim_timer.h:367
SignalId
Signal Ids raised by this object.
Definition sim_timer.h:201
@ Signal_CompMatch
Definition sim_timer.h:211
@ Signal_Event
Definition sim_timer.h:206
void update()
Force update of the internal prescaler.
Definition sim_timer.h:306
long comp_value(size_t index) const
Getter for a compare value.
Definition sim_timer.h:337
long wrap() const
Getter for the wrapping value.
Definition sim_timer.h:299
long top() const
Getter for the TOP value.
Definition sim_timer.h:319
TickSource tick_source() const
Getter for the tick source mode.
Definition sim_timer.h:313
bool comp_enabled(size_t index) const
Getter for a compare value enable.
Definition sim_timer.h:343
SlopeMode slope_mode() const
Getter for the slope mode.
Definition sim_timer.h:325
SlopeMode
Counter direction mode.
Definition sim_timer.h:179
@ Slope_Down
Down-counting.
Definition sim_timer.h:183
@ Slope_Double
Dual-slope counting.
Definition sim_timer.h:185
EventType
Event type flags used when signaling.
Definition sim_timer.h:189
#define YASIMAVR_BEGIN_NAMESPACE
Definition sim_globals.h:58
#define AVR_CORE_PUBLIC_API
Definition sim_globals.h:46
#define YASIMAVR_END_NAMESPACE
Definition sim_globals.h:59
YASIMAVR_BEGIN_NAMESPACE typedef long long cycle_count_t
Definition sim_types.h:40
Definition sim_signal.h:39