Acuqisition de valeur sous Interrupt
Dependents: souflerie-sp3-wifi-F411re-2
Revision 0:28e814664b6e, committed 2021-05-23
- Comitter:
- schnf30
- Date:
- Sun May 23 13:17:57 2021 +0000
- Commit message:
- Bouton
Changed in this revision
bouton.cpp | Show annotated file Show diff for this revision Revisions of this file |
bouton.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 28e814664b6e bouton.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bouton.cpp Sun May 23 13:17:57 2021 +0000 @@ -0,0 +1,41 @@ +#include "mbed.h" +#include "bouton.h" + +// Joystick Pins +InterruptIn up(A2); +InterruptIn down(D4); +InterruptIn left(A4); +InterruptIn right(A5); +volatile char DataEvent; // 0 pas de changement + +void Eventleft() +{ + DataEvent = AIp; +} +void Eventright() +{ + DataEvent = AIm; +} +void Eventup() +{ + DataEvent = VFAirp; +} +void Eventdown() +{ + DataEvent = VFAirm; +} +void InitBouton(void) +{ + up.rise(&Eventup); + down.rise(&Eventdown); + left.rise(&Eventleft); + right.rise(&Eventright); + + DataEvent = Nochange; +} +char EtatBouton(void) +{ + char temp = DataEvent; + DataEvent = Nochange; + return temp; +}
diff -r 000000000000 -r 28e814664b6e bouton.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bouton.h Sun May 23 13:17:57 2021 +0000 @@ -0,0 +1,10 @@ +#ifndef _bouton_h +#define _bouton_h +#define VFAirp 'F' +#define VFAirm 'G' +#define AIp 'm' +#define AIm 'n' +#define Nochange 0 +void InitBouton(void); +char EtatBouton(void); +#endif \ No newline at end of file