fremoclock  1_3A01
FREMO Clock - Software for UTG
ClockKernel.h
Go to the documentation of this file.
1 
34 /*
35  Copyright (C) 2007 Bernd Wisotzki
36 
37  This library is free software; you can redistribute it and/or
38  modify it under the terms of the GNU Lesser General Public
39  License as published by the Free Software Foundation; either
40  version 2.1 of the License, or (at your option) any later version.
41 
42  This library is distributed in the hope that it will be useful,
43  but WITHOUT ANY WARRANTY; without even the implied warranty of
44  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
45  Lesser General Public License for more details.
46 
47  You should have received a copy of the GNU Lesser General Public
48  License along with this library; if not, write to the Free Software
49  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50 */
51 
52 #ifndef CLOCKKERNEL_H_
53 #define CLOCKKERNEL_H_
54 
55 #include <stdint.h> // typedef uint8_t, typedef uint16_t
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 /* -- Defines --------------------------------------------------------------- */
62 
69 typedef struct {
70  uint8_t hour;
71  uint8_t minute;
72 } fclock_t;
73 
74 #define CLOCK_MIDNIGHT { 0, 0 }
75 // CLOCK_MIDNIGHT should be defined as 'const fclock_t', but C sucks:
76 // extern const fclock_t CLOCK_MIDNIGHT;
77 
78 //TODO: should we define status_t as bit field and use on ClockSetStatus, ... ?
79 
85 #define CLOCK_STATUS_RUN 0
86 
92 #define CLOCK_STATUS_TIME 1
93 
94 //#define CLOCK_STATUS_XXX 2-7 //reserved for future use
95 
96 #define CLOCK_TIME_FACTOR_MIN 10
97 #define CLOCK_TIME_FACTOR_MAX 119
98 
99 #define CLOCK_PULSE_WIDTH_MIN 5
100 #define CLOCK_PULSE_WIDTH_MAX 19
101 
102 /*-- FunctionPrototypes ----------------------------------------------------- */
103 
104 // for comment see ClockKernel.c
105 void ClockKernelInit(void);
106 
107 // for comment see ClockKernel.c
108 void SysTimerUserInterrupt(void);
109 
110 // for comment see ClockKernel.c
111 void SysTimerUserInterrupt10(void);
112 
113 // for comment see ClockKernel.c
114 void SysTimerUserInterrupt100(void);
115 
116 /* Initalize clock */
117 //void ClockInit(void);
118 
119 // for comment see ClockKernel.c
120 void ClockSetStatus(uint8_t ucStatus);
121 
122 // for comment see ClockKernel.c
123 uint8_t ClockReadStatus(void);
124 
125 // for comment see ClockKernel.c
126 uint8_t ClockIsRunning(void); //FIXME: replace by: const uint8_t CLOCK_IS_RUNNING = _BV(CLOCK_STATUS_RUN) | _BV(CLOCK_STATUS_TIME;
127 
128 // for comment see ClockKernel.c
129 void ClockSetPeriod(uint16_t uiPeriod);
130 
131 // for comment see ClockKernel.c
132 uint16_t ClockReadPeriod(void);
133 
134 // for comment see ClockKernel.c
135 void ClockSetPulse(uint16_t uiPulse);
136 
137 // for comment see ClockKernel.c
138 uint16_t ClockReadPulse(void);
139 
140 // for comment see ClockKernel.c
141 void ClockSetTime(fclock_t newValue);
142 
143 // for comment see ClockKernel.c
144 fclock_t ClockGetTime(void);
145 
146 // for comment see ClockKernel.c
147 void ClockSetTimeFactor(uint8_t ucFactor);
148 
149 // for comment see ClockKernel.c
150 uint8_t ClockReadTimeFactor(void);
151 
152 //TODO: use fclock_t for the following functions instead of two
153 // separate minute/hour functions
154 
155 // for comment see ClockKernel.c
156 void ClockSetStartTimeMinute(uint8_t ucMinute);
157 
158 // for comment see ClockKernel.c
159 uint8_t ClockReadStartTimeMinute(void);
160 
161 // for comment see ClockKernel.c
162 void ClockSetStartTimeHour(uint8_t ucHour);
163 
164 // for comment see ClockKernel.c
165 uint8_t ClockReadStartTimeHour(void);
166 
167 // for comment see ClockKernel.c
168 void ClockSetEndTimeMinute(uint8_t ucMinute);
169 
170 // for comment see ClockKernel.c
171 uint8_t ClockReadEndTimeMinute(void);
172 
173 // for comment see ClockKernel.c
174 void ClockSetEndTimeHour(uint8_t ucHour);
175 
176 // for comment see ClockKernel.c
177 uint8_t ClockReadEndTimeHour(void);
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif /* CLOCKKERNEL_H_ */
uint8_t ClockReadEndTimeHour(void)
Get the hour of the end time.
Definition: ClockKernel.c:446
A struct with hour and minute.
Definition: ClockKernel.h:69
uint8_t ClockReadStartTimeHour(void)
Get the hour of the start time.
Definition: ClockKernel.c:398
void SysTimerUserInterrupt10(void)
This function is called by SysHWTimer every 10ms.
Definition: ClockKernel.c:145
void ClockSetPeriod(uint16_t uiPeriod)
Set length of model minute in 100ms.
Definition: ClockKernel.c:239
void ClockSetTime(fclock_t newValue)
Set actual time.
Definition: ClockKernel.c:301
uint8_t minute
minute value 0..59
Definition: ClockKernel.h:71
void SysTimerUserInterrupt(void)
This function is called by SysHWTimer every 1ms.
Definition: ClockKernel.c:135
void ClockSetPulse(uint16_t uiPulse)
Set length of pulse length in 100ms.
Definition: ClockKernel.c:270
uint16_t ClockReadPulse(void)
Get length of pulse length in 100ms.
Definition: ClockKernel.c:286
uint8_t ClockReadStartTimeMinute(void)
Get the minute of the start time.
Definition: ClockKernel.c:374
void ClockSetStartTimeMinute(uint8_t ucMinute)
Set the minute of the start time.
Definition: ClockKernel.c:362
uint16_t ClockReadPeriod(void)
Get length of model minute in 100ms.
Definition: ClockKernel.c:255
void SysTimerUserInterrupt100(void)
This function is called by SysHWTimer every 100ms.
Definition: ClockKernel.c:155
uint8_t hour
hour value 0..23
Definition: ClockKernel.h:70
uint8_t ClockReadStatus(void)
Read status of pulse generator.
Definition: ClockKernel.c:214
fclock_t ClockGetTime(void)
Get actual time.
Definition: ClockKernel.c:317
uint8_t ClockReadTimeFactor(void)
Get time factor.
Definition: ClockKernel.c:350
void ClockSetStatus(uint8_t ucStatus)
Set status of pulse generator.
Definition: ClockKernel.c:187
void ClockSetEndTimeHour(uint8_t ucHour)
Set the hour of the end time.
Definition: ClockKernel.c:434
uint8_t ClockReadEndTimeMinute(void)
Get the minute of the end time.
Definition: ClockKernel.c:422
uint8_t ClockIsRunning(void)
Value used as parameter to ClockSetStatus() to start clock.
Definition: ClockKernel.c:228
void ClockSetTimeFactor(uint8_t ucFactor)
Set time factor.
Definition: ClockKernel.c:331
void ClockSetStartTimeHour(uint8_t ucHour)
Set the hour of the start time.
Definition: ClockKernel.c:386
void ClockSetEndTimeMinute(uint8_t ucMinute)
Set the minute of the end time.
Definition: ClockKernel.c:410
void ClockKernelInit(void)
Initialization of the pulse generator.
Definition: ClockKernel.c:107