0

我正在为 STM8S105C6T6 开发 i2c 驱动程序。我无法收到I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED. 请指教我哪里错了。

void I2C_ACC_ByteRead(u8 I2C_Slave_Address, u8 ReadAddr, u8 *pBuffer)
{   
    /* while the bus is busy */
    while(I2C_GetFlagStatus(I2C_FLAG_BUSBUSY));

    /* send start condition */
    I2C_GenerateSTART(ENABLE);

    /* test in I2C event and clear it */
    while(!I2C_CheckEvent(I2C_EVENT_MASTER_MODE_SELECT));

    /* send address to write */
    I2C_Send7bitAddress(I2C_Slave_Address, I2C_DIRECTION_TX);

    /* test on EV6 and clear it */
    while(!I2C_CheckEvent(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));

    /* send the address of the first byte to be read and wait event detection */
    I2C_SendData(ReadAddr); /* LSB */

    /* test on EV8 and clear it */
    while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED));

    /* send start condition for the second time */
    I2C_GenerateSTART(ENABLE);

    /* test in I2C event and clear it */
    while(!I2C_CheckEvent(I2C_EVENT_MASTER_MODE_SELECT));

    /* send EEPROM address to write */
    I2C_Send7bitAddress(I2C_Slave_Address, I2C_DIRECTION_RX);

    ...
}

在此先感谢您的帮助。

4

0 回答 0