Andrew Boyson / motorhome

Dependencies:   net lpc1768 crypto clock web fram log

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.c Source File

main.c

00001 #include "lpc1768.h"
00002 #include "periphs.h"
00003 #include "led.h"
00004 #include "clk.h"
00005 #include "log.h"
00006 #include "fram.h"
00007 #include "net.h"
00008 #include "settings.h"
00009 #include "web.h"
00010 #include "settings.h"
00011 #include "values.h"
00012 #include "restart.h"
00013 #include "restart-this.h"
00014 #include "crypto.h"
00015 #include "i2c1.h"
00016 #include "lcd.h"
00017 #include "can.h"
00018 #include "comms.h"
00019 
00020 int main()
00021 {
00022     RestartZone = RESTART_ZONE_INIT;
00023             PeriphsInit();
00024                 LedInit();
00025             Lpc1768Init();
00026                 ClkInit();
00027                 LogInit(ClkNowTmUtc, 115200);
00028     if (       FramInit()) goto end; //Reserves 1 FRAM byte to detect if empty
00029            FramAllocate(4);          //Reserves 4 FRAM bytes where the watchdog used to hold the last program position
00030              CryptoInit();           //Uses log
00031                 NetInit();
00032     if (SettingsNtpInit()) goto end; //Loads of FRAM
00033                 WebInit();           //No FRAM
00034     if (   SettingsInit()) goto end;
00035     if (     ValuesInit()) goto end;
00036                I2C1Init();
00037                 LcdInit();
00038                 CanInit();
00039               CommsInit();
00040     while (1)
00041     {   
00042         RestartZone = RESTART_ZONE_LOG;              LogMain();
00043         RestartZone = RESTART_ZONE_CLOCK;            ClkMain();
00044         RestartZone = RESTART_ZONE_NET;              NetMain();
00045         RestartZone = RESTART_ZONE_VALUES;        ValuesMain();
00046         RestartZone = RESTART_ZONE_LPC1768;      Lpc1768Main();
00047         RestartZone = RESTART_ZONE_CRYPTO;        CryptoMain();
00048         I2C1Main();
00049          LcdMain();
00050          CanMain();
00051        CommsMain();
00052     }
00053 
00054 end:
00055     Led1Set(1); Led2Set(1); Led3Set(1); Led4Set(1);
00056     return 0;
00057 }