Monitor motorhome leisure battery and provide simple control of habitation

Dependencies:   net lpc1768 crypto clock web fram log

Committer:
andrewboyson
Date:
Wed Feb 10 17:26:07 2021 +0000
Revision:
2:5229cab71d69
Parent:
0:b843d647695c
Child:
3:b96c6f6bbffc
Added pwm.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 0:b843d647695c 1 #include "lpc1768.h"
andrewboyson 0:b843d647695c 2 #include "periphs.h"
andrewboyson 0:b843d647695c 3 #include "led.h"
andrewboyson 0:b843d647695c 4 #include "clk.h"
andrewboyson 0:b843d647695c 5 #include "log.h"
andrewboyson 0:b843d647695c 6 #include "fram.h"
andrewboyson 0:b843d647695c 7 #include "net.h"
andrewboyson 0:b843d647695c 8 #include "1-wire.h"
andrewboyson 0:b843d647695c 9 #include "1-wire-device.h"
andrewboyson 0:b843d647695c 10 #include "heating.h"
andrewboyson 0:b843d647695c 11 #include "settings.h"
andrewboyson 0:b843d647695c 12 #include "web.h"
andrewboyson 0:b843d647695c 13 #include "settings.h"
andrewboyson 0:b843d647695c 14 #include "values.h"
andrewboyson 0:b843d647695c 15 #include "restart.h"
andrewboyson 0:b843d647695c 16 #include "restart-this.h"
andrewboyson 0:b843d647695c 17 #include "crypto.h"
andrewboyson 2:5229cab71d69 18 #include "i2c1.h"
andrewboyson 2:5229cab71d69 19 #include "lcd.h"
andrewboyson 0:b843d647695c 20
andrewboyson 0:b843d647695c 21 int main()
andrewboyson 0:b843d647695c 22 {
andrewboyson 0:b843d647695c 23 RestartZone = RESTART_ZONE_INIT;
andrewboyson 0:b843d647695c 24 PeriphsInit();
andrewboyson 0:b843d647695c 25 LedInit();
andrewboyson 0:b843d647695c 26 Lpc1768Init();
andrewboyson 0:b843d647695c 27 ClkInit();
andrewboyson 0:b843d647695c 28 LogInit(ClkNowTmUtc, 115200);
andrewboyson 0:b843d647695c 29 if ( FramInit()) goto end; //Reserves 1 FRAM byte to detect if empty
andrewboyson 0:b843d647695c 30 FramAllocate(4); //Reserves 4 FRAM bytes where the watchdog used to hold the last program position
andrewboyson 0:b843d647695c 31 CryptoInit(); //Uses log
andrewboyson 0:b843d647695c 32 NetInit();
andrewboyson 0:b843d647695c 33 if (SettingsNtpInit()) goto end; //Loads of FRAM
andrewboyson 0:b843d647695c 34 WebInit(); //No FRAM
andrewboyson 0:b843d647695c 35 OneWireInit(); //No FRAM
andrewboyson 0:b843d647695c 36 DeviceInit(); //No FRAM
andrewboyson 0:b843d647695c 37 HeatingInit(); //Loads of FRAM
andrewboyson 0:b843d647695c 38 if ( SettingsInit()) goto end;
andrewboyson 0:b843d647695c 39 if ( ValuesInit()) goto end;
andrewboyson 2:5229cab71d69 40 I2C1Init();
andrewboyson 2:5229cab71d69 41 LcdInit();
andrewboyson 0:b843d647695c 42 while (1)
andrewboyson 0:b843d647695c 43 {
andrewboyson 0:b843d647695c 44 RestartZone = RESTART_ZONE_LOG; LogMain();
andrewboyson 0:b843d647695c 45 RestartZone = RESTART_ZONE_CLOCK; ClkMain();
andrewboyson 0:b843d647695c 46 RestartZone = RESTART_ZONE_NET; NetMain();
andrewboyson 0:b843d647695c 47 RestartZone = RESTART_ZONE_VALUES; ValuesMain();
andrewboyson 0:b843d647695c 48 RestartZone = RESTART_ZONE_ONE_WIRE; if (OneWireMain()) break;
andrewboyson 0:b843d647695c 49 RestartZone = RESTART_ZONE_DEVICE; if ( DeviceMain()) break;
andrewboyson 0:b843d647695c 50 RestartZone = RESTART_ZONE_HEATING; HeatingMain();
andrewboyson 0:b843d647695c 51 RestartZone = RESTART_ZONE_LPC1768; Lpc1768Main();
andrewboyson 0:b843d647695c 52 RestartZone = RESTART_ZONE_CRYPTO; CryptoMain();
andrewboyson 2:5229cab71d69 53 I2C1Main();
andrewboyson 2:5229cab71d69 54 LcdMain();
andrewboyson 0:b843d647695c 55 }
andrewboyson 0:b843d647695c 56
andrewboyson 0:b843d647695c 57 end:
andrewboyson 0:b843d647695c 58 Led1Set(1); Led2Set(1); Led3Set(1); Led4Set(1);
andrewboyson 0:b843d647695c 59 return 0;
andrewboyson 0:b843d647695c 60 }