Added V2Protocol handlers to the AVRISP project to enter/exit programming mode, and...
[pub/lufa.git] / Projects / Incomplete / 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 <avr/io.h>
41 #include <util/delay.h>
42
43 #include <LUFA/Drivers/USB/USB.h>
44 #include <LUFA/Drivers/Peripheral/SPI.h>
45
46 #include "../Descriptors.h"
47 #include "V2ProtocolConstants.h"
48 #include "V2ProtocolParams.h"
49
50 /* Macros: */
51 #define PROGRAMMER_ID "AVRISP_MK2"
52 #define TARGET_BUST_TIMEOUT_MS 100
53
54 /* Function Prototypes: */
55 void V2Protocol_ProcessCommand(void);
56
57 #if defined(INCLUDE_FROM_V2PROTOCOL_C)
58 static uint8_t V2Protocol_GetSPIPrescalerMask(void);
59 static void V2Protocol_ChangeTargetResetLine(bool ResetTarget);
60 static void V2Protocol_DelayMS(uint8_t MS);
61 static uint8_t V2Protocol_WaitWhileTargetBusy(void);
62
63 static void V2Protocol_Command_Unknown(uint8_t V2Command);
64 static void V2Protocol_Command_SignOn(void);
65 static void V2Protocol_Command_GetSetParam(uint8_t V2Command);
66 static void V2Protocol_Command_LoadAddress(void);
67 static void V2Protocol_Command_EnterISPMode(void);
68 static void V2Protocol_Command_LeaveISPMode(void);
69 static void V2Protocol_Command_ChipErase(void);
70 static void V2Protocol_Command_ReadFuseLockSigOSCCAL(uint8_t V2Command);
71 static void V2Protocol_Command_WriteFuseLock(uint8_t V2Command);
72 static void V2Protocol_Command_SPIMulti(void);
73 #endif
74
75 #endif
76