123

Dependencies:   mbed

Fork of LG by igor Apu

Revision:
149:abbf7663d27d
Parent:
137:14a0c452cf32
Child:
156:e68ee0bcdcda
--- a/Device.c	Fri Apr 29 13:53:50 2016 +0000
+++ b/Device.c	Tue May 03 05:12:26 2016 +0000
@@ -2,6 +2,7 @@
 
 Device device;
 HashParam hashParamTable[HASH_PARAM_COUNT];
+HashFunc  hashFuncTable[HASH_FUNC_COUNT];
 
 void InitDevice(void)
 {
@@ -15,16 +16,53 @@
   enable_timer1();
   enable_timer2();
   
-  //Load settings
-  device.settings.address = 0; //Debug
-  device.settings.uart.startupBaudRate = 38400;
+  //Load default settings
+  InitAllWithDefaults();
+  
+  //Load from flash
+  FlashReadAll();
 
-  //Init maintenance communication port
-  UART_InitSet (0, 921600, 0x03);
-  //UART_InitSet (1, 115200, 0x03);
-  
+  //Init flash memory
+  InitFlash();
+  //Init service port
+  InitServicePort();
   //Init host commununication port
   InitHostPort();
   //Init host commununication protocol
   InitHostProtocol();
-}
\ No newline at end of file
+  InitSSP();
+  
+  //Init light-up and back light unit
+  InitLightUp();
+  //Init dither
+  InitDither();
+  //Init path length control system
+  InitPathLengthControlSystem();
+}
+
+void StartDevice(void){
+  StartLightUp();
+  StartDither();
+}
+
+void InitAllWithDefaults(void){
+  device.settings.address = 0;
+  device.settings.uart.startupBaudRate = 38400;
+  
+  InitFlashWithDefaults();
+  InitServicePortWithDefaults();
+  InitHostPortWithDefaults();
+  InitHostProtocolWithDefaults();
+  InitLightUpWithDefaults();
+  InitSSPWithDefaults();
+  InitDitherWithDefaults();
+  InitPathLengthControlSystemWithDefaults();
+}
+/*
+int32_t FindByHash(uint32_t hash){
+  for (uint32_t i = 0; i < HASH_PARAM_COUNT; i++){
+    if (hashParamTable[i].hash == hash) return i;
+  }
+  return -1;
+}
+*/
\ No newline at end of file