fremoclock  1_3A01
FREMO Clock - Software for UTG
ClockKernel.h File Reference

User function called by timer ISR. More...

Go to the source code of this file.

Data Structures

struct  fclock_t
 A struct with hour and minute. More...
 

Macros

#define CLOCK_MIDNIGHT   { 0, 0 }
 "00:00" alias "24:00" More...
 
#define CLOCK_STATUS_RUN   0
 Status Bit of pulse generator: start/stop. More...
 
#define CLOCK_STATUS_TIME   1
 Status Bit of pulse generator: with/without increment of actual time. More...
 
#define CLOCK_TIME_FACTOR_MIN   10
 minimum *10 (10 = 1:1,0) More...
 
#define CLOCK_TIME_FACTOR_MAX   119
 maximum *10 (119 = 1:11.9) More...
 
#define CLOCK_PULSE_WIDTH_MIN   5
 minimum pulse width in 0.1s (5 = 500ms) More...
 
#define CLOCK_PULSE_WIDTH_MAX   19
 maximum pulse width in 0.1s (19 = 1.9s) More...
 

Functions

void ClockKernelInit (void)
 Initialization of the pulse generator. More...
 
void SysTimerUserInterrupt (void)
 This function is called by SysHWTimer every 1ms. More...
 
void SysTimerUserInterrupt10 (void)
 This function is called by SysHWTimer every 10ms. More...
 
void SysTimerUserInterrupt100 (void)
 This function is called by SysHWTimer every 100ms. More...
 
void ClockSetStatus (uint8_t ucStatus)
 Set status of pulse generator. More...
 
uint8_t ClockReadStatus (void)
 Read status of pulse generator. More...
 
uint8_t ClockIsRunning (void)
 Value used as parameter to ClockSetStatus() to start clock. More...
 
void ClockSetPeriod (uint16_t uiPeriod)
 Set length of model minute in 100ms. More...
 
uint16_t ClockReadPeriod (void)
 Get length of model minute in 100ms. More...
 
void ClockSetPulse (uint16_t uiPulse)
 Set length of pulse length in 100ms. More...
 
uint16_t ClockReadPulse (void)
 Get length of pulse length in 100ms. More...
 
void ClockSetTime (fclock_t newValue)
 Set actual time. More...
 
fclock_t ClockGetTime (void)
 Get actual time. More...
 
void ClockSetTimeFactor (uint8_t ucFactor)
 Set time factor. More...
 
uint8_t ClockReadTimeFactor (void)
 Get time factor. More...
 
void ClockSetStartTimeMinute (uint8_t ucMinute)
 Set the minute of the start time. More...
 
uint8_t ClockReadStartTimeMinute (void)
 Get the minute of the start time. More...
 
void ClockSetStartTimeHour (uint8_t ucHour)
 Set the hour of the start time. More...
 
uint8_t ClockReadStartTimeHour (void)
 Get the hour of the start time. More...
 
void ClockSetEndTimeMinute (uint8_t ucMinute)
 Set the minute of the end time. More...
 
uint8_t ClockReadEndTimeMinute (void)
 Get the minute of the end time. More...
 
void ClockSetEndTimeHour (uint8_t ucHour)
 Set the hour of the end time. More...
 
uint8_t ClockReadEndTimeHour (void)
 Get the hour of the end time. More...
 

Detailed Description

User function called by timer ISR.

Subroutines for clock kernel with:

  • Init
  • UserISR (userdefined function, called by SysHWTimer every 1mS)
  • handler

Software:

  • AVR-GCC

Targets:

  • AtMega128 on PROTO_128
  • AtMega48/88/168

History:

  • 070102 First implementation (R 0)
  • 070225 Complete Rework
  • 070311 Added new functions and removed old debugging code
  • 150427 StS: Rename file
  • 150518 StS: function for is running state
Version
$Id: ClockKernel.h 159 2016-09-03 06:51:47Z pischky $
Author
Bernd Wisotzki [BA] wsb56.nosp@m.@use.nosp@m.rs.so.nosp@m.urce.nosp@m.forge.nosp@m..net
Date
25-Feb-2007

Definition in file ClockKernel.h.

Macro Definition Documentation

#define CLOCK_MIDNIGHT   { 0, 0 }

"00:00" alias "24:00"

Definition at line 74 of file ClockKernel.h.

#define CLOCK_PULSE_WIDTH_MAX   19

maximum pulse width in 0.1s (19 = 1.9s)

Definition at line 100 of file ClockKernel.h.

#define CLOCK_PULSE_WIDTH_MIN   5

minimum pulse width in 0.1s (5 = 500ms)

Definition at line 99 of file ClockKernel.h.

#define CLOCK_STATUS_RUN   0

Status Bit of pulse generator: start/stop.

See also
ClockSetStatus()
ClockReadStatus()

Definition at line 85 of file ClockKernel.h.

#define CLOCK_STATUS_TIME   1

Status Bit of pulse generator: with/without increment of actual time.

See also
ClockSetStatus()
ClockReadStatus()

Definition at line 92 of file ClockKernel.h.

#define CLOCK_TIME_FACTOR_MAX   119

maximum *10 (119 = 1:11.9)

Definition at line 97 of file ClockKernel.h.

#define CLOCK_TIME_FACTOR_MIN   10

minimum *10 (10 = 1:1,0)

Definition at line 96 of file ClockKernel.h.

Function Documentation

fclock_t ClockGetTime ( void  )

Get actual time.

Atomic access to variable clock.

Returns
the actual time
See also
ClockSetTime()

Definition at line 317 of file ClockKernel.c.

uint8_t ClockIsRunning ( void  )

Value used as parameter to ClockSetStatus() to start clock.

Returns
_BV(CLOCK_STATUS_RUN) | _BV(CLOCK_STATUS_TIME)

Definition at line 228 of file ClockKernel.c.

void ClockKernelInit ( void  )

Initialization of the pulse generator.

Definition at line 107 of file ClockKernel.c.

uint8_t ClockReadEndTimeHour ( void  )

Get the hour of the end time.

Returns
the current value of variable endTimeHour
See also
ClockSetEndTimeMinute()
ClockReadEndTimeMinute()
ClockSetEndTimeHour()

Definition at line 446 of file ClockKernel.c.

uint8_t ClockReadEndTimeMinute ( void  )

Get the minute of the end time.

Returns
the current value of variable endTimeMinute
See also
ClockSetEndTimeMinute()
ClockSetEndTimeHour()
ClockReadEndTimeHour()

Definition at line 422 of file ClockKernel.c.

uint16_t ClockReadPeriod ( void  )

Get length of model minute in 100ms.

The read is done with interrupts disabled.

Returns
the current value of clockPeriod
See also
ClockSetPeriod()

Definition at line 255 of file ClockKernel.c.

uint16_t ClockReadPulse ( void  )

Get length of pulse length in 100ms.

The read is done with interrupts disabled.

Returns
the current value of clockPulse
See also
ClockSetPulse()

Definition at line 286 of file ClockKernel.c.

uint8_t ClockReadStartTimeHour ( void  )

Get the hour of the start time.

Returns
the current value of variable startTimeHour
See also
ClockSetStartTimeMinute()
ClockReadStartTimeMinute()
ClockSetStartTimeHour()

Definition at line 398 of file ClockKernel.c.

uint8_t ClockReadStartTimeMinute ( void  )

Get the minute of the start time.

Returns
the current value of variable startTimeMinute
See also
ClockSetStartTimeMinute()
ClockSetStartTimeHour()
ClockReadStartTimeHour()

Definition at line 374 of file ClockKernel.c.

uint8_t ClockReadStatus ( void  )

Read status of pulse generator.

The read is done with interrupts disabled.

Returns
the value of clockStatus
See also
CLOCK_STATUS_RUN
CLOCK_STATUS_TIME
ClockSetStatus()

Definition at line 214 of file ClockKernel.c.

uint8_t ClockReadTimeFactor ( void  )

Get time factor.

Returns
the current time factor
See also
ClockSetTimeFactor()

Definition at line 350 of file ClockKernel.c.

void ClockSetEndTimeHour ( uint8_t  ucHour)

Set the hour of the end time.

Parameters
ucHournew value of variable endTimeMinute
See also
ClockSetEndTimeMinute()
ClockReadEndTimeMinute()
ClockReadEndTimeHour()

Definition at line 434 of file ClockKernel.c.

void ClockSetEndTimeMinute ( uint8_t  ucMinute)

Set the minute of the end time.

Parameters
ucMinutenew value of variable endTimeMinute
See also
ClockReadEndTimeMinute()
ClockSetEndTimeHour()
ClockReadEndTimeHour()

Definition at line 410 of file ClockKernel.c.

void ClockSetPeriod ( uint16_t  uiPeriod)

Set length of model minute in 100ms.

The write is done with interrupts disabled.

Parameters
uiPeriodthe new value of clockPeriod
See also
ClockReadPeriod()

Definition at line 239 of file ClockKernel.c.

void ClockSetPulse ( uint16_t  uiPulse)

Set length of pulse length in 100ms.

The write is done with interrupts disabled.

Parameters
uiPulsethe new value for clockPulse
See also
ClockReadPulse()

Definition at line 270 of file ClockKernel.c.

void ClockSetStartTimeHour ( uint8_t  ucHour)

Set the hour of the start time.

Parameters
ucHournew value of variable startTimeHour
See also
ClockSetStartTimeMinute()
ClockReadStartTimeMinute()
ClockReadStartTimeHour()

Definition at line 386 of file ClockKernel.c.

void ClockSetStartTimeMinute ( uint8_t  ucMinute)

Set the minute of the start time.

Parameters
ucMinutenew value of variable startTimeMinute
See also
ClockReadStartTimeMinute()
ClockSetStartTimeHour()
ClockReadStartTimeHour()

Definition at line 362 of file ClockKernel.c.

void ClockSetStatus ( uint8_t  ucStatus)

Set status of pulse generator.

Bits used are:

  • 0: start/stop
  • 1: with/without increment of actual time
  • 2-7: unused, reserved for future use

The write is done with interrupts disabled.

Parameters
ucStatusthe new status
See also
CLOCK_STATUS_RUN
CLOCK_STATUS_TIME
ClockReadStatus()

Definition at line 187 of file ClockKernel.c.

void ClockSetTime ( fclock_t  newValue)

Set actual time.

Atomic access to variable clock.

Parameters
newValuethe new value for clock.
See also
ClockGetTime()

Definition at line 301 of file ClockKernel.c.

void ClockSetTimeFactor ( uint8_t  ucFactor)

Set time factor.

Parameters
ucFactorthe new time factor.
See also
ClockReadTimeFactor()

Definition at line 331 of file ClockKernel.c.

Here is the call graph for this function:

void SysTimerUserInterrupt ( void  )

This function is called by SysHWTimer every 1ms.

Be careful, not to overload this isr. Runs with global interrupts disabled.

Definition at line 135 of file ClockKernel.c.

void SysTimerUserInterrupt10 ( void  )

This function is called by SysHWTimer every 10ms.

Be careful, not to overload this isr. Runs with global interrupts disabled.

Definition at line 145 of file ClockKernel.c.

void SysTimerUserInterrupt100 ( void  )

This function is called by SysHWTimer every 100ms.

Be careful, not to overload this isr. Runs with global interrupts disabled.

Definition at line 155 of file ClockKernel.c.

Here is the call graph for this function: