// increment write index, the write void EventEnqueue(uint8_t eventType, uint32_t eventData) { #if 0 if (eventType == WF_EVENT_ERROR) { dbgprintf("WF_EVENT_ERROR\n"); } #endif t_event *p_eventInQueue; // if event queue has filled then most likely a series of errors have occurred, // so it is probably best to simply throw away any new events if (isEventQFull()) { return; } p_eventInQueue = &g_eventQueue.event[g_eventQueue.writeIndex]; // write data to queue p_eventInQueue->eventType = eventType; p_eventInQueue->eventData = eventData; IncrementWriteIndex(); }
static void WriteTxBuffer(tString * const pBuf) { unsigned char i = 0; unsigned int LocalCount = TxCount; /* if there isn't enough room in the buffer then characters are lost */ while ( pBuf[i] != 0 && LocalCount < TX_BUFFER_SIZE ) { TxBuffer[WriteIndex] = pBuf[i++]; IncrementWriteIndex(); LocalCount++; } /* keep a sticky bit for lost characters */ if ( pBuf[i] != 0 ) { gAppStats.DebugUartOverflow = 1; } /* * update the count (which can be decremented in the ISR * and start sending characters if the UART is currently idle */ if ( i > 0 ) { portENTER_CRITICAL(); TxCount += i; #if 0 if ( TxCount > TX_BUFFER_SIZE ) { while(1); } #endif if ( TxBusy == 0 ) { EnableSmClkUser(BT_DEBUG_UART_USER); UCA3TXBUF = TxBuffer[ReadIndex]; IncrementReadIndex(); TxBusy = 1; TxCount--; } portEXIT_CRITICAL(); } }