From dd312cead486c5abb1c3e8efb949fc433ecadff9 Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Mon, 23 Jan 2012 20:28:34 +0000
Subject: [PATCH] Make all AVRISP-MKII programmer parameters readable, since
 there's no real good reason to restrict parameter reads. Fix misspelt target
 reset polarity EEPROM variable.

---
 Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c     |  4 +++-
 Projects/AVRISP-MKII/Lib/V2ProtocolParams.c    | 10 +++++-----
 Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c |  4 ++--
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
index 7368125f6..f51eeaeb2 100644
--- a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
+++ b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
@@ -515,7 +515,9 @@ void ISPProtocol_SPIMulti(void)
 	}
 }
 
-/** Blocking delay for a given number of milliseconds.
+/** Blocking delay for a given number of milliseconds. This provides a simple wrapper around
+ *  the avr-libc provided delay function, so that the delay function can be called with a
+ *  constant value (to prevent run-time floating point operations being required).
  *
  *  \param[in] DelayMS  Number of milliseconds to delay for
  */
diff --git a/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c b/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c
index 3c1a88130..5028dad88 100644
--- a/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c
+++ b/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c
@@ -37,7 +37,7 @@
 #include "V2ProtocolParams.h"
 
 /* Non-Volatile Parameter Values for EEPROM storage */
-static uint8_t EEMEM EEPROM_Rest_Polarity = 0x00;
+static uint8_t EEMEM EEPROM_Reset_Polarity = 0x00;
 
 /* Volatile Parameter Values for RAM storage */
 static ParameterItem_t ParameterTable[] =
@@ -71,7 +71,7 @@ static ParameterItem_t ParameterTable[] =
 		  .ParamValue       = 6                                  },
 
 		{ .ParamID          = PARAM_RESET_POLARITY,
-		  .ParamPrivileges  = PARAM_PRIV_WRITE,
+		  .ParamPrivileges  = PARAM_PRIV_READ | PARAM_PRIV_WRITE,
 		  .ParamValue       = 0x01                               },
 
 		{ .ParamID          = PARAM_STATUS_TGT_CONN,
@@ -79,7 +79,7 @@ static ParameterItem_t ParameterTable[] =
 		  .ParamValue       = STATUS_ISP_READY                   },
 
 		{ .ParamID          = PARAM_DISCHARGEDELAY,
-		  .ParamPrivileges  = PARAM_PRIV_WRITE,
+		  .ParamPrivileges  = PARAM_PRIV_READ | PARAM_PRIV_WRITE,
 		  .ParamValue       = 0x00                               },
 	};
 
@@ -88,7 +88,7 @@ static ParameterItem_t ParameterTable[] =
 void V2Params_LoadNonVolatileParamValues(void)
 {
 	/* Target RESET line polarity is a non-volatile value, retrieve current parameter value from EEPROM */
-	V2Params_GetParamFromTable(PARAM_RESET_POLARITY)->ParamValue = eeprom_read_byte(&EEPROM_Rest_Polarity);
+	V2Params_GetParamFromTable(PARAM_RESET_POLARITY)->ParamValue = eeprom_read_byte(&EEPROM_Reset_Polarity);
 }
 
 /** Updates any parameter values that are sourced from hardware rather than explicitly set by the host, such as
@@ -163,7 +163,7 @@ void V2Params_SetParameterValue(const uint8_t ParamID,
 
 	/* The target RESET line polarity is a non-volatile parameter, save to EEPROM when changed */
 	if (ParamID == PARAM_RESET_POLARITY)
-	  eeprom_update_byte(&EEPROM_Rest_Polarity, Value);
+	  eeprom_update_byte(&EEPROM_Reset_Polarity, Value);
 }
 
 /** Retrieves a parameter entry (including ID, value and privileges) from the parameter table that matches the given
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
index 132acf154..529510f46 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
@@ -444,10 +444,10 @@ static void XPROGProtocol_SetParam(void)
 	switch (XPROGParam)
 	{
 		case XPRG_PARAM_NVMBASE:
-			XPROG_Param_NVMBase = Endpoint_Read_32_BE();
+			XPROG_Param_NVMBase       = Endpoint_Read_32_BE();
 			break;
 		case XPRG_PARAM_EEPPAGESIZE:
-			XPROG_Param_EEPageSize = Endpoint_Read_16_BE();
+			XPROG_Param_EEPageSize    = Endpoint_Read_16_BE();
 			break;
 		case XPRG_PARAM_NVMCMD_REG:
 			XPROG_Param_NVMCMDRegAddr = Endpoint_Read_8();
-- 
GitLab