void bluetooth_add_data(void) { *rxBTBufWrPtr++ = UART2_Read(); //Put received character in the buffer if ( rxBTBufWrPtr > &rxBluetoothBuffer[SIZE_RxBuffer - 1] ) { //Check if end of buffer rxBTBufWrPtr = &rxBluetoothBuffer[0]; //Wrap pointer to beginning } }
unsigned int UART2_ReadBuffer(uint8_t *buffer, const unsigned int bufLen) { unsigned int numBytesRead = 0; while (numBytesRead < (bufLen)) { if (uart2_obj.rxStatus.s.empty) { break; } else { buffer[numBytesRead++] = UART2_Read(); } } return numBytesRead; }
void laser_init() { char init = 'U'; char resp; UART2_Write(&init, 1); while (1) { if (UART2_Read(&resp) == 0) { // Check for response if (resp == ':') { break; } } } }
/** * Relays data from Bluetooth to Radio */ void relayFromBluetooth() { /* UART1 - FTDI USB * UART2 - Bluetooth * UART3 - Radio */ if(!UART2_ReceiveBufferIsEmpty()) //New data on UART2 InjectLoop(UART2_Read()); //Reads data from UART2 and sends to injector //Lets see if there is some data available to send to radio if(!CircularBufferIsEmpty(&(inject.outBuff))) UART3_Write(CircularBufferDeque(&(inject.outBuff))); }
unsigned long laser_read() { char read[] = "B"; UART2_Write(&read, 1); unsigned long temp = 0; while(1){ if(UART2_Read(&read) == 0) { temp |= (read[0] << 24); break; } } while(1){ if(UART2_Read(&read) == 0) { temp |= (read[0] << 16); break; } } while(1){ if(UART2_Read(&read) == 0) { temp |= (read[0] << 8); break; } } while(1){ if(UART2_Read(&read) == 0) { temp |= (read[0]); break; } } while(1){ if(UART2_Read(&read) == 0) break; } while(1){ if(UART2_Read(&read) == 0) break; } return temp; }
/** uint8_t DRV_UART2_Read ( void ) */ uint8_t DRV_UART2_Read (void) { return(UART2_Read()); }
void UART2_Read_Text (char *Output, unsigned int length) { int i; for(int i=0; i<length;i++) Output[i] = UART2_Read(); }