Microcontrôleur de commande des E/S de la voiture

Files at this revision

API Documentation at this revision

Comitter:
ajuton
Date:
Fri Apr 01 16:25:01 2022 +0000
Parent:
107:0965c72c798e
Commit message:
sans la led !

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0965c72c798e -r 0fbfc4b71626 main.cpp
--- a/main.cpp	Thu Mar 24 21:23:09 2022 +0000
+++ b/main.cpp	Fri Apr 01 16:25:01 2022 +0000
@@ -21,7 +21,7 @@
 DigitalIn BP1(D2);
 DigitalIn BP2(D3);
 
-DigitalOut led(LED1);
+//DigitalOut led(LED1);
 
 static BufferedSerial serial_port(USBTX, USBRX,115200);
 SPISlave device(D11, D12, D13, A3); // mosi, miso, sclk, ssel
@@ -72,10 +72,14 @@
         
         if (device.receive()) {
             int v = device.read();   // Read byte from master
-            v = (v + 1) % 0x100;     // Add one to it, modulo 256
-            device.reply(v);         // Make this the next reply
+            //v = (v + 1) % 0x100;     // Add one to it, modulo 256
+            //device.reply(v);         // Make this the next reply
             sprintf(text,"valeur du caractere recu SPI : %d\n\r",v);
             serial_port.write(text,strlen(text));
+            if(v=='a')
+                led = 1;
+            else if (v=='e')
+                led = 0;
         }
         
         bp1_old = bp1;