3 Copyright (C) Dean Camera, 2009.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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 V2ProtocolTarget.c.
36 #ifndef _V2_PROTOCOL_TARGET_
37 #define _V2_PROTOCOL_TARGET_
41 #include <util/delay.h>
43 #include <LUFA/Drivers/USB/USB.h>
44 #include <LUFA/Drivers/Peripheral/SPI.h>
46 #include "../Descriptors.h"
47 #include "V2ProtocolConstants.h"
48 #include "V2ProtocolParams.h"
51 /** Total number of allowable ISP programming speeds supported by the device */
52 #define TOTAL_PROGRAMMING_SPEEDS 7
54 /** Timeout in milliseconds of target busy-wait loops waiting for a command to complete */
55 #define TARGET_BUSY_TIMEOUT_MS 240
57 /* External Variables: */
58 extern uint32_t CurrentAddress
;
60 /* Inline Functions: */
61 /** Blocking delay for a given number of milliseconds, via a hardware timer.
63 * \param[in] DelayMS Number of milliseconds to delay for
65 static inline void V2Protocol_DelayMS(uint8_t DelayMS
)
68 while (TCNT0
< DelayMS
);
71 /* Function Prototypes: */
72 uint8_t V2Protocol_GetSPIPrescalerMask(void);
73 void V2Protocol_ChangeTargetResetLine(bool ResetTarget
);
74 void V2Protocol_DelayMS(uint8_t MS
);
75 uint8_t V2Protocol_WaitForProgComplete(uint8_t ProgrammingMode
, uint16_t PollAddress
, uint8_t PollValue
,
76 uint8_t DelayMS
, uint8_t ReadMemCommand
);
77 uint8_t V2Protocol_WaitWhileTargetBusy(void);
78 void V2Protocol_LoadExtendedAddress(void);