Space / Mbed 2 deprecated SITAEL_LED-Button_Polling

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
pinofal
Date:
Wed Jun 01 10:40:15 2022 +0000
Parent:
2:8cd95bea99dc
Commit message:
Test linee di connessione MIMA-STM32-SC

Changed in this revision

LED-Button-Polling.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/LED-Button-Polling.cpp	Sun Jul 01 11:30:52 2018 +0000
+++ b/LED-Button-Polling.cpp	Wed Jun 01 10:40:15 2022 +0000
@@ -5,7 +5,13 @@
 // crea oggetti Button, LED e serialPC  
 DigitalIn myButton(USER_BUTTON);
 DigitalOut myLed(LED1);
-Serial pc(USBTX, USBRX); 
+DigitalIn InMIMA(PA_0); //PC_1; PB_0; PA_1; PA_0
+DigitalOut OutSC(PC_0); 
+DigitalIn InSC(PA_10); 
+DigitalOut OutMIMA(PA_9); //PB_3; PB_6; PC_7; PA_9 
+
+
+Serial pc(USBTX, USBRX, 921600); 
 
 
 /********/
@@ -13,28 +19,57 @@
 /********/
 int main() 
 {
-    // imposta velocità della comunicazione con il PC
-    pc.baud(921600);
+    // messaggio di benvenuto
+    pc.printf("\r\nHello World \r\n");
+    myLed = 1; // Accendi LED
+    wait_ms(1000);
+    myLed = 0; // Accendi LED
+    wait_ms(1000);
+
     
-    // messaggio di benvenuto
-    pc.printf("\r\nHallo Amaldi Students - Exercise 3 \r\n");
-  
     //imposta il funzionamento del pulsante come "PullDown": Aperto = '0'. L'altra modalità di funzinamento è PullUp
-    myButton.mode(PullDown);
+    myButton.mode(PullUp);
+    InMIMA.mode(PullUp);
+    InSC.mode(PullUp);
   
     // POLLING: replica sul LED myLED lo stato del pulsante myButton
     while(true) 
     {
-        if (myButton == 1) 
-        { 
+        //+++++ INIZIO Comunicazione da STM32 verso MIMA ++++++++++++++
+        OutSC=myButton;
+        if (InMIMA == 0) 
+        {
             // Button is pressed
             myLed = 1; // Accendi LED
+            pc.printf("InMIMA = 0 \r\n");
         }
         else 
         {
             // Button i released
             myLed = 0; // Spegni LED
+            pc.printf("InMIMA = 1 \r\n");
         }
+        //+++++ FINE Comunicazione da STM32 verso MIMA ++++++++++++++        
+        
+        //+++++ INIZIO Comunicazione da S/C verso STM32 ++++++++++++++
+        OutMIMA=myButton;
+        if (InSC == 0) 
+        {
+            // Button is pressed
+            myLed = 1; // Accendi LED
+            pc.printf("InSC = 0 \r\n");
+        }
+        else 
+        {
+            // Button i released
+            myLed = 0; // Spegni LED
+            pc.printf("InSC = 1 \r\n");
+        }
+        //+++++ FINE Comunicazione da S/C verso STM32 ++++++++++++++
+        
+        pc.printf("\r\n"); // per facilità di lettura
+        wait_ms(200);
+        
     }
-}
- 
\ No newline at end of file
+    
+ }
\ No newline at end of file