Add function documentation to the AVRISP project.
[pub/USBasp.git] / Projects / Incomplete / AVRISP / Lib / V2ProtocolParams.c
index 61f4a88..9914c08 100644 (file)
@@ -84,24 +84,21 @@ static ParameterItem_t ParameterTable[] =
        };\r
 \r
 \r
+/** Loads saved non-volatile parameter values from the EEPROM into the parameter table, as needed. */\r
 void V2Params_LoadEEPROMParamValues(void)\r
 {\r
        /* Target RESET line polarity is a non-volatile value, retrieve current parameter value from EEPROM */\r
        V2Params_GetParamFromTable(PARAM_RESET_POLARITY)->ParamValue = eeprom_read_byte(&EEPROM_Rest_Polarity);\r
 }\r
 \r
-static ParameterItem_t* V2Params_GetParamFromTable(uint8_t ParamID)\r
-{\r
-       /* Find the parameter in the parameter table if present */\r
-       for (uint8_t TableIndex = 0; TableIndex < (sizeof(ParameterTable) / sizeof(ParameterTable[0])); TableIndex++)\r
-       {\r
-               if (ParamID == ParameterTable[TableIndex].ParamID)\r
-                 return &ParameterTable[TableIndex];\r
-       }\r
-       \r
-       return NULL;\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
+ *  \param ParamID  Parameter ID whose privellages are to be retrieved from the table\r
+ *\r
+ *  \return Privellages for the requested parameter, as a mask of PARAM_PRIV_* masks\r
+ */ \r
 uint8_t V2Params_GetParameterPrivellages(uint8_t ParamID)\r
 {\r
        ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);\r
@@ -112,6 +109,12 @@ uint8_t V2Params_GetParameterPrivellages(uint8_t ParamID)
        return ParamInfo->ParamPrivellages;\r
 }\r
 \r
+/** Retrieves the current value for a given parameter in the parameter table.\r
+ *\r
+ *  \param ParamID  Parameter ID whose value is to be retrieved from the table\r
+ *\r
+ *  \return Current value of the parameter in the table, or 0 if not found\r
+ */ \r
 uint8_t V2Params_GetParameterValue(uint8_t ParamID)\r
 {\r
        ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);\r
@@ -122,6 +125,13 @@ uint8_t V2Params_GetParameterValue(uint8_t ParamID)
        return ParamInfo->ParamValue;\r
 }\r
 \r
+/** Sets the value for a given parameter in the parameter table.\r
+ *\r
+ *  \param ParamID  Parameter ID whose value is to be set in the table\r
+ *  \param Value  New value to set the parameter to\r
+ *\r
+ *  \return Pointer to the associated parameter information from the parameter table if found, NULL otherwise\r
+ */\r
 void V2Params_SetParameterValue(uint8_t ParamID, uint8_t Value)\r
 {\r
        ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);\r
@@ -135,3 +145,22 @@ void V2Params_SetParameterValue(uint8_t ParamID, uint8_t Value)
        if (ParamID == PARAM_RESET_POLARITY)\r
          eeprom_write_byte(&EEPROM_Rest_Polarity, Value);  \r
 }\r
+\r
+/** Retrieves a parameter entry (including ID, value and privellages) from the parameter table that matches the given\r
+ *  parameter ID.\r
+ *\r
+ *  \param ParamID  Parameter ID to find in the table\r
+ *\r
+ *  \return Pointer to the associated parameter information from the parameter table if found, NULL otherwise\r
+ */\r
+static ParameterItem_t* V2Params_GetParamFromTable(uint8_t ParamID)\r
+{\r
+       /* Find the parameter in the parameter table if present */\r
+       for (uint8_t TableIndex = 0; TableIndex < (sizeof(ParameterTable) / sizeof(ParameterTable[0])); TableIndex++)\r
+       {\r
+               if (ParamID == ParameterTable[TableIndex].ParamID)\r
+                 return &ParameterTable[TableIndex];\r
+       }\r
+       \r
+       return NULL;\r
+}\r