Enzo Grimeau
/
buffertest
test pour buffer
main.cpp
- Committer:
- gr91
- Date:
- 2020-11-23
- Revision:
- 10:8895b56c630c
- Parent:
- 9:a9dfb95b5d8a
- Child:
- 11:f6ca29fae30c
File content as of revision 10:8895b56c630c:
#include "mbed.h" // Echo avec buffer circulaire // lien serie via USB avec Terarerm // Universite Paris-Saclay - IUT Cachan RawSerial pc_raw(USBTX, USBRX); // ou SERIAL-TX, SERIAL_RX ou PA_2,PA_3 CircularBuffer < char, 1024> mon_buffer; // buffer circulaire de 1024 char DigitalOut ledB(D8); void reception_symbole(void); int main() { char symbole; pc_raw.baud(115200); pc_raw.attach(&reception_symbole); pc_raw.printf("Echo test buffer circulaire\r\n"); ledB=0; mon_buffer.reset(); while(1) { while(!mon_buffer.empty()) { mon_buffer.pop(symbole); pc_raw.putc(symbole); } } } void reception_symbole(void) { char symbole; if(pc_raw.readable()) { ledB=!ledB; symbole=pc_raw.getc(); mon_buffer.push(symbole); } }