82 virtual unsigned int CpuCycle();
85 void RegisterACompForICapture(
HWAcomp *acomp);
88 void SetACIC(
bool acic) {
if(icapSource != NULL) icapSource->SetACIC(acic); }
152 wgmfunc_t wgmfunc[WGM_tablesize];
153 unsigned long compare[OCRIDX_maxUnits];
154 unsigned long compare_dbl[OCRIDX_maxUnits];
155 bool compareEnable[OCRIDX_maxUnits];
159 bool compare_output_state[OCRIDX_maxUnits];
162 void CountTimer(
void);
164 virtual void InputCapture(
void);
170 void HandleEvent(
CEtype event);
172 void SetClockMode(
int _cs);
174 void SetCounter(
unsigned long val);
176 void SetCompareOutputMode(
int idx,
COMtype mode);
178 void SetCompareOutput(
int idx);
180 void SetPWMCompareOutput(
int idx,
bool topOrDown);
183 bool WGMisPWM(
void) {
return wgm != WGM_NORMAL && wgm != WGM_CTC_OCRA && wgm != WGM_CTC_ICR; }
185 bool WGMuseICR(
void) {
return wgm == WGM_FASTPWM_ICR || wgm == WGM_CTC_ICR || wgm == WGM_PCPWM_ICR || wgm == WGM_PFCPWM_ICR; }
189 void WGMfunc_normal(
CEtype event);
191 void WGMfunc_ctc(
CEtype event);
193 void WGMfunc_fastpwm(
CEtype event);
195 void WGMfunc_pcpwm(
CEtype event);
197 void WGMfunc_pfcpwm(
CEtype event);
209 void SetCompareRegister(
int idx,
unsigned char val);
211 unsigned char GetCompareRegister(
int idx);
214 void Set_TCNT(
unsigned char val) { SetCounter(val); }
219 void Set_OCRA(
unsigned char val) { SetCompareRegister(0, val); }
221 unsigned char Get_OCRA() {
return GetCompareRegister(0); }
224 void Set_OCRB(
unsigned char val) { SetCompareRegister(1, val); }
226 unsigned char Get_OCRB() {
return GetCompareRegister(1); }
253 void SetCompareRegister(
int idx,
bool high,
unsigned char val);
255 unsigned char GetCompareRegister(
int idx,
bool high);
257 void SetComplexRegister(
bool is_icr,
bool high,
unsigned char val);
259 unsigned char GetComplexRegister(
bool is_icr,
bool high);
265 void Set_TCNTH(
unsigned char val) { SetComplexRegister(
false,
true, val); }
267 unsigned char Get_TCNTH() {
return GetComplexRegister(
false,
true); }
269 void Set_TCNTL(
unsigned char val) { SetComplexRegister(
false,
false, val); }
271 unsigned char Get_TCNTL() {
return GetComplexRegister(
false,
false); }
274 void Set_OCRAH(
unsigned char val) { SetCompareRegister(0,
true, val); }
276 unsigned char Get_OCRAH() {
return GetCompareRegister(0,
true); }
278 void Set_OCRAL(
unsigned char val) { SetCompareRegister(0,
false, val); }
280 unsigned char Get_OCRAL() {
return GetCompareRegister(0,
false); }
283 void Set_OCRBH(
unsigned char val) { SetCompareRegister(1,
true, val); }
285 unsigned char Get_OCRBH() {
return GetCompareRegister(1,
true); }
287 void Set_OCRBL(
unsigned char val) { SetCompareRegister(1,
false, val); }
289 unsigned char Get_OCRBL() {
return GetCompareRegister(1,
false); }
292 void Set_OCRCH(
unsigned char val) { SetCompareRegister(2,
true, val); }
294 unsigned char Get_OCRCH() {
return GetCompareRegister(2,
true); }
296 void Set_OCRCL(
unsigned char val) { SetCompareRegister(2,
false, val); }
298 unsigned char Get_OCRCL() {
return GetCompareRegister(2,
false); }
301 void Set_ICRH(
unsigned char val) { SetComplexRegister(
true,
true, val); }
303 unsigned char Get_ICRH() {
return GetComplexRegister(
true,
true); }
305 void Set_ICRL(
unsigned char val) { SetComplexRegister(
true,
false, val); }
307 unsigned char Get_ICRL() {
return GetComplexRegister(
true,
false); }
353 void Set_TCCR(
unsigned char val);
383 void Set_TCCR(
unsigned char val);
422 void Set_WGM(
int val);
429 void Set_TCCRA(
unsigned char val);
434 void Set_TCCRB(
unsigned char val);
476 void Set_WGM(
int val);
483 void Set_TCCRA(
unsigned char val);
488 void Set_TCCRB(
unsigned char val);
535 void Set_WGM(
int val);
542 void Set_TCCRA(
unsigned char val);
547 void Set_TCCRB(
unsigned char val);
600 void Set_TCCRA(
unsigned char val);
605 void Set_TCCRB(
unsigned char val);
610 void Set_TCCRC(
unsigned char val);
663 void Set_TCCRA(
unsigned char val);
668 void Set_TCCRB(
unsigned char val);
673 void Set_TCCRC(
unsigned char val);
715 void SetPWM(
bool isCompareEvent);
718 void SetDeadTime(
bool pwmValue);
730 void TimerEvent(
bool isCompareEvent) { SetPWM(isCompareEvent); }
736 void SetDeadTime(
int highTime,
int lowTime) { dtHigh = highTime; dtLow = lowTime; }
739 void SetOCRMode(
bool isPWM,
int comMode);
755 void Reset(
unsigned char v) { inValue = regValue = v; }
758 unsigned char operator=(
unsigned char v) { inValue = v;
return v; }
761 operator unsigned char() {
return regValue; }
769 bool ClockAndChanged(
void) {
if(inValue != regValue) { regValue = inValue;
return true; }
return false; }
772 void MaskOutSync(
unsigned char mask) { inValue &= ~mask; regValue = inValue; }
852 void Set_TCNT(
unsigned char val) { tcnt_in_val = val; tcnt_set_flag =
true; }
857 void Set_TCCR(
unsigned char val) { tccr_inout_val = val; }
862 void Set_OCRA(
unsigned char val) { ocra_inout_val = val; }
867 void Set_OCRB(
unsigned char val) { ocrb_inout_val = val; }
872 void Set_OCRC(
unsigned char val) { ocrc_inout_val = val; }
877 void Set_DTPS1(
unsigned char val) { dtps1_inout_val = val; }
882 void Set_DT1A(
unsigned char val) { dt1a_inout_val = val; }
887 void Set_DT1B(
unsigned char val) { dt1b_inout_val = val; }
892 unsigned char set_from_reg(
const IOSpecialReg *reg,
unsigned char nv);
894 unsigned char get_from_client(
const IOSpecialReg *reg,
unsigned char v);
897 void SetPrescalerClock(
bool pcke);
900 void TimerCounter(
void);
903 bool PrescalerMux(
void);
906 bool DeadTimePrescalerMux(
void);
909 void TransferInputValues(
void);
912 void TransferOutputValues(
void);
941 unsigned int CpuCycle();
TraceValue * counterTrace
TraceValue instance for counter itself.
COMtype
types of compare match output modes
TimerEventListener * eventListener
event listener for timer events
int cfg_com_b
internal (async) setting for compare output modul B
unsigned char operator=(unsigned char v)
assign new register value
unsigned char Get_OCRAH()
Register access to read output compare register A high byte.
bool WGMisPWM(void)
returns true, if WGM is in one of the PWM modes
unsigned char Get_TCCRA()
Register access to read control register A.
Basic AVR device, contains the core functionality.
unsigned long vlast_tcnt
timercounter BEFORE count operation
bool asyncClock_plllock
pll frequency is locked
void MaskOutSync(unsigned char mask)
Mask out a value inside sync area and do not force a change event.
int asyncClock_step
step counter for step delays. -1, if not in async mode
bool tocrb_internal_flag
OCFxB flag is set, have to be delayed by 1 CK.
int icapNCcounter
counter for input capture noise canceler
IOSpecialReg * gtccrRegister
instance of GTCCR register
unsigned long counter
THE timer counter.
unsigned char dtprescaler
dead time prescaler counter
IOReg< HWTimer16 > ocrc_h_reg
output compare C register, high byte
int wgm_raw
this is the wgm raw value from register
int dtHigh
dead time raise delay
unsigned char inValue
input register value
unsigned char Get_OCRB()
Register access to read output compare register B.
compare[0] value reached for one count cycle
int cfg_com_a
internal (async) setting for compare output modul A
void SetDeadTime(int highTime, int lowTime)
Configure dead time counter.
void Set_OCRA(unsigned char val)
Register access to set output compare register A.
IRQLine * timerOCRBInt
irq line for output compare B interrupt
int dtLow
dead time fall delay
void Set_OCRB(unsigned char val)
Register access to set output compare register B.
unsigned char Get_TCCRB()
Register access to read control register B.
void Set_TCCR(unsigned char val)
Register access to set control register.
void WGMFunc_noop(CEtype event)
WGM noop function.
void Set_ICRL(unsigned char val)
Register access to set input capture register low byte.
unsigned char Get_TCNTL()
Register access to read counter register low byte.
void Set_DTPS1(unsigned char val)
Register access to set dead time prescaler.
TraceValue * counterTrace
TraceValue instance for counter itself.
bool icapNCstate
state for input capture noise canceler
unsigned char tccrb_val
register value TCCRB
unsigned char Get_TCCRB()
Register access to read control register B.
unsigned char Get_OCRC()
Register access to read output compare register C.
IOReg< HWTimer8_1C > tccr_reg
control register
PinAtPort outPinInv
inverted output pin for OCR unit
HWTimerTinyX5_SyncReg tccr_inout_val
register value TCCR1
IOReg< HWTimer16 > ocra_h_reg
output compare A register, high byte
Timer unit with 8Bit counter and one output compare unit.
int cfg_mode
internal (async) timer mode setting
Extends BasicTimerUnit to provide common support to all types of 8Bit timer units.
unsigned char regValue
valid register value inside sync area
unsigned char Get_TCCR()
Register access to read control register.
unsigned long limit_top
TOP value for counting.
unsigned char tccra_val
register value TCCRA
unsigned char Get_OCRA()
Register access to read output compare register A.
IOReg< HWTimer16 > ocra_l_reg
output compare A register, low byte
IOReg< HWTimer8 > tcnt_reg
counter register
void Set_OCRBL(unsigned char val)
Register access to set output compare register B low byte.
bool WGMuseICR(void)
returns true, if WGM uses IC register for defining TOP counter value
HWTimerTinyX5_SyncReg ocrb_inout_val
register value OCRB
unsigned char Get_DT1B()
Register access to read dead time value for channel B.
IOReg< HWTimer16 > tcnt_h_reg
counter register, high byte
unsigned char ocra_internal_val
internal (async) register value for OCRA1
IOReg< HWTimer16 > ocrc_l_reg
output compare C register, low byte
unsigned char tccrb_val
register value TCCRB
unsigned char accessTempRegister
the high byte temporary register for read/write access to TCNT and ICR
Represents a timer interrupt line, Frontend for timer interrupts.
BOTTOM reached for one count cycle.
bool count_down
counter counts down, used for precise pwm modes
unsigned char tccra_val
register value TCCRA
unsigned long ocra_compare
active compare value for OCR A unit
unsigned long limit_bottom
BOTTOM value for up/down counting.
unsigned char tccrb_val
register value TCCRB
unsigned char tccr_val
register value TCCR
Interface class to connect hardware units to control registers.
unsigned char Get_TCCRC()
Register access to read control register C.
IOSpecialReg * dt1aRegister
instance of DT1A register
unsigned char dtps1_inout_val
register value DTPS1
PinAtPort outPin
normal output pin for OCR unit
void Set_ICRH(unsigned char val)
Register access to set input capture register high byte.
IOReg< HWTimer16_2C3 > tccra_reg
control register A
unsigned char Get_TCNTH()
Register access to read counter register high byte.
unsigned char Get_OCRCH()
Register access to read output compare register C high byte.
IOReg< HWTimer8_2C > tccrb_reg
control register B
int cfg_prescaler
internal (async) prescaler setting
bool asyncClock_pll
pll is switched on
IOSpecialReg * dt1bRegister
instance of DT1B register
void Set_OCRC(unsigned char val)
Register access to set output compare register C.
PWM output unit for timer 1 on ATtiny25/45/85.
unsigned long prescaler
THE prescaler counter.
IOReg< HWTimer16_2C3 > tccrb_reg
control register B
bool ocrPWM
flag, if OCR unit is in PWM mode
void Set_OCRCH(unsigned char val)
Register access to set output compare register C high byte.
bool captureInputState
saved state for input capture
bool asyncClock_lsm
mode switch for lsm mode (32MHz clock)
an counter overflow occured
IOReg< HWTimer8_2C > tccra_reg
control register A
IOReg< HWTimer16 > icr_h_reg
input capture register, high byte
TraceValue * dTPrescalerTrace
TraceValue instance for dead time prescaler.
TimerTinyX5_OCR ocra_unit
OCR control unit for OCR channel A.
PrescalerMultiplexer * premx
prescaler multiplexer
Timer unit with 16Bit counter and 2 output compare units, but 3 config registers. ...
unsigned char Get_OCRB()
Register access to read output compare register B.
IRQLine * timerOCRAInt
irq line for output compare A interrupt
Build a register for TraceValue's.
unsigned char Get_TCNT()
Register access to read counter register high byte.
void SetACIC(bool acic)
reflect ACIC flag to input capture source
unsigned char tccrb_val
register value TCCRB
compare[1] value reached for one count cycle
Helper class to simulate transfer of register values from bus area to timer async area...
IOReg< HWTimer16 > icr_l_reg
input capture register, low byte
timer unit for timer 1 on ATtiny25/45/85
unsigned char tcnt_in_val
input register value for TCNT
unsigned char tcnt_out_val
output register value for TCNT
IOReg< HWTimerTinyX5 > tccr_reg
control register
unsigned char Get_TCCRA()
Register access to read control register.
void Set_TCNTH(unsigned char val)
Register access to set counter register high byte.
Timer unit with 16Bit counter and 2 output compare units and 2 config registers.
int cs
select value for prescaler multiplexer
HWTimerTinyX5_SyncReg dt1a_inout_val
register value DT1A
unsigned char Get_TCCR()
Register access to read control register.
void Set_TCNT(unsigned char val)
Register access to set counter register high byte.
unsigned char GetBusValue(void)
read register value on input area
bool icapRisingEdge
Input capture on rising edge.
void Set_TCNT(unsigned char val)
Register access to set counter register.
void TimerEvent(bool isCompareEvent)
OCR event.
TimerTinyX5_OCR ocrb_unit
OCR control unit for OCR channel B.
unsigned char Get_ICRL()
Register access to read input capture register low byte.
unsigned char Get_DTPS1()
Register access to read dead time prescaler.
unsigned char Get_ICRH()
Register access to read input capture register high byte.
unsigned char Get_OCRCL()
Register access to read output compare register C low byte.
IOReg< HWTimer16_3C > tccra_reg
control register A
bool icapNoiseCanceler
Noise canceler for input capturing enabled.
IOReg< HWTimer16 > tcnt_l_reg
counter register, low byte
unsigned char Get_OCRBL()
Register access to read output compare register B low byte.
unsigned char Get_TCCRA()
Register access to read control register A.
unsigned char tccr_val
register value TCCR
void Set_DT1B(unsigned char val)
Register access to set dead time value for channel B.
long long SystemClockOffset
unsigned char Get_TCCR()
Register access to read control register.
bool tocra_internal_flag
OCFxA flag is set, have to be delayed by 1 CK.
TraceValue * prescalerTrace
TraceValue instance for prescaler.
bool ClockAndChanged(void)
check after one clock, if register value has changed
HWTimerTinyX5_SyncReg dt1b_inout_val
register value DT1B
unsigned char Get_TCNT()
Register access to read counter register.
IOReg< HWTimer16_3C > tccrc_reg
control register C
IOReg< HWTimer16_1C > tccrb_reg
control register B
unsigned char Get_DT1A()
Register access to read dead time value for channel A.
IOReg< HWTimer16 > ocrb_l_reg
output compare B register, low byte
WGMtype
types of waveform generation modes
compare[2] value reached for one count cycle
Timer unit with 16Bit counter and 3 output compare units.
HWTimerTinyX5_SyncReg ocra_inout_val
register value OCRA
unsigned long icapRegister
Input capture register.
unsigned long limit_max
MAX value for counting.
int wgm_raw
this is the wgm raw value from register
void Set_OCRAH(unsigned char val)
Register access to set output compare register A high byte.
unsigned char ocrb_internal_val
internal (async) register value for OCRB1
virtual void fireEvent(int event)=0
IOReg< HWTimerTinyX5 > tcnt_reg
counter register
AvrDevice * core
pointer to device core
unsigned char tccra_val
register value TCCRA
unsigned char Get_TCCRB()
Register access to read control register.
int updown_counting
count direction control flag, true, if up/down counting
unsigned char Get_OCRA()
Register access to read output compare register A.
Timer unit with 16Bit counter and one output compare unit.
HWTimerTinyX5_SyncReg ocrc_inout_val
register value OCRC
IRQLine * timerOverflow
irq line for overflow interrupt
IOReg< HWTimer16_1C > tccra_reg
control register A
unsigned long vtcnt
THE timercounter.
Timer unit with 8Bit counter and no output compare unit.
IOReg< HWTimerTinyX5 > tocrc_reg
OCR register channel C.
void Set_TCNTL(unsigned char val)
Register access to set counter register low byte.
IOReg< HWTimerTinyX5 > dt1b_reg
dead time generator register channel B
IOReg< HWTimerTinyX5 > dtps1_reg
dead time generator prescaler register
IOReg< HWTimer8_0C > tccr_reg
control register
bool ocrOut
OCR status before dead time generator.
IOReg< HWTimer16 > ocrb_h_reg
output compare B register, high byte
int wgm_raw
this is the wgm raw value from register
void ForceEvent()
Manual change of OCR unit by force bit.
int cfg_dtprescaler
internal (async) dead time prescaler setting
void Reset(unsigned char v)
perform a reset to set valid reset values without clock
IOReg< HWTimer16_2C3 > tccrc_reg
control register C
PrescalerMultiplexer without external count pin.
void Set_DT1A(unsigned char val)
Register access to set dead time value for channel A.
bool at8515_mode
signals, that this timer units is used in AT90S8515
IOReg< HWTimer8 > ocra_reg
output compare A register
unsigned char tccra_val
register value TCCRA
void Set_OCRA(unsigned char val)
Register access to set output compare register A.
IOReg< HWTimerTinyX5 > tocra_reg
OCR register channel A.
unsigned char tccrb_val
register value TCCRB
unsigned char Get_TCCRC()
Register access to read control register C.
Class, which provides input capture source for 16bit timers.
IOReg< HWTimer16_3C > tccrb_reg
control register B
IRQLine * timerCapture
irq line for capture interrupt
bool tcnt_set_flag
flag to signal, that a new counter value was set
int dtCounter
dead time counter
unsigned char Get_TCCRA()
Register access to read control register A.
unsigned char tccra_val
register value TCCRA
Timer unit with 8Bit counter and 2 output compare unit.
ICaptureSource * icapSource
Input capture source.
virtual ~TimerEventListener()
unsigned char Get_TCCRB()
Register access to read control register B.
unsigned char Get_TCCRA()
Register access to read control register A.
CEtype
event types for timer/counter
IOReg< HWTimer16_2C2 > tccrb_reg
control register B
void SetTimerEventListener(TimerEventListener *listener)
Set event listener.
unsigned long ocrb_compare
active compare value for OCR B unit
IOReg< HWTimerTinyX5 > dt1a_reg
dead time generator register channel A
bool cfg_ctc
internal (async) flag for clear timer counter
void Set_OCRAL(unsigned char val)
Register access to set output compare register A low byte.
Extends BasicTimerUnit to provide common support to all types of 16Bit timer units.
SystemClockOffset asyncClock_locktime
time, when pll is locked
IOReg< HWTimerTinyX5 > tocrb_reg
OCR register channel B.
bool tov_internal_flag
TOV flag is set, have to be delayed by 1 CK.
IOReg< HWTimer8 > ocrb_reg
output compare B register
IOSpecialReg * dtps1Register
instance of DTPS1 register
unsigned char Get_TCCRB()
Register access to read control register B.
void Set_OCRCL(unsigned char val)
Register access to set output compare register C low byte.
HWTimerTinyX5_SyncReg gtccr_in_val
input register value GTCCR
OCRIDXtype
indices for OC units
unsigned char tcnt_out_async_tmp
temporary register value for TCNT in async mode
IOSpecialReg * pllcsrRegister
instance of PLLCSR register
Analog comparator peripheral.
unsigned char Get_OCRAL()
Register access to read output compare register A low byte.
IRQLine * timerOverflowInt
irq line for overflow interrupt
AvrDevice * core
pointer to device core
unsigned char Get_OCRBH()
Register access to read output compare register B high byte.
void Set_OCRBH(unsigned char val)
Register access to set output compare register B high byte.
IOReg< HWTimer16_2C2 > tccra_reg
control register A
WGMtype wgm
waveform generation mode
bool asyncClock_async
mode switch for async mode
void Set_OCRB(unsigned char val)
Register access to set output compare register B.