From 3991c94b3858bbb02ca9ea6497cf60c84635b99a Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 24 Jul 2009 01:26:36 +0000 Subject: [PATCH] Ensure new Benito Programmer project matches Don's established LED behaviour - flash LED while generating target /RESET pulse, ping-pong LEDs during enumeration. --- LUFA/ManPages/LUFAPoweredProjects.txt | 4 ++-- Projects/Benito/Benito.c | 32 ++++++++++++++++++++------- Projects/Benito/Benito.h | 16 ++++---------- Projects/Benito/Benito.txt | 5 +++++ Projects/Benito/makefile | 3 ++- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/LUFA/ManPages/LUFAPoweredProjects.txt b/LUFA/ManPages/LUFAPoweredProjects.txt index 68e6fb619e..11d16480e3 100644 --- a/LUFA/ManPages/LUFAPoweredProjects.txt +++ b/LUFA/ManPages/LUFAPoweredProjects.txt @@ -20,10 +20,10 @@ * * - AVROpendous, an open design/source set of AVR USB development boards: http://avropendous.org/ * - Benito #7, a no-frills USB board: http://www.dorkbotpdx.org/blog/feurig/benito_7_the_next_big_thing - * - USBFoo, an AT90USB162 based development board: http://shop.kernelconcepts.de/product_info.php?products_id=102 + * - Bumble-B, yet another AT90USB162 development board: http://fletchtronics.net/ * - USB10 AKA "The Ferret", a AT90USB162 development board: http://www.soc-machines.com + * - USBFoo, an AT90USB162 based development board: http://shop.kernelconcepts.de/product_info.php?products_id=102 * - Teensy and Teensy++, two other AVR USB development boards: http://www.pjrc.com/teensy/index.html - * - Bumble-B, yet another AT90USB162 development board: http://fletchtronics.net/ * * \section Sec_LUFAProjects Projects Using LUFA (Hobbyist) * diff --git a/Projects/Benito/Benito.c b/Projects/Benito/Benito.c index 720a2245d0..1afb74a72c 100644 --- a/Projects/Benito/Benito.c +++ b/Projects/Benito/Benito.c @@ -45,6 +45,9 @@ volatile uint8_t TxPulseMSRemaining = 0; /** Counter for the number of milliseconds remaining for the RX activity LED pulse being generated. */ volatile uint8_t RxPulseMSRemaining = 0; +/** Counter for the number of milliseconds remaining for the enumeration LED ping-pong being generated. */ +volatile uint8_t PingPongMSRemaining = 0; + /** LUFA CDC Class driver interface configuration and state information. This structure is * passed to all CDC Class driver functions, so that multiple instances of the same class * within a device can be differentiated from one another. @@ -78,8 +81,6 @@ int main(void) { SetupHardware(); - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); - for (;;) { /* Echo bytes from the host to the target via the hardware USART */ @@ -103,10 +104,20 @@ int main(void) /* Check if the millisecond timer has elapsed */ if (TIFR0 & (1 << OCF0A)) { + /* Check if the LEDs should be ping-ponging (during enumeration) */ + if (PingPongMSRemaining && !(--PingPongMSRemaining)) + { + LEDs_ChangeLEDs(LEDMASK_BUSY, (~LEDs_GetLEDs() & LEDMASK_BUSY)); + PingPongMSRemaining = PING_PONG_LED_PULSE_MS; + } + /* Check if the reset pulse period has elapsed, if so tristate the target reset line */ if (ResetPulseMSRemaining && !(--ResetPulseMSRemaining)) - AVR_RESET_LINE_DDR &= ~AVR_RESET_LINE_MASK; - + { + LEDs_TurnOffLEDs(LEDMASK_BUSY); + AVR_RESET_LINE_DDR &= ~AVR_RESET_LINE_MASK; + } + /* Turn off TX LED(s) once the TX pulse period has elapsed */ if (TxPulseMSRemaining && !(--TxPulseMSRemaining)) LEDs_TurnOffLEDs(LEDMASK_TX); @@ -151,22 +162,25 @@ void SetupHardware(void) /** Event handler for the library USB Connection event. */ void EVENT_USB_Connect(void) { - LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); + PingPongMSRemaining = PING_PONG_LED_PULSE_MS; + LEDs_SetAllLEDs(LEDMASK_TX); } /** Event handler for the library USB Disconnection event. */ void EVENT_USB_Disconnect(void) { - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + PingPongMSRemaining = 0; + LEDs_TurnOffLEDs(LEDMASK_BUSY); } /** Event handler for the library USB Configuration Changed event. */ void EVENT_USB_ConfigurationChanged(void) { - LEDs_SetAllLEDs(LEDMASK_USB_READY); + PingPongMSRemaining = 0; + LEDs_TurnOffLEDs(LEDMASK_BUSY); if (!(CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface))) - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + LEDs_TurnOnLEDs(LEDMASK_ERROR); } /** Event handler for the library USB Unhandled Control Packet event. */ @@ -224,6 +238,8 @@ void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const C /* Check if the DTR line has been asserted - if so, start the target AVR's reset pulse */ if (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR) { + LEDs_TurnOnLEDs(LEDMASK_BUSY); + AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK; ResetPulseMSRemaining = AVR_RESET_PULSE_MS; } diff --git a/Projects/Benito/Benito.h b/Projects/Benito/Benito.h index 5eefd7aeb6..740319f64e 100644 --- a/Projects/Benito/Benito.h +++ b/Projects/Benito/Benito.h @@ -51,24 +51,16 @@ #include /* Macros: */ - /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ - #define LEDMASK_USB_NOTREADY LEDS_NO_LEDS - - /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ - #define LEDMASK_USB_ENUMERATING (LEDS_LED1 | LEDS_LED2) - - /** LED mask for the library LED driver, to indicate that the USB interface is ready. */ - #define LEDMASK_USB_READY LEDS_NO_LEDS - - /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ - #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED2) - /** LED mask for the library LED driver, to indicate TX activity. */ #define LEDMASK_TX LEDS_LED1 /** LED mask for the library LED driver, to indicate RX activity. */ #define LEDMASK_RX LEDS_LED2 + #define LEDMASK_ERROR (LEDS_LED1 | LEDS_LED2) + + #define LEDMASK_BUSY (LEDS_LED1 | LEDS_LED2) + /* Function Prototypes: */ void SetupHardware(void); diff --git a/Projects/Benito/Benito.txt b/Projects/Benito/Benito.txt index 956c69a335..857a28f8d1 100644 --- a/Projects/Benito/Benito.txt +++ b/Projects/Benito/Benito.txt @@ -90,5 +90,10 @@ * Makefile CDEFS * Pulse length in milliseconds for the activity Tx/Rx LEDs. * + * + * PING_PONG_LED_PULSE_MS + * Makefile CDEFS + * Pulse length in milliseconds for the enumeration LED ping-poning between toggles. + * * */ diff --git a/Projects/Benito/makefile b/Projects/Benito/makefile index 71422b64e4..a785788c7d 100644 --- a/Projects/Benito/makefile +++ b/Projects/Benito/makefile @@ -196,7 +196,8 @@ CDEFS += -DAVR_RESET_LINE_PORT="PORTB" CDEFS += -DAVR_RESET_LINE_DDR="DDRB" CDEFS += -DAVR_RESET_LINE_MASK="(1 << 0)" CDEFS += -DAVR_RESET_PULSE_MS=10 -CDEFS += -DTX_RX_LED_PULSE_MS=10 +CDEFS += -DTX_RX_LED_PULSE_MS=30 +CDEFS += -DPING_PONG_LED_PULSE_MS=100 # Place -D or -U options here for ASM sources ADEFS = -DF_CPU=$(F_CPU)