Added ENABLE_TELNET_SERVER compile time option to the Webserver project to disable...
[pub/USBasp.git] / Projects / Benito / Benito.c
index fc87d63..86da27a 100644 (file)
@@ -1,13 +1,13 @@
 /*\r
              LUFA Library\r
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2009.\r
+     Copyright (C) Dean Camera, 2010.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
@@ -48,6 +48,9 @@ volatile struct
        uint8_t PingPongLEDPulse; /**< Milliseconds remaining for enumeration Tx/Rx ping-pong LED pulse */\r
 } PulseMSRemaining;\r
 \r
        uint8_t PingPongLEDPulse; /**< Milliseconds remaining for enumeration Tx/Rx ping-pong LED pulse */\r
 } PulseMSRemaining;\r
 \r
+/** Previous state of the virtual DTR control line from the host */\r
+bool PreviousDTRState = false;\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
 /** 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
@@ -142,9 +145,6 @@ void SetupHardware(void)
        MCUSR &= ~(1 << WDRF);\r
        wdt_disable();\r
 \r
        MCUSR &= ~(1 << WDRF);\r
        wdt_disable();\r
 \r
-       /* Disable clock division */\r
-       clock_prescale_set(clock_div_1);\r
-\r
        /* Hardware Initialization */\r
        Serial_Init(9600, false);\r
        LEDs_Init();\r
        /* Hardware Initialization */\r
        Serial_Init(9600, false);\r
        LEDs_Init();\r
@@ -247,12 +247,16 @@ ISR(USART1_RX_vect, ISR_BLOCK)
  */\r
 void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
 {\r
  */\r
 void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
 {\r
+       bool CurrentDTRState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR);\r
+\r
        /* Check if the DTR line has been asserted - if so, start the target AVR's reset pulse */\r
        /* 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
+       if (!(PreviousDTRState) && CurrentDTRState)\r
        {\r
                LEDs_SetAllLEDs(LEDMASK_BUSY);\r
        \r
                AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK;\r
                PulseMSRemaining.ResetPulse = AVR_RESET_PULSE_MS;\r
        }\r
        {\r
                LEDs_SetAllLEDs(LEDMASK_BUSY);\r
        \r
                AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK;\r
                PulseMSRemaining.ResetPulse = AVR_RESET_PULSE_MS;\r
        }\r
+       \r
+       PreviousDTRState = CurrentDTRState;\r
 }\r
 }\r