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

16 Commits

Author SHA1 Message Date
Werner Almesberger
c1071309d8 atusb/fw/: added "HardMAC" support (not yet using the TRX's MAC)
- include/atusb/ep0.h (enum atspi_requests), ep0.c (my_setup): added
  new "HardMAC" requests ATUSB_RX_MODE and ATUSB_TX
- mac.h, mac.c: basic "HardMAC" procedure
- board_app.c (INT0_vect): call MAC-specific interrupt handler if
  provided
- Makefile (OBJS): added mac.o
2011-07-12 12:26:07 -03:00
Werner Almesberger
42483d67b4 atusb/fw/: added improved support for interrupt synchronization
At an interrupt barrier, the host must be able to ensure that no
interrupt generated before reaching the barrier is still pending and
will be delivered after crossing the barrier.

For this, we introduce the following concept:

- interrupts have a serial number. This number is sent to the host
  on EP 1 (currently bulk) to signal the interrupt, instead of the
  zero byte we used previously.

- the new request ATUSB_SPI_WRITE2_SYNC returns the interrupt
  serial number from after the register write (the register write
  itself is the interrupt barrier).

- the host can now check if the serial indicated from bulk and the
  serial from ATUSB_SPI_WRITE2_SYNC are the same. If yes, interrupts
  are synchronized. If not, it has to wait for the interrupt to be
  signaled on EP 1.

We should also consider the case that the interrupt serial has gotten
ahead of ATUSB_SPI_WRITE2_SYNC. But that seems to happen rarely. In
any case, it's something for the host driver to worry about, not for
the firmware.

- board.h (irq_serial), board_app.c (irq_serial, INT0_vect): count
  the interrupt serial number and return it when signaling the
  interrupt
- include/atusb/ep0.h (ATUSB_SPI_WRITE2_SYNC), ep0.c (my_setup):
  new request ATUSB_SPI_WRITE2_SYNC that does a register write, then
  returns the interrupt serial
2011-07-07 15:51:07 -03:00
Werner Almesberger
ead7ade51e Revert "atusb/fw/: added optional debug log with request ATUSB_READ_LOG"
This reverts commit 39e3d4e61a.

The log isn't so useful in its present state because we may have to
unplug/replug to get out of a troublesome condition.
2011-07-05 19:39:25 -03:00
Werner Almesberger
39e3d4e61a atusb/fw/: added optional debug log with request ATUSB_READ_LOG 2011-07-05 18:52:56 -03:00
Werner Almesberger
f7b9a18917 atusb/fw/: new request ATUSB_GPIO_CLEANUP to re-enable INT0
- board.h (gpio_cleanup), board_app.c (gpio_cleanup): restore INT0
  when done manipulating GPIOs
- board.c (gpio): updated comment explaining how to restore INT0
- include/atusb/ep0.h (enum atspi_requests), ep0.c
  (ATUSB_GPIO_CLEANUP): new request to return to normal operation
  after ATUSB_GPIO
2011-06-20 23:11:09 -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
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
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
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
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
e42203b723 atusb/fw/: new request ATUSB_SLP_TR to pulse SLP_TR
- include/atusb/ep0.h (enum atspi_requests): added ATUSB_SLP_TR
- ep0.c (my_setup): call slp_tr on ATUSB_SLP_TR
- board.h (slp_tr), board.c: pulse SLP_TR high
2011-06-05 22:34:49 -03:00
Werner Almesberger
370cd320ef atusb/fw: new request ATUSB_GPIO for direct GPIO access
reset_rf now resets all GPIOs to their default state. This way, we
can easily recover from an incomplete or incorrect use of ATUSB_GPIO.

- atusb.c (main), board.c (reset_rf): moved call to spi_init into
  reset_rf
- board.c (reset_rf, board_init): moved GPIO setup to reset_rf
- board.c (reset_rf): set GPIOs to reset defaults
- board.h (gpio), board.c: read/modify/write all settings of GPIO
  ports
- include/atusb/ep0.h (enum atspi_requests): added new request
  ATUSB_GPIO
- ep0.c (my_setup): ATUSB_GPIO reads/reconfigures a GPIO port
2011-06-04 10:29:10 -03:00
Werner Almesberger
b733431847 atusb/fw/ep0.c: fixed ATUSB_SRAM_READ
- ep0.c (my_setup): ATUSB_SRAM_READ is FROM_DEV, not TO_DEV
- ep0.c (my_setup): in ATUSB_SRAM_READ, write setup->wLength bytes,
  not "size" (which is uninitialized)
2011-06-03 14:25:19 -03:00
Werner Almesberger
8c57277953 atusb/fw/: added free-running 48 bit 8 MHz counter for clock measurements
- atusb.c (main): poll the 16 bit timer for overflows
- board.h (timer_poll, timer_read), (board.c (timer_h, timer_poll,
  timer_read, board_init): added support for a free-running 48 bit timer
  (16 bits in hardware, 32 bits in software)
- include/atusb/ep0.h (ATUSB_TIMER), ep0.c (my_setup): new request
  ATUSB_TIMER to retrieve the value of the 8 MHz counter
- include/atusb/ep0.h (enum atspi_requests): describe what the groups
  of requests do
2011-05-29 21:05:28 -03:00
Werner Almesberger
42dae8dde2 atusb/fw: implemented ATUSB_RESET
- board.c (board_init): disable the watchdog timer (tricky !)
- board.h (reset_cpu), board.c: enable the watchdog timer to cause a
  CPU reset
- ep0.c (my_setup): uncommented and updated ATUSB_RESET handler
2011-05-09 23:52:00 -03:00
Werner Almesberger
78cfc8ffeb moved atusb/fw3/ to atusb/fw/ 2011-02-22 00:24:07 -03:00