1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-22 14:04:59 +02:00
Commit Graph

272 Commits

Author SHA1 Message Date
Werner Almesberger
7fd9044d94 atusb/fw/: add SPI block reception
This decreases the retrieval time for a frame of 102 bytes from
660 us to 384 us, corresponding to a speed change from about
1.26 Mbps to 2.17 Mbps (102 bytes plus 2 bytes overhead).
2013-07-30 19:52:54 -03:00
Werner Almesberger
0706773e38 atusb/fw/Makefile: improve size reporting (show segment sizes) 2013-07-24 17:19:55 -03:00
Werner Almesberger
998ac7e5c6 atusb/fw/mac.c (next_buf): dedicated function for incrementing buffer indices 2013-07-24 16:21:38 -03:00
Werner Almesberger
b73d5fc1af atusb/fw/mac.c: remove queued_rx; buffer frames in the MCU instead
queued_rx held a frame in the transceiver's receive buffer until we could
transfer it. This may cause frame loss if a new reception begins.

We now retrieve frames from the transceiver immediately and buffer them
in the MCU.
2013-07-24 07:57:35 -03:00
Werner Almesberger
6416fa8d0b atusb/fw/mac.c: add section titles 2013-07-23 12:50:42 -03:00
Werner Almesberger
367c1abb0e atusb/fw/: echo back TX ACK sequence number; don't panic if driver times out TX 2013-04-01 22:04:05 -03:00
Werner Almesberger
9b2696b848 atusb/fw/usb/: enable MCU reset on USB bus reset after config selection
This way the host can reset the MCU if it's hung (for example, in the
panic loop) and we don't need to unplug-replug.
2013-04-01 15:54:44 -03:00
Werner Almesberger
65722d417a atusb/fw/mac.c: queue frame reception if USB is busy
This way we we make sure we retrieve the frame and thus release dynamic
buffer protection (if enabled).
2013-04-01 15:17:37 -03:00
Werner Almesberger
ad70d7c129 include/atusb/atusb.h: salvage cute explanation of 0x1540 from usb-ids.h 2013-04-01 14:43:36 -03:00
Werner Almesberger
dab0d183a2 atusb/fw/include/atusb/usb-ids.h: remove (and adapt former users) 2013-04-01 14:40:14 -03:00
Werner Almesberger
d76bdf6a82 atusb/fw/mac.c (handle_irq): move frame reception to separate function 2013-04-01 14:29:57 -03:00
Werner Almesberger
60ee82ba93 atusb/fw/mac.c (handle_irq): only handle TRX_END; never fall back to seq ints 2013-04-01 12:48:30 -03:00
Werner Almesberger
3e749c3140 fw/include/atusb/ep0.h: protect also USB_DIR_IN and USB_DIR_OUT
They're currently not defined by libusb, but since the kernel has them,
they may eventually also end up in user space.
2013-04-01 11:23:48 -03:00
Werner Almesberger
16dd767857 fw/include/atusb/ep0.h (USB_TYPE_VENDOR): avoid conflict with /usr/include/usb.h 2013-04-01 05:59:18 -03:00
Werner Almesberger
2d43876e4a atusb/fw/board.h: de-duplicate USB ID definitions (now originate from atusb.h) 2013-04-01 05:54:58 -03:00
Werner Almesberger
12d3401f64 fw/include/atusb/: move shared protocol definitions from ep0.h to atusb.h 2013-04-01 05:47:53 -03:00
Werner Almesberger
647f3c0375 atusb/fw/: get rid of some more "int"s
No size change this time.
2013-03-29 19:19:49 -03:00
Werner Almesberger
a8db238cbb atusb/fw/: convert functions returning "int" to "bool"
Firmware size is down from 5612 to 3590 bytes. Wow !
2013-03-29 19:14:11 -03:00
Werner Almesberger
c9ab070ffd atusb/fw/mac.c (do_tx): add timeout for transition to TRX_STATUS_RX_[AACK_]ON 2013-03-29 18:50:54 -03:00
Werner Almesberger
211280356d atusb/fw/mac.c: check CRC and auto-discard bad frames 2013-03-29 17:02:24 -03:00
Werner Almesberger
5fc9575e4e atusb/fw/mac.c (do_tx): pulse SLP_TR instead of sending TRX_CMD_TX_START 2013-03-29 15:03:03 -03:00
Werner Almesberger
88c7e64e38 atusb/fw/mac.c (txing, queued_tx_ack): change from "int" to "bool" 2013-02-20 18:48:53 -03:00
Werner Almesberger
de8bcc1925 atusb/fw/mac.c: always wait for stability before changing transceiver state 2013-02-20 13:05:33 -03:00
Werner Almesberger
852aaf1b66 atusb/fw/: reset MAC state on ATUSB_RF_RESET 2013-02-13 09:30:21 -03:00
Werner Almesberger
911eb4d4b5 fw/mac.c (handle_irq): read REG_IRQ_STATUS also if we ignore the value
Else, we won't get any further interrupts.
2013-02-13 01:35:23 -03:00
Werner Almesberger
42f1a78807 atben/atben.sch, atusb/atrf.sch: correct and clarify ESR of X1 (reported by Wolfgang Spraul)
The maximum ESR is 100 Ohm, not 80 Ohm. Also changes "=" to "<=" to
make it clear that this is a maximum value.
2012-05-29 02:48:31 -03:00
Werner Almesberger
65f1454d87 atusb/usb.sch: bring back USB_A_PLUG (was lost for an unknown reason)
The symbol/component name got changed to USB_A_PLUG~ and the component
was no longer found. Re-inserting it seem to have solved that problem.
2012-05-23 23:49:31 -03:00
Werner Almesberger
b401a53bf5 Updated profiles (atusb, atusb-sil, cntr) for move of USB symbols 2011-08-14 04:43:12 -03:00
Werner Almesberger
c699a921c1 Updated profiles (atusb, atusb-sil, cntr) for move of usb_a_plug_smt.fpd 2011-08-14 03:09:00 -03:00
Werner Almesberger
e87ad08097 Updated profiles (atusb, atusb-sil, cntr) for move of MCU symbols 2011-08-14 01:25:53 -03:00
Werner Almesberger
7a8ca1b50b Updated profiles (atben, atusb, atusb-sil, cntr) for move of qfn.fpd and qfp.fpd 2011-08-14 00:47:17 -03:00
Werner Almesberger
eeeb5599f8 atusb/fw/mac.c: reserved code 0 and added notification of TX completion
- mac.c (queued_tx_ack, rx_done, handle_irq): on TX completion, send a
  a zero byte on EP 1
- mac.c (handle_irq): don't receive zero-sized frames (they're
  malformed anyway), so that size zero can be used to signal TX
  completion
2011-07-13 14:22:49 -03:00
Werner Almesberger
da7803a746 atusb/fw/: some small "HardMAC" fixes 2011-07-12 17:48:17 -03:00
Werner Almesberger
862b554e2d libatrf: added HardMAC functions
This function set isn't really usable for real communication. Its main
purpose is to help with testing the firmware.

- tools/lib/driver.h (struct atrf_driver): added driver functions for
  HardMAC access
- tools/include/atrf.h (atrf_rx_mode, atrf_rx, atrf_tx),
  tools/lib/atrf.c: functions to enable/disable HardMAC mode and to
  send/receive frames
2011-07-12 17:45:59 -03:00
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
e700b81642 atusb/fw/Makefile (bindist): new target to upload and describe atusb.bin 2011-07-12 12:26:07 -03:00
Werner Almesberger
7cae01bc0e atusb/fw/board_app.c (INT0_vect): limit interrupt serials to 0x80-0xff
This leaves the range 0x00-0x7f for other uses.
2011-07-12 12:25:53 -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
8f949842db atusb/fw/: remove unused items when building the USB driver for the boot loader
- usb/atu2.c (NUM_EPS), board.h (NUM_EPS): moved definition to
  board.h
- board.h (NUM_EPS): use one EP for the boot loader, two for the
  application
- usb/atu2.c (ep_init): initialize EP 1 only in an application build
2011-06-26 06:59:13 -03:00
Werner Almesberger
6909fc232a atusb/fw/Makefile: introduce target-specific compliation variants
- Makefile (USB_OBJS): moved into OBJS and BOOT_OBJS
- Makefile (OBJS): atu2.o is now app-atu2.o
- Makefile (BOOT_OBJS): atu2.o is now boot-atu2.o
- Makefile (MKDEP, %.o): moved dependency generation to macro $(MKDEP)
- Makefile (app-%.o): build from usb/%.c
- Makefile (boot -%.o): build from usb/%.c and set -DBOOT_LOADER
2011-06-26 06:56:01 -03:00
Werner Almesberger
23c592250e atusb/fw/board_app.c: do not read and accumulate IRQs; flash LED when EP1 busy
To indicate an interrupt, we just send a zero byte.
2011-06-23 13:03:34 -03:00
Werner Almesberger
27fc0a0e2c atusb/fw/: aggregate interrupts while waiting
- board_app.c (INT0_vect): always read IRQ_STATUS, even if an
  interrupt is already enqueued
- board_app.c (INT0_vect): if an interrupt is enqueued, accumulate
  the interrupts signaled since
- board_app.c (irqs_more): when a pending transfer completes, send
  interrupts accumulated since (if any)
2011-06-23 09:41:40 -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
12fef1b196 atusb/fw/: disable INT0 if manipulating GPIOs (tentative)
Since GPIO manipulations may cause stray INT0 activity, we turn off
INT0 handing on ATUSB_GPIO. The MCU must be reset to restore access
to INT0.

There are still issues to resolve with the GPIO test. It may turn
out that there's a less invasive solution than just turning off
INT0 completely.

- board_app.c (gpio): mask INT0 before manipulating GPIOs
- board_app.c (board_app_init): make it clearer that EIMSK is a bit
  mask
2011-06-20 20:50:22 -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
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