Increase timeout of Mass Storage and Still Image host commands to 10 seconds (up...
[pub/USBasp.git] / Projects / AVRISP / Lib / V2Protocol.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 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 "ISPProtocol.h"
47 #include "PDIProtocol.h"
48
49 /* Preprocessor Checks: */
50 #if (BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)
51 #undef ENABLE_ISP_PROTOCOL
52
53 #if !defined(ENABLE_PDI_PROTOCOL)
54 #define ENABLE_PDI_PROTOCOL
55 #endif
56 #endif
57
58 /* Macros: */
59 /** Programmer ID string, returned to the host during the CMD_SIGN_ON command processing */
60 #define PROGRAMMER_ID "AVRISP_MK2"
61
62 /** Timeout in milliseconds of target busy-wait loops waiting for a command to complete */
63 #define TARGET_BUSY_TIMEOUT_MS 240
64
65 /* Inline Functions: */
66 /** Blocking delay for a given number of milliseconds, via a hardware timer.
67 *
68 * \param[in] DelayMS Number of milliseconds to delay for
69 */
70 static inline void V2Protocol_DelayMS(uint8_t DelayMS)
71 {
72 TCNT0 = 0;
73 while (TCNT0 < DelayMS);
74 }
75
76 /* External Variables: */
77 extern uint32_t CurrentAddress;
78 extern bool MustSetAddress;
79
80 /* Function Prototypes: */
81 void V2Protocol_ProcessCommand(void);
82
83 #if defined(INCLUDE_FROM_V2PROTOCOL_C)
84 static void V2Protocol_UnknownCommand(uint8_t V2Command);
85 static void V2Protocol_SignOn(void);
86 static void V2Protocol_GetSetParam(uint8_t V2Command);
87 static void V2Protocol_ResetProtection(void);
88 static void V2Protocol_LoadAddress(void);
89 #endif
90
91 #endif
92