mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 08:10:17 +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:
parent
23c592250e
commit
8a2d80a93c
@ -81,6 +81,8 @@ void *atusb_open(const char *arg)
|
||||
dsc->dev = dev;
|
||||
dsc->error = 0;
|
||||
|
||||
atusb_driver.reg_read(dsc, REG_IRQ_STATUS);
|
||||
|
||||
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)
|
||||
{
|
||||
struct atusb_dsc *dsc = handle;
|
||||
uint8_t irq, buf[100];
|
||||
int res, i;
|
||||
char buf;
|
||||
int res;
|
||||
|
||||
if (dsc->error)
|
||||
return 0;
|
||||
|
||||
irq = atusb_driver.reg_read(handle, REG_IRQ_STATUS);
|
||||
if (irq)
|
||||
timeout_ms = 1;
|
||||
|
||||
res = usb_bulk_read(dsc->dev, 1,
|
||||
(char *) &buf, sizeof(buf), timeout_ms);
|
||||
if (res != -ETIMEDOUT) {
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "usb_bulk_read: %d\n", res);
|
||||
dsc->error = 1;
|
||||
return 0; /* handle this via atrf_error */
|
||||
}
|
||||
for (i = 0; i != res; i++)
|
||||
irq |= buf[i];
|
||||
if (res == -ETIMEDOUT)
|
||||
return 0;
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "usb_bulk_read: %d\n", res);
|
||||
dsc->error = 1;
|
||||
return 0; /* handle this via atrf_error */
|
||||
}
|
||||
return irq;
|
||||
|
||||
return atusb_driver.reg_read(handle, REG_IRQ_STATUS);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user