Пример #1
0
/*---------------------------------------------------------------------------*/
void App_Update(void)
{
#ifdef ATLIBGS_INTERFACE_SPI
    GainSpan_SPI_Update(GAINSPAN_SPI_CHANNEL);
#else
#endif
}
/*---------------------------------------------------------------------------*
 * 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);
        }
    }
}
Пример #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++;
    }
}
/*---------------------------------------------------------------------------*
 * Routine:  GainSpan_SPI_ReceiveByte
 *---------------------------------------------------------------------------*
 * Description:
 *      Get a byte in the GainSpan_SPI receive FIFO buffer.
 * Inputs:
 *      uint8_t *aByte -- Returned byte (if any)
 * Outputs:
 *      bool -- true if byte returned, else false
 *---------------------------------------------------------------------------*/
bool GainSpan_SPI_ReceiveByte(uint8_t channel, uint8_t *aByte)
{
    bool found = false;

    /* When looking for a byte, update the state */
    GainSpan_SPI_Update(channel);

    /* Check to see if any bytes have been placed in the FIFO and */
    /* are waiting to be pulled out. */
    if (G_GainSpan_SPI_RXIn != G_GainSpan_SPI_RXOut) {
        *aByte = G_GainSpan_SPI_RXBuffer[G_GainSpan_SPI_RXOut++];
        if (G_GainSpan_SPI_RXOut >= GAINSPAN_SPI_RX_BUFFER_SIZE)
            G_GainSpan_SPI_RXOut = 0;
        found = true;
    }

    return found;
}
Пример #5
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
}
Пример #6
0
void GainSpan_CmdLib_Update(void)
{
    GainSpan_SPI_Update(GAINSPAN_SPI_CHANNEL);
}