asser
Dependencies: mbed X_NUCLEO_IHM02A1
uart.cpp
00001 #include "mbed.h" 00002 00003 #define TAILLEWRITE 22 00004 #define TAILLEREAD 20 00005 Serial serial(PC_10,PC_11,115200); 00006 Serial pc(SERIAL_TX, SERIAL_RX, 115200); 00007 event_callback_t receptionCallback; 00008 bool consigne = false; 00009 00010 char bufferWrite[TAILLEWRITE] = "3.1415/15000/50000"; 00011 char bufferRead[TAILLEREAD]; 00012 00013 void recupererConsigne(int events); 00014 00015 void envoyerPosition() 00016 { 00017 serial.printf("%s", bufferWrite); 00018 } 00019 00020 int main() { 00021 00022 Ticker t; 00023 t.attach(&envoyerPosition, 0.1f); 00024 00025 receptionCallback.attach(recupererConsigne); 00026 serial.read((uint8_t*)bufferRead, TAILLEREAD, receptionCallback, SERIAL_EVENT_RX_COMPLETE); 00027 while(1) 00028 { 00029 pc.printf("Consigne lu : %s\n\r", bufferRead); 00030 if(consigne == true) 00031 { 00032 //pc.printf("Consigne lu : %s\n\r", bufferRead); 00033 consigne = false; 00034 } 00035 } 00036 } 00037 00038 00039 void recupererConsigne(int events) 00040 { 00041 consigne = true; 00042 serial.read((uint8_t*)bufferRead, TAILLEREAD, receptionCallback, SERIAL_EVENT_RX_COMPLETE); 00043 00044 }
Generated on Thu Jul 14 2022 05:39:00 by 1.7.2