uint16_t rxBtuart() { uint8_t result; if (!btRxFifo.pop(result)) return 0xffff; return result; }
int UsbMidiModule::_read() { _poll(); u8 byte = 0; m_midiInFifo.pop(&byte); return byte; }
extern "C" void USART3_IRQHandler(void) { if (USART_GetITStatus(UART3, USART_IT_TXE) != RESET) { uint8_t txchar; if (debugTxFifo.pop(txchar)) { /* Write one byte to the transmit data register */ USART_SendData(UART3, txchar); } else { USART_ITConfig(UART3, USART_IT_TXE, DISABLE); } } }
void cliTask(void * pdata) { char line[CLI_COMMAND_MAX_LEN+1]; int pos = 0; cliPrompt(); for (;;) { uint8_t c; while (!cliRxFifo.pop(c)) { CoTickDelay(10); // 20ms } if (c == 12) { // clear screen serialPrint("\033[2J\033[1;1H"); cliPrompt(); } else if (c == 127) { // backspace if (pos) { line[--pos] = '\0'; serialPutc(c); } } else if (c == '\r' || c == '\n') { // enter serialCrlf(); line[pos] = '\0'; cliExecLine(line); pos = 0; cliPrompt(); } else if (isascii(c) && pos < CLI_COMMAND_MAX_LEN) { line[pos++] = c; serialPutc(c); } } }
void btTask(void* pdata) { uint8_t byte; btFlag = CoCreateFlag(true, false); btTx.size = 0; // Look for BT module baudrate, try 115200, and 9600 // Already initialised to g_eeGeneral.bt_baudrate // 0 : 115200, 1 : 9600, 2 : 19200 uint32_t x = g_eeGeneral.btBaudrate; btStatus = btPollDevice() ; // Do we get a response? for (int y=0; y<2; y++) { if (btStatus == 0) { x += 1 ; if (x > 2) { x = 0 ; } btSetBaudrate(x) ; CoTickDelay(1) ; // 2mS btStatus = btPollDevice() ; // Do we get a response? } } if (btStatus) { btStatus = x + 1 ; if ( x != g_eeGeneral.btBaudrate ) { x = g_eeGeneral.btBaudrate ; // Need to change Bt Baudrate btChangeBaudrate( x ) ; btStatus += (x+1) * 10 ; btSetBaudrate( x ) ; } } else { btInit(); } CoTickDelay(1) ; btPollDevice(); // Do we get a response? while (1) { uint32_t x = CoWaitForSingleFlag(btFlag, 10); // Wait for data in Fifo if (x == E_OK) { // We have some data in the Fifo while (btTxFifo.pop(byte)) { btTxBuffer[btTx.size++] = byte; if (btTx.size > 31) { btSendBuffer(); } } } else if (btTx.size) { btSendBuffer(); } } }
void pop(Fifo& fifo) { typename Fifo::value_type t; fifo.pop(t); }
bool telemetrySecondPortReceive(uint8_t & data) { return serial2RxFifo.pop(data); }