123

Dependencies:   mbed

Fork of LG by igor Apu

Revision:
182:2bd8ec44998f
Parent:
177:672ef279c8e0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DeviceUser.c	Sun Jul 10 05:35:08 2016 +0000
@@ -0,0 +1,96 @@
+#include "Device.h"
+
+extern Device device;
+
+void InitUserDefaultSettings(void){
+  device.user.address = 0;
+  InitUserDecoderDefaultSettings();
+  InitUserEncoderDefaultSettings();
+  InitUserRequestDefaultSettings();
+  InitUserResponseDefaultSettings();
+}
+
+void InitUserState(void){
+  InitUserDecoderState();
+  InitUserEncoderState();
+  InitUserRequestState();
+  InitUserResponseState();
+}
+
+void DeviceStartUser(void){
+  DeviceStartUserDecoder();
+  DeviceStartUserEncoder();
+  DeviceStartUserRequest();
+  DeviceStartUserResponse();
+}
+
+void userDecodePin(void) {
+  /*
+  *** Action ***
+  int ChkSumm;
+
+  if ((Device_Mode == DM_EXT_LATCH_DELTA_PS_PULSE) || (Device_Mode == DM_EXT_LATCH_DELTA_BINS_PULSE)) //e. exteranal latch with autoanswer on external pulse //r. внешняя защелка с автоответом по внешнему импульсу
+    {
+        if (Ext_Latch_Rdy)
+        {
+            // B_Delta_PS
+            // cc 00 a0 00 00 a0 ; 38400/38400
+            // cc 00 a0 30 00 d0 ; 115200/115200
+            // cc 1F a0 60 01 1f ; 38400/921200
+            rcv_num_byt = 6;
+            rcv_buf[0] = COMMAND_PREFIX; 
+            rcv_buf[1] = 0x1f; //Device_blk.My_Addres; //e. set the broadcasting address for delay on line for different addresses //r. задаем широковещательный адрес, чтобы была задержка на линии для разл.адресов
+            if (Device_Mode == DM_EXT_LATCH_DELTA_PS_PULSE)
+            {
+                rcv_buf[2] = Bcmd_DeltaPS; // 0xA0; 
+            }
+            else
+            {
+                rcv_buf[2] = Bcmd_DeltaBINS; // 0xB0; 
+            }
+            rcv_buf[3] = ((Copy_SRgR & 0x38) << 1) & 0x70; //r. 0x30; // 0x60; 
+            ChkSumm = rcv_buf[1] + rcv_buf[2] + rcv_buf[3];
+            rcv_buf[4] = Hi(ChkSumm); 
+            rcv_buf[5] = Lo(ChkSumm);
+            rcv_Rdy = 1;
+        }       
+    }
+  */
+  
+  if (device.counters.latch.state.enabled) {
+  //TODO:
+  //  device.counters.latch.state.clock = ...
+  //  if (device.counters.latch.state.format == 0) {
+  //    //DeltaPS
+  //    device.counters.latch.state.angle = ...
+  //    if (device.counters.latch.state.reset) {
+  //      device.counters.dither.state.angle -= device.counters.latch.state.angle;
+  //    }
+  //  } else if (device.counters.latch.state.format == 1) {
+  //    //DeltaBINS
+  //    device.counters.latch.state.angle = ...
+  //    if (device.counters.latch.state.reset) {
+  //      device.counters.dither.state.angle = 0;
+  //    }
+  //  } else if (device.counters.latch.state.format == 3) {
+  //    //DeltaSF
+  //    device.counters.latch.state.angle = ...
+  //    if (device.counters.latch.state.reset) {
+  //      device.counters.dither.state.angle = 0;
+  //    }
+  //  }
+    
+    device.user.response.counter = 0;
+    device.user.response.trigger = BROADCAST_FRAME * device.user.address; //0/100/200 mks
+    device.user.response.type = RESPONSE_DELAYED;
+    if (device.counters.latch.state.format == 0){
+      device.user.response.code = DELTA_PS;
+    } else if (device.counters.latch.state.format == 1){
+      device.user.response.code = DELTA_BINS;
+    } else if (device.counters.latch.state.format == 2){
+      device.user.response.code = DELTA_SF;
+    };
+  
+    device.user.response.enabled = 1;  
+  };
+}
\ No newline at end of file