Andrew Boyson / oldheating

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

main/main.c

Committer:
andrewboyson
Date:
2019-01-02
Revision:
16:48ef9d43018b
Parent:
15:f91462db6088
Child:
17:13a1068dda70

File content as of revision 16:48ef9d43018b:

#include "system.h"
#include "watchdog.h"
#include "periphs.h"
#include "led.h"
#include "clock.h"
#include "log.h"
#include "fram.h"
#include "net-server.h"
#include "1-wire.h"
#include "1-wire-device.h"
#include "heating.h"
#include "settings.h"
#include "ntp-client.h"
#include "http-server.h"
#include "settings.h"
#include "values.h"
#include "debounce.h"
#include "fault.h"

int main()
{
    FaultZone = FAULT_ZONE_INIT;
          PeriphsInit();
           SystemInit();
              LedInit();
            ClockInit();
              LogInit(ClockTmUtc, 115200);
    if (     FramInit()) goto end; //Reserves 1 FRAM byte to detect if empty
         FramAllocate(4);          //Reserves 4 FRAM bytes where the watchdog used to hold the last program position
        NetServerInit();
    if (NtpClientInit()) goto end;
       HttpServerInit();
          OneWireInit();
           DeviceInit();
          HeatingInit();
         DebounceInit();
    if ( SettingsInit()) goto end;
    if (   ValuesInit()) goto end;
         WatchdogInit();
      
    while (1)
    {   
        FaultZone = FAULT_ZONE_LOG;             LogMain();
        FaultZone = FAULT_ZONE_CLOCK;         ClockMain();
        FaultZone = FAULT_ZONE_NET;       NetServerMain();
        FaultZone = FAULT_ZONE_NONE;      NtpClientMain();
        FaultZone = FAULT_ZONE_NONE;         ValuesMain();
        FaultZone = FAULT_ZONE_NONE;  if (  OneWireMain()) break;
        FaultZone = FAULT_ZONE_NONE;  if (   DeviceMain()) break;
        FaultZone = FAULT_ZONE_NONE;        HeatingMain();
        FaultZone = FAULT_ZONE_NONE;       WatchdogMain();
    }

end:
    Led1Set(1); Led2Set(1); Led3Set(1); Led4Set(1);
    return 0;
}