Dmitry Kovalev / Mbed 2 deprecated LG2

Dependencies:   mbed

Fork of LG by igor Apu

Revision:
69:70849751d98e
Parent:
68:46937d192c39
Child:
71:7835a18110bd
--- a/DeviceProtocol.h	Sat Feb 20 13:13:09 2016 +0000
+++ b/DeviceProtocol.h	Mon Feb 22 19:50:48 2016 +0000
@@ -5,16 +5,42 @@
 #include "stdint.h"
 
 /*Move this to uart_m.h when protocol completed*/
-#define IOBufferSize        1024
-typedef struct _IOCyclicBuffer {
-    uint8_t buffer[IOBufferSize];
+#define InputBufferSize        1024
+typedef struct _DeviceInputBuffer {
+    uint8_t buffer[InputBufferSize];
     int start; //first byte position
     int end;   //last byte position
-} IOCyclicBuffer;
+} DeviceInputBuffer;
 /*Move this to uart_m.h when protocol completed*/
-IOCyclicBuffer ReadBuffer1;
-/*Move this to uart_m.h when protocol completed*/
-IOCyclicBuffer WriteBuffer1;
+#define OuputBufferSize        1024
+typedef struct _DeviceOutputBuffer {
+    uint8_t buffer[OuputBufferSize];
+    int count; //byte count
+} DeviceOutputBuffer;
+
+typedef struct _DeviceCommunicationState {
+    DeviceInputBuffer RequestBuffer;
+    DeviceOutputBuffer ResponseBuffer;
+  //Request settings
+    uint32_t RequestBaudRate;
+    uint8_t  RequestCode;
+    uint8_t  RequestSelect;
+  //Response settings
+    uint8_t  ResponseReady;
+    uint8_t  ResponseCode;
+    uint8_t  ResponseSelect;
+    uint32_t ResponseBaudRate;
+    //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;
+    //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;
+} DeviceCommunicationState;
+
+typedef struct _DeviceState {
+    DeviceCommunicationState communication;
+} DeviceState;
 
 /*
 typedef struct {
@@ -134,7 +160,9 @@
 };
 */
 
-int PullRequest(IOCyclicBuffer *b);
+int PullRequest(DeviceInputBuffer *b);
+
+void TransmitResponse(void);
 
 void SetDeviceMode(uint8_t param);
 void InitDeltaBINS(uint8_t param);