UART Driver to receive asynchronous Serial Comms from a Raspberry Pi and parse the results.
Diff: SerialComms.cpp
- Revision:
- 2:cb74b330b285
- Parent:
- 1:bf3fb80028d8
- Child:
- 3:b608ee5b9b5d
diff -r bf3fb80028d8 -r cb74b330b285 SerialComms.cpp --- a/SerialComms.cpp Mon Feb 15 19:59:59 2016 +0000 +++ b/SerialComms.cpp Mon Feb 15 20:09:32 2016 +0000 @@ -7,15 +7,16 @@ _HLC_Conn-> baud(SERIAL_BAUD_RATE); _HLC_Conn -> format(8,SerialBase::None,1); - _HLC_Conn -> attach(this,&SerialComms::incoming,Serial::RxIrq); + _HLC_Conn -> attach(this,&SerialComms::incomingDataISR,Serial::RxIrq); - dataUpdate = FALSE; + incomingDataUpdate = FALSE; } -void SerialComms::incoming() +void SerialComms::incomingDataISR() { int a = 0; + dataCheck = 0; for(uint8_t charCount=0; charCount<(2*NUM_BYTES_RECEIVING); charCount++) { if((charCount%2) == 1) @@ -25,10 +26,10 @@ } else { - _HLC_Conn -> getc(); + dataCheck += _HLC_Conn -> getc(); } } - dataUpdate = TRUE; + incomingDataUpdate = TRUE; // for(int c = 0; c < 4; c++) // { @@ -38,9 +39,9 @@ int *SerialComms::returnMotorSpeeds() { - if(SerialComms::dataUpdate == TRUE) + if(SerialComms::incomingDataUpdate == TRUE && dataCheck == 10) { - SerialComms::dataUpdate = FALSE; + SerialComms::incomingDataUpdate = FALSE; return receiverBuffer; } else