This is the mail archive of the mailing list for the eCos project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug 1001397] I2C driver for Kinetic microcontrollers

Please do not reply to this email. Use the web interface provided at:

--- Comment #29 from Ilija Kocho <> 2012-12-25 21:31:55 GMT ---
(In reply to comment #27)

Hi again Tomas

> Thank you for your reply.
> (In reply to comment #23)
> > (In reply to comment #22)
> > > I am trying to clean up my backlog. Your I2C driver appears to be almost ready
> > > for check in. I wander if you have tried the patch proposed in comment 21.
> > 
> > The patch makes sense to me, though I have not had a chance to test it.
> As you may have seen I took the liberty to apply the patch from comment 21. It
> compiles fine, but I haven't tested the runtime.
> One thing that bothers me is the WAIT_BUS_READY(), it looks like busy waiting,
> but I can't estimate implications since I don't have enough insight into
> I2C. Can you comment on this please?

I looked through other I2C drivers and I found out that some of them have
similar macro. So we have a precedent, but I would look for better solution.
For instance what would happen if we replace the macro with something like this

bool is_bus_free(freescale_i2c_extra *extra )
    bool bus_free;
    if (!extra->i2c_owner) {
        freescale_i2c_t *i2c_s = FREESCALE_I2C_P(extra->i2c_base);
        if(i2c_s->s & FREESCALE_I2C_S_BUSY_M){
            bus_free = false;
        } else {
            extra->i2c_got_nack = 0;
            extra->i2c_owner = 1;
            bus_free = true;
    } else {
        bus_free = true;
    return bus_free;

Then something like this:

static cyg_bool
freescale_i2c_handle_xfer(const cyg_i2c_device * dev, int address)
  freescale_i2c_device *fdev = (freescale_i2c_device*) dev;
  freescale_i2c_extra  *extra = (freescale_i2c_extra *)
  cyg_uint8             data = *extra->i2c_data.i2c_tx_data;
  freescale_i2c_t      *i2c_s = FREESCALE_I2C_P (extra->i2c_base);

  // Nothing to do
  if (extra->i2c_count == 0)
    return 0;

-  // Take the bus ownership
-  WAIT_BUS_READY (extra);
+  // Check the bus ownership
+  if(!is_bus_free(extra))
+    return 0;




Configure bugmail:
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]