Ensure TPI enable timing requirements are met in AVRISP-MKII programmer. Remove inval...
[pub/USBasp.git] / Projects / AVRISP-MKII / Lib / V2Protocol.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
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.
20
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
28 this software.
29 */
30
31 /** \file
32 *
33 * Header file for V2Protocol.c.
34 */
35
36 #ifndef _V2_PROTOCOL_
37 #define _V2_PROTOCOL_
38
39 /* Includes: */
40 #include <LUFA/Drivers/USB/USB.h>
41 #include <LUFA/Drivers/Peripheral/SPI.h>
42
43 #include "../Descriptors.h"
44 #include "V2ProtocolConstants.h"
45 #include "V2ProtocolParams.h"
46 #include "ISP/ISPProtocol.h"
47 #include "XPROG/XPROGProtocol.h"
48
49 /* Preprocessor Checks: */
50 #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
51 #undef ENABLE_ISP_PROTOCOL
52
53 #if !defined(ENABLE_XPROG_PROTOCOL)
54 #define ENABLE_XPROG_PROTOCOL
55 #endif
56 #endif
57
58 /* Macros: */
59 #if !defined(__DOXYGEN__)
60 #define _GETADCMUXMASK2(x, y) x ## y
61 #define _GETADCMUXMASK(x, y) _GETADCMUXMASK2(x, y)
62 #endif
63
64 /** Programmer ID string, returned to the host during the CMD_SIGN_ON command processing */
65 #define PROGRAMMER_ID "AVRISP_MK2"
66
67 /** Timeout period for each issued command from the host before it is aborted */
68 #define COMMAND_TIMEOUT_MS 200
69
70 /** Command timeout counter register, GPIOR for speed */
71 #define TimeoutMSRemaining GPIOR0
72
73 /** MUX mask for the VTARGET ADC channel number */
74 #define VTARGET_ADC_CHANNEL_MASK _GETADCMUXMASK(ADC_CHANNEL, VTARGET_ADC_CHANNEL)
75
76 /* External Variables: */
77 extern uint32_t CurrentAddress;
78 extern bool MustSetAddress;
79
80 /* Function Prototypes: */
81 void V2Protocol_Init(void);
82 void V2Protocol_ProcessCommand(void);
83
84 #if defined(INCLUDE_FROM_V2PROTOCOL_C)
85 static void V2Protocol_UnknownCommand(uint8_t V2Command);
86 static void V2Protocol_SignOn(void);
87 static void V2Protocol_GetSetParam(uint8_t V2Command);
88 static void V2Protocol_ResetProtection(void);
89 static void V2Protocol_LoadAddress(void);
90 #endif
91
92 #endif
93