0

I'm working on the i2c driver for STM8S105C6T6. I cannot receive the I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED. Please, advice where I'm wrong.

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);

    ...
}

Thanks in advance for the help.

pushkin
  • 9,575
  • 15
  • 51
  • 95

0 Answers0