stm32 i2c read/write

787562067 googcheng at qq.com
Wed Apr 3 11:33:00 UTC 2019


HI, ALL
  i dont know what i have missed, but the code can not read the data



extern stm32f4_i2c_bus_entry *const stm32f4_i2c1;

rtems_task Init(rtems_task_argument argument)
{
    puts( "\n\n*** i2c test begin ***\n");

    uint8_t buf[20] = {0};
    
    rtems_status_code sc = stm32f4_i2c_init(stm32f4_i2c1);
    printf("the sc is %d\n", sc);
    
    
    stm32f4_i2c_message msg = {0};
    msg.addr = 0x50;
    msg.read = false;
    msg.len = 1;
    msg.buf = buf;
    buf[0] = 0x66;
    sc = stm32f4_i2c_process_message(stm32f4_i2c1, &msg);
    printf("the write status %d\n", sc);
    rtems_task_wake_after(200);
    
    
    memset(buf, 0, sizeof(buf));
    msg.read = true;
    msg.len = 1;
    msg.buf = buf;
    sc = stm32f4_i2c_process_message(stm32f4_i2c1, &msg);
    printf("the read status %d\n", sc);
    sleep(1);
    printf("value is %x\n", buf[0]);
  
  

    (void) rtems_task_delete( RTEMS_SELF );
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20190403/a982ea8d/attachment.html>


More information about the users mailing list