From 24ca2d49fef526b95e6efcd3cdcbe38377ae4f02 Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Tue, 29 Nov 2011 11:30:25 +0000
Subject: [PATCH] Bit-bang ISP in the AVRISP-MKII clone project needs to set
 MOSI pin to the MSB of the data byte on startup, not the LSB.

---
 Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
index 2158f4de2..a6ec53600 100644
--- a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
+++ b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
@@ -243,7 +243,8 @@ uint8_t ISPTarget_TransferSoftSPIByte(const uint8_t Byte)
 	SoftSPI_Data          = Byte;
 	SoftSPI_BitsRemaining = 8;
 
-	if (SoftSPI_Data & 0x01)
+	/* Set initial MOSI pin state according to the byte to be transferred */
+	if (SoftSPI_Data & (1 << 7))
 	  PORTB |=  (1 << 2);
 	else
 	  PORTB &= ~(1 << 2);
-- 
GitLab