fremoclock  1_3A01
FREMO Clock - Software for UTG
UserSettings.c
Go to the documentation of this file.
1 
25 /*
26  Copyright (C) 2015 Stefan Seibt
27 
28  This library is free software; you can redistribute it and/or
29  modify it under the terms of the GNU Lesser General Public
30  License as published by the Free Software Foundation; either
31  version 2.1 of the License, or (at your option) any later version.
32 
33  This library is distributed in the hope that it will be useful,
34  but WITHOUT ANY WARRANTY; without even the implied warranty of
35  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36  Lesser General Public License for more details.
37 
38  You should have received a copy of the GNU Lesser General Public
39  License along with this library; if not, write to the Free Software
40  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
41 */
42 
43 #include <stdint.h> // typedef uint8_t, typedef uint16_t
44 
45 /* -- System wide includes -------------------------------------------------- */
46 #include <avr/io.h> // #define E2END
47 #include <avr/eeprom.h> // #define EEMEM,
48  // eeprom_read_byte(), eeprom_update_byte()
49 
50 /* -- Special Includes e.g. Onboard or direct attached Equipment ------------ */
51 #include "UserSettings.h"
52 
53 /* -- global Variables ------------------------------------------------------ */
54 
55 /* -- EEPROM ---------------------------------------------------------------- */
56 // note: write EEMEM before varaible name to make doxygen happy
57 // mega128= 4k
58 // mega168= 512
59 // to keep in line with sv programming: SV1-4 are not stored in EEPROM
60 uint8_t EEMEM eucEepromSize;
61 uint8_t EEMEM eucSwVersion;
62 uint16_t EEMEM euiSerialNumber;
63 
64 // parameter
65 // values are assigned in UserInterfaceCommonDataInit()). Only eucEepromStatus
66 // has to be set to 255 to get this done.
67 uint8_t EEMEM eucSystemStatus;
68 uint8_t EEMEM eucClockTimeFactor;
69 uint8_t EEMEM eucClockPulse;
70 uint8_t EEMEM eucClockMinute;
71 uint8_t EEMEM eucClockHour;
72 uint8_t EEMEM eucStartTimeMinute;
73 uint8_t EEMEM eucStartTimeHour;
74 uint8_t EEMEM eucEndTimeMinute;
75 uint8_t EEMEM eucEndTimeHour;
76 uint8_t EEMEM eucEepromStatus = 255;
77 
78 //FIXME: looks like this variables gets allocated in reverse order in eeprom => use struct
79 
80 /* -- flash ----------------------------------------------------------------- */
81 // was muss hier rein?? IDs fuer SV, Seriennummer, SW-Version....
82 
83 /* -- Standard functions ---------------------------------------------------- */
84 
85 // for comment see UserSettings.h
87 {
88  return eeprom_read_byte(&eucEepromStatus);
89 }
90 
91 // for comment see UserSettings.h
93 {
94  return eeprom_read_byte(&eucSystemStatus);
95 }
96 
97 // for comment see UserSettings.h
98 void UserSettingsSetSystemStatus(uint8_t status)
99 {
100  eeprom_update_byte(&eucSystemStatus, status);
101 }
102 
103 // for comment see UserSettings.h
104 void UserSettingsSetEepromStatus(uint8_t status)
105 {
106  eeprom_update_byte(&eucEepromStatus, status);
107 }
108 
109 //FIXME: pulse: used as 16 bit value, but stored as 8 bit value
110 // for comment see UserSettings.h
111 void UserSettingsSaveClockValues(uint8_t factor, uint16_t pulse,
112  uint8_t startMinute, uint8_t startHour,
113  uint8_t endMinute, uint8_t endHour,
114  uint8_t minute, uint8_t hour)
115 {
116  eeprom_update_byte(&eucClockTimeFactor, factor);
117  eeprom_update_byte(&eucStartTimeMinute, startMinute);
118  eeprom_update_byte(&eucStartTimeHour, startHour);
119  eeprom_update_byte(&eucEndTimeMinute, endMinute);
120  eeprom_update_byte(&eucEndTimeHour, endHour);
121  eeprom_update_byte(&eucClockPulse, pulse);
122  eeprom_update_byte(&eucClockMinute, minute);
123  eeprom_update_byte(&eucClockHour, hour);
124 }
125 
126 // for comment see UserSettings.h
128 {
129  return eeprom_read_byte(&eucStartTimeMinute);
130 }
131 
132 // for comment see UserSettings.h
134 {
135  return eeprom_read_byte(&eucStartTimeHour);
136 }
137 
138 // for comment see UserSettings.h
140 {
141  return eeprom_read_byte(&eucEndTimeMinute);
142 }
143 
144 // for comment see UserSettings.h
146 {
147  return eeprom_read_byte(&eucEndTimeHour);
148 }
149 
150 // for comment see UserSettings.h
152 {
153  return eeprom_read_byte(&eucClockMinute);
154 }
155 
156 // for comment see UserSettings.h
158 {
159  return eeprom_read_byte(&eucClockHour);
160 }
161 
162 // for comment see UserSettings.h
164 {
165  return eeprom_read_byte(&eucClockTimeFactor);
166 }
167 
168 //FIXME: used as 16 bit value, but stored as 8 bit value
169 // for comment see UserSettings.h
170 uint16_t UserSettingsGetPulse(void)
171 {
172  return eeprom_read_byte(&eucClockPulse);
173 }
uint8_t EEMEM eucEndTimeMinute
SV12:
Definition: UserSettings.c:74
uint8_t EEMEM eucClockPulse
SV7: length o clock pulse in 10mS.
Definition: UserSettings.c:69
uint8_t UserSettingsGetFactor(void)
Read factor from EEPROM.
Definition: UserSettings.c:163
uint8_t EEMEM eucStartTimeHour
SV11:
Definition: UserSettings.c:73
uint8_t UserSettingsGetStartMinute(void)
Read minute of startTime from EEPROM.
Definition: UserSettings.c:127
uint8_t EEMEM eucEepromSize
SV1: SV_ADDR_EEPROM_SIZE (not used for now)
Definition: UserSettings.c:60
uint8_t EEMEM eucSystemStatus
SV5: system status.
Definition: UserSettings.c:67
uint8_t EEMEM eucClockMinute
SV8: actual model time.
Definition: UserSettings.c:70
void UserSettingsSetSystemStatus(uint8_t status)
Write system status to EEPROM.
Definition: UserSettings.c:98
uint8_t EEMEM eucEndTimeHour
SV13:
Definition: UserSettings.c:75
Subroutines for UserSettings.
uint8_t UserSettingsGetEepromStatus(void)
Read eeprom status from EEPROM.
Definition: UserSettings.c:86
uint8_t UserSettingsGetCurrentMinute(void)
Read minute of current clock time from EEPROM.
Definition: UserSettings.c:151
uint16_t UserSettingsGetPulse(void)
Read pulse width from EEPROM.
Definition: UserSettings.c:170
void UserSettingsSaveClockValues(uint8_t factor, uint16_t pulse, uint8_t startMinute, uint8_t startHour, uint8_t endMinute, uint8_t endHour, uint8_t minute, uint8_t hour)
Write factor, pulse width, startTime, endTime and current clock to EEPROM.
Definition: UserSettings.c:111
uint8_t EEMEM eucSwVersion
SV2: SV_ADDR_SW_VERSION (not used for now)
Definition: UserSettings.c:61
uint8_t UserSettingsGetStartHour(void)
Read hour of startTime from EEPROM.
Definition: UserSettings.c:133
uint8_t EEMEM eucClockHour
SV9: actual model time.
Definition: UserSettings.c:71
uint8_t EEMEM eucClockTimeFactor
SV6: factor for time shortening.
Definition: UserSettings.c:68
uint16_t EEMEM euiSerialNumber
SV3,4: SV_ADDR_SERIAL_NUMBER (not used for now)
Definition: UserSettings.c:62
uint8_t UserSettingsGetEndHour(void)
Read hour of endTime from EEPROM.
Definition: UserSettings.c:145
uint8_t UserSettingsGetSystemStatus(void)
Read system status from EEPROM.
Definition: UserSettings.c:92
void UserSettingsSetEepromStatus(uint8_t status)
Write eeprom status to EEPROM.
Definition: UserSettings.c:104
uint8_t EEMEM eucStartTimeMinute
SV10:
Definition: UserSettings.c:72
uint8_t UserSettingsGetEndMinute(void)
Read minute of endTime from EEPROM.
Definition: UserSettings.c:139
uint8_t EEMEM eucEepromStatus
SVxx: if 255 eeprom is erased.
Definition: UserSettings.c:76
uint8_t UserSettingsGetCurrentHour(void)
Read hour of current clock time from EEPROM.
Definition: UserSettings.c:157