Example #1
0
/**
*
* This function sends a buffer that has been previously specified by setting
* up the instance variables of the instance. This function is designed to be
* an internal function for the XPs2 component such that it may be called
* from a shell function that sets up the buffer or from an interrupt handler.
*
* This function sends the specified buffer of data to the PS/2 port in either
* polled or interrupt driven modes. This function is non-blocking such that
* it will return before the data has been sent.
*
* In a polled mode, this function will only send 1 byte which is as much data
* transmitter can buffer. The application may need to call it repeatedly to
* send a buffer.
*
* In interrupt mode, this function will start sending the specified buffer and
* then the interrupt handler of the driver will continue until the buffer
* has been sent. A callback function, as specified by the application, will
* be called to indicate the completion of sending the buffer.
*
* @param    InstancePtr is a pointer to the XPs2 instance to be worked on.
*
* @return
*
* NumBytes is the number of bytes actually sent
*
* @note
*
* None.
*
*****************************************************************************/
unsigned int XPs2_SendBuffer(XPs2 *InstancePtr)
{
    unsigned int SentCount = 0;

    /*
     * If the transmitter is empty send one byte of data
     */
    if (!XPs2_mIsTransmitFull(InstancePtr->BaseAddress))
    {
        XPs2_SendByte(InstancePtr->BaseAddress,
                      InstancePtr->SendBuffer.NextBytePtr[SentCount]);

        SentCount = 1;
    }
    /*
     * Update the buffer to reflect the bytes that were sent
     * from it
     */
    InstancePtr->SendBuffer.NextBytePtr += SentCount;
    InstancePtr->SendBuffer.RemainingBytes -= SentCount;

    /*
     * If interrupts are enabled as indicated by the receive interrupt, then
     * enable the transmit interrupt
     */
    if (XPs2_mIsIntrEnabled((InstancePtr->BaseAddress), XPS2_INT_RX_FULL))
    {
        XPs2_mEnableIntr(InstancePtr->BaseAddress, XPS2_INT_TX_ALL |
                                                   XPS2_INT_WDT_TOUT);
    }

    return SentCount;
}
Example #2
0
/**
*
* This function sends a data byte to PS/2. This function operates in the
* polling mode and blocks until the data has been put into the transmit
* holding register.
*
* @param    BaseAddress contains the base address of the PS/2 port.
* @param    Data contains the data byte to be sent.
*
* @return   None.
*
* @note     None.
*
*****************************************************************************/
void
XPs2_SendByte(u32 BaseAddress, u8 Data)
{
	while (XPs2_mIsTransmitFull(BaseAddress)) {
	}

	XIo_Out8(BaseAddress + XPS2_TX_REG_OFFSET, Data);
}