Andrew Boyson / oldheating

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

main/main.c

Committer:
andrewboyson
Date:
2019-01-08
Revision:
20:904a4f043f2c
Parent:
19:969f7be69225
Child:
28:bb55def47737

File content as of revision 20:904a4f043f2c:

#include "system.h"
#include "periphs.h"
#include "led.h"
#include "clk.h"
#include "log.h"
#include "fram.h"
#include "net.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"
#include "userfault.h"

int main()
{
    FaultZone = FAULT_ZONE_INIT;
          PeriphsInit();
           SystemInit();
              LedInit();
              ClkInit();
              LogInit(ClkNowTmUtc, 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
              NetInit("ch4", "ch6");
    if (NtpClientInit()) goto end;
       HttpServerInit();
          OneWireInit();
           DeviceInit();
          HeatingInit();
         DebounceInit();
    if ( SettingsInit()) goto end;
    if (   ValuesInit()) goto end;
            FaultInit();
      
    while (1)
    {   
        FaultZone = FAULT_ZONE_LOG;              LogMain();
        FaultZone = FAULT_ZONE_CLOCK;            ClkMain();
        FaultZone = FAULT_ZONE_NET;              NetMain();
        FaultZone = FAULT_ZONE_NTP_CLIENT; NtpClientMain();
        FaultZone = FAULT_ZONE_VALUES;        ValuesMain();
        FaultZone = FAULT_ZONE_ONE_WIRE; if (OneWireMain()) break;
        FaultZone = FAULT_ZONE_DEVICE;   if ( DeviceMain()) break;
        FaultZone = FAULT_ZONE_HEATING;      HeatingMain();
        FaultZone = FAULT_ZONE_FAULT;          FaultMain();
    }

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