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
main.cpp
- Committer:
- Giamarchi
- Date:
- 2021-06-20
- Revision:
- 0:f812f3896eb5
- Child:
- 1:5fa10ee92f94
- Child:
- 2:4f8eaf28aea5
- Child:
- 3:b869fd151c26
File content as of revision 0:f812f3896eb5:
/* mbed Microcontroller Library * Copyright (c) 2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 */ #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; // 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); // Test de l'horloge Systeme pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock); compteur = 0; 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); } // 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); } */ }