Joel Manuel Fernandez Cuyubamba
/
Partie4
TD
exercice4.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 | /* |
jomfec | 0:e54fcd358582 | 2 | #include "mbed.h" |
jomfec | 0:e54fcd358582 | 3 | Ticker flipper1; //déclaration du premier Ticker |
jomfec | 0:e54fcd358582 | 4 | Ticker flipper2; //déclaration du deuxième Ticker |
jomfec | 0:e54fcd358582 | 5 | DigitalOut sortie1(p5); |
jomfec | 0:e54fcd358582 | 6 | DigitalOut sortie2(p6); |
jomfec | 0:e54fcd358582 | 7 | void task1() ; //prototypes |
jomfec | 0:e54fcd358582 | 8 | void task2() ; |
jomfec | 0:e54fcd358582 | 9 | int main() { |
jomfec | 0:e54fcd358582 | 10 | flipper1.attach(&task1, 0.2); //task1 appelée toutes les 200ms |
jomfec | 0:e54fcd358582 | 11 | flipper2.attach(&task2, 1.0); //task2 appelée toutes les 1s |
jomfec | 0:e54fcd358582 | 12 | while(1) { |
jomfec | 0:e54fcd358582 | 13 | wait(0.2); |
jomfec | 0:e54fcd358582 | 14 | } |
jomfec | 0:e54fcd358582 | 15 | } |
jomfec | 0:e54fcd358582 | 16 | // Corps des fonctions task1 et task2 |
jomfec | 0:e54fcd358582 | 17 | void task1(void){ |
jomfec | 0:e54fcd358582 | 18 | sortie1.write(!sortie1.read()); // inversion de la sortie1 |
jomfec | 0:e54fcd358582 | 19 | } |
jomfec | 0:e54fcd358582 | 20 | void task2(void){ |
jomfec | 0:e54fcd358582 | 21 | sortie2.write(!sortie2.read()); // inversion de la sortie2 |
jomfec | 0:e54fcd358582 | 22 | } |
jomfec | 0:e54fcd358582 | 23 | */ |