michael hollegha
/
ScanfNonBlocking
Non Blocking ReadCString
Fork of ProcVisDemo by
Diff: ScanfNonBlocking.cpp
- Revision:
- 2:c7dac33300a8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ScanfNonBlocking.cpp Thu Apr 07 09:51:06 2016 +0000 @@ -0,0 +1,45 @@ + +#include "mbed.h" +#include "BtnEventM0.h" +#include "Serial_HL.h" + +SerialBLK pc(USBTX, USBRX); +SvProtocol ua0(&pc); + +// LSB MSB +BusOut lb(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1); + +char txt[30]; + +void Blinker(); Timer t1; + +int main() +{ + t1.start(); + lb = 0; + pc.format(8,SerialBLK::None,1); pc.baud(115200); + + while(1) + { + Blinker(); + if( pc.IsDataAvail() ) { + ua0.ReadCString(txt,'\n'); + strcat(txt,"\n"); + ua0.Puts(txt); + } + } +} + + +void Blinker() +{ + if( t1.read_ms()<200 ) + return; + t1.reset(); + if( !lb ) + lb = 0x000F; + else + lb = 0; +} + +