asser
Dependencies: mbed X_NUCLEO_IHM02A1
Diff: uart.cpp
- Revision:
- 5:bbca34b60427
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/uart.cpp Sun May 19 20:09:32 2019 +0000 @@ -0,0 +1,44 @@ +#include "mbed.h" + +#define TAILLEWRITE 22 +#define TAILLEREAD 20 +Serial serial(PC_10,PC_11,115200); +Serial pc(SERIAL_TX, SERIAL_RX, 115200); +event_callback_t receptionCallback; +bool consigne = false; + +char bufferWrite[TAILLEWRITE] = "3.1415/15000/50000"; +char bufferRead[TAILLEREAD]; + +void recupererConsigne(int events); + +void envoyerPosition() +{ + serial.printf("%s", bufferWrite); +} + +int main() { + + Ticker t; + t.attach(&envoyerPosition, 0.1f); + + receptionCallback.attach(recupererConsigne); + serial.read((uint8_t*)bufferRead, TAILLEREAD, receptionCallback, SERIAL_EVENT_RX_COMPLETE); + while(1) + { + pc.printf("Consigne lu : %s\n\r", bufferRead); + if(consigne == true) + { + //pc.printf("Consigne lu : %s\n\r", bufferRead); + consigne = false; + } + } +} + + +void recupererConsigne(int events) +{ + consigne = true; + serial.read((uint8_t*)bufferRead, TAILLEREAD, receptionCallback, SERIAL_EVENT_RX_COMPLETE); + +} \ No newline at end of file