X2D lib first commit

Revision:
24:eac91efdc315
Parent:
23:87c967bdb0ff
Child:
25:28895e3d96c5
--- a/X2D.cpp	Wed Jan 06 10:28:06 2021 +0000
+++ b/X2D.cpp	Mon Apr 19 14:19:33 2021 +0000
@@ -11,19 +11,19 @@
 
 
 DigitalOut Reg_Data(PC_1);  // Jaune
-DigitalOut RxTx(PC_0);      // Violet?
+DigitalOut RxTx(PC_0, 0);   // Violet? , reset to force Application mode (not FBL)
 DigitalOut Tx(PA_9);        // Noir
-DigitalOut UART(PA_0, 1);   // Rouge
+DigitalOut UART(PA_0, 1);   // Rouge, set to UART mode
 
-//DigitalIn CD(PC_0);         // Bleu
+//DigitalIn CD(PC_0);       // Bleu
 //DigitalIn Rx(PB_7);       // Vert
-//DigitalIn BU(PA_4);         // Blanc
+//DigitalIn BU(PA_4);       // Blanc
 DigitalIn CLR(PA_1);        // Orange
 DigitalIn RSTO(PC_2);       // Gris
 
 InterruptIn Rx(PB_7, PullUp);
 
-PlatformMutex sendbit_mutex;
+//PlatformMutex sendbit_mutex;
 
 pulse_t timeDiff;
 CircularBuffer<pulse_t, BUF_SIZE> PulseWidth;
@@ -180,7 +180,8 @@
 int i;
 
     //pc.printf("\r\n");
-    Tx=1;
+// EM 20210117 remove to avoid glitch (tested)
+//    Tx=1;
     for(i=0; i<17; i++)
         SendBit(0);
     for(i=0; i<6; i++)
@@ -206,9 +207,8 @@
 int i, chksum=0;
 
     RxTx = 0;       //set pin rxtx to Tx
-    Tx=0;
-//    wait_us(500);
-    //wait_ms(1);
+// EM removed 20210117 don't need since it is already set to 1 at the end
+//    Tx=0;
 
     SendPreamble();
 
@@ -223,9 +223,10 @@
     SendByte((char)chksum);
     SendPostamble();
 
-//    Tx=1;
+    RxTx = 1;       //set pin rxtx to Rx
 
-    RxTx = 1;       //set pin rxtx to Rx
+//EM 20210117 Always finish then restart with Tx=1 (tested)
+    Tx=1;
     //pc.printf("\r\n");
 }
 
@@ -266,10 +267,11 @@
     msg.data[6] = (char)prog;
     msg.data[7] = 0x64;
 
+    msg.length = 8;
+
     for(i=0; i<3; i++)
         {
         msg.data[5]=i;     //message count
-        msg.length = 8;
         MessageTx.push(msg);
         //wait_ms(30);
         }