]> git.gir.st - tmk_keyboard.git/blob - protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/V2Protocol.h
Squashed 'tmk_core/' changes from caca2c0..dc0e46e
[tmk_keyboard.git] / protocol / lufa / LUFA-git / Projects / AVRISP-MKII / Lib / V2Protocol.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2014.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2014 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 disclaims 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 <avr/interrupt.h>
42 #include <avr/wdt.h>
43
44 #include <LUFA/Drivers/USB/USB.h>
45
46 #include "../AVRISPDescriptors.h"
47 #include "V2ProtocolConstants.h"
48 #include "V2ProtocolParams.h"
49 #include "ISP/ISPProtocol.h"
50 #include "XPROG/XPROGProtocol.h"
51 #include "Config/AppConfig.h"
52
53 /* Preprocessor Checks: */
54 #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
55 #undef ENABLE_ISP_PROTOCOL
56
57 #if !defined(ENABLE_XPROG_PROTOCOL)
58 #define ENABLE_XPROG_PROTOCOL
59 #endif
60 #endif
61
62 #if defined(USB_SERIES_4_AVR) && ((VTARGET_ADC_CHANNEL == 2) || (VTARGET_ADC_CHANNEL == 3)) && !defined(NO_VTARGET_DETECT)
63 #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.
64 #endif
65
66 #if defined(VTARGET_USE_INTERNAL_REF)
67 #undef VTARGET_REF_VOLTS
68 #define VTARGET_REF_VOLTS 2.56
69
70 #define VTARGET_REF_MASK ADC_REFERENCE_INT2560MV
71 #else
72 #define VTARGET_REF_MASK ADC_REFERENCE_AVCC
73 #endif
74
75 /* Macros: */
76 /** Programmer ID string, returned to the host during the CMD_SIGN_ON command processing. */
77 #define PROGRAMMER_ID "AVRISP_MK2"
78
79 /** Timeout period for each issued command from the host before it is aborted (in 10ms ticks). */
80 #define COMMAND_TIMEOUT_TICKS 100
81
82 /** Command timeout ticks remaining counter, GPIOR for speed. */
83 #define TimeoutTicksRemaining GPIOR1
84
85 /** MUX mask for the VTARGET ADC channel number. */
86 #define VTARGET_ADC_CHANNEL_MASK ADC_GET_CHANNEL_MASK(VTARGET_ADC_CHANNEL)
87
88 /* External Variables: */
89 extern uint32_t CurrentAddress;
90 extern bool MustLoadExtendedAddress;
91
92 /* Function Prototypes: */
93 void V2Protocol_Init(void);
94 void V2Protocol_ProcessCommand(void);
95
96 #if defined(INCLUDE_FROM_V2PROTOCOL_C)
97 static void V2Protocol_UnknownCommand(const uint8_t V2Command);
98 static void V2Protocol_SignOn(void);
99 static void V2Protocol_GetSetParam(const uint8_t V2Command);
100 static void V2Protocol_ResetProtection(void);
101 static void V2Protocol_LoadAddress(void);
102 #endif
103
104 #endif
105
Imprint / Impressum