123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- #define INCLUDE_FROM_V2PROTOCOL_PARAMS_C
- #include "V2ProtocolParams.h"
- static uint8_t EEMEM EEPROM_Reset_Polarity = 0x01;
- static uint8_t EEMEM EEPROM_SCK_Duration = 0x06;
- static ParameterItem_t ParameterTable[] =
- {
- { .ParamID = PARAM_BUILD_NUMBER_LOW,
- .ParamPrivileges = PARAM_PRIV_READ,
- .ParamValue = 0 },
- { .ParamID = PARAM_BUILD_NUMBER_HIGH,
- .ParamPrivileges = PARAM_PRIV_READ,
- .ParamValue = 0 },
- { .ParamID = PARAM_HW_VER,
- .ParamPrivileges = PARAM_PRIV_READ,
- .ParamValue = 0x00 },
- { .ParamID = PARAM_SW_MAJOR,
- .ParamPrivileges = PARAM_PRIV_READ,
- .ParamValue = 0x01 },
- { .ParamID = PARAM_SW_MINOR,
- .ParamPrivileges = PARAM_PRIV_READ,
- .ParamValue = FIRMWARE_VERSION_MINOR },
- { .ParamID = PARAM_VTARGET,
- .ParamPrivileges = PARAM_PRIV_READ,
- .ParamValue = (uint8_t)(3.3 * 10) },
- { .ParamID = PARAM_SCK_DURATION,
- .ParamPrivileges = PARAM_PRIV_READ | PARAM_PRIV_WRITE,
- .ParamValue = 6 },
- { .ParamID = PARAM_RESET_POLARITY,
- .ParamPrivileges = PARAM_PRIV_READ | PARAM_PRIV_WRITE,
- .ParamValue = 0x01 },
- { .ParamID = PARAM_STATUS_TGT_CONN,
- .ParamPrivileges = PARAM_PRIV_READ,
- .ParamValue = STATUS_ISP_READY },
- { .ParamID = PARAM_DISCHARGEDELAY,
- .ParamPrivileges = PARAM_PRIV_READ | PARAM_PRIV_WRITE,
- .ParamValue = 0x00 },
- };
- void V2Params_LoadNonVolatileParamValues(void)
- {
-
- uint8_t ResetPolarity = eeprom_read_byte(&EEPROM_Reset_Polarity);
- uint8_t SCKDuration = eeprom_read_byte(&EEPROM_SCK_Duration);
-
- if (ResetPolarity != 0xFF)
- V2Params_GetParamFromTable(PARAM_RESET_POLARITY)->ParamValue = ResetPolarity;
-
- if (SCKDuration != 0xFF)
- V2Params_GetParamFromTable(PARAM_SCK_DURATION)->ParamValue = SCKDuration;
- }
- void V2Params_UpdateParamValues(void)
- {
- #if (defined(ADC) && !defined(NO_VTARGET_DETECT))
-
- V2Params_GetParamFromTable(PARAM_VTARGET)->ParamValue = (((uint16_t)(VTARGET_REF_VOLTS * 10 * VTARGET_SCALE_FACTOR) * ADC_GetResult()) / 1024);
- #endif
- }
- uint8_t V2Params_GetParameterPrivileges(const uint8_t ParamID)
- {
- ParameterItem_t* const ParamInfo = V2Params_GetParamFromTable(ParamID);
- if (ParamInfo == NULL)
- return 0;
- return ParamInfo->ParamPrivileges;
- }
- uint8_t V2Params_GetParameterValue(const uint8_t ParamID)
- {
- ParameterItem_t* const ParamInfo = V2Params_GetParamFromTable(ParamID);
- if (ParamInfo == NULL)
- return 0;
- return ParamInfo->ParamValue;
- }
- void V2Params_SetParameterValue(const uint8_t ParamID,
- const uint8_t Value)
- {
- ParameterItem_t* const ParamInfo = V2Params_GetParamFromTable(ParamID);
- if (ParamInfo == NULL)
- return;
- ParamInfo->ParamValue = Value;
-
- if (ParamID == PARAM_RESET_POLARITY)
- eeprom_update_byte(&EEPROM_Reset_Polarity, Value);
-
- if (ParamID == PARAM_SCK_DURATION)
- eeprom_update_byte(&EEPROM_SCK_Duration, Value);
- }
- static ParameterItem_t* const V2Params_GetParamFromTable(const uint8_t ParamID)
- {
- ParameterItem_t* CurrTableItem = ParameterTable;
-
- for (uint8_t TableIndex = 0; TableIndex < TABLE_PARAM_COUNT; TableIndex++)
- {
- if (ParamID == CurrTableItem->ParamID)
- return CurrTableItem;
- CurrTableItem++;
- }
- return NULL;
- }
|