IniSat Modèle 1 Version 2 TP 1 : Mise en oeuvre de la carte Nucléo 32 Exo 1 : Hello Word Exo 2 : Lecture vitesse de l'horloge Exo 3 : Clignotement asynchrone de 2 Dels

Revision:
3:b869fd151c26
Parent:
0:f812f3896eb5
--- a/main.cpp	Sun Jun 20 23:21:43 2021 +0000
+++ b/main.cpp	Wed Jun 23 09:46:55 2021 +0000
@@ -1,69 +1,86 @@
-/* mbed Microcontroller Library
- * Copyright (c) 2019 ARM Limited
- * SPDX-License-Identifier: Apache-2.0
- */
+/*******************************************************************************
+    Université de Montpellier
+    NemoSpace   IUT de Nîmes
+    IniSat Modèle 1 Version 2
+*******************************************************************************/
+//      TP n°3 : Trame pour débuter
+
+//  Exo 1 : Lecture tension batterie
+//  Exo 2 : Lecture courants faces solaires
+//  Exo 3 : Modes de fonctionnement
 
 #include "mbed.h"
 #include "platform/mbed_thread.h"
-
-Serial pc(USBTX, USBRX);        // Dialogue UART par USB à 9600 Baud
-// Initialise the digital pin LED1 as an output
-DigitalOut led(LED1);           // Ligne PB_3 sur carte Nucléo
-DigitalOut led_r(PB_0);         // Del rouge carte CPU
-DigitalOut led_v(PB_1);         // Del verte carte CPU
-//PwmOut servo(PB_0);
-
-Ticker Synchro_Led_Ro;
-Ticker Synchro_Led_Ve;
-
-uint8_t compteur;
+#include "system.h"
+#include "user.h"
 
-// Blinking rate in milliseconds
-#define BLINKING_RATE_MS    500
-
-void Tache_Led_Ro(void) {
-    led_r = !led_r;
-}
+uint8_t etat, etat_mem;
+float mes_accu;
 
-void Tache_Led_Ve(void) {
-    led_v = !led_v;
-}
-
-int main()
-{
-    pc.printf("\r\nIniSat V2 : TP1\r\n\n");     // Hello World
-    Synchro_Led_Ro.attach(&Tache_Led_Ro,1);
-    thread_sleep_for(150);
-    Synchro_Led_Ve.attach(&Tache_Led_Ve,0.33);    
+int main() {
     
-    //  Test de l'horloge Systeme
-    pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock);
-    compteur = 0;
+    Init_System();
+    etat = 0;
+
+    while (1) {
+        thread_sleep_for(1);        // Boucle toutes les 1 milliseconde environ
+        
+//      Gestion des modes avec une machine d'états      
+        switch (etat)
+        {
+/******************************************************************************/
+// Mode Init :      Mise sous tension
+//                  Initialisation du µC
+
+            case 0:
+
+                break;
+/******************************************************************************/            
+//  Mode Gestion :  Gestion des actions
+//                  Contrôle du système
+
+            case 1:
+  
+                break;
+/******************************************************************************/            
+//  Mode Mission :  Acquisition de données (Mesure Courant faces solaires)
+//                  Stockage
+
+            case 2:
+
+                break;
+/******************************************************************************/             
+//  Mode Radio :    Transmission de données
 
-    while (true) {
-        led = !led;
-        compteur++;
-        pc.printf("%d\r\n",compteur);
-        thread_sleep_for(BLINKING_RATE_MS);
-    }
-    
-//   servo.period_ms(20);            //Period = 20 ms (f=50 Hz)
-    
-/*    while(true) {    
-        for(int pw=1000; pw <= 2000; pw=pw+20) {
-            servo.pulsewidth_us(pw);    //Set new servo position
-//            wait_ms(200);
-            thread_sleep_for(200);
+            case 3:
+
+                break;  
+/******************************************************************************/             
+//  Mode Survie :   Attente recharge de l'accu
+                    
+            case 4:
+
+                break;
+/******************************************************************************/
+//  Mode Zombie :   Coupure des consommateurs
+//                  Passage en mode faible consommation
+//                  Diminution de la fréquence du CPU
+//                  passage en mode Sleep
+
+            case 5:
+
+                break;
+/******************************************************************************/
+            default:
+                etat = 0;
+                break;
+/******************************************************************************/          
+        }   // end switch
+        if(etat != etat_mem)            //  Debug des états
+        {
+            pc.printf("Etat_%d\r\n",etat);
+            etat_mem = etat;
         }
-//        wait_ms(1000);                  //Wait before reverse direction
-        thread_sleep_for(1000);
-        for(int pw=2000; pw >= 1000; pw=pw-20) {
-            servo.pulsewidth_us(pw);    //Set new servo position
-//            wait_ms(200);
-            thread_sleep_for(200);
-        }
-//        wait_ms(1000);
-        thread_sleep_for(1000);
-    }
-    */
-}
+    }   // end while
+}   // end main
+/******************************************************************************/  
\ No newline at end of file