1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-09 10:50:37 +02:00
Commit Graph

927 Commits

Author SHA1 Message Date
Werner Almesberger
b7276d282a atrf-xmit/atrf-xmit.c: updated to no longer use atrf_interrupt
- atrf-xmit.c (xfer_one): use atrf_interrupt_wait instead of
  atrf_interrupt to pull the interrupt line
- atrf-xmit.c (xfer_one): removed delay-based wait to interrupt
- atrf-xmit.c (xfer_one): use atrf_interrupt_wait instead of reading
  REG_IRQ_STATUS directly
2011-06-20 20:41:30 -03:00
Werner Almesberger
b4a6e8ef46 tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
  (wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
  with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
  of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
  to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
  not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
  atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
  receive, transmit, transmit_pattern, ping_tx, ping_rx),
  atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
  lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
  updated use of wait_for_interrupt
2011-06-20 20:08:42 -03:00
Werner Almesberger
55354c7f91 tools/lib/atben.c: added support for interrupt_wait (polled)
- atben.c (atben_interrupt_wait): loop until either the timeout has
  been reached or an interrupt has occurred
- atben.c (atben_driver): added atben_interrupt_wait
2011-06-20 20:08:42 -03:00
Werner Almesberger
4d4cec6a67 tools/lib/timeout.h, tools/lib/timeout.c: added timeout/deadline functions 2011-06-20 19:11:51 -03:00
Werner Almesberger
106ef7ff7f tools/atrf-xmit/atrf-xmit.c: corrected title comment 2011-06-20 18:22:29 -03:00
Werner Almesberger
668d8c61cf tools/: added interrupt_wait support to atnet and atrf-proxy (untested)
- atrf-proxy/PROTOCOL: WAIT is now implemented and takes a timeout
  argument
- atrf-proxy/atrf-proxy.c (cmd_more): implemented WAIT command using
  atrf_interrupt_wait
- lib/atnet.c (atnet_interrupt_wait, atnet_driver): added
  interrupt_wait (using WAIT)
2011-06-20 17:42:48 -03:00
Werner Almesberger
b0dd5ced20 tools/: updated tools to use flush_interrupts
- atrf-txrx/atrf-txrx.c (init_txrx), atrf-xmit/atrf-xmit.c
  (init_common): instead of reading REG_IRQ_STATUS, use
  flush_interrupts to flush interrupts
2011-06-20 17:27:19 -03:00
Werner Almesberger
620709a20a libatrf: new function to reliably flush interrupts
- misctxrx.h (flush_interrupts), misctxrx.c: reliably flush interrupts
  on all drivers (with the exception of atnet talking to an atusb)
2011-06-20 17:21:40 -03:00
Werner Almesberger
110ecf67a1 tools/lib/: added interrupt_wait support to atusb and atusb-spi driver
- atusb-common.c (atusb_open): claim interface, so that we can do bulk
  I/O without complaints from the kernel
- atusb-common.h (atusb_interrupt_wait), atusb-common.c: blocking read
  for interrupt status byte on EP1
- atusb.c (atusb_driver), atusb-spi.c (atusb_spi_driver): provide the
  interrupt_wait operation
2011-06-20 17:10:29 -03:00
Werner Almesberger
e6f0a1d410 libatrf: new function atrf_interrupt_wait for interrupt-driven wait for interrupt
- tools/lib/driver.h (struct atrf_driver): new driver operation
  interrupt_wait
- include/atrf.h (atrf_interrupt_wait), atrf.c: new function to
  wait for a transceiver interrupt without polling
2011-06-20 17:10:29 -03:00
Werner Almesberger
0120f62242 atusb/fw/: added reporting of RF interrupts via bulk EP1
- board.h (board_app_init), board_app.c (board_app_init): new function
  for application-specific board initialization
- atusb.c (main): call board_app_init
- board_app.c (INT0_vect): on RF interrupt, read REG_IRQ_STATUS and
  send the status byte on EP1
- board_app.c (board_app_init): set up interrupt on rising edge of
  INT0 (INT_RF)
- descr.c (config_descriptor): added EP1 as bulk IN
2011-06-20 15:49:33 -03:00
Werner Almesberger
244e449131 atusb/fw/usb/: added support for bulk IN EP 1
The code is quite special-cased. Some more changes will be necessary
for interrupt or OUT EPs.

- atu2.c (NUM_EPS): increased from 1 to 2
- atu2.c (ep_rx): send zero-length packet also for EPs != 0
- atu2.c (handle_ep): clear FIFOCON when sending data on EP != 0
- atu2.c (ep_init): configure EP 1 as bulk IN with size 64
- usb.c (NUM_EPS): we don't need to define NUM_EPS here
2011-06-20 14:34:08 -03:00
Werner Almesberger
3f74098ce2 atusb/fw/ep0.c (my_setup): fixed test for ATUSB_SPI_READ2 2011-06-20 13:43:17 -03:00
Werner Almesberger
a37bba8755 tools/lib: added USB-SPI driver for ATUSB
- atusb-spi.c: ATUSB driver that uses the ATUSB_SPI_* functions instead
  of ATUSB_{REG,BUF,SRAM}_*
- driver.h, atrf.c (drivers, atrf_usb_handle): added atusb_spi_driver
- Makefile (OBJS): added atusb-spi.o
2011-06-19 15:50:50 -03:00
Werner Almesberger
9a0184cacb atusb/fw/: new mechanism for SPI commands (more general than reg/buf requests)
- ep0.c (setup_request): store combined request code in "req", for
  later reuse
- include/ep0.h (ATUSB_SPI_WRITE, ATUSB_SPI_READ1, ATUSB_SPI_READ2),
  ep0.c (setup_request): new requests that translate easily into
  general SPI operations
2011-06-19 15:50:49 -03:00
Werner Almesberger
13f031be25 tools/lib/: split non-SPI code from atusb.c in preparation for SPI-based driver
- atusb.c (atusb_error, atusb_clear_error, atusb_open, atusb_close,
  atusb_reset, atusb_reset_rf, atusb_test_mode, atusb_slp_tr,
  atusb_interrupt, atusb_set_clkm, atusb_dev_handle): moved to
  atusb-common.c
- atusb-common.c (atusb_set_clkm): pass atusb_reg_write via
  atusb_driver.reg_write instead
- atusb.c (FROM_DEV, TO_DEV, struct atusb_dsc): moved to atusb-common.h
- Makefile (OBJS): added atusb-common.o
2011-06-19 14:06:00 -03:00
Werner Almesberger
9746205fd9 tools/lib/atusb.c: added missing standard #includes 2011-06-19 13:09:45 -03:00
Werner Almesberger
e77658fe26 tools/dirtpan/dirtpan.c: cleaned up embarrassing explanation of control byte
- dirtpan.c: changed control byte from innovative 7 bit layout to the
  more common 8 bits. My, haven't we had our morning coffee yet ?
- dirtpan.c: added explanation that the two highest bits of the
  control byte have to be zero, to avoid conflicting with RFC4944
2011-06-19 08:40:56 -03:00
Werner Almesberger
29664701a8 BOOKSHELF: added RFC4944 (6LoWPAN) as "rfc4944" and "6lowpan" 2011-06-19 08:39:54 -03:00
Stefan Schmidt
a48c6dcb30 usb/dfu.h: Include usb.h to avoid gcc warning
With warnings treated as errors I get this:
In file included from flash.c:19:0:
usb/dfu.h:107:35: error: 'struct setup_request' declared inside parameter list
usb/dfu.h:107:35: error: its scope is only this definition or declaration, which
 is probably not what you want
make: *** [flash.o] Error 1

Struct setup_request is declared in usb.h so include it.

Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
2011-06-17 12:01:38 -03:00
Werner Almesberger
cce781078e web/index.html: removed duplicate IMG tag 2011-06-15 03:22:42 -03:00
Werner Almesberger
7e1b47bc0c web/: added zoomed-in view of atusb in action 2011-06-15 03:21:09 -03:00
Werner Almesberger
394ca56f2c web/Makefile: also upload the ~800 pixels images 2011-06-15 02:01:45 -03:00
Werner Almesberger
ea7103ef8e web/: Ben-WPAN overview page
http://downloads.qi-hardware.com/people/werner/wpan/web/
2011-06-15 01:48:26 -03:00
Werner Almesberger
a800eb8794 tools/dirtpan/dirtpan.c: added missing #include "daemon.h", oops 2011-06-13 20:01:31 -03:00
Werner Almesberger
9ef447865b tools/: rearranged cwtest/atrf-path to be more clear about reset and do re-init
- include/cwtest.h (cw_test_needs_reset), lib/cwtest.c
  (cw_test_needs_reset): new function to indicate all cases where the
  transceiver needs to be reset (instead of using SLP_TR)
- lib/cwtest.c (cw_test_end): use cw_test_needs_reset instead of
  open-coding the decision
- lib/cwtest.c (enter_test_mode_230, start_test_mode_231): always wait
  for the PLL to lock. Contrary to the assumption in the previous
  commit, we should always see this interrupt.
- atrf-path/atrf-path.c (sample): initialize the transceiver if we had
  to reset it
- atrf-path/atrf-path.c (sample), atrf-path/atrf-path.c (do_half_sweep):
  moved the tTR19 delay to "sweep", so that all branches share it and it
  is taken only once
2011-06-13 14:24:59 -03:00
Werner Almesberger
8c00833542 lib/cwtest.c (start_test_mode_231): don't insist on IRQ_PLL_LOCK
We seem to have a path where the PLL is already locked when we get
there. We thus never get an interrupt and hang.

Pending further investigation, just use a timeout that is longer
than the worst-case PLL lock time.
2011-06-13 12:37:42 -03:00
Werner Almesberger
39c37258c5 prod/: P_ON test for atusb can't work as intended ... because we're not in P_ON
The explanation is simple: reset from any state but P_ON throws us
back into TRX_OFF, not P_ON. That's why the P_ON test only worked
predictably after power-cycling the board.

- prod/atusb (gpio_usb): removed P_ON test
- prod/atben (gpio_ben): added comment to P_ON test explaining why
  it works in this case
2011-06-12 07:46:26 -03:00
Werner Almesberger
3e37af63ca prod/doc/setup.hmac: changed boot.hex and atusb.bin to the ce16a16 versions 2011-06-12 07:28:59 -03:00
Werner Almesberger
d135eb2c2a prod/atben (gpio_ben): in TRX_OFF, use that MISO is Z if nSS = H 2011-06-11 21:19:43 -03:00
Werner Almesberger
13f4a35a62 prod/atusb: P_ON test turned out to be unreliable - skip it for now
Some of the transceiver pull-up/downs don't seem to work as
expected. Until further analysis, we perform equivalent testing
in TRX_OFF, which only uses the MCU's pull-ups.
2011-06-11 21:05:46 -03:00
Werner Almesberger
5f3cc767f8 prod/atusb (TRX_OFF): walk all GPIOs. Also, use that MISO is Z if nSS = H 2011-06-11 21:04:25 -03:00
Werner Almesberger
fb80f514b8 prod/atusb (TRX_OFF): C5 was "x" for no good reason - changed to "H" 2011-06-11 20:48:27 -03:00
Werner Almesberger
ce16a16f73 atusb/fw/atusb.c (main): sleep (idle mode) while waiting for interrupts
This saves about 2 mA, leaving about 8 mA when idle. The transceiver
should consume 0.5 mA in TRX_OFF, CLKM up to 4 mA, and the idle MCU
core 1 mA. USB current is unknown.
2011-06-11 14:31:13 -03:00
Werner Almesberger
b42577bb72 atusb/fw/boot.c: adjusted the delay loop and don't race with dfu-util
- boot.c (MS_TO_LOOPS): increased loop count now that we no longer
  have to poll
- boot.c (main): increased delay from 2.0 s to 2.5 s, because we were
  racing with a sleep(2) in dfu-util
2011-06-11 14:26:52 -03:00
Werner Almesberger
376236949b atusb/fw/usb/: we were busy-looping on TXINI. Mask the interrupt when idle.
- usb/usb.h (usb_ep_change), usb/atu2.c (usb_ep_change): new function
  called by the USB stack to notify the hardware-specific driver of
  an endpoint state change (EP_TX or EP_RX)
- usb/usb.c (usb_io): call usb_ep_change
- usb/atu2.c (handle_ep): mask TXINI if we have nothing to send
2011-06-11 14:17:44 -03:00
Werner Almesberger
d03beb2257 atusb/fw/: changed USB stack to use interrupts instead of polling
Note: this change surprisingly _increases_ the DFU wait in the boot
loader. Not yet sure why.

- boot.c (main): move the interrupt vectors to the boot loader
  section
- atusb.c (main): move the interrupt vectors to the application
  section
- boot.c (main): enable global interrupts while looping (disable
  them before jumping to the application)
- board_app.c (__timer_read, timer_read): removed wrapped since
  we're now always called with interrupts disabled
- usb/atu2.c (ep_init): enable endpoint interrupts
- usb/atu2.c (usb_init): enable device interrupts
- usb/atu2.c (usb_poll, USB_GEN_vect, USB_COM_vect): moved poll
  loop code into separate handlers for device and endpoint
  interrupts
- boot.c (main), atusb.c (main): removed call to usb_poll
2011-06-11 11:06:18 -03:00
Werner Almesberger
f9681e5b4f atusb/fw/usb/atu2.c: use implicit race-free "and" when writing to UDINT/UEINTX
The old code could accidently acknowledge interrupts that appeared
between the read and the write in UxINTx &= mask.

- atu2.c (handle_ep): writing to UEINTX implies a race-free "and"
- atu2.c (usb_poll): writing to UDINT implies a race-free "and"
2011-06-11 08:16:23 -03:00
Werner Almesberger
a69916da52 atusb/fw/: make timer code use interrupts instead of polling
- board_app.c (timer_poll): replaced with interrupt handler
- board_app.c (__timer_read): merged polling of timer_poll into the
  read loop (so it works as before, provided that interrupts are
  disabled)
- board_app.c (timer_read): run __timer_read with interrupts disabled
- board_app.c (timer_init): enable timer 1 overflow interrupt
- atusb.c (main): enabled global interrupts
- atusb.c (main): don't call poll_timer anymore
- board.h (timer_poll): removed
2011-06-11 08:13:31 -03:00
Werner Almesberger
2acdaca218 atusb/fw/: moved timer initialization to board_app.c as well
- board.c (board_init), board_app.h (timer_init), board_app.c
  (timer_init): moved timer initialization from board_init to
  new function timer_init
- atusb.c (main): call timer_init
2011-06-11 01:52:16 -03:00
Werner Almesberger
2d7ee91430 atusb/fw/: added transition from runtime to DFU mode according to DFU spec
- descr.c (config_descriptor): added DFU interface descriptor
- ep0.c (my_dfu_setup, my_set_interface, ep0_init): added DFU
  interface switching
- ep0.c (my_reset, ep0_init): CPU-reset (into boot loader) on
  USB bus reset when in appDETACH
- Makefile (OBJS): added dfu_common.o
2011-06-10 23:26:36 -03:00
Werner Almesberger
5f50611735 atusb/fw/usb/: DFU_ITF_DESCR also needs a protocol argument
- dfu.h (enum dfu_itf_proto): bInterfaceProtocol values for DFU
  functional descriptor
- dfu.h (DFU_ITF_DESCR): added protocol argument
- dfu.c (config_descriptor): pass protocol to DFU_ITF_DESCR
2011-06-10 23:15:51 -03:00
Werner Almesberger
2544004a86 atusb/fw/: moved common elements of DFU processing to dfu_common.c
- dfu.c (functional_descriptor, dfu, my_descr), dfu.h (dfu_my_descr):
  moved to dfu_common.c
- dfu.c (my_setup), dfu.h (dfu_setup_common), dfu_common.c
  (dfu_setup_common): moved handling of DFU_GETSTATUS, DFU_CLRSTATUS,
  and DFU_GETSTATE from my_setup to dfu_setup_common
- dfu_common.c (my_descr), dfu.c (dfu_init): renamed my_descr to
  dfu_my_descr
- Makefile (BOOT_OBJS): added dfu_common.o
2011-06-10 22:04:12 -03:00
Werner Almesberger
bbe27fc357 atusb/fw: revert most of the user_setups change and use simple callback instead
This allows us to do other things as well, e.g., change state.

- ep0.c (ep0_init), usb/dfu.c (dfu_init): use user_setup
- usb/atu2.c (usb_poll): no need to reset user_setup - the user's
  reset function can do that
- usb/usb.h (user_setups), usb/usb.c (handle_setup): removed
  user_setups
- usb/usb.h (user_set_interface), usb/usb.c (user_set_interface,
  handle_setup): callback for SET_INTERFACE
2011-06-10 21:50:42 -03:00
Werner Almesberger
7a2c785e29 atusb/fw/usb/dfu.h: define DFU interface descriptor, for later sharing
- dfu.h (DFU_ITF_DESCR): define DFU interface descriptor
- dfu.c (config_descriptor): use DFU_ITF_DESCR instead of open-coding
  the descriptor
2011-06-10 19:33:24 -03:00
Werner Almesberger
3cc92cc4a6 atusb/fw/: define USB bus current (40 mA) in board.h based on measured value
The measured values are:

board idle, looping	  9 mA
LED on			+ 5 mA
TX CW (+3 dBm)		+14 mA
			------
			 28 mA
			======

Adding a margin of 12 mA, we get 40 mA. DFU used 30 mA so far, the
application 50 mA.

- board.h (BOARD_MAX_mA): define maximum USB bus current
- descr.c (config_descriptor), usb/dfu.c (config_descriptor):
  use BOARD_MAX_mA for bMaxPower instead of hard-coding values
2011-06-10 19:33:24 -03:00
Werner Almesberger
89d13ce8f8 atusb/fw/: SET_INTERFACE can now select among interfaces (changes user_setup)
- ep0.c (ep0_init), usb/dfu.c (dfu_init): set user_setups[0] instead
  of user_setup
- usb/atu2.c (usb_poll): reset user_setup on bus reset
- usb/usb.h (user_setups), usb/usb.c (user_setups): array of
  interface-specific setup functions
- usb/usb.c (handle_setup): in SET_INTERFACE, select setup function
  from user_setups according to interface
- usb/usb.c (handle_setup): if user_setup is not set (e.g., the
  optional SET_INTERFACE was never issued), fall back to user_setups[0]
2011-06-10 17:12:57 -03:00
Werner Almesberger
4d4e132f0a atrf-xmit: tightened checking of interrupt behaviour
- atrf-xmit.c (xfer_one): also check that also the sender has no
  pending interrupts before we start sending
- atrf-xmit.c (xfer_one): interrupt poll loop (now disabled) checked
  the sender, not the receiver. oops.
- atrf-xmit.c (xfer_one): upon reception, check that the sender has
  finished (IRQ_TRX_END) as well
2011-06-09 21:08:14 -03:00
Werner Almesberger
256ac01ab2 atusb/fw/board.c (reset_rf): increased 1 us delays to nominally 2 us
They should be at least 625 ns. Can't hurt to have a little tolerance.
2011-06-09 20:55:33 -03:00
Werner Almesberger
78ab017990 tools/atrf-proxy/atrf-proxy.c (cmd_zero): reduce poll delay from 100 ms to 2 ms
The overly generous delay has the effect of encouraging dubious
optimizations elsewhere. Not a good idea.
2011-06-09 20:54:07 -03:00