3      Copyright (C) Dean Camera, 2012. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaim all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  33  *  Header file for V2Protocol.c. 
  41                 #include <avr/interrupt.h> 
  44                 #include <LUFA/Drivers/USB/USB.h> 
  46                 #include "../Descriptors.h" 
  47                 #include "V2ProtocolConstants.h" 
  48                 #include "V2ProtocolParams.h" 
  49                 #include "ISP/ISPProtocol.h" 
  50                 #include "XPROG/XPROGProtocol.h" 
  52         /* Preprocessor Checks: */ 
  53                 #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) 
  54                         #undef ENABLE_ISP_PROTOCOL 
  56                         #if !defined(ENABLE_XPROG_PROTOCOL) 
  57                                 #define ENABLE_XPROG_PROTOCOL 
  61                 #if defined(USB_SERIES_4_AVR) && ((VTARGET_ADC_CHANNEL == 2) || (VTARGET_ADC_CHANNEL == 3)) && !defined(NO_VTARGET_DETECT) 
  62                         #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. 
  65                 #if defined(VTARGET_USE_INTERNAL_REF) 
  66                         #undef  VTARGET_REF_VOLTS 
  67                         #define VTARGET_REF_VOLTS 2.56 
  69                         #define VTARGET_REF_MASK ADC_REFERENCE_INT2560MV 
  71                         #define VTARGET_REF_MASK ADC_REFERENCE_AVCC 
  75                 /** Programmer ID string, returned to the host during the CMD_SIGN_ON command processing. */ 
  76                 #define PROGRAMMER_ID              "AVRISP_MK2" 
  78                 /** Timeout period for each issued command from the host before it is aborted (in 10ms ticks). */ 
  79                 #define COMMAND_TIMEOUT_TICKS      100 
  81                 /** Command timeout ticks remaining counter, GPIOR for speed. */ 
  82                 #define TimeoutTicksRemaining      GPIOR1 
  84                 /** MUX mask for the VTARGET ADC channel number. */ 
  85                 #define VTARGET_ADC_CHANNEL_MASK   ADC_GET_CHANNEL_MASK(VTARGET_ADC_CHANNEL) 
  87         /* External Variables: */ 
  88                 extern uint32_t CurrentAddress
; 
  89                 extern bool     MustLoadExtendedAddress
; 
  91         /* Function Prototypes: */ 
  92                 void V2Protocol_Init(void); 
  93                 void V2Protocol_ProcessCommand(void); 
  95                 #if defined(INCLUDE_FROM_V2PROTOCOL_C) 
  96                         static void V2Protocol_UnknownCommand(const uint8_t V2Command
); 
  97                         static void V2Protocol_SignOn(void); 
  98                         static void V2Protocol_GetSetParam(const uint8_t V2Command
); 
  99                         static void V2Protocol_ResetProtection(void); 
 100                         static void V2Protocol_LoadAddress(void);