Monitor motorhome leisure battery and provide simple control of habitation
Dependencies: net lpc1768 crypto clock web fram log
main/main.c@3:b96c6f6bbffc, 2021-04-18 (annotated)
- Committer:
- andrewboyson
- Date:
- Sun Apr 18 19:05:35 2021 +0000
- Revision:
- 3:b96c6f6bbffc
- Parent:
- 2:5229cab71d69
- Child:
- 9:d957af50fdc2
Added WIZ module to control WIZ lights.
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 | 2:5229cab71d69 | 18 | #include "i2c1.h" |
andrewboyson | 2:5229cab71d69 | 19 | #include "lcd.h" |
andrewboyson | 3:b96c6f6bbffc | 20 | #include "wiz.h" |
andrewboyson | 0:b843d647695c | 21 | |
andrewboyson | 0:b843d647695c | 22 | int main() |
andrewboyson | 0:b843d647695c | 23 | { |
andrewboyson | 0:b843d647695c | 24 | RestartZone = RESTART_ZONE_INIT; |
andrewboyson | 0:b843d647695c | 25 | PeriphsInit(); |
andrewboyson | 0:b843d647695c | 26 | LedInit(); |
andrewboyson | 0:b843d647695c | 27 | Lpc1768Init(); |
andrewboyson | 0:b843d647695c | 28 | ClkInit(); |
andrewboyson | 0:b843d647695c | 29 | LogInit(ClkNowTmUtc, 115200); |
andrewboyson | 0:b843d647695c | 30 | if ( FramInit()) goto end; //Reserves 1 FRAM byte to detect if empty |
andrewboyson | 0:b843d647695c | 31 | FramAllocate(4); //Reserves 4 FRAM bytes where the watchdog used to hold the last program position |
andrewboyson | 0:b843d647695c | 32 | CryptoInit(); //Uses log |
andrewboyson | 0:b843d647695c | 33 | NetInit(); |
andrewboyson | 0:b843d647695c | 34 | if (SettingsNtpInit()) goto end; //Loads of FRAM |
andrewboyson | 0:b843d647695c | 35 | WebInit(); //No FRAM |
andrewboyson | 0:b843d647695c | 36 | OneWireInit(); //No FRAM |
andrewboyson | 0:b843d647695c | 37 | DeviceInit(); //No FRAM |
andrewboyson | 0:b843d647695c | 38 | HeatingInit(); //Loads of FRAM |
andrewboyson | 0:b843d647695c | 39 | if ( SettingsInit()) goto end; |
andrewboyson | 0:b843d647695c | 40 | if ( ValuesInit()) goto end; |
andrewboyson | 2:5229cab71d69 | 41 | I2C1Init(); |
andrewboyson | 2:5229cab71d69 | 42 | LcdInit(); |
andrewboyson | 3:b96c6f6bbffc | 43 | WizInit(); |
andrewboyson | 0:b843d647695c | 44 | while (1) |
andrewboyson | 0:b843d647695c | 45 | { |
andrewboyson | 0:b843d647695c | 46 | RestartZone = RESTART_ZONE_LOG; LogMain(); |
andrewboyson | 0:b843d647695c | 47 | RestartZone = RESTART_ZONE_CLOCK; ClkMain(); |
andrewboyson | 0:b843d647695c | 48 | RestartZone = RESTART_ZONE_NET; NetMain(); |
andrewboyson | 0:b843d647695c | 49 | RestartZone = RESTART_ZONE_VALUES; ValuesMain(); |
andrewboyson | 0:b843d647695c | 50 | RestartZone = RESTART_ZONE_ONE_WIRE; if (OneWireMain()) break; |
andrewboyson | 0:b843d647695c | 51 | RestartZone = RESTART_ZONE_DEVICE; if ( DeviceMain()) break; |
andrewboyson | 0:b843d647695c | 52 | RestartZone = RESTART_ZONE_HEATING; HeatingMain(); |
andrewboyson | 0:b843d647695c | 53 | RestartZone = RESTART_ZONE_LPC1768; Lpc1768Main(); |
andrewboyson | 0:b843d647695c | 54 | RestartZone = RESTART_ZONE_CRYPTO; CryptoMain(); |
andrewboyson | 2:5229cab71d69 | 55 | I2C1Main(); |
andrewboyson | 2:5229cab71d69 | 56 | LcdMain(); |
andrewboyson | 3:b96c6f6bbffc | 57 | WizMain(); |
andrewboyson | 0:b843d647695c | 58 | } |
andrewboyson | 0:b843d647695c | 59 | |
andrewboyson | 0:b843d647695c | 60 | end: |
andrewboyson | 0:b843d647695c | 61 | Led1Set(1); Led2Set(1); Led3Set(1); Led4Set(1); |
andrewboyson | 0:b843d647695c | 62 | return 0; |
andrewboyson | 0:b843d647695c | 63 | } |