Ensure new Benito Programmer project matches Don's established LED behaviour - flash LED while generating target /RESET pulse, ping-pong LEDs during enumeration.
This commit is contained in:
		
							parent
							
								
									2a0c28e6e4
								
							
						
					
					
						commit
						3991c94b38
					
				
					 5 changed files with 38 additions and 24 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
 *  - USB10 AKA "The Ferret", a AT90USB162 development board: http://www.soc-machines.com
 | 
			
		||||
 *  - 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/
 | 
			
		||||
 *  - 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
 | 
			
		||||
 * 
 | 
			
		||||
 *  \section Sec_LUFAProjects Projects Using LUFA (Hobbyist)
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,9 +104,19 @@ 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))
 | 
			
		||||
			{
 | 
			
		||||
				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))
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,24 +51,16 @@
 | 
			
		|||
		#include <LUFA/Drivers/USB/Class/CDC.h>
 | 
			
		||||
 | 
			
		||||
	/* 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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -90,5 +90,10 @@
 | 
			
		|||
 *    <td>Makefile CDEFS</td>
 | 
			
		||||
 *    <td>Pulse length in milliseconds for the activity Tx/Rx LEDs.</td>
 | 
			
		||||
 *   </tr>
 | 
			
		||||
 *   <tr>
 | 
			
		||||
 *    <td>PING_PONG_LED_PULSE_MS</td>
 | 
			
		||||
 *    <td>Makefile CDEFS</td>
 | 
			
		||||
 *    <td>Pulse length in milliseconds for the enumeration LED ping-poning between toggles.</td>
 | 
			
		||||
 *   </tr>
 | 
			
		||||
 *  </table>
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue