{\r
SetupHardware();\r
\r
- V2Params_LoadEEPROMParamValues();\r
+ V2Params_LoadNonVolatileParamValues();\r
\r
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
\r
{
Process_AVRISP_Commands();\r
\r
- #if defined(ADC)\r
- /* Update VTARGET parameter with the latest ADC conversion of VTARGET on supported AVR models */\r
- V2Params_SetParameterValue(PARAM_VTARGET, ((5 * 10 * ADC_GetResult()) / 1024));\r
- #endif
-\r
+ V2Params_UpdateParamValues();\r
+ \r
USB_USBTask();\r
}\r
}\r
\r
\r
/** Loads saved non-volatile parameter values from the EEPROM into the parameter table, as needed. */\r
-void V2Params_LoadEEPROMParamValues(void)\r
+void V2Params_LoadNonVolatileParamValues(void)\r
{\r
- /* Target RESET line polarity is a non-volatile value, retrieve current parameter value from EEPROM */\r
+ /* Target RESET line polarity is a non-volatile value, retrieve current parameter value from EEPROM -\r
+ * NB: Cannot call V2Protocol_SetParameterValue() here, as that will cause another EEPROM write!\r
+ */\r
V2Params_GetParamFromTable(PARAM_RESET_POLARITY)->ParamValue = eeprom_read_byte(&EEPROM_Rest_Polarity);\r
}\r
\r
+/** Updates any parameter values that are sourced from hardware rather than explicitly set by the host, such as\r
+ * VTARGET levels from the ADC on supported AVR models.\r
+ */\r
+void V2Params_UpdateParamValues(void)\r
+{\r
+ #if defined(ADC)\r
+ /* Update VTARGET parameter with the latest ADC conversion of VTARGET on supported AVR models */\r
+ V2Params_GetParamFromTable(PARAM_VTARGET)->ParamValue = ((5 * 10 * ADC_GetResult()) / 1024);\r
+ #endif\r
+}\r
+\r
/** Retrieves the host PC read/write privellages for a given parameter in the parameter table. This should\r
* be called before calls to \ref V2Params_GetParameterValue() or \ref V2Params_SetParameterValue() when\r
* getting or setting parameter values in response to requests from the host.\r
\r
#include <LUFA/Version.h>
\r
+ #if defined(ADC)\r
+ #include <LUFA/Drivers/Peripheral/ADC.h>\r
+ #endif\r
+ \r
#include "V2Protocol.h"\r
#include "V2ProtocolConstants.h"\r
\r
} ParameterItem_t;
/* Function Prototypes: */\r
- void V2Params_LoadEEPROMParamValues(void);\r
+ void V2Params_LoadNonVolatileParamValues(void);\r
+ void V2Params_UpdateParamValues(void);\r
\r
uint8_t V2Params_GetParameterPrivellages(uint8_t ParamID);\r
uint8_t V2Params_GetParameterValue(uint8_t ParamID);\r