- 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
- 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
- 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)
- 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
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
- 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
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
- 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
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>
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.
- 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
- 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
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
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"
- 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
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
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
- 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]
- 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
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
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
- 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)
- 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
- 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
- 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#
- 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
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.
- 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
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.
- 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
- 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