Dmitry Kovalev / Mbed 2 deprecated LG2

Dependencies:   mbed

Fork of LG by igor Apu

Revision:
71:7835a18110bd
Parent:
69:70849751d98e
Child:
72:f5e189c62bcb
--- a/DeviceProtocol.h	Mon Feb 22 20:11:04 2016 +0000
+++ b/DeviceProtocol.h	Tue Feb 23 05:55:37 2016 +0000
@@ -4,17 +4,16 @@
 #include "DeviceSettings.h"
 #include "stdint.h"
 
-/*Move this to uart_m.h when protocol completed*/
 #define InputBufferSize        1024
 typedef struct _DeviceInputBuffer {
     uint8_t buffer[InputBufferSize];
-    int start; //first byte position
-    int end;   //last byte position
+    int start; //read start position
+    int end;   //write start position
 } DeviceInputBuffer;
-/*Move this to uart_m.h when protocol completed*/
-#define OuputBufferSize        1024
+
+#define OutputBufferSize        64
 typedef struct _DeviceOutputBuffer {
-    uint8_t buffer[OuputBufferSize];
+    uint8_t buffer[OutputBufferSize];
     int count; //byte count
 } DeviceOutputBuffer;
 
@@ -22,24 +21,37 @@
     DeviceInputBuffer RequestBuffer;
     DeviceOutputBuffer ResponseBuffer;
   //Request settings
-    uint32_t RequestBaudRate;
-    uint8_t  RequestCode;
-    uint8_t  RequestSelect;
+    uint32_t requestBaudRate;
+    uint8_t  requestCode;
+    uint8_t  requestSelect;
   //Response settings
-    uint8_t  ResponseReady;
-    uint8_t  ResponseCode;
-    uint8_t  ResponseSelect;
-    uint32_t ResponseBaudRate;
+    uint8_t  responseReady;
+    uint8_t  responseCode;
+    uint8_t  responseSelect;
+    uint32_t responseBaudRate;
+    //Delta command response mode
+    DeviceDeltaMode deltaMode;
     //Response broadcast and external latch delay
-    uint32_t ResponseDelay;       //Values in mks; 0 - immediate response
-    uint32_t ResponseDelayClock;  //Values in mks; response delay clock - send response if clock > delay;
+    uint32_t responseDelay;       //Values in mks; 0 - immediate response
+    uint32_t responseDelayClock;  //Values in mks; response delay clock - send response if clock > delay;
     //Periodical response
-    uint32_t ResponsePeriod;      //Values in mks; 0 - no periodic response; 2000 - 500Hz
-    uint32_t ResponsePeriodClock; //Values in mks; response period clock - send response if clock > period;
+    uint32_t responsePeriod;      //Values in mks; 0 - no periodic response; 2000 - 500Hz
+    uint32_t responsePeriodClock; //Values in mks; response period clock - send response if clock > period;
 } DeviceCommunicationState;
 
+typedef struct _DeviceLatchState {
+    //Latch mode
+    DeviceLatchMode mode;
+} DeviceLatchState;
+
+typedef struct _DeviceCountersState {
+    //Latch
+    DeviceLatchState latch;
+} DeviceCountersState;
+
 typedef struct _DeviceState {
     DeviceCommunicationState communication;
+    DeviceCountersState counters;
 } DeviceState;
 
 /*
@@ -164,7 +176,10 @@
 
 void TransmitResponse(void);
 
-void SetDeviceMode(uint8_t param);
-void InitDeltaBINS(uint8_t param);
+DeviceLatchMode DecodeLatchModeFromDeviceMode(uint8_t param);
+DeviceDeltaMode DecodeDeltaModeFromDeviceMode(uint8_t param);
+uint32_t DecodeResponseBaudRateFromDeltaBINS(uint8_t param);
+uint32_t DecodeRequestBaudRateFromDeltaBINS(uint8_t param);
+uint32_t DecodeResponsePeriodFromDeltaBINS(uint8_t param);
 
 #endif  /* __DEVICEPROTOCOL_H__ */
\ No newline at end of file