diff options
author | tmk <hasu@tmk-kbd.com> | 2015-05-13 11:13:10 +0900 |
---|---|---|
committer | tmk <hasu@tmk-kbd.com> | 2015-05-13 11:13:10 +0900 |
commit | f6d56675f9f981c5464f0ca7a1fbb0162154e8c5 (patch) | |
tree | 57c9d4b3808a26116ae0ee7956fc00b84841aa2b /protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h | |
parent | 4d116a04e94cf0d19317d5b44e4fa9f34a3e5594 (diff) |
Squashed 'tmk_core/' changes from caca2c0..dc0e46e
dc0e46e Rename LUFA to LUFA-git
3bfa7fa Remove LUFA-120730
215b764 Merge commit 'afa0f22a9299686fd88f58ce09c5b521ac917e8f' as 'protocol/lufa/LUFA'
afa0f22 Squashed 'protocol/lufa/LUFA/' content from commit def7fca
c0c42fa Remove submodule of LUFA
30f897d Merge commit '87ced33feb74e79c3281dda36eb6d6d153399b41' as 'protocol/usb_hid/USB_Host_Shield_2.0'
87ced33 Squashed 'protocol/usb_hid/USB_Host_Shield_2.0/' content from commit aab4a69
14f6d49 Remove submodule of USB_Host_Shield_2.0
git-subtree-dir: tmk_core
git-subtree-split: dc0e46eaa4367d4e218f8816e3c117895820f07c
Diffstat (limited to 'protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h')
m--------- | protocol/lufa/LUFA-git | 0 | ||||
-rw-r--r-- | protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h | 147 |
2 files changed, 147 insertions, 0 deletions
diff --git a/protocol/lufa/LUFA-git b/protocol/lufa/LUFA-git deleted file mode 160000 -Subproject b6c18b2a7c544653efbe12a1d4e8ba65e7d83c3 diff --git a/protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h b/protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h new file mode 100644 index 0000000000..1687abac18 --- /dev/null +++ b/protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h @@ -0,0 +1,147 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2014. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaims all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Header file for ISPTarget.c. + */ + +#ifndef _ISP_TARGET_ +#define _ISP_TARGET_ + + /* Includes: */ + #include <avr/io.h> + #include <avr/pgmspace.h> + #include <util/delay.h> + + #include <LUFA/Drivers/USB/USB.h> + #include <LUFA/Drivers/Peripheral/SPI.h> + + #include "../V2Protocol.h" + #include "ISPProtocol.h" + #include "Config/AppConfig.h" + + /* Preprocessor Checks: */ + #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) + #undef ENABLE_ISP_PROTOCOL + + #if !defined(ENABLE_XPROG_PROTOCOL) + #define ENABLE_XPROG_PROTOCOL + #endif + #endif + + /* Macros: */ + /** Low level device command to issue an extended FLASH address, for devices with over 128KB of FLASH. */ + #define LOAD_EXTENDED_ADDRESS_CMD 0x4D + + /** Macro to convert an ISP frequency to a number of timer clock cycles for the software SPI driver. */ + #define TIMER_COMP(freq) (((F_CPU / 8) / 2 / freq) - 1) + + /** ISP rescue clock speed in Hz, for clocking targets with incorrectly set fuses. */ + #define ISP_RESCUE_CLOCK_SPEED 4000000 + + /* External Variables: */ + extern bool HardwareSPIMode; + + /* Function Prototypes: */ + void ISPTarget_EnableTargetISP(void); + void ISPTarget_DisableTargetISP(void); + void ISPTarget_ConfigureRescueClock(void); + void ISPTarget_ConfigureSoftwareSPI(const uint8_t SCKDuration); + uint8_t ISPTarget_TransferSoftSPIByte(const uint8_t Byte); + void ISPTarget_ChangeTargetResetLine(const bool ResetTarget); + uint8_t ISPTarget_WaitWhileTargetBusy(void); + void ISPTarget_LoadExtendedAddress(void); + uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, + const uint16_t PollAddress, + const uint8_t PollValue, + const uint8_t DelayMS, + const uint8_t ReadMemCommand); + + /* Inline Functions: */ + /** Sends a byte of ISP data to the attached target, using the appropriate SPI hardware or + * software routines depending on the selected ISP speed. + * + * \param[in] Byte Byte of data to send to the attached target + */ + static inline void ISPTarget_SendByte(const uint8_t Byte) + { + if (HardwareSPIMode) + SPI_SendByte(Byte); + else + ISPTarget_TransferSoftSPIByte(Byte); + } + + /** Receives a byte of ISP data from the attached target, using the appropriate + * SPI hardware or software routines depending on the selected ISP speed. + * + * \return Received byte of data from the attached target + */ + static inline uint8_t ISPTarget_ReceiveByte(void) + { + uint8_t ReceivedByte; + + if (HardwareSPIMode) + ReceivedByte = SPI_ReceiveByte(); + else + ReceivedByte = ISPTarget_TransferSoftSPIByte(0x00); + + #if defined(INVERTED_ISP_MISO) + return ~ReceivedByte; + #else + return ReceivedByte; + #endif + } + + /** Sends and receives a byte of ISP data to and from the attached target, using the + * appropriate SPI hardware or software routines depending on the selected ISP speed. + * + * \param[in] Byte Byte of data to send to the attached target + * + * \return Received byte of data from the attached target + */ + static inline uint8_t ISPTarget_TransferByte(const uint8_t Byte) + { + uint8_t ReceivedByte; + + if (HardwareSPIMode) + ReceivedByte = SPI_TransferByte(Byte); + else + ReceivedByte = ISPTarget_TransferSoftSPIByte(Byte); + + #if defined(INVERTED_ISP_MISO) + return ~ReceivedByte; + #else + return ReceivedByte; + #endif + } + +#endif + |