Skip to content
Snippets Groups Projects
Commit 58017e14 authored by Christos Gentsos's avatar Christos Gentsos
Browse files

Mitig: make I2C never write to TMRed variables

parent 76d0d092
Branches
Tags
No related merge requests found
......@@ -15,10 +15,11 @@ const char MFR_DAT[] = "190801";
const char MFR_SER[] = "123456789";
void page_chk();
uint8_t page_tmp;
uint16_t page __xMR;
extern uint16_t use_pec __xMR;
uint8_t use_pec_local;
uint8_t use_pec_tmp;
void set_pec();
void accvolt();
......@@ -93,7 +94,7 @@ static const int8_t cmd_data_lengths[] = {
static int8_t cmd_data_length_query = -1;
static cmd_t cmds_cmds[] = (cmd_t[]){
{0x00, (int8_t *)&cmd_data_lengths[0], (uint8_t *)&page, (fp_t)NULL, &page_chk, (fp_t)NULL, QUERY_WR | QUERY_RD | QUERY_FMT_8B, 0},
{0x00, (int8_t *)&cmd_data_lengths[0], (uint8_t *)&page_tmp, (fp_t)NULL, &page_chk, (fp_t)NULL, QUERY_WR | QUERY_RD | QUERY_FMT_8B, 0},
{0x1A, (int8_t *)&cmd_data_length_query, (uint8_t *)&query_r, (fp_t)NULL, &query_prp, (fp_t)NULL, QUERY_SUP, 1},
{0x8B, (int8_t *)&cmd_data_lengths[2], (uint8_t *)&curpage_volt, &accvolt, (fp_t)NULL, (fp_t)NULL, QUERY_RD | QUERY_FMT_LIN, 0},
{0x8C, (int8_t *)&cmd_data_lengths[3], (uint8_t *)&curpage_curr, &acccurr, (fp_t)NULL, (fp_t)NULL, QUERY_RD | QUERY_FMT_LIN, 0},
......@@ -137,7 +138,7 @@ static cmd_t ext_cmds_cmds[] = (cmd_t[]){
{0x05, (int8_t *)&ext_cmd_data_lengths[0], (uint8_t *)&dummy_byte, (fp_t)NULL, &boot_new_fw, (fp_t)NULL, 0, 0},
{0x06, (int8_t *)&ext_cmd_data_lengths[1], (uint8_t *)&dummy_byte, (fp_t)NULL, &uc_reset, (fp_t)NULL, 0, 0},
{0xA0, (int8_t *)&ext_cmd_data_lengths[2], (uint8_t *)&TMR_ERROR_CNT, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL, 0, 0},
{0xB0, (int8_t *)&ext_cmd_data_lengths[3], (uint8_t *)&use_pec_local, (fp_t)NULL, &set_pec, (fp_t)NULL, 0, 1},
{0xB0, (int8_t *)&ext_cmd_data_lengths[3], (uint8_t *)&use_pec_tmp, (fp_t)NULL, &set_pec, (fp_t)NULL, 0, 1},
{0xC0, (int8_t *)&ext_cmd_data_lengths[4], (uint8_t *)&temp_curve_points_data, (fp_t)NULL, &set_tc_curve, (fp_t)NULL, 0, 0},
{0xC1, (int8_t *)&ext_cmd_data_lengths[5], (uint8_t *)&temp_matrix_row, (fp_t)NULL, &set_tc_matrix, (fp_t)NULL, 0, 0},
{0xC4, (int8_t *)&ext_cmd_data_lengths[6], (uint8_t *)&tc_on, (fp_t)NULL, &set_tc_onoff, (fp_t)NULL, 0, 0}};
......@@ -182,8 +183,10 @@ void boot_new_fw()
void __xMR page_chk()
{
if (page > 2)
if (page_tmp > 2)
page = 2;
else
page = page_tmp;
}
......@@ -241,7 +244,7 @@ void __xMR set_frpms()
void __xMR set_pec()
{
use_pec = use_pec_local;
use_pec = use_pec_tmp;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment