Ensure new Benito Programmer project matches Don's established LED behaviour - flash...
authorDean Camera <dean@fourwalledcubicle.com>
Fri, 24 Jul 2009 01:26:36 +0000 (01:26 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Fri, 24 Jul 2009 01:26:36 +0000 (01:26 +0000)
LUFA/ManPages/LUFAPoweredProjects.txt
Projects/Benito/Benito.c
Projects/Benito/Benito.h
Projects/Benito/Benito.txt
Projects/Benito/makefile

index 68e6fb6..11d1648 100644 (file)
  *\r
  *  - AVROpendous, an open design/source set of AVR USB development boards: http://avropendous.org/\r
  *  - Benito #7, a no-frills USB board: http://www.dorkbotpdx.org/blog/feurig/benito_7_the_next_big_thing\r
- *  - USBFoo, an AT90USB162 based development board: http://shop.kernelconcepts.de/product_info.php?products_id=102\r
+ *  - Bumble-B, yet another AT90USB162 development board: http://fletchtronics.net/\r
  *  - USB10 AKA "The Ferret", a AT90USB162 development board: http://www.soc-machines.com\r
+ *  - USBFoo, an AT90USB162 based development board: http://shop.kernelconcepts.de/product_info.php?products_id=102\r
  *  - Teensy and Teensy++, two other AVR USB development boards: http://www.pjrc.com/teensy/index.html\r
- *  - Bumble-B, yet another AT90USB162 development board: http://fletchtronics.net/\r
  * \r
  *  \section Sec_LUFAProjects Projects Using LUFA (Hobbyist)\r
  *\r
index 720a224..1afb74a 100644 (file)
@@ -45,6 +45,9 @@ volatile uint8_t TxPulseMSRemaining    = 0;
 /** Counter for the number of milliseconds remaining for the RX activity LED pulse being generated. */\r
 volatile uint8_t RxPulseMSRemaining    = 0;\r
 \r
+/** Counter for the number of milliseconds remaining for the enumeration LED ping-pong being generated. */\r
+volatile uint8_t PingPongMSRemaining   = 0;\r
+\r
 /** LUFA CDC Class driver interface configuration and state information. This structure is\r
  *  passed to all CDC Class driver functions, so that multiple instances of the same class\r
  *  within a device can be differentiated from one another.\r
@@ -78,8 +81,6 @@ int main(void)
 {\r
        SetupHardware();\r
 \r
-       LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
-\r
        for (;;)\r
        {\r
                /* Echo bytes from the host to the target via the hardware USART */\r
@@ -103,10 +104,20 @@ int main(void)
                /* Check if the millisecond timer has elapsed */\r
                if (TIFR0 & (1 << OCF0A))\r
                {\r
+                       /* Check if the LEDs should be ping-ponging (during enumeration) */\r
+                       if (PingPongMSRemaining && !(--PingPongMSRemaining))\r
+                       {\r
+                               LEDs_ChangeLEDs(LEDMASK_BUSY, (~LEDs_GetLEDs() & LEDMASK_BUSY));\r
+                               PingPongMSRemaining = PING_PONG_LED_PULSE_MS;\r
+                       }\r
+               \r
                        /* Check if the reset pulse period has elapsed, if so tristate the target reset line */\r
                        if (ResetPulseMSRemaining && !(--ResetPulseMSRemaining))\r
-                         AVR_RESET_LINE_DDR &= ~AVR_RESET_LINE_MASK;\r
-\r
+                       {\r
+                               LEDs_TurnOffLEDs(LEDMASK_BUSY);\r
+                               AVR_RESET_LINE_DDR &= ~AVR_RESET_LINE_MASK;\r
+                       }\r
+                       \r
                        /* Turn off TX LED(s) once the TX pulse period has elapsed */\r
                        if (TxPulseMSRemaining && !(--TxPulseMSRemaining))\r
                          LEDs_TurnOffLEDs(LEDMASK_TX);\r
@@ -151,22 +162,25 @@ void SetupHardware(void)
 /** Event handler for the library USB Connection event. */\r
 void EVENT_USB_Connect(void)\r
 {\r
-       LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
+       PingPongMSRemaining = PING_PONG_LED_PULSE_MS;\r
+       LEDs_SetAllLEDs(LEDMASK_TX);\r
 }\r
 \r
 /** Event handler for the library USB Disconnection event. */\r
 void EVENT_USB_Disconnect(void)\r
 {\r
-       LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+       PingPongMSRemaining = 0;\r
+       LEDs_TurnOffLEDs(LEDMASK_BUSY);\r
 }\r
 \r
 /** Event handler for the library USB Configuration Changed event. */\r
 void EVENT_USB_ConfigurationChanged(void)\r
 {\r
-       LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
+       PingPongMSRemaining = 0;\r
+       LEDs_TurnOffLEDs(LEDMASK_BUSY);\r
 \r
        if (!(CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface)))\r
-         LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
+         LEDs_TurnOnLEDs(LEDMASK_ERROR);\r
 }\r
 \r
 /** Event handler for the library USB Unhandled Control Packet event. */\r
@@ -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 */\r
        if (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR)\r
        {\r
+               LEDs_TurnOnLEDs(LEDMASK_BUSY);\r
+       \r
                AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK;\r
                ResetPulseMSRemaining = AVR_RESET_PULSE_MS;\r
        }\r
index 5eefd7a..740319f 100644 (file)
                #include <LUFA/Drivers/USB/Class/CDC.h>\r
 \r
        /* Macros: */\r
-               /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
-               #define LEDMASK_USB_NOTREADY      LEDS_NO_LEDS\r
-\r
-               /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
-               #define LEDMASK_USB_ENUMERATING  (LEDS_LED1 | LEDS_LED2)\r
-\r
-               /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
-               #define LEDMASK_USB_READY        LEDS_NO_LEDS\r
-\r
-               /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */\r
-               #define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED2)\r
-               \r
                /** LED mask for the library LED driver, to indicate TX activity. */\r
                #define LEDMASK_TX               LEDS_LED1\r
 \r
                /** LED mask for the library LED driver, to indicate RX activity. */\r
                #define LEDMASK_RX               LEDS_LED2\r
                \r
+               #define LEDMASK_ERROR            (LEDS_LED1 | LEDS_LED2)\r
+               \r
+               #define LEDMASK_BUSY             (LEDS_LED1 | LEDS_LED2)\r
+\r
        /* Function Prototypes: */\r
                void SetupHardware(void);\r
 \r
index 956c69a..857a28f 100644 (file)
  *    <td>Makefile CDEFS</td>\r
  *    <td>Pulse length in milliseconds for the activity Tx/Rx LEDs.</td>\r
  *   </tr>\r
+ *   <tr>\r
+ *    <td>PING_PONG_LED_PULSE_MS</td>\r
+ *    <td>Makefile CDEFS</td>\r
+ *    <td>Pulse length in milliseconds for the enumeration LED ping-poning between toggles.</td>\r
+ *   </tr>\r
  *  </table>\r
  */\r
index 71422b6..a785788 100644 (file)
@@ -196,7 +196,8 @@ CDEFS += -DAVR_RESET_LINE_PORT="PORTB"
 CDEFS += -DAVR_RESET_LINE_DDR="DDRB"\r
 CDEFS += -DAVR_RESET_LINE_MASK="(1 << 0)"\r
 CDEFS += -DAVR_RESET_PULSE_MS=10\r
-CDEFS += -DTX_RX_LED_PULSE_MS=10\r
+CDEFS += -DTX_RX_LED_PULSE_MS=30\r
+CDEFS += -DPING_PONG_LED_PULSE_MS=100\r
 \r
 # Place -D or -U options here for ASM sources\r
 ADEFS = -DF_CPU=$(F_CPU)\r