+\r
+static void V2Protocol_ChangeTargetResetLine(bool ResetTarget)\r
+{\r
+ if (ResetTarget)\r
+ {\r
+ RESET_LINE_DDR |= RESET_LINE_MASK;\r
+ \r
+ if (!(V2Protocol_GetParameter(PARAM_RESET_POLARITY)))\r
+ RESET_LINE_PORT |= RESET_LINE_MASK;\r
+ }\r
+ else\r
+ {\r
+ RESET_LINE_PORT &= ~RESET_LINE_MASK; \r
+ RESET_LINE_DDR &= ~RESET_LINE_MASK;\r
+ }\r
+}\r
+\r
+static uint8_t V2Protocol_GetParameter(uint8_t ParamID)\r
+{\r
+ /* Find the parameter in the parameter table and retrieve the value */\r
+ for (uint8_t TableIndex = 0; TableIndex < (sizeof(ParameterTable) / sizeof(ParameterTable[0])); TableIndex++)\r
+ {\r
+ if (ParamID == ParameterTable[TableIndex].ParameterID)\r
+ return ParameterTable[TableIndex].ParameterValue;\r
+ }\r
+ \r
+ return 0;\r
+}\r
+\r
+static void V2Protocol_SetParameter(uint8_t ParamID, uint8_t Value)\r
+{\r
+ /* The target RESET line polarity is a non-volatile parameter, save to EEPROM when changed */\r
+ if (ParamID == PARAM_RESET_POLARITY)\r
+ eeprom_write_byte(&EEPROM_Rest_Polarity, Value);\r
+\r
+ /* Find the parameter in the parameter table and store the new value */\r
+ for (uint8_t TableIndex = 0; TableIndex < (sizeof(ParameterTable) / sizeof(ParameterTable[0])); TableIndex++)\r
+ {\r
+ if (ParamID == ParameterTable[TableIndex].ParameterID)\r
+ {\r
+ ParameterTable[TableIndex].ParameterValue = Value;\r
+ return;\r
+ }\r
+ }\r
+}\r
+\r
+void V2Protocol_Init(void)\r
+{\r
+ /* Target RESET line polarity is a non-volatile value, retrieve current parameter value from EEPROM */\r
+ V2Protocol_SetParameter(PARAM_RESET_POLARITY, eeprom_read_byte(&EEPROM_Rest_Polarity));\r
+}\r