FabLab Nîmes / Mbed 2 deprecated FabLab_TP_06

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Giamarchi
Date:
Thu Feb 03 17:52:19 2022 +0000
Parent:
1:95172f59262a
Commit message:
Timer

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Jan 15 15:55:11 2019 +0000
+++ b/main.cpp	Thu Feb 03 17:52:19 2022 +0000
@@ -1,145 +1,60 @@
-/*************************************/
-//  YNCREA ISEN Nîmes
-//  CSI3 Electronique Numérique
-//
-//  Cours : Systèmes à microcontrôleur
-//  Prof : Frédéric Giamarchi
-//
-//  Date : 15 janv 2019
-//  Test TP 01 : Controle de 8 Dels par 2 Boutons poussoir
-/*************************************/
+//==============================================================================
+//  FabLab Nîmes
+//  Initiation à la Programmation
+//  Auteur : Frédéric Giamarchi
+
+//  Date : 21 janv. 2022
+//  TP : 
+//  Test des Timers
+//==============================================================================
+//              Déclarations des ressources
 #include "mbed.h"
 
-DigitalOut L0(PB_1);
-DigitalOut L1(PB_2);
-DigitalOut L2(PB_10);
-DigitalOut L3(PB_11);
-DigitalOut L4(PB_12);
-DigitalOut L5(PB_13);
-DigitalOut L6(PB_14);
-DigitalOut L7(PB_15);
+Timer t;
 
-DigitalIn BTN3(PC_6);
-DigitalIn BTN4(PC_5);
+//==============================================================================
+//              Déclaration des broches
+DigitalOut  DEL_RO(PA_11);              // Ligne PA_11 sur la carte Nucléo
+Serial      pc(USBTX, USBRX);           // Dialogue Série port USB à 9600 Baud
+AnalogIn    POT(PA_0);                  // Ligne PA_0 en entrée analogique
 
-//DigitalOut BZ(PC_7);
+//==============================================================================
+//              Déclaration des variables
+uint8_t variable;                        // variable de type entier (0 à 255)
+char c;                                 // variable de type caractère
+float temp;                           // variable de type réel
+uint16_t mesure;
 
-//uint8_t L[8] = {L0, L1, L2, L3, L4, L5, L6, L7};
-
-void set_8Dels(uint8_t position)
+//==============================================================================
+//              Déclaration des Fonctions
+void Ma_Fonction(void)
 {
-    L0 = position & 0x01;
-    L1 = position & 0x02;
-    L2 = position & 0x04;
-    L3 = position & 0x08;
-    L4 = position & 0x10;
-    L5 = position & 0x20;
-    L6 = position & 0x40;
-    L7 = position & 0x80;
+    variable = 0;
 }
 
-uint8_t ptr_3 = 0;
-uint8_t ptr_4 = 0;
-uint8_t pointeur = 1;
-uint8_t compteur = 0;
-uint8_t etat_del = 0;
-/***********************************************/
-// Fonction Appui_BTN3
-// Renvoie l'état actif ou relaché du bouton poussoir BTN3
-uint8_t Appui_BTN3(void)
+//==============================================================================
+//              Début du Programme
+int main()                              // Fonction principale
 {
-uint8_t etat_BTN3 = 0;      // variable état BTN3 à 0 par défaut
+// Autres valeurs standard : 9600 19200 38400 57600 115200
+    pc.baud(38400);
+    pc.printf("\r\nFabLab TP Test Timer\r\n\n");
+    variable = 0;
+//  Test de l'horloge Systeme
+    pc.printf("Horloge CPU a %d Hz\r\n", SystemCoreClock);
+
+    t.start();                          // Compteur activé
+// 10 caractères, chaque caractère compte 10 bits (8 + 1 bit de start et 1 bit de stop)
+    pc.printf("Bonjour !\n");
+    t.stop();                           // Compteur stoppé
+    pc.printf("Duree du texte : %f s\n",t.read());
     
-    if(!BTN3)               // Test appui sur BTN3
-    {
-        wait(0.2);          // tempo d'anti rebond
-        etat_BTN3 = 1;       // variable à 1
-    }
-    return etat_BTN3;       // La fonction renvoie la valeur 0 ou 1
-}
-/***********************************************/
-// Fonction Appui_BTN4
-// Renvoie l'état actif ou relaché du bouton poussoir BTN4
-uint8_t Appui_BTN4(void)
-{
-uint8_t etat_BTN4 = 0;
-    
-    if(!BTN4)
-    {
-        wait(0.2);
-        etat_BTN4 = 1;
-    }
-    return etat_BTN4;    
-}
-/***********************************************/
-int main()
-{ 
+//==============================================================================
+//              Boucle Infinie
     while(1)
     {
-/********       Question 1      ****************/
-/*
-        L0 = Appui_BTN3();          // Contrôle L0 par BTN3
-*/
-/********       Question 2      ****************/   
-/*
-        if(Appui_BTN3())
-        {
-            pointeur <<=1;          // Décalage vers la gauche
-            if(pointeur == 0)       // Test Limite gauche
-                pointeur = 0x80;    // Blocage
-            set_8Dels(pointeur);    // Affichage
-        }
-*/
-/********       Question 3      ****************/
-/*
-        if(Appui_BTN4())
-        {
-            pointeur >>=1;          // Décalage vers la droite
-            if(pointeur == 0)       // Test Limite droite
-                pointeur = 1;       // Blocage
-            set_8Dels(pointeur);
-        }
-*/
-/********       Question 4      ****************/
-
-        wait_ms(10);                // Execution toutes les 10 ms
-        compteur++;                 // Incrémente un compteur temps
         
-        if(Appui_BTN3())
-        {
-            ptr_3++;                // incrémente un pointeur
-            compteur = 0;           // RAZ compteur temps
-        }
-/********       Question 5      ****************/ 
-    
-        if(Appui_BTN4())
-        {
-            ptr_4++;
-            compteur = 0;
-        }    
-/********       Question 4 et 5     ****************/
-
-        if(compteur == 100)         // Est-ce que cela fait 1 sec
-        {
-            if(ptr_3 != 0)          // Test pointeur 3 -> Question 4
-            {
-                // Masque OU logique avec etat_Del
-                // Le masque est un décalage vers la gauche d'un 1 logique
-                // Le nombre de décalage est défini par le pointeur
-                etat_del = etat_del | 1<<(ptr_3 - 1); 
-                ptr_3 = 0;              // Pointeur à 0
-            }  
-            if(ptr_4 != 0)          // Test pointeur 4 -> Question 5
-                // Masque ET logique avec etat_Del
-                // Le masque est un décalage vers la gauche d'un 1 logique
-                // Le nombre de décalage est défini par le pointeur
-                // Ensuite le résultat du masque est inversé
-                etat_del = etat_del & ~(1<<ptr_4 - 1);
-            ptr_4 = 0;
-                 
-            set_8Dels(etat_del);
-        }   
-/***********************************************/
     }           // Fin du while(1)
-}               // Fin du main()
-/***********************************************/
\ No newline at end of file
+//==============================================================================
+}               // Fin du Programme
+//==============================================================================
\ No newline at end of file
--- a/mbed.bld	Tue Jan 15 15:55:11 2019 +0000
+++ b/mbed.bld	Thu Feb 03 17:52:19 2022 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file