Acuqisition de valeur sous Interrupt
Dependents: souflerie-sp3-wifi-F411re-2
Diff: bouton.cpp
- Revision:
- 0:28e814664b6e
--- /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; +}