Andrew Boyson / oldheating

Dependencies:   net 1-wire lpc1768 crypto clock web fram log

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.c Source File

main.c

00001 #include "lpc1768.h"
00002 #include "periphs.h"
00003 #include "led.h"
00004 #include "clk.h"
00005 #include "log.h"
00006 #include "fram.h"
00007 #include "net.h"
00008 #include "1-wire.h"
00009 #include "1-wire-device.h"
00010 #include "heating.h"
00011 #include "settings.h"
00012 #include "web.h"
00013 #include "settings.h"
00014 #include "values.h"
00015 #include "restart.h"
00016 #include "restart-this.h"
00017 #include "crypto.h"
00018 
00019 int main()
00020 {
00021     RestartZone = RESTART_ZONE_INIT;
00022             PeriphsInit();
00023                 LedInit();
00024             Lpc1768Init();
00025                 ClkInit();
00026                 LogInit(ClkNowTmUtc, 115200);
00027     if (       FramInit()) goto end; //Reserves 1 FRAM byte to detect if empty
00028            FramAllocate(4);          //Reserves 4 FRAM bytes where the watchdog used to hold the last program position
00029              CryptoInit();           //Uses log
00030                 NetInit();
00031     if (SettingsNtpInit()) goto end; //Loads of FRAM
00032                 WebInit();           //No FRAM
00033             OneWireInit();           //No FRAM
00034              DeviceInit();           //No FRAM
00035             HeatingInit();           //Loads of FRAM
00036     if (   SettingsInit()) goto end;
00037     if (     ValuesInit()) goto end;
00038     while (1)
00039     {   
00040         RestartZone = RESTART_ZONE_LOG;              LogMain();
00041         RestartZone = RESTART_ZONE_CLOCK;            ClkMain();
00042         RestartZone = RESTART_ZONE_NET;              NetMain();
00043         RestartZone = RESTART_ZONE_VALUES;        ValuesMain();
00044         RestartZone = RESTART_ZONE_ONE_WIRE; if (OneWireMain()) break;
00045         RestartZone = RESTART_ZONE_DEVICE;   if ( DeviceMain()) break;
00046         RestartZone = RESTART_ZONE_HEATING;      HeatingMain();
00047         RestartZone = RESTART_ZONE_LPC1768;      Lpc1768Main();
00048         RestartZone = RESTART_ZONE_CRYPTO;        CryptoMain();
00049     }
00050 
00051 end:
00052     Led1Set(1); Led2Set(1); Led3Set(1); Led4Set(1);
00053     return 0;
00054 }