Added new VTARGET_USE_INTERNAL_REF configuration option to the AVRISP-MKII clone...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 26 Jul 2011 03:07:32 +0000 (03:07 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 26 Jul 2011 03:07:32 +0000 (03:07 +0000)
LUFA/ManPages/ChangeLog.txt
LUFA/ManPages/CompileTimeTokens.txt
Projects/AVRISP-MKII/AVRISP-MKII.txt
Projects/AVRISP-MKII/Lib/V2Protocol.c
Projects/AVRISP-MKII/Lib/V2Protocol.h
Projects/AVRISP-MKII/makefile

index 91aa6fe..639e6c7 100644 (file)
@@ -39,6 +39,7 @@
   *   - Added new AudioInputHost Host LowLevel demo
   *   - Added new AudioOutputHost Host LowLevel demo
   *   - Added new "checksource" target to all library project makefiles
+  *   - Added new VTARGET_USE_INTERNAL_REF configuration option to the AVRISP-MKII clone project (thanks to Volker Bosch)
   *
   *  <b>Changed:</b>
   *  - Core:
index 22acb7b..e96f7c1 100644 (file)
  *  can be accurately set and the \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events manually raised by the RAISE_EVENT macro.
  *  When defined, this token disables the library's auto-detection of the connection state by the aforementioned suspension and wake up events.
  *
- *  <b>NO_SOF_EVENTS</b> - (\ref Group_Events) - <i>AVR8, UC3</i> \n
+ *  <b>NO_SOF_EVENTS</b> - (\ref Group_Events) - <i>All Architectures</i> \n
  *  By default, there exists a LUFA application event for the start of each USB frame while the USB bus is not suspended in either host or device mode.
  *  This event can be selectively enabled or disabled by calling the appropriate device or host mode function. When this compile time token is defined,
  *  the ability to receive USB Start of Frame events via the \ref EVENT_USB_Device_StartOfFrame() or \ref EVENT_USB_Host_StartOfFrame() events is removed,
  *  is through control endpoint requests. Defining this token will remove several features related to the selection and control of device
  *  endpoints internally, saving space. Generally, this is usually only useful in (some) bootloaders and is best avoided.
  *
- *  <b>INTERRUPT_CONTROL_ENDPOINT</b> - (\ref Group_USBManagement) - <i>AVR8 Only</i> \n
+ *  <b>INTERRUPT_CONTROL_ENDPOINT</b> - (\ref Group_USBManagement) - <i>All Architectures</i> \n
  *  Some applications prefer to not call the USB_USBTask() management task regularly while in device mode, as it can complicate code significantly.
  *  Instead, when device mode is used this token can be passed to the library via the -D switch to allow the library to manage the USB control
  *  endpoint entirely via USB controller interrupts asynchronously to the user application. When defined, USB_USBTask() does not need to be called
index fb6411b..ab355bf 100644 (file)
  *        to the ADC. <i>Ignored when compiled for targets lacking an ADC, or when NO_VTARGET_DETECT is defined.</i></td>
  *   </tr>
  *   <tr>
+ *    <td>VTARGET_USE_INTERNAL_REF</td>
+ *    <td>Makefile LUFA_OPTS</td>
+ *    <td>Selects the internal 2.56V ADC reference voltage, instead of using the AVR's VREF pin. When enabled, this option will
+ *        override the VTARGET_REF_VOLTS configuration option.</i></td>
+ *   </tr>
+ *   <tr>
  *    <td>VTARGET_SCALE_FACTOR</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Indicates the target's supply voltage scale factor when applied to the ADC. A simple resistive divider can be used on the
index 4c8f058..65e34fa 100644 (file)
@@ -57,7 +57,7 @@ void V2Protocol_Init(void)
        /* 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();
index 8e9e6ff..2511571 100644 (file)
                #if defined(USB_SERIES_4_AVR) && ((VTARGET_ADC_CHANNEL == 2) || (VTARGET_ADC_CHANNEL == 3))
                        #error The U4 AVR chips do not contain ADC channels 2 or 3. Please change VTARGET_ADC_CHANNEL or define NO_VTARGET_DETECT in the makefile.
                #endif
+               
+               #if defined(VTARGET_USE_INTERNAL_REF)
+                       #undef  VTARGET_REF_VOLTS
+                       #define VTARGET_REF_VOLTS 2.56
+                       
+                       #define VTARGET_REF_MASK ADC_REFERENCE_INT2560MV
+               #else
+                       #define VTARGET_REF_MASK ADC_REFERENCE_AVCC
+               #endif
 
        /* Macros: */
                /** Programmer ID string, returned to the host during the CMD_SIGN_ON command processing. */
index 0675242..36c6c89 100644 (file)
@@ -140,6 +140,7 @@ LUFA_OPTS += -D ENABLE_XPROG_PROTOCOL
 LUFA_OPTS += -D VTARGET_ADC_CHANNEL=2
 LUFA_OPTS += -D VTARGET_REF_VOLTS=5
 LUFA_OPTS += -D VTARGET_SCALE_FACTOR=1
+#LUFA_OPTS += -D VTARGET_USE_INTERNAL_REF
 #LUFA_OPTS += -D NO_VTARGET_DETECT
 #LUFA_OPTS += -D LIBUSB_DRIVER_COMPAT
 #LUFA_OPTS += -D XCK_RESCUE_CLOCK_ENABLE