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

221 Commits

Author SHA1 Message Date
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
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
ec7c93789a atusb/fw/: added "lazy enabling" of UART-SPI after ATUSB_GPIO
- spi.h (spi_off), spi.c: disable the UART
- spi.c (spi_initialized, spi_begin, spi_init): initialize the UART
  if necessary
- board_app.c (gpio): call spi_off to disable the UART instead of
  open-coding the operation
- board_app.c (gpio): don't explicitly re-enable the UART but defer it
  to the next communication
2011-06-09 14:02:26 -03:00
Werner Almesberger
814cf6fd78 atusb/fw/boot.c (main): reset_rf implies spi_init - no need to call it here 2011-06-09 12:52:51 -03:00
Werner Almesberger
ed6d43bb35 atusb/fw/board_app.c: removed unnecessary includes 2011-06-09 12:51:13 -03:00
Werner Almesberger
e678401ac3 atusb/fw/: split board functions into app-only/shared part (boot overlflowed)
- board.c (timer_h, reset_cpu, read_irq, slp_tr, timer_poll,
  timer_read, gpio): moved to new file board_app.c
- Makefile (OBJS): added board_app.o
2011-06-09 12:48:44 -03:00
Werner Almesberger
b41076135c atusb: include the position of fiducials in atusb-pos.csv (for fab)
The SMT fab was looking there for the positions (alas, in vain).
Seems as good a place as any.

- atusb.brd: bumped file version to 20110607 (didn't change the version
  printed on the layout since the layout itself didn't change)
- atusb.brd: changed fiducials from "virtual" to "normal+insert", to
  include them in the position report
- atusb.brd: renamed the fiducials to give them unique names
- Makefile: bumped fab files version to 20110607
2011-06-07 16:51:26 -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
e6f7d85e8a atudb/fw: disable the UART in ATUSB_GPIO
- board.c (gpio): split GPIO setup and probing
- board.c (gpio): disable the UART while probing GPIOs
2011-06-05 18:27:40 -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
8a436b8abd atusb/: swapped C10 and C13 in schematics, to match layout
- atrf.sch: C10 (EVDD bypass) and C13 (DEVDD bypass) had their roles
  swapped in the layout. Swapped them in the schematics to match the
  layout.
- atusb.brd: updated the netlist
- atusb.sch, usb.sch: commit noise
2011-05-27 04:29:01 -03:00
Werner Almesberger
926ed26188 atusb: varistor Vdc was off by 100 mV; made it clearer that we use Vdc, not Vb
- atusb/atusb.sch, atusb/usb.sch, atusb/atrf.sch: bumped schematics
  version to 20110519
- atusb/usb.sch (VR1, VR2, VR3): changed voltage from 5.6 V to 5.5 V
- atusb/usb.sch (VR1, VR2, VR3): clarified that the voltage is Vdc, not Vb
- bom/atrf.chr (AVR-M1005C080MTACB): Vdc is 5.5 V, not 5.6 V
- bom/atrf.sub (VR[0-9]*): allow #.#Vdc as an alternative to #V#
2011-05-19 14:23:33 -03:00
Werner Almesberger
b82db55f4a atusb/fw/Makefile: new target "update" to update the application via DFU
- Makefile (USB_ID, dfu): moved USB ID to variable, for sharing
- Makefile (.PHONY, update): new target to reset atusb and to DFU new
  firmware
2011-05-11 05:29:54 -03:00
Werner Almesberger
85f60de9d5 atusb/fw: use the unique serial number of the ATmega8/16/32U2 for iSerialNumber
- usb/usb.h (USB_LANGID_ENGLISH_US): added USB LANGID for US-English
- board.h (board_sernum), board.c (board_sernum, hex, get_sernum,
  board_init): provide the board's serial number in "board_sernum"
  (UTF-encoded)
- sernum.h (sernum_get_descr), sernum.c (sernum_get_descr): return
  string descriptors for the serial number
- descr.c (device_descriptor), usb/dfu.c (device_descriptor):
  set iSerialNumber if serial number is available
- atusb.c (main), usb/dfu.c (my_descr): call sernum_get_descr for
  unknown descriptors
- Makefile (OBJS, BOOT_OBJS): added sernum.o
2011-05-10 17:23:08 -03:00
Werner Almesberger
fd91546c59 atusb/fw/Makefile (dfu): our functional descriptor is fine, no need for -t
What caused the error that looked like a problem with the functional
descriptor was in fact the boot loader resetting between the bus scan
and retrieval of the descriptor.
2011-05-10 11:53:32 -03:00
Werner Almesberger
ddd0022350 atusb/fw/boot.c (main): don't time out until there is an application
This prevents the boot loader from resetting all the time and makes
it easier to "catch" it with dfu-util.
2011-05-10 11:51:46 -03:00
Werner Almesberger
fc1a334bf6 atusb/fw/usb/dfu.c (dfu): lowered bwPollTimeout from 1 s to 100 ms and explained why 2011-05-10 08:32:12 -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
6179f31fc0 atusb/fw/README: boot loader flashing time was a bit too optimistic (15 -> 30 s) 2011-05-09 23:44:51 -03:00
Werner Almesberger
1f99435bba atusb/fw/README: updated for complete firmware upload process 2011-05-09 22:06:33 -03:00
Werner Almesberger
0db361d49d atusb/fw/Makefile (dfu): pass transfer size to hide DFU non-compliance
We currently don't provide the DFU Functional Descriptor, which modern
versions of dfu-util request to determine the transfer size. Luckily,
they don't do this if the transfer size is given on the command line.
2011-05-09 22:02:28 -03:00
Werner Almesberger
eeb3af6a03 atusb/fw: fixed USB bus reset handling by software
- usb/atu2.c (ep_init): moved before usb_poll
- usb/atu2.c (usb_poll): register bit was used as mask, not as shift
- usb/atu2.c (usb_poll): call ep_init on USB bus reset
- usb/atu2.c (usb_reset): don't make USB bus reset force a hardware reset
- Makefile (.PHONY, dfu): new target to upload the application with DFU
2011-05-09 21:13:41 -03:00
Werner Almesberger
c5992bc675 atusb/fw/Makefile (.PHONY): added development-only phony targets 2011-05-09 21:12:26 -03:00
Werner Almesberger
f4342f49ae atusb: enlarged USB positioning pin hole; general cleanup
- modules/usb_a_plug_smt.fpd: enlarged hole for positioning pins from
  1.1 mm to 1.15 mm
- atusb/usb.sch, atusb/atusb.cmp, atusb/atusb.brd: removed trailing space
  from CON1's value
- atusb/atusb.sch, atusb/usb.sch, atusb/atrf.sch: schematics title still
  said AT86RF230, not 231
- atusb/README-SMT: corrected a typo
- atusb/README-PCB: specified the tolerance of the hole for the positioning
  pins of the USB connector
- atusb/README-PCB: added the 16-17 mm hole for the USB connector to the
  specification
- atusb/: bumped all version numbers to 20110330
2011-03-31 03:27:11 -03:00
Werner Almesberger
6487c32387 atben/README-PCB, atusb/README-PCB: clarifications regarding holes
- atben/README-PCB, atusb/README-PCB: illustrations now contain holes
- atben/README-PCB, atusb/README-PCB: clarified distinction antenna via
  vs. hole
2011-03-29 07:53:03 -03:00
Werner Almesberger
74706cfae8 atusb.brd: updated USB-A-PLUG-SMT footprint (fped put the layers wrong) 2011-03-24 21:19:08 -03:00
Werner Almesberger
6ff2740e9b atusb.brd: moved FIDUCAL label away from mounting hole; bumped version number
- atusb.brd: "FIDUCIAL" label was on hole; moved it
- atusb.brd: bumped version to 110325
2011-03-24 13:17:04 -03:00
Werner Almesberger
269f77079a added the front solder paste to the PCB fab package (for stencil production)
- atben/README-PCB, atusb/README-PCB: added *-SoldP_Front.gtp
- makefiles/Makefile.kicad (GERBERS): added $(NAME)-SoldP_Front.gtp
- makefiles/Makefile.kicad (gerbv): also show the board edge
2011-03-24 13:12:00 -03:00
Werner Almesberger
1c4c78e110 atusb.brd: added two vias to connect front and back ground at USB shield 2011-03-24 12:45:35 -03:00
Werner Almesberger
38bea8ec54 README-SMT: various small clarifications
- atben/README-SMT, atusb/README-SMT: added "component to "orientation"
- atben/README-SMT, atusb/README-SMT: added "drawings" to "footprint
  reference"
- atben/README-SMT, atusb/README-SMT: mention once more that the automatic
  insertion file is for the front only
2011-03-24 12:18:14 -03:00
Werner Almesberger
f242368deb atben. atusb: bumped version numbers to 110324 2011-03-24 05:07:50 -03:00
Werner Almesberger
af6d563194 README-PCB: relaxed antenna via size from 8 mil to <= 15 mil 2011-03-24 00:26:10 -03:00
Werner Almesberger
7e20be97dc atben.brd, atusb.brd: set solder mask opening of fiducials to 2 mm
- atben/atben.brd, atusb/atusb.brd: set solder mask clearance of fiducials
  to 0.1 mil, so that the real solder mask opening has a diameter of
  almost) exactly 2 mm (instead of 2 mm plus 10 mil)
2011-03-23 23:46:44 -03:00
Werner Almesberger
16ac7e5f4b miscellaneous integration of fiducials
- atben/atben.brd, atusb/atusb.brd: set insertion of fiducials to
  "virtual"
- makefiles/Makefile.kicad ($(NAME)-footprints.pdf): added FIDUCIAL
2011-03-23 17:44:59 -03:00
Werner Almesberger
7a9e5185b9 atusb: added two fiducial marks
- atusb.pro: added fiducial.mod
- atusb.brd: added two fiducial marks
- atusb.brd: adjusted RF and RF power ground zones
- atusb.brd (CON1): moved component reference out of the way
- atusb.brd: bumped version to 110323
2011-03-23 13:08:48 -03:00