Prevent the CDC Device Class driver from sending empty IN packets on every service...
[pub/USBasp.git] / Projects / AVRISP / Lib / V2ProtocolParams.c
index 9914c08..2d646a9 100644 (file)
@@ -85,12 +85,25 @@ static ParameterItem_t ParameterTable[] =
 \r
 \r
 /** Loads saved non-volatile parameter values from the EEPROM into the parameter table, as needed. */\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
 {\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
        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
 /** 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