Changeset cfc53c1 in rtems


Ignore:
Timestamp:
11/24/14 10:55:44 (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
f7d2795
Parents:
55db0e5
Message:

i2c: Fix endian issue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/dev/i2c/gpio-nxp-pca9535.c

    r55db0e5 rcfc53c1  
    4444)
    4545{
    46   uint8_t buf[1] = { port };
     46  uint8_t out[1] = { port };
     47  uint8_t in[sizeof(*val)];
    4748  i2c_msg msgs[2] = {
    4849    {
    4950      .addr = dev->address,
    5051      .flags = 0,
    51       .len = (uint16_t) sizeof(buf),
    52       .buf = &buf[0]
     52      .len = (uint16_t) sizeof(out),
     53      .buf = &out[0]
    5354    }, {
    5455      .addr = dev->address,
    5556      .flags = I2C_M_RD,
    56       .len = (uint16_t) sizeof(*val),
    57       .buf = (uint8_t *) val
     57      .len = (uint16_t) sizeof(in),
     58      .buf = &in[0]
    5859    }
    5960  };
     61  int err;
    6062
    61   return i2c_bus_transfer(dev->bus, &msgs[0], RTEMS_ARRAY_SIZE(msgs));
     63  err = i2c_bus_transfer(dev->bus, &msgs[0], RTEMS_ARRAY_SIZE(msgs));
     64  *val = in[0] | (in[1] << 8);
     65
     66  return err;
    6267}
    6368
     
    6873)
    6974{
    70   uint8_t buf[3] = { port, (uint8_t) val, (uint8_t) (val >> 8) };
     75  uint8_t out[3] = { port, (uint8_t) val, (uint8_t) (val >> 8) };
    7176  i2c_msg msgs[1] = {
    7277    {
    7378      .addr = dev->address,
    7479      .flags = 0,
    75       .len = (uint16_t) sizeof(buf),
    76       .buf = &buf[0]
     80      .len = (uint16_t) sizeof(out),
     81      .buf = &out[0]
    7782    }
    7883  };
Note: See TracChangeset for help on using the changeset viewer.