<div>HI, i have tried some days to know stm32 i2c, almost make it , but i still can not read the data correctly</div><div>i think this is the right method, but dont know where i go wrong. please reply me<br></div><div><br></div><div>//add i2c pin config in io.h</div><div><br></div><div>#define STM32F4_PIN_I2C(port, idx, altfunc) \<br>  { \<br>    { \<br>      .pin_first = STM32F4_GPIO_PIN(port, idx), \<br>      .pin_last = STM32F4_GPIO_PIN(port, idx), \<br>      .mode = STM32F4_GPIO_MODE_AF, \<br>      .otype = STM32F4_GPIO_OTYPE_OPEN_DRAIN, \<br>      .ospeed = STM32F4_GPIO_OSPEED_2_MHZ, \<br>      .pupd = STM32F4_GPIO_NO_PULL, \<br>      .af = altfunc \<br>    } \<br>  }<br><br>#define STM32F4_PIN_I2C1_SCL      STM32F4_PIN_I2C(1, 8, STM32F4_GPIO_AF_I2C1)<br>#define STM32F4_PIN_I2C1_SDA      STM32F4_PIN_I2C(1, 9, STM32F4_GPIO_AF_I2C1)<br>#endif /* STM32F4_FAMILY_F4XXXX */</div><div><br></div><div><br></div><div><span style="font-weight: bold;">start-config-io.c</span></div><div><br></div><div> #endif<br>  #ifdef STM32F4_ENABLE_UART_4<br>    STM32F4_PIN_UART4_TX_PA0,<br>    STM32F4_PIN_UART4_RX_PA1,<br>  #endif<br>  #ifdef STM32F4_ENABLE_UART_5<br>    STM32F4_PIN_UART5_TX_PC12,<br>    STM32F4_PIN_UART5_RX_PD2,<br>  #endif<br>  #ifdef STM32F4_ENABLE_USART_6<br>    STM32F4_PIN_USART6_TX_PC6,<br>    STM32F4_PIN_USART6_RX_PC7,<br>  #endif<br>  #ifdef STM32F4_ENABLE_I2C1<br>    STM32F4_PIN_I2C1_SCL,<br>    STM32F4_PIN_I2C1_SDA,<br>  #endif<br>  #ifdef STM32F4_ENABLE_I2C2<br>    #error Not implemented.<br>  #endif</div><div><br></div><div><br></div><div><br></div><div>the application code, using the stm32 i2c driver :</div><div><br></div><div>extern stm32f4_i2c_bus_entry *const stm32f4_i2c1;<br><br>rtems_task Init(rtems_task_argument argument)<br>{<br>    puts( "\n\n*** i2c test begin ***\n");<br>    LED_INIT();<br>    LED_OFF();<br>    uint8_t buf[20] = {0};<br>    <br>    rtems_status_code sc = stm32f4_i2c_init(stm32f4_i2c1);<br>    printf("the sc is %d\n", sc);<br>    <br>    <br>    stm32f4_i2c_message msg = {0};<br>    msg.addr = 0x50;<br>    msg.read = false;<br>    msg.len = 1;<br>    msg.buf = buf;<br>    buf[0] = 0x66;<br>    sc = stm32f4_i2c_process_message(stm32f4_i2c1, &msg);<br>    printf("the write status %d\n", sc);<br>    rtems_task_wake_after(2);<br>    <br>    <br>    memset(buf, 0, sizeof(buf));<br>    msg.read = true;<br>    msg.len = 1;<br>    msg.buf = buf;<br>    sc = stm32f4_i2c_process_message(stm32f4_i2c1, &msg);<br>    printf("the read status %d\n", sc);<br>    sleep(1);<br>    <br>    int i = 0;<br>    for(i = 0; i < 10; i++)<br>        printf("%x\t", buf[i]);<br>  <br>  <br><br>    (void)rtems_task_delete( RTEMS_SELF );<br>}</div><div><br></div><div><br></div><div>but i can not read the data, log outputs:<br></div><div><br><br>*** i2c test begin ***<br><br>the sc is 0<br>the write status 0<br>the read status 0<br><br>[09:32:46.369]Rx 0       0       0       0       0       0       0       0       0       0 <br></div>