Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SerialComms.cpp
00001 /* ##################################################################### 00002 SerialComms.cpp 00003 --------------- 00004 00005 Surface Ship, Group 5 00006 --------------------- 00007 00008 Written by: Steven Kay 00009 00010 Date: February 2016 00011 00012 Function: This 00013 00014 Version: 1.0 00015 00016 Version History 00017 --------------- 00018 00019 1.1 rgdfgdfgdfggdfgdg 00020 00021 1.0 gdgddfdddgd 00022 00023 ##################################################################### */ 00024 00025 #include "mbed.h" 00026 #include "SerialComms.h" 00027 00028 SerialComms::SerialComms(PinName tx,PinName rx) 00029 { 00030 _HLC_Conn = new RawSerial(tx,rx); 00031 _HLC_Conn-> baud(SERIAL_BAUD_RATE); 00032 _HLC_Conn -> format(8,SerialBase::None,1); 00033 00034 _HLC_Conn -> attach(this,&SerialComms::incomingDataISR,RawSerial::RxIrq); 00035 00036 incomingDataUpdate = FALSE; 00037 } 00038 00039 void SerialComms::incomingDataISR() 00040 { 00041 receiverBuffer = _HLC_Conn -> getc(); 00042 incomingDataUpdate = TRUE; 00043 } 00044 00045 uint8_t SerialComms::getCommData() 00046 { 00047 if(incomingDataUpdate == TRUE) 00048 { 00049 if( ((receiverBuffer&0x0F)==MOTORS_FORWARD || 00050 (receiverBuffer&0x0F)==MOTORS_BACKWARD || 00051 (receiverBuffer&0x0F)==MOTORS_LEFT || 00052 (receiverBuffer&0x0F)==MOTORS_RIGHT || 00053 (receiverBuffer&0x0F)==MOTORS_ARM || 00054 (receiverBuffer&0x0F)==MOTORS_OFF || 00055 (receiverBuffer>>4)&(0x0F)==MAGNET_ON || 00056 (receiverBuffer>>4)&(0x0F)==MAGNET_OFF 00057 /* AND BALLAST REQUIREMENTS */ ) ) 00058 { 00059 incomingDataUpdate = FALSE; 00060 return receiverBuffer; 00061 } 00062 else 00063 { 00064 incomingDataUpdate = FALSE; 00065 return 0xFF; 00066 } 00067 } 00068 else 00069 { 00070 incomingDataUpdate = FALSE; 00071 return 0xFF; 00072 } 00073 }
Generated on Fri Aug 5 2022 03:29:58 by
1.7.2