FabLab Nîmes / Mbed 2 deprecated FabLab_TP_05

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Giamarchi
Date:
Fri Dec 17 01:16:38 2021 +0000
Parent:
1:95172f59262a
Commit message:
TP 05

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	Fri Dec 17 01:16:38 2021 +0000
@@ -1,145 +1,47 @@
-/*************************************/
-//  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 : 6 janv. 2022
+//  TP 05 : Mesure de la température par une résistance CTN de 4,7k Ohm
+//  Affichage de la température sur le PC
+//==============================================================================
+//              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);
-
-DigitalIn BTN3(PC_6);
-DigitalIn BTN4(PC_5);
-
-//DigitalOut BZ(PC_7);
-
-//uint8_t L[8] = {L0, L1, L2, L3, L4, L5, L6, L7};
-
-void set_8Dels(uint8_t position)
-{
-    L0 = position & 0x01;
-    L1 = position & 0x02;
-    L2 = position & 0x04;
-    L3 = position & 0x08;
-    L4 = position & 0x10;
-    L5 = position & 0x20;
-    L6 = position & 0x40;
-    L7 = position & 0x80;
-}
+//==============================================================================
+//              Déclaration des broches
+DigitalOut  DEL(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
 
-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)
-{
-uint8_t etat_BTN3 = 0;      // variable état BTN3 à 0 par défaut
+//==============================================================================
+//              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;                        // variable de type entier (0 à 65535)
+
+//==============================================================================
+//              Début du Programme
+int main()                              // Fonction principale
+{ 
+    pc.printf("\r\nFabLab TP 5\r\n\n");
+    temp = 0;
     
-    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      ****************/
+//  Mesure de la tension analogique issue de la résistance CTN 4,7kΩ
 
-        wait_ms(10);                // Execution toutes les 10 ms
-        compteur++;                 // Incrémente un compteur temps
+//  Linéarisation de la courbe et correction
+
+//  Affichage sur le PC
+        pc.printf("%.1f C\r\n",temp);           // format : 10,3 C
         
-        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	Fri Dec 17 01:16:38 2021 +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