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:
2:4f8eaf28aea5
Parent:
0:f812f3896eb5
--- a/main.cpp	Sun Jun 20 23:21:43 2021 +0000
+++ b/main.cpp	Wed Jun 23 09:36:43 2021 +0000
@@ -1,69 +1,27 @@
-/* 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°1 : Trame pour débuter
 
 #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;
+#include "system.h"
+#include "user.h"
 
 uint8_t compteur;
 
-// Blinking rate in milliseconds
-#define BLINKING_RATE_MS    500
-
-void Tache_Led_Ro(void) {
-    led_r = !led_r;
-}
-
-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);
+    Init_System();      // Initialisation du µC 
     compteur = 0;
 
-    while (true) {
-        led = !led;
+    while (1) {
+        thread_sleep_for(500);
         compteur++;
+        
         pc.printf("%d\r\n",compteur);
-        thread_sleep_for(BLINKING_RATE_MS);
+        DEL = !DEL;
     }
-    
-//   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);
-        }
-//        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);
-    }
-    */
 }