/******************************************************************************* * Function Name: UART_1_SpiUartWriteTxData ******************************************************************************** * * Summary: * Places a data entry into the transmit buffer to be sent at the next available * bus time. * This function is blocking and waits until there is space available to put the * requested data in the transmit buffer. * * Parameters: * txDataByte: the data to be transmitted. * * Return: * None * *******************************************************************************/ void UART_1_SpiUartWriteTxData(uint32 txData) { #if(UART_1_INTERNAL_TX_SW_BUFFER_CONST) uint32 locHead; uint32 intSourceMask; #endif /* (UART_1_INTERNAL_TX_SW_BUFFER_CONST) */ #if(UART_1_CHECK_TX_SW_BUFFER) { /* Head index to put data */ locHead = (UART_1_txBufferHead + 1u); /* Adjust TX software buffer index */ if(UART_1_TX_BUFFER_SIZE == locHead) { locHead = 0u; } while(locHead == UART_1_txBufferTail) { /* Wait for space in TX software buffer */ } /* TX software buffer has at least one room */ if((UART_1_txBufferHead == UART_1_txBufferTail) && (UART_1_FIFO_SIZE != UART_1_GET_TX_FIFO_ENTRIES)) { /* TX software buffer is empty: put data directly in TX FIFO */ UART_1_TX_FIFO_WR_REG = txData; } /* Put data in TX software buffer */ else { /* Clear old status of INTR_TX_NOT_FULL. It sets at the end of transfer when TX FIFO is empty. */ UART_1_ClearTxInterruptSource(UART_1_INTR_TX_NOT_FULL); UART_1_PutWordInTxBuffer(locHead, txData); UART_1_txBufferHead = locHead; /* Enable interrupt to transmit */ intSourceMask = UART_1_INTR_TX_NOT_FULL; intSourceMask |= UART_1_GetTxInterruptMode(); UART_1_SpiUartEnableIntTx(intSourceMask); } } #else { while(UART_1_FIFO_SIZE == UART_1_GET_TX_FIFO_ENTRIES) { /* Block while TX FIFO is FULL */ } UART_1_TX_FIFO_WR_REG = txData; } #endif }
/******************************************************************************* * Function Name: UART_1_SpiUartDisableIntTx ****************************************************************************//** * * Disables TX interrupt sources. * * \return * Returns TX interrupt sources enabled before function call. * *******************************************************************************/ uint32 UART_1_SpiUartDisableIntTx(void) { uint32 intSourceMask; intSourceMask = UART_1_GetTxInterruptMode(); UART_1_SetTxInterruptMode(UART_1_NO_INTR_SOURCES); return (intSourceMask); }