I2C_TransmitOneByte Function

Appendices: P08

Appendices:

I2C_TransmitOneByte Function

                /****************************************************************************
                 * Function:    BOOL TransmitOneByte( I2C_MODULE i2c_port, BYTE data )
                 * Summary:     This transmits one byte to the EEPROM.
                 * Description: This transmits one byte to the EEPROM, and reports errors for
                 *              any bus collisions.
                 * Precondition: The transfer must have been previously started.
                 *
                 * Parameters:  i2c_port    - I2C_MODULE
                 *              data        - Data byte to transmit
                 *
                 * Returns:     TRUE    - Data was sent successfully
                 *              FALSE   - A bus collision occurred
                 *
                 * Remarks:     This is a blocking routine that waits for the transmission to
                 *              complete.
                  ****************************************************************************/
                BOOL TransmitOneByte( I2C_MODULE i2c_port, BYTE data )
                {
                /* Wait for the transmitter to be ready */
                    while(!I2CTransmitterIsReady(i2c_port));
                /* Transmit the byte */
                    if(I2CSendByte(i2c_port, data) == I2C_MASTER_BUS_COLLISION)
                    {
                        printf("Error: I2C Master Bus Collision\n");
                        return FALSE;
                    }
                /* Wait for the transmission to finish */
                    while(!I2CTransmissionHasCompleted(i2c_port));
                    return TRUE;
                }
                

  • Other product and company names mentioned herein are trademarks or trade names of their respective companies. © 2014 Digilent Inc. All rights reserved.