interrupt géré compil ok sans isr

Fork of T2_STM32 by Atechsys

Revision:
2:ab0ccf9bb38c
Parent:
1:979edb6d1559
Child:
5:d6484db1ec5c
diff -r 979edb6d1559 -r ab0ccf9bb38c main.cpp
--- a/main.cpp	Fri Dec 22 15:20:09 2017 +0000
+++ b/main.cpp	Sun Jan 14 15:50:49 2018 +0000
@@ -1,20 +1,81 @@
 #include "mbed.h"
 
-//SAVE_TEST 2
+  // Modification dans variant.h de la variable PWM_FREQUENCY afin de changer la fréquence par défaut du PWM
+
+//#include "StepperMotor.h"           // Classe Moteur pas à pas
+#include "Cylinder.h"
+#include "Carriage.h"
+#include "Lift.h"                   // Classe Ascenseur
+#include "Config.h"                 // Bibliothéque Configuration
 
-PwmOut mypwm(PWM_OUT);
+unsigned char Carriage_CurrentPos = 1, 
+              Lift_CurrentPos = 1,
+              RxdBuffer[2],         // Déclaration Buffer de réception
+              ActualAdress = 0,
+              Address = 0,
+              Command = 0,
+              Check_serial_is_OK,
+              State = 0;
+int           Sequence = 0,
+              i = 0,
+              j = 0;
+unsigned long CurrentMillis;        // Variable millis
+bool          test = true;
 
-DigitalOut myled(LED1);
+Lift Lift(Lift_pinUp, Lift_pinDown, Lift_UpSensor, Lift_MiddleSensor);                                                               //Appel de l'objet ascenseur
+Cylinder Cylinder(Cylinder_OriginSensor, Cylinder_StepPin, Cylinder_DirPin, Cylinder_EnablePin, Cylinder_PosMin, Cylinder_PosMax);   //Appel de l'objet barillet
+Carriage Carriage(Carriage_OriginSensor, Carriage_StepPin, Carriage_DirPin, Carriage_EnablePin, Carriage_PosMin, Carriage_PosMax);   //Appel de l'objet chariot
+
+void setup() {
+
+  Serial.begin(115200);                         // Port série pour communication avec Raspberry
+  
+  pinMode(Carriage_OriginSensor, INPUT_PULLUP);
+  pinMode(Buzzer_Output, OUTPUT);
+  pinMode(Cylinder_EnablePin, INPUT);
+  digitalWrite(Cylinder_DirPin, LOW);
+  Cylinder.Origin(Cylinder_OriginSensor);
+  
+}
+
+void loop() {
 
-int main() {
-    
-    mypwm.period_ms(10);
-    mypwm.pulsewidth_ms(1);
+// Remise à zéro des variables de communications à chaque boucle
+  Address = 0;    
+  Command = 0;
+  State = 0;
+  
+  ReadSerial();   // Lecture série
+
+  Address = RxdBuffer[0];
+  Command = RxdBuffer[1];
   
-    printf("pwm set to %.2f %%\n", mypwm.read() * 100);
-    
-    while(1) {
-        myled = !myled;
-        wait(1);
-    }
-}
+  Check_serial_is_OK = 0;
+  // Tester la trame recu
+  if ((Address != Start_Command) && (Command != Start_Command)){      // si la trame est correct (pas de 9 dans la commande ou l'adresse)   
+      Check_serial_is_OK = 1;
+  }
+  else{                                                               // si la trame est mauvaise, ou identique, ne rien faire dans le switch/case
+    Address = 0;
+  }
+
+//////////////////////////////////// DEV: Affichage de la trame reçue ////////////////////////////////////
+  Serial3.print("Reception : ");
+  Serial3.print(Start_Command);
+  Serial3.print(RxdBuffer[0]);
+  Serial3.println(RxdBuffer[1]);
+
+  digitalWrite(Buzzer_Output, HIGH);
+  delay(500);
+  digitalWrite(Buzzer_Output, LOW);
+  delay(500);
+  digitalWrite(Buzzer_Output, HIGH);
+  delay(500);
+  digitalWrite(Buzzer_Output, LOW);
+  delay(500);
+  digitalWrite(Buzzer_Output, HIGH);
+  delay(500);
+  digitalWrite(Buzzer_Output, LOW);
+  delay(500);
+  
+}
\ No newline at end of file