3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 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.
40 #if !defined(__ASSEMBLER__)
41 #include <LUFA/Drivers/USB/USB.h>
42 #include <LUFA/Drivers/Peripheral/SPI.h>
44 #include "../Descriptors.h"
45 #include "V2ProtocolConstants.h"
46 #include "V2ProtocolParams.h"
47 #include "ISP/ISPProtocol.h"
48 #include "XPROG/XPROGProtocol.h"
51 /* Preprocessor Checks: */
52 #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
53 #undef ENABLE_ISP_PROTOCOL
55 #if !defined(ENABLE_XPROG_PROTOCOL)
56 #define ENABLE_XPROG_PROTOCOL
61 #if !defined(__DOXYGEN__)
62 #define _GETADCMUXMASK2(x, y) x ## y
63 #define _GETADCMUXMASK(x, y) _GETADCMUXMASK2(x, y)
66 /** Programmer ID string, returned to the host during the CMD_SIGN_ON command processing. */
67 #define PROGRAMMER_ID "AVRISP_MK2"
69 /** Timeout period for each issued command from the host before it is aborted. */
70 #define COMMAND_TIMEOUT_MS 200
72 /** Command timeout counter register, GPIOR for speed. */
73 #define TimeoutMSRemaining GPIOR0
75 /** MUX mask for the VTARGET ADC channel number. */
76 #define VTARGET_ADC_CHANNEL_MASK _GETADCMUXMASK(ADC_CHANNEL, VTARGET_ADC_CHANNEL)
78 #if !defined(WIN_AVRDUDE_COMPAT)
79 #define SELECT_DATA_OUT_ENDPOINT() Endpoint_SetEndpointDirection(ENDPOINT_DIR_OUT);
81 #define SELECT_DATA_OUT_ENDPOINT() Endpoint_SelectEndpoint();
84 /* External Variables: */
85 #if !defined(__ASSEMBLER__)
86 extern uint32_t CurrentAddress
;
87 extern bool MustLoadExtendedAddress
;
90 /* Function Prototypes: */
91 #if !defined(__ASSEMBLER__)
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);