X2D lib first commit

Revision:
25:28895e3d96c5
Parent:
24:eac91efdc315
--- a/X2D.cpp	Mon Apr 19 14:19:33 2021 +0000
+++ b/X2D.cpp	Sat Oct 01 10:09:38 2022 +0000
@@ -30,6 +30,8 @@
 CircularBuffer<msg_t, 10> MessageTx;
 CircularBuffer<msg_t, 10> MessageRx;
 
+static char cnt_1=0;
+
 bool dataBits[BIT_SIZE]={0};
 
 unsigned short maison=0;
@@ -156,7 +158,6 @@
 {
 int i=0;
 bool bit;
-static char cnt=0;
 
     //pc.printf("%0.2X ", value);
     for(i=0; i<8; i++)
@@ -164,13 +165,13 @@
         bit = (bool)(0x01 & (value>>i)); // LSB first
         SendBit(bit); 
         if(bit)
-            cnt++;
+            cnt_1++;
         else
-            cnt=0;
-        if(cnt == 5)
+            cnt_1=0;
+        if(cnt_1 == 5)
             {
             SendBit(0);
-            cnt=0;
+            cnt_1=0;
             }
         }
 }
@@ -211,6 +212,7 @@
 //    Tx=0;
 
     SendPreamble();
+    cnt_1 =0;   // reset counter of consecutive 1 bits
 
     for(i=0; i<length; i++)
         {
@@ -454,7 +456,7 @@
     UART = 1;
 
 #if NO_STM8
-    write_ctrl_reg(0x01E22F); // 1200 baud, deviation =1, Asynchrone, clock OFF
+    write_ctrl_reg(0x01E22F); // see .xls file ; 1200 baud, deviation =1, Asynchrone, clock OFF
     Ctrl_Reg = read_ctrl_reg();
     DBG("Ctrl_reg = %X", Ctrl_Reg);
 #endif