This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
[Bug 1001397] I2C driver for Kinetic microcontrollers
- From: bugzilla-daemon at bugs dot ecos dot sourceware dot org
- To: ecos-patches at ecos dot sourceware dot org
- Date: Tue, 25 Dec 2012 21:31:58 +0000
- Subject: [Bug 1001397] I2C driver for Kinetic microcontrollers
- Auto-submitted: auto-generated
- References: <bug-1001397-104@http.bugs.ecos.sourceware.org/>
Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001397
--- Comment #29 from Ilija Kocho <ilijak@siva.com.mk> 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
(untested):
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 *)
dev->i2c_bus->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;
.....
}
Ilija
--
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.