Date:2011-06-21 02:03:52 (8 years 3 months ago)
Author:Werner Almesberger
Commit:d0fb1a8992d1cf83c558c87ae4dedfae063ddc8f
Message:tools/: the great removal of atrf_interrupt

- atrf-proxy/PROTOCOL, atrf-proxy/atrf-proxy.c (cmd_zero): removed the
POLL command
- lib/atben.c (atben_driver): don't export atben_interrupt anymore (we
still use it internally)
- lib/atnet.c (atnet_interrupt, atnet_driver): removed atnet_interrupt
- lib/atusb-common.h (atusb_interrupt), lib/atusb-common.h
(atusb_interrupt), lib/atusb-spi.c (atusb_spi_driver),
lib/atusb.c (atusb_driver): removed atusb_interrupt
- lib/driver.h (struct atrf_driver): removed "interrupt"
- include/atrf.h (atrf_interrupt), lib/atrf.c (atrf_interrupt): removed
Files: tools/atrf-proxy/PROTOCOL (1 diff)
tools/atrf-proxy/atrf-proxy.c (2 diffs)
tools/include/atrf.h (1 diff)
tools/lib/atben.c (1 diff)
tools/lib/atnet.c (2 diffs)
tools/lib/atrf.c (1 diff)
tools/lib/atusb-common.c (1 diff)
tools/lib/atusb-common.h (1 diff)
tools/lib/atusb-spi.c (1 diff)
tools/lib/atusb.c (1 diff)
tools/lib/driver.h (1 diff)

Change Details

tools/atrf-proxy/PROTOCOL
5656+value
5757-message
5858
59POLL
60+0|1
61-message
62
6359WAIT timeout_ms
6460+value
6561-message
tools/atrf-proxy/atrf-proxy.c
196196
197197static int cmd_zero(struct atrf_dsc *dsc, struct netio *netio, const char *cmd)
198198{
199    int res;
200
201199    if (!strcasecmp(cmd, "spec")) {
202200        const char *spec = atrf_driver_spec(dsc, 1);
203201
...... 
231229        buf[got] = '\n';
232230        return netio_write(netio, buf, got+1);
233231    }
234    if (!strcasecmp(cmd, "poll")) {
235        res = atrf_interrupt(dsc);
236        if (res < 0)
237            return netio_printf(netio, "-I/O error\n");
238        if (!res)
239            usleep(2*1000);
240        return netio_printf(netio, "+%d\n", res);
241    }
242232    return netio_printf(netio, "-unrecognized command\n");
243233}
244234
tools/include/atrf.h
5555void atrf_sram_write(struct atrf_dsc *dsc, uint8_t addr, uint8_t value);
5656uint8_t atrf_sram_read(struct atrf_dsc *dsc, uint8_t addr);
5757
58int atrf_interrupt(struct atrf_dsc *dsc);
5958int atrf_interrupt_wait(struct atrf_dsc *dsc, int timeout_ms);
6059
6160#endif /* !ATRF_H */
tools/lib/atben.c
436436    .buf_read = atben_buf_read,
437437    .sram_write = atben_sram_write,
438438    .sram_read = atben_sram_read,
439    .interrupt = atben_interrupt,
440439    .interrupt_wait = atben_interrupt_wait,
441440};
tools/lib/atnet.c
441441/* ----- RF interrupt ------------------------------------------------------ */
442442
443443
444static int atnet_interrupt(void *handle)
445{
446    struct atnet_dsc *dsc = handle;
447    unsigned long value;
448    char *end;
449
450    if (dsc->error)
451        return -1;
452    if (dialog(dsc, "POLL") < 0) {
453        dsc->error = 1;
454        return -1;
455    }
456    value = strtoul(dsc->reply+1, &end, 0);
457    if (*end || value > 1) {
458        fprintf(stderr, "invalid response \"%s\"\n", dsc->reply+1);
459        dsc->error = 1;
460        return -1;
461    }
462    return value;
463}
464
465
466444int atnet_interrupt_wait(void *handle, int timeout_ms)
467445{
468446    struct atnet_dsc *dsc = handle;
...... 
515493    .buf_read = atnet_buf_read,
516494    .sram_write = atnet_sram_write,
517495    .sram_read = atnet_sram_read,
518    .interrupt = atnet_interrupt,
519496    .interrupt_wait = atnet_interrupt_wait,
520497};
tools/lib/atrf.c
318318}
319319
320320
321int atrf_interrupt(struct atrf_dsc *dsc)
322{
323    return
324        dsc->driver->interrupt ? dsc->driver->interrupt(dsc->handle) : 1;
325}
326
327
328321int atrf_interrupt_wait(struct atrf_dsc *dsc, int timeout_ms)
329322{
330323    return dsc->driver->interrupt_wait ?
tools/lib/atusb-common.c
174174/* ----- RF interrupt ------------------------------------------------------ */
175175
176176
177int atusb_interrupt(void *handle)
178{
179    struct atusb_dsc *dsc = handle;
180    uint8_t buf;
181    int res;
182
183    if (dsc->error)
184        return -1;
185
186    res = usb_control_msg(dsc->dev, FROM_DEV, ATUSB_POLL_INT, 0, 0,
187        (void *) &buf, 1, 1000);
188    if (res < 0) {
189        fprintf(stderr, "ATUSB_POLL_INT: %d\n", res);
190        dsc->error = 1;
191        return -1;
192    }
193
194    return buf;
195}
196
197
198177/*
199178 * The logic here is a bit tricky. Assuming that we can get a lot of
200179 * interrupts, system state can change as follows:
tools/lib/atusb-common.h
3333void atusb_reset_rf(void *handle);
3434void atusb_test_mode(void *handle);
3535void atusb_slp_tr(void *handle, int on, int pulse);
36int atusb_interrupt(void *handle);
3736int atusb_interrupt_wait(void *handle, int timeout_ms);
3837
3938int atusb_set_clkm(void *handle, int mhz);
tools/lib/atusb-spi.c
167167    .buf_read = atusb_spi_buf_read,
168168    .sram_write = atusb_spi_sram_write,
169169    .sram_read = atusb_spi_sram_read,
170    .interrupt = atusb_interrupt,
171170    .interrupt_wait = atusb_interrupt_wait,
172171};
tools/lib/atusb.c
161161    .buf_read = atusb_buf_read,
162162    .sram_write = atusb_sram_write,
163163    .sram_read = atusb_sram_read,
164    .interrupt = atusb_interrupt,
165164    .interrupt_wait = atusb_interrupt_wait,
166165};
tools/lib/driver.h
3535    int (*buf_read)(void *dsc, void *buf, int size);
3636    void (*sram_write)(void *dsc, uint8_t addr, uint8_t value);
3737    uint8_t (*sram_read)(void *dsc, uint8_t addr);
38    int (*interrupt)(void *dsc);
3938    int (*interrupt_wait)(void *dsc, int timeout_ms);
4039};
4140

Archive Download the corresponding diff file



interactive