Documentation: Add additional project links.
[pub/USBasp.git] / Projects / AVRISP-MKII / Lib / ISP / ISPTarget.h
index 4c0ea82..16fd330 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2012.
+     Copyright (C) Dean Camera, 2019.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2019  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
@@ -18,7 +18,7 @@
   advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
-  The author disclaim all warranties with regard to this
+  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
@@ -47,7 +47,7 @@
                #include "../V2Protocol.h"
                #include "ISPProtocol.h"
                #include "Config/AppConfig.h"
-               
+
        /* Preprocessor Checks: */
                #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
                        #undef ENABLE_ISP_PROTOCOL
                #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)
+               #define ISP_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;
+               extern bool ISPTarget_HardwareSPIMode;
 
        /* Function Prototypes: */
                void    ISPTarget_EnableTargetISP(void);
@@ -93,7 +93,7 @@
                 */
                static inline void ISPTarget_SendByte(const uint8_t Byte)
                {
-                       if (HardwareSPIMode)
+                       if (ISPTarget_HardwareSPIMode)
                          SPI_SendByte(Byte);
                        else
                          ISPTarget_TransferSoftSPIByte(Byte);
                 */
                static inline uint8_t ISPTarget_ReceiveByte(void)
                {
-                       #if !defined(INVERTED_ISP_MISO)
-                       if (HardwareSPIMode)
-                         return SPI_ReceiveByte();
+                       uint8_t ReceivedByte;
+
+                       if (ISPTarget_HardwareSPIMode)
+                         ReceivedByte = SPI_ReceiveByte();
                        else
-                         return ISPTarget_TransferSoftSPIByte(0x00);
+                         ReceivedByte = ISPTarget_TransferSoftSPIByte(0x00);
+
+                       #if defined(INVERTED_ISP_MISO)
+                       return ~ReceivedByte;
                        #else
-                       if (HardwareSPIMode)
-                         return ~SPI_ReceiveByte();
-                       else
-                         return ~ISPTarget_TransferSoftSPIByte(0x00);
+                       return  ReceivedByte;
                        #endif
                }
 
                 */
                static inline uint8_t ISPTarget_TransferByte(const uint8_t Byte)
                {
-                       #if !defined(INVERTED_ISP_MISO)
-                       if (HardwareSPIMode)
-                         return SPI_TransferByte(Byte);
+                       uint8_t ReceivedByte;
+
+                       if (ISPTarget_HardwareSPIMode)
+                         ReceivedByte = SPI_TransferByte(Byte);
                        else
-                         return ISPTarget_TransferSoftSPIByte(Byte);
+                         ReceivedByte = ISPTarget_TransferSoftSPIByte(Byte);
+
+                       #if defined(INVERTED_ISP_MISO)
+                       return ~ReceivedByte;
                        #else
-                       if (HardwareSPIMode)
-                         return ~SPI_TransferByte(Byte);
-                       else
-                         return ~ISPTarget_TransferSoftSPIByte(Byte);
+                       return  ReceivedByte;
                        #endif
                }