
TD
exercice3.cpp@0:e54fcd358582, 2016-05-02 (annotated)
- Committer:
- jomfec
- Date:
- Mon May 02 09:05:23 2016 +0000
- Revision:
- 0:e54fcd358582
INFO2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jomfec | 0:e54fcd358582 | 1 | #include "mbed.h" |
jomfec | 0:e54fcd358582 | 2 | /* |
jomfec | 0:e54fcd358582 | 3 | Timer timer1; |
jomfec | 0:e54fcd358582 | 4 | Timer timer2; // définition des timers |
jomfec | 0:e54fcd358582 | 5 | DigitalOut sortie1(p5); |
jomfec | 0:e54fcd358582 | 6 | DigitalOut sortie2(p6); |
jomfec | 0:e54fcd358582 | 7 | void task1(void); // prototype de tâche1 |
jomfec | 0:e54fcd358582 | 8 | void task2(void); // prototype de tâche2 //... |
jomfec | 0:e54fcd358582 | 9 | int main() { |
jomfec | 0:e54fcd358582 | 10 | timer1.start(); // déclenchement du timer1 |
jomfec | 0:e54fcd358582 | 11 | timer2.start(); // déclenchement du timer2 |
jomfec | 0:e54fcd358582 | 12 | while(1) { |
jomfec | 0:e54fcd358582 | 13 | if (timer1.read_ms()>=200) // lecture du temps du timer1 |
jomfec | 0:e54fcd358582 | 14 | { |
jomfec | 0:e54fcd358582 | 15 | task1(); // appel de la fonction liée au timer1 |
jomfec | 0:e54fcd358582 | 16 | timer1.reset(); // remise à zéro du timer1 |
jomfec | 0:e54fcd358582 | 17 | } |
jomfec | 0:e54fcd358582 | 18 | if (timer2.read_ms()>=1000) // lecture du temps du timer2 |
jomfec | 0:e54fcd358582 | 19 | { |
jomfec | 0:e54fcd358582 | 20 | task2(); // appel de la fonction liée au timer2 |
jomfec | 0:e54fcd358582 | 21 | timer2.reset(); // remise à zéro du timer2 |
jomfec | 0:e54fcd358582 | 22 | } |
jomfec | 0:e54fcd358582 | 23 | } |
jomfec | 0:e54fcd358582 | 24 | } |
jomfec | 0:e54fcd358582 | 25 | // Corps des fonctions task1 et task2 |
jomfec | 0:e54fcd358582 | 26 | void task1(void){ |
jomfec | 0:e54fcd358582 | 27 | sortie1.write(!sortie1.read()); // inversion de la sortie1 |
jomfec | 0:e54fcd358582 | 28 | } |
jomfec | 0:e54fcd358582 | 29 | void task2(void){ |
jomfec | 0:e54fcd358582 | 30 | sortie2.write(!sortie2.read()); // inversion de la sortie2 |
jomfec | 0:e54fcd358582 | 31 | } |
jomfec | 0:e54fcd358582 | 32 | */ |