heat control  r71
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
timer.h File Reference
#include "types.h"
Include dependency graph for timer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define T0_TOP   255
 
#define T0_RELOAD   0xb1
 
#define T0_INC20   25
 
#define IV_1S   1202
 
#define BTN_DN   (PINB & _BV(PINB2))
 
#define BTN_UP   (PINB & _BV(PINB1))
 
#define DEBOUNCED_S   130
 
#define DEBOUNCED_L   8 * DEBOUNCED_S
 
#define BTN_TEMP_DELTA   100
 
#define ENG_RUN_CW   PORTB |= _BV(PB4)
 
#define ENG_STOP_CW   PORTB &= ~_BV(PB4)
 
#define ENG_RUN_CCW   PORTB |= _BV(PB3)
 
#define ENG_STOP_CCW   PORTB &= ~_BV(PB3)
 
#define OVM_MSR   8
 

Functions

void TimerInit (void)
 initialize timer resource
period: 32µs More...
 
 ISR (TIMER0_COMPA_vect)
 compare match interrupt service for OCR0A More...
 
BTN_CODE DecodeButton (void)
 identify whether a (and which) button is pressed or not More...
 
UCHAR GetTenthSec (void)
 interface to get the global tenth seconds More...
 
UCHAR gMov (void)
 return minute overflow counter More...
 
void sMov (UCHAR mov)
 set minute overflow counter More...
 

Macro Definition Documentation

#define BTN_DN   (PINB & _BV(PINB2))

addressing the value of down button from input pin

Definition at line 24 of file timer.h.

Referenced by DecodeButton().

#define BTN_TEMP_DELTA   100

delta temperature which takes place on a single button press [m°C]

Definition at line 40 of file timer.h.

#define BTN_UP   (PINB & _BV(PINB1))

addressing the value of up button from input pin

Definition at line 28 of file timer.h.

Referenced by DecodeButton().

#define DEBOUNCED_L   8 * DEBOUNCED_S

number of timer increments to realize a long debounce delay

Definition at line 36 of file timer.h.

Referenced by DecodeButton().

#define DEBOUNCED_S   130

number of timer increments to realize a short debounce delay

Definition at line 32 of file timer.h.

Referenced by DecodeButton().

#define ENG_RUN_CCW   PORTB |= _BV(PB3)

translation of engine mode ENG_RUN_CCW to proper output signals

Definition at line 52 of file timer.h.

Referenced by ControlEngine().

#define ENG_RUN_CW   PORTB |= _BV(PB4)

translation of engine mode ENG_RUN_CW to proper output signals

Definition at line 44 of file timer.h.

Referenced by ControlEngine().

#define ENG_STOP_CCW   PORTB &= ~_BV(PB3)

translation of engine mode ENG_STOP_CCW to proper output signals

Definition at line 56 of file timer.h.

Referenced by ControlEngine(), and ISR().

#define ENG_STOP_CW   PORTB &= ~_BV(PB4)

translation of engine mode ENG_STOP_CW to proper output signals

Definition at line 48 of file timer.h.

Referenced by ControlEngine(), and ISR().

#define IV_1S   1202

number of timer overflows till 1 second

Definition at line 20 of file timer.h.

Referenced by ISR().

#define OVM_MSR   8

number of minute overflows, source for MEASSET recording

Definition at line 60 of file timer.h.

Referenced by main().

#define T0_INC20   25

number of required timer increments to get a resolution of 833µs

Definition at line 16 of file timer.h.

Referenced by EnableUsi(), ISR(), and TimerInit().

#define T0_RELOAD   0xb1

adjust timer overflow period to 20ms

Definition at line 12 of file timer.h.

#define T0_TOP   255

highest countable value @ 8 bit resolution

Definition at line 8 of file timer.h.

Function Documentation

BTN_CODE DecodeButton ( void  )

identify whether a (and which) button is pressed or not

Parameters
btnOffoffset value, indicates the action which is active dependent on the press duration
Returns
button code which identifies the operation pattern (button(s) pressed/not pressed)

Definition at line 119 of file timer.c.

References BC_DN, BC_DNUP, BC_DNUP_L, BC_NONE, BC_UP, BTN_DN, BTN_UP, DEBOUNCED_L, DEBOUNCED_S, FALSE, g_debouncer, TRUE, UCHAR, and UINT.

Referenced by main().

Here is the caller graph for this function:

UCHAR GetTenthSec ( void  )

interface to get the global tenth seconds

Returns
tenth seconds

Definition at line 192 of file timer.c.

References g_s100.

Referenced by PrintPage().

Here is the caller graph for this function:

UCHAR gMov ( void  )

return minute overflow counter

Returns
minute overflow counter

Definition at line 200 of file timer.c.

References g_mov.

Referenced by main().

Here is the caller graph for this function:

ISR ( TIMER0_COMPA_vect  )

compare match interrupt service for OCR0A

Parameters
TIMER0_COMPA_vectdesired compare match interrupt vector

counter to count a tenth of a second

counter to count one second

Definition at line 72 of file timer.c.

References ENG_TIMER::allow, CM_MEAS, ENG_TIMER::cnt, ENG_TIMER::em, EM_STOP, ENG_STOP_CCW, ENG_STOP_CW, FALSE, g_ctm, g_debouncer, g_min, g_mov, g_s100, g_sec, IV_1S, NUM_MS, T0_INC20, UCHAR, and UINT.

void sMov ( UCHAR  mov)

set minute overflow counter

Parameters
movoverflow value to set

Definition at line 208 of file timer.c.

References g_mov.

Referenced by main().

Here is the caller graph for this function:

void TimerInit ( void  )

initialize timer resource
period: 32µs

TCCR0B <- Timer/Counter0 Control Register B
| - | - | - | TSM [0] | PSR0 [0] | CS02 [1] | CS01 [0] | CS00 [0] |
clock selection:
CS02:CS00, we need a clkio division of 256

enable compare match mode

T0 match value (to get 20ms period)

enable compare match A interrupt

no PLL used

Definition at line 38 of file timer.c.

References CTC0, T0_INC20, and TCC_R0.

Referenced by Init().

Here is the caller graph for this function: