UART Driver to receive asynchronous Serial Comms from a Raspberry Pi and parse the results.
SerialComms.cpp
- Committer:
- sk398
- Date:
- 2016-03-04
- Revision:
- 6:74b5ac7719f4
- Parent:
- 4:85353bd571f2
- Child:
- 7:34c5934a01f0
File content as of revision 6:74b5ac7719f4:
/* ##################################################################### SerialComms.cpp --------------- Surface Ship, Group 5 --------------------- Written by: Steven Kay Date: February 2016 Function: This Version: 1.0 Version History --------------- 1.1 rgdfgdfgdfggdfgdg 1.0 gdgddfdddgd ##################################################################### */ #include "mbed.h" #include "SerialComms.h" SerialComms::SerialComms(PinName tx,PinName rx) { _HLC_Conn = new RawSerial(tx,rx); _HLC_Conn-> baud(SERIAL_BAUD_RATE); _HLC_Conn -> format(8,SerialBase::None,1); _HLC_Conn -> attach(this,&SerialComms::incomingDataISR,RawSerial::RxIrq); incomingDataUpdate = FALSE; } void SerialComms::incomingDataISR() { receiverBuffer = _HLC_Conn -> getc(); incomingDataUpdate = TRUE; } uint8_t SerialComms::getCommData() { if(incomingDataUpdate == TRUE) { incomingDataUpdate = FALSE; return receiverBuffer; } else { return 0xFF; } }