|
|
Contains the main function - the initialization of all ports, functions and the main loop:
-
Resetting of all pins of all ports (to input pins with pull-up resistors).
-
Initialization of LCD pins (if RTC_LCD_DEBUG or RTC_LCD_TIMEDEBUG is set to 1).
-
Initialization of Comparator Pin and Comparator itself (input from DCF77 module).
-
Initialization of the pin for the DCF77 indicator LED.
-
Initialization of I2C pins.
-
Initialization of LCD (if RTC_LCD_DEBUG or RTC_LCD_TIMEDEBUG is set to 1).
-
Initialization of Timer and the respective Interrupt.
-
Initialization of I2C and configuration as I2C slave.
-
Initialization of internal data structures.
-
Read current state of DS1307 RTC chip and set it up if it has no battery powered time information.
-
Read current state of SAA1064 LED 7 segment driver chip and start a LED checkup/demo.
-
Start DCF77 module (if enabled) and start a new synchronization cycle.
-
Main Loop:
-
Check for arrived data from an external I2C master (get time command or set config command) and and perform the requested operation (using the control registers ctrl_data). The following operations (sending or receiving data to or from DS1307 RTC chip) will be performed as I2C master.
-
If the DCF77 module is enabled, read in the current signal value.
-
If the DCF77 module is enabled, start an new synchronization cycle, when an update cycle has reached (every DCF77_UPDATE_CYCLE minutes). During an update cycle, the function dcf77_sync() is periodically called via Interrupt Service Routine ISR(TIMER0_COMPA_vect) and, depending on the internal state (return value), the respective time information is saved into the dcf77_time structure (and written to the DS1307 RTC chip, except of the seconds). After receiving the last data item (year), the synchronization cycle is finished and the received data (including the seconds) will be written to the DS1307 RTC chip.
-
Read time data from DS1307 RTC chip and print it on the LCD and or LED, if the LCD and/or LED output is enabled.
-
Save current configuration and time data into control registers (ctrl_data). These registers are the I/O registers for I2C communication as slave.
- Date
- Created 05.08.2010
- Modified 20.03.2013
- See Also
- dcf77.h
-
lcd.h
-
port_definitions.h
- Author
- Michael Skutek, micha.nosp@m.el@s.nosp@m.kutek.nosp@m..de
Definition at line 158 of file main.c.
|