IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Commit Details
Date: | 2011-06-21 02:03:52 (12 years 9 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 | ||
---|---|---|
56 | 56 | +value |
57 | 57 | -message |
58 | 58 | |
59 | POLL | |
60 | +0|1 | |
61 | -message | |
62 | ||
63 | 59 | WAIT timeout_ms |
64 | 60 | +value |
65 | 61 | -message |
tools/atrf-proxy/atrf-proxy.c | ||
---|---|---|
196 | 196 | |
197 | 197 | static int cmd_zero(struct atrf_dsc *dsc, struct netio *netio, const char *cmd) |
198 | 198 | { |
199 | int res; | |
200 | ||
201 | 199 | if (!strcasecmp(cmd, "spec")) { |
202 | 200 | const char *spec = atrf_driver_spec(dsc, 1); |
203 | 201 | |
... | ... | |
231 | 229 | buf[got] = '\n'; |
232 | 230 | return netio_write(netio, buf, got+1); |
233 | 231 | } |
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 | } | |
242 | 232 | return netio_printf(netio, "-unrecognized command\n"); |
243 | 233 | } |
244 | 234 |
tools/include/atrf.h | ||
---|---|---|
55 | 55 | void atrf_sram_write(struct atrf_dsc *dsc, uint8_t addr, uint8_t value); |
56 | 56 | uint8_t atrf_sram_read(struct atrf_dsc *dsc, uint8_t addr); |
57 | 57 | |
58 | int atrf_interrupt(struct atrf_dsc *dsc); | |
59 | 58 | int atrf_interrupt_wait(struct atrf_dsc *dsc, int timeout_ms); |
60 | 59 | |
61 | 60 | #endif /* !ATRF_H */ |
tools/lib/atben.c | ||
---|---|---|
436 | 436 | .buf_read = atben_buf_read, |
437 | 437 | .sram_write = atben_sram_write, |
438 | 438 | .sram_read = atben_sram_read, |
439 | .interrupt = atben_interrupt, | |
440 | 439 | .interrupt_wait = atben_interrupt_wait, |
441 | 440 | }; |
tools/lib/atnet.c | ||
---|---|---|
441 | 441 | /* ----- RF interrupt ------------------------------------------------------ */ |
442 | 442 | |
443 | 443 | |
444 | static 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 | ||
466 | 444 | int atnet_interrupt_wait(void *handle, int timeout_ms) |
467 | 445 | { |
468 | 446 | struct atnet_dsc *dsc = handle; |
... | ... | |
515 | 493 | .buf_read = atnet_buf_read, |
516 | 494 | .sram_write = atnet_sram_write, |
517 | 495 | .sram_read = atnet_sram_read, |
518 | .interrupt = atnet_interrupt, | |
519 | 496 | .interrupt_wait = atnet_interrupt_wait, |
520 | 497 | }; |
tools/lib/atrf.c | ||
---|---|---|
318 | 318 | } |
319 | 319 | |
320 | 320 | |
321 | int atrf_interrupt(struct atrf_dsc *dsc) | |
322 | { | |
323 | return | |
324 | dsc->driver->interrupt ? dsc->driver->interrupt(dsc->handle) : 1; | |
325 | } | |
326 | ||
327 | ||
328 | 321 | int atrf_interrupt_wait(struct atrf_dsc *dsc, int timeout_ms) |
329 | 322 | { |
330 | 323 | return dsc->driver->interrupt_wait ? |
tools/lib/atusb-common.c | ||
---|---|---|
174 | 174 | /* ----- RF interrupt ------------------------------------------------------ */ |
175 | 175 | |
176 | 176 | |
177 | int 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 | ||
198 | 177 | /* |
199 | 178 | * The logic here is a bit tricky. Assuming that we can get a lot of |
200 | 179 | * interrupts, system state can change as follows: |
tools/lib/atusb-common.h | ||
---|---|---|
33 | 33 | void atusb_reset_rf(void *handle); |
34 | 34 | void atusb_test_mode(void *handle); |
35 | 35 | void atusb_slp_tr(void *handle, int on, int pulse); |
36 | int atusb_interrupt(void *handle); | |
37 | 36 | int atusb_interrupt_wait(void *handle, int timeout_ms); |
38 | 37 | |
39 | 38 | int atusb_set_clkm(void *handle, int mhz); |
tools/lib/atusb-spi.c | ||
---|---|---|
167 | 167 | .buf_read = atusb_spi_buf_read, |
168 | 168 | .sram_write = atusb_spi_sram_write, |
169 | 169 | .sram_read = atusb_spi_sram_read, |
170 | .interrupt = atusb_interrupt, | |
171 | 170 | .interrupt_wait = atusb_interrupt_wait, |
172 | 171 | }; |
tools/lib/atusb.c | ||
---|---|---|
161 | 161 | .buf_read = atusb_buf_read, |
162 | 162 | .sram_write = atusb_sram_write, |
163 | 163 | .sram_read = atusb_sram_read, |
164 | .interrupt = atusb_interrupt, | |
165 | 164 | .interrupt_wait = atusb_interrupt_wait, |
166 | 165 | }; |
tools/lib/driver.h | ||
---|---|---|
35 | 35 | int (*buf_read)(void *dsc, void *buf, int size); |
36 | 36 | void (*sram_write)(void *dsc, uint8_t addr, uint8_t value); |
37 | 37 | uint8_t (*sram_read)(void *dsc, uint8_t addr); |
38 | int (*interrupt)(void *dsc); | |
39 | 38 | int (*interrupt_wait)(void *dsc, int timeout_ms); |
40 | 39 | }; |
41 | 40 |