/*---------------------------------------------------------------------------*
 * Routine:  GainSpan_SPI_SendDataBlock
 *---------------------------------------------------------------------------*
 * Description:
 *      Send an array of data out the transmit FIFO.  This routine will
 *      block until all the bytes are sent.
 * Inputs:
 *      const uint8_t *aData -- data to send
 *      uint16_t aLen -- Number of bytes to send.
 * Outputs:
 *      void
 *---------------------------------------------------------------------------*/
void GainSpan_SPI_SendDataBlock(uint8_t channel, const uint8_t *aData, uint16_t aLen)
{
    /* Send each byte one at a time unless out of space */
    uint16_t i;

    for (i = 0; i < aLen; ++i) {
        while (1) {
            if (GainSpan_SPI_SendByte(aData[i]))
                break;
            GainSpan_SPI_Update(channel);
        }
    }
}
/*---------------------------------------------------------------------------*
 * Routine:  GainSpan_SPI_SendData
 *---------------------------------------------------------------------------*
 * Description:
 *      Send an array of data bytes out the transmit FIFO.  This routine
 *      does not block and returns the number of bytes sent.
 * Inputs:
 *      const uint8_t *aData -- data to send
 *      uint16_t aLen -- Number of bytes to send.
 * Outputs:
 *      uint16_t -- Number of bytes actually buffered and sent.
 *---------------------------------------------------------------------------*/
uint16_t GainSpan_SPI_SendData(const uint8_t *aData, uint16_t aLen)
{
    uint16_t i;

    /* Send each byte one at a time unless out of space */
    for (i = 0; i < aLen; ++i) {
        if (!GainSpan_SPI_SendByte(aData[i]))
            break;
    }

    /* Return the number of bytes that did get into the transmit FIFO */
    return i;
}
Example #3
0
/*-------------------------------------------------------------------------*
 * Prototypes:
 *-------------------------------------------------------------------------*/
void IGainSpan_CmdLib_Write(const void *txData, uint16_t dataLength)
{
    const uint8_t *tx = (uint8_t *)txData;

    while (dataLength--) {
        /* Keep trying to send this data until it goes */
        while (!GainSpan_SPI_SendByte(*tx)) {
            /* Process any incoming data as well */
            GainSpan_SPI_Update(GAINSPAN_SPI_CHANNEL);
        }

        tx++;
    }
}
Example #4
0
 /*---------------------------------------------------------------------------*/
void App_Write(const void *txData, uint16_t dataLength)
{
    const uint8_t *tx = (uint8_t *)txData;
#ifdef ATLIBGS_INTERFACE_SPI
    while (dataLength--) {
        /* Keep trying to send this data until it goes */
        while (!GainSpan_SPI_SendByte(*tx)) {
            /* Process any incoming data as well */
            GainSpan_SPI_Update(GAINSPAN_SPI_CHANNEL);
        }

        tx++;
    }
#else
    while (dataLength--) {
        /* Keep trying to send this data until it goes */
        while (!GainSpan_UART_SendByte(*tx)) {
        }
        tx++;
    }
#endif
}