![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
version with updated libs
Dependencies: F7_Ethernet mbed MbedJSONValue LCD_DISCO_F746NG mbed-rtos BSP_DISCO_F746NG CANMsg NetworkAPI SDFileSystem_Warning_Fixed GroveStreamsmodified LcdDiscoF746NgTracer JSON
Diff: ManageBufferJPA.cpp
- Branch:
- jpa
- Revision:
- 3:2de8e4771674
- Child:
- 4:fbbf5d1785e7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ManageBufferJPA.cpp Wed Sep 02 12:54:45 2020 +0000 @@ -0,0 +1,65 @@ +#include "mbed.h" + +const int kMaxBufferSize = 125; +volatile char bufferSerialUSB[kMaxBufferSize+3]; +volatile int idxSerialIntUSB = 0; +int idxSerialUserUSB = 0; +volatile int msgSerialUSB = 0; + +//RawSerial +RawSerial serialUSB(USBTX, USBRX); // serial PC +Serial serial2(PC_6, PC_7); // TX, RX for udp bridge +Serial serial7(PF_7, PF_6); // TX, RX for extension +volatile char x; +// --------------------------------------------------- +void serialUSB_int_recv() +{ + if(serialUSB.readable()) + { + bufferSerialUSB[idxSerialIntUSB]=(serialUSB.getc()); + idxSerialIntUSB++; + if (idxSerialIntUSB >= kMaxBufferSize) {idxSerialIntUSB = 0;} + bufferSerialUSB[idxSerialIntUSB]= 0; + msgSerialUSB = 1; + } + return; +} + +void initSerial() + { + serialUSB.baud(115200); + serialUSB.attach(&serialUSB_int_recv, Serial::RxIrq); + serial2.baud(115200); // required for UDP bridge + serial7.baud(115200); // required for tasmota + //serial7.attach(&pc_recv, Serial::RxIrq); + + bufferSerialUSB[0] = '\0'; + + } + +void sendSerialUSB(char * str) + { + serialUSB.printf(str); + } + +void receiveSerialUSB() + { + while(idxSerialIntUSB != idxSerialUserUSB) + { + x=bufferSerialUSB[idxSerialUserUSB]; + printf("%c",x); + idxSerialUserUSB = idxSerialUserUSB + 1; + if (idxSerialUserUSB >= kMaxBufferSize) {idxSerialUserUSB = 0;} + } + msgSerialUSB = 0; + } + +void sendserial2(char * str) + { + serial2.printf(str); + } + +void sendserial7(char * str) + { + serial7.printf(str); + } \ No newline at end of file