aboutsummaryrefslogtreecommitdiffstats
path: root/Projects
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2013-01-13 12:46:23 +0000
committerDean Camera <dean@fourwalledcubicle.com>2013-01-13 12:46:23 +0000
commit397d77cb44fe3c8cbdc9113f02d9a6a2b8c836fd (patch)
tree06898940dd1ff649f713fb01b9476e73383ba649 /Projects
parentf2c241548010df18dcacf18979d80f40b31cd864 (diff)
downloadlufa-397d77cb44fe3c8cbdc9113f02d9a6a2b8c836fd.tar.gz
lufa-397d77cb44fe3c8cbdc9113f02d9a6a2b8c836fd.tar.bz2
lufa-397d77cb44fe3c8cbdc9113f02d9a6a2b8c836fd.zip
Updated AVRISP-MKII Clone Programmer project so that the SCK clock period is saved in EEPROM (thanks to Gerhard Wesser).
Diffstat (limited to 'Projects')
-rw-r--r--Projects/AVRISP-MKII/Lib/V2ProtocolParams.c30
-rw-r--r--Projects/AVRISP-MKII/Lib/V2ProtocolParams.h6
2 files changed, 26 insertions, 10 deletions
diff --git a/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c b/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c
index 135521adf..585bb6521 100644
--- a/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c
+++ b/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c
@@ -37,7 +37,10 @@
#include "V2ProtocolParams.h"
/* Non-Volatile Parameter Values for EEPROM storage */
-static uint8_t EEMEM EEPROM_Reset_Polarity = 0x01;
+static uint8_t EEMEM EEPROM_Reset_Polarity = 0x01;
+
+/* Non-Volatile Parameter Values for EEPROM storage */
+static uint8_t EEMEM EEPROM_SCK_Duration = 0x06;
/* Volatile Parameter Values for RAM storage */
static ParameterItem_t ParameterTable[] =
@@ -87,8 +90,17 @@ static ParameterItem_t ParameterTable[] =
/** Loads saved non-volatile parameter values from the EEPROM into the parameter table, as needed. */
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_Reset_Polarity);
+ /* Read parameter values that are stored in non-volatile EEPROM */
+ uint8_t ResetPolarity = eeprom_read_byte(&EEPROM_Reset_Polarity);
+ uint8_t SCKDuration = eeprom_read_byte(&EEPROM_SCK_Duration);
+
+ /* Update current parameter table if the EEPROM contents was not blank */
+ if (ResetPolarity != 0xFF)
+ V2Params_GetParamFromTable(PARAM_RESET_POLARITY)->ParamValue = ResetPolarity;
+
+ /* Update current parameter table if the EEPROM contents was not blank */
+ if (SCKDuration != 0xFF)
+ V2Params_GetParamFromTable(PARAM_SCK_DURATION)->ParamValue = SCKDuration;
}
/** Updates any parameter values that are sourced from hardware rather than explicitly set by the host, such as
@@ -112,7 +124,7 @@ void V2Params_UpdateParamValues(void)
*/
uint8_t V2Params_GetParameterPrivileges(const uint8_t ParamID)
{
- ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);
+ ParameterItem_t* const ParamInfo = V2Params_GetParamFromTable(ParamID);
if (ParamInfo == NULL)
return 0;
@@ -132,7 +144,7 @@ uint8_t V2Params_GetParameterPrivileges(const uint8_t ParamID)
*/
uint8_t V2Params_GetParameterValue(const uint8_t ParamID)
{
- ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);
+ ParameterItem_t* const ParamInfo = V2Params_GetParamFromTable(ParamID);
if (ParamInfo == NULL)
return 0;
@@ -154,7 +166,7 @@ uint8_t V2Params_GetParameterValue(const uint8_t ParamID)
void V2Params_SetParameterValue(const uint8_t ParamID,
const uint8_t Value)
{
- ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);
+ ParameterItem_t* const ParamInfo = V2Params_GetParamFromTable(ParamID);
if (ParamInfo == NULL)
return;
@@ -164,6 +176,10 @@ 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_Reset_Polarity, Value);
+
+ /* The target SCK line period is a non-volatile parameter, save to EEPROM when changed */
+ if (ParamID == PARAM_SCK_DURATION)
+ eeprom_update_byte(&EEPROM_SCK_Duration, Value);
}
/** Retrieves a parameter entry (including ID, value and privileges) from the parameter table that matches the given
@@ -173,7 +189,7 @@ void V2Params_SetParameterValue(const uint8_t ParamID,
*
* \return Pointer to the associated parameter information from the parameter table if found, NULL otherwise
*/
-static ParameterItem_t* V2Params_GetParamFromTable(const uint8_t ParamID)
+static ParameterItem_t* const V2Params_GetParamFromTable(const uint8_t ParamID)
{
ParameterItem_t* CurrTableItem = ParameterTable;
diff --git a/Projects/AVRISP-MKII/Lib/V2ProtocolParams.h b/Projects/AVRISP-MKII/Lib/V2ProtocolParams.h
index 84c524fc6..21e4e81ca 100644
--- a/Projects/AVRISP-MKII/Lib/V2ProtocolParams.h
+++ b/Projects/AVRISP-MKII/Lib/V2ProtocolParams.h
@@ -48,7 +48,7 @@
#include "V2ProtocolConstants.h"
#include "ISP/ISPTarget.h"
#include "Config/AppConfig.h"
-
+
/* Macros: */
/** Parameter privilege mask to allow the host PC to read the parameter's value. */
#define PARAM_PRIV_READ (1 << 0)
@@ -58,7 +58,7 @@
/** Total number of parameters in the parameter table */
#define TABLE_PARAM_COUNT (sizeof(ParameterTable) / sizeof(ParameterTable[0]))
-
+
#if (!defined(FIRMWARE_VERSION_MINOR) || defined(__DOXYGEN__))
/** Minor firmware version, reported to the host on request; must match the version
* the host is expecting, or it (may) reject further communications with the programmer. */
@@ -84,7 +84,7 @@
const uint8_t Value);
#if defined(INCLUDE_FROM_V2PROTOCOL_PARAMS_C)
- static ParameterItem_t* V2Params_GetParamFromTable(const uint8_t ParamID);
+ static ParameterItem_t* const V2Params_GetParamFromTable(const uint8_t ParamID);
#endif
#endif