Minor documentation improvements.
[pub/USBasp.git] / Projects / AVRISP-MKII / Lib / V2Protocol.c
index a955a95..fa3d6a3 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2012.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -42,30 +42,26 @@ uint32_t CurrentAddress;
 /** Flag to indicate that the next read/write operation must update the device's current extended FLASH address */
 bool MustLoadExtendedAddress;
 
 /** Flag to indicate that the next read/write operation must update the device's current extended FLASH address */
 bool MustLoadExtendedAddress;
 
-/** Command timeout expiration flag. */
-volatile bool TimeoutExpired;
 
 
-#if (ARCH == ARCH_AVR8) // TODO: FIXME
 /** ISR to manage timeouts whilst processing a V2Protocol command */
 ISR(WDT_vect, ISR_BLOCK)
 {
        TimeoutExpired = true;
        wdt_disable();
 }
 /** ISR to manage timeouts whilst processing a V2Protocol command */
 ISR(WDT_vect, ISR_BLOCK)
 {
        TimeoutExpired = true;
        wdt_disable();
 }
-#endif
 
 
-/** Initialises the hardware and software associated with the V2 protocol command handling. */
+/** Initializes the hardware and software associated with the V2 protocol command handling. */
 void V2Protocol_Init(void)
 {
        #if defined(ADC)
        /* Initialize the ADC converter for VTARGET level detection on supported AVR models */
        ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);
        ADC_SetupChannel(VTARGET_ADC_CHANNEL);
 void V2Protocol_Init(void)
 {
        #if defined(ADC)
        /* Initialize the ADC converter for VTARGET level detection on supported AVR models */
        ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);
        ADC_SetupChannel(VTARGET_ADC_CHANNEL);
-       ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | VTARGET_ADC_CHANNEL_MASK);
+       ADC_StartReading(VTARGET_REF_MASK | ADC_RIGHT_ADJUSTED | VTARGET_ADC_CHANNEL_MASK);
        #endif
 
        V2Params_LoadNonVolatileParamValues();
        #endif
 
        V2Params_LoadNonVolatileParamValues();
-       
+
        #if defined(ENABLE_ISP_PROTOCOL)
        ISPTarget_ConfigureRescueClock();
        #endif
        #if defined(ENABLE_ISP_PROTOCOL)
        ISPTarget_ConfigureRescueClock();
        #endif
@@ -79,12 +75,10 @@ void V2Protocol_ProcessCommand(void)
 {
        uint8_t V2Command = Endpoint_Read_8();
 
 {
        uint8_t V2Command = Endpoint_Read_8();
 
-       #if (ARCH == ARCH_AVR8) // TODO: FIXME
        /* Start the watchdog with timeout interrupt enabled to manage the timeout */
        TimeoutExpired = false;
        wdt_enable(WDTO_1S);
        WDTCSR |= (1 << WDIE);
        /* Start the watchdog with timeout interrupt enabled to manage the timeout */
        TimeoutExpired = false;
        wdt_enable(WDTO_1S);
        WDTCSR |= (1 << WDIE);
-       #endif
 
        switch (V2Command)
        {
 
        switch (V2Command)
        {
@@ -146,10 +140,8 @@ void V2Protocol_ProcessCommand(void)
                        break;
        }
 
                        break;
        }
 
-       #if (ARCH == ARCH_AVR8) // TODO: FIXME
        /* Disable the timeout management watchdog timer */
        wdt_disable();
        /* Disable the timeout management watchdog timer */
        wdt_disable();
-       #endif
 
        Endpoint_WaitUntilReady();
        Endpoint_SelectEndpoint(AVRISP_DATA_OUT_EPNUM);
 
        Endpoint_WaitUntilReady();
        Endpoint_SelectEndpoint(AVRISP_DATA_OUT_EPNUM);