1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-25 18:57:11 +02:00

tools/lib/atusb-common.c: updated for new interrupt handling in firmware

- atusb-common.c (atusb_interrupt_wait): the atusb firmware no longer
  reads and accumulates IRQs for us. We now just wait for the
  notification, then read IRQ_STATUS. Let higher layers take care of
  retries and all that.
- atusb-common.c (atusb_open): clear any pending interrupts
This commit is contained in:
Werner Almesberger 2011-06-23 13:14:39 -03:00
parent 23c592250e
commit 8a2d80a93c

View File

@ -81,6 +81,8 @@ void *atusb_open(const char *arg)
dsc->dev = dev; dsc->dev = dev;
dsc->error = 0; dsc->error = 0;
atusb_driver.reg_read(dsc, REG_IRQ_STATUS);
return dsc; return dsc;
} }
@ -203,28 +205,23 @@ void atusb_slp_tr(void *handle, int on, int pulse)
int atusb_interrupt_wait(void *handle, int timeout_ms) int atusb_interrupt_wait(void *handle, int timeout_ms)
{ {
struct atusb_dsc *dsc = handle; struct atusb_dsc *dsc = handle;
uint8_t irq, buf[100]; char buf;
int res, i; int res;
if (dsc->error) if (dsc->error)
return 0; return 0;
irq = atusb_driver.reg_read(handle, REG_IRQ_STATUS);
if (irq)
timeout_ms = 1;
res = usb_bulk_read(dsc->dev, 1, res = usb_bulk_read(dsc->dev, 1,
(char *) &buf, sizeof(buf), timeout_ms); (char *) &buf, sizeof(buf), timeout_ms);
if (res != -ETIMEDOUT) { if (res == -ETIMEDOUT)
if (res < 0) { return 0;
fprintf(stderr, "usb_bulk_read: %d\n", res); if (res < 0) {
dsc->error = 1; fprintf(stderr, "usb_bulk_read: %d\n", res);
return 0; /* handle this via atrf_error */ dsc->error = 1;
} return 0; /* handle this via atrf_error */
for (i = 0; i != res; i++)
irq |= buf[i];
} }
return irq;
return atusb_driver.reg_read(handle, REG_IRQ_STATUS);
} }