Monitor motorhome leisure battery and provide simple control of habitation
Dependencies: net lpc1768 crypto clock web fram log
main/main.c@0:b843d647695c, 2021-01-14 (annotated)
- Committer:
- andrewboyson
- Date:
- Thu Jan 14 16:05:55 2021 +0000
- Revision:
- 0:b843d647695c
- Child:
- 2:5229cab71d69
Creation (mostly a copy of heating at the moment)
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:b843d647695c | 18 | |
andrewboyson | 0:b843d647695c | 19 | int main() |
andrewboyson | 0:b843d647695c | 20 | { |
andrewboyson | 0:b843d647695c | 21 | RestartZone = RESTART_ZONE_INIT; |
andrewboyson | 0:b843d647695c | 22 | PeriphsInit(); |
andrewboyson | 0:b843d647695c | 23 | LedInit(); |
andrewboyson | 0:b843d647695c | 24 | Lpc1768Init(); |
andrewboyson | 0:b843d647695c | 25 | ClkInit(); |
andrewboyson | 0:b843d647695c | 26 | LogInit(ClkNowTmUtc, 115200); |
andrewboyson | 0:b843d647695c | 27 | if ( FramInit()) goto end; //Reserves 1 FRAM byte to detect if empty |
andrewboyson | 0:b843d647695c | 28 | FramAllocate(4); //Reserves 4 FRAM bytes where the watchdog used to hold the last program position |
andrewboyson | 0:b843d647695c | 29 | CryptoInit(); //Uses log |
andrewboyson | 0:b843d647695c | 30 | NetInit(); |
andrewboyson | 0:b843d647695c | 31 | if (SettingsNtpInit()) goto end; //Loads of FRAM |
andrewboyson | 0:b843d647695c | 32 | WebInit(); //No FRAM |
andrewboyson | 0:b843d647695c | 33 | OneWireInit(); //No FRAM |
andrewboyson | 0:b843d647695c | 34 | DeviceInit(); //No FRAM |
andrewboyson | 0:b843d647695c | 35 | HeatingInit(); //Loads of FRAM |
andrewboyson | 0:b843d647695c | 36 | if ( SettingsInit()) goto end; |
andrewboyson | 0:b843d647695c | 37 | if ( ValuesInit()) goto end; |
andrewboyson | 0:b843d647695c | 38 | while (1) |
andrewboyson | 0:b843d647695c | 39 | { |
andrewboyson | 0:b843d647695c | 40 | RestartZone = RESTART_ZONE_LOG; LogMain(); |
andrewboyson | 0:b843d647695c | 41 | RestartZone = RESTART_ZONE_CLOCK; ClkMain(); |
andrewboyson | 0:b843d647695c | 42 | RestartZone = RESTART_ZONE_NET; NetMain(); |
andrewboyson | 0:b843d647695c | 43 | RestartZone = RESTART_ZONE_VALUES; ValuesMain(); |
andrewboyson | 0:b843d647695c | 44 | RestartZone = RESTART_ZONE_ONE_WIRE; if (OneWireMain()) break; |
andrewboyson | 0:b843d647695c | 45 | RestartZone = RESTART_ZONE_DEVICE; if ( DeviceMain()) break; |
andrewboyson | 0:b843d647695c | 46 | RestartZone = RESTART_ZONE_HEATING; HeatingMain(); |
andrewboyson | 0:b843d647695c | 47 | RestartZone = RESTART_ZONE_LPC1768; Lpc1768Main(); |
andrewboyson | 0:b843d647695c | 48 | RestartZone = RESTART_ZONE_CRYPTO; CryptoMain(); |
andrewboyson | 0:b843d647695c | 49 | } |
andrewboyson | 0:b843d647695c | 50 | |
andrewboyson | 0:b843d647695c | 51 | end: |
andrewboyson | 0:b843d647695c | 52 | Led1Set(1); Led2Set(1); Led3Set(1); Led4Set(1); |
andrewboyson | 0:b843d647695c | 53 | return 0; |
andrewboyson | 0:b843d647695c | 54 | } |