Commit 930973a8 authored by Adam Wujek's avatar Adam Wujek

main_fw/i2c: Avoid using globals in Replication Scope

Avoid errors when COAST is used and no optimizations are enabled
Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parent f500f93e
...@@ -262,7 +262,7 @@ cmd_space_t cmds = { ...@@ -262,7 +262,7 @@ cmd_space_t cmds = {
cmds_cmds cmds_cmds
}; };
static uint32_t fw_write_buf[FLASH_ROW_SIZE/4]; static uint32_t fw_write_buf[FLASH_ROW_SIZE/sizeof(uint32_t)] __xMR;
void uc_reset() void uc_reset()
{ {
...@@ -297,7 +297,7 @@ void boot_new_fw() ...@@ -297,7 +297,7 @@ void boot_new_fw()
} }
/* backup existing user data */ /* backup existing user data */
for (uint8_t i = 0; i < FLASH_ROW_SIZE/4; ++i) for (uint8_t i = 0; i < FLASH_ROW_SIZE/sizeof(uint32_t); ++i)
fw_write_buf[i] = char_user_flash[i]; fw_write_buf[i] = char_user_flash[i];
/* set 0xBEC0ABCD copy FW code */ /* set 0xBEC0ABCD copy FW code */
...@@ -401,6 +401,13 @@ void set_tmr_error(void) ...@@ -401,6 +401,13 @@ void set_tmr_error(void)
#if defined(MMFANT) || defined(MMPROT) #if defined(MMFANT) || defined(MMPROT)
/* Get 32 bit word from flash with word_index.
* Needed for COAST when optimizations are disabled. */
static uint32_t get_flash_32(uint8_t word_index)
{
return ((uint32_t *)&user_flash)[word_index];
}
void __xMR fan_config() void __xMR fan_config()
{ {
fan_installed[0] = (fan_config_1_2 >> 7) & 0x1; fan_installed[0] = (fan_config_1_2 >> 7) & 0x1;
...@@ -415,12 +422,11 @@ void __xMR fan_config() ...@@ -415,12 +422,11 @@ void __xMR fan_config()
fan_cmdrpm[2] = (fan_config_3_4 >> 6) & 0x1; fan_cmdrpm[2] = (fan_config_3_4 >> 6) & 0x1;
fan_ppr[2] = (fan_config_3_4 >> 4) & 0x3; fan_ppr[2] = (fan_config_3_4 >> 4) & 0x3;
uint32_t *char_user_flash = (uint32_t *)&user_flash;
user_flash_t *tmp_user_flash = (user_flash_t *)&fw_write_buf; user_flash_t *tmp_user_flash = (user_flash_t *)&fw_write_buf;
/* backup existing user data */ /* backup existing user data */
for (uint8_t i = 0; i < FLASH_ROW_SIZE/4; ++i) for (uint8_t i = 0; i < FLASH_ROW_SIZE/sizeof(uint32_t); ++i)
fw_write_buf[i] = char_user_flash[i]; fw_write_buf[i] = get_flash_32(i);
/* set 0xBEC0ABCD copy FW code */ /* set 0xBEC0ABCD copy FW code */
for (uint8_t i = 0; i < 3; ++i) { for (uint8_t i = 0; i < 3; ++i) {
...@@ -453,12 +459,11 @@ void __xMR set_frpms() ...@@ -453,12 +459,11 @@ void __xMR set_frpms()
setfrpms[1] = linear_to_float(setfrpms_lin[1]); setfrpms[1] = linear_to_float(setfrpms_lin[1]);
setfrpms[2] = linear_to_float(setfrpms_lin[2]); setfrpms[2] = linear_to_float(setfrpms_lin[2]);
uint32_t *char_user_flash = (uint32_t *)&user_flash;
user_flash_t *tmp_user_flash = (user_flash_t *)&fw_write_buf; user_flash_t *tmp_user_flash = (user_flash_t *)&fw_write_buf;
/* backup existing user data */ /* backup existing user data */
for (uint8_t i = 0; i < FLASH_ROW_SIZE/4; ++i) for (uint8_t i = 0; i < FLASH_ROW_SIZE/sizeof(uint32_t); ++i)
fw_write_buf[i] = char_user_flash[i]; fw_write_buf[i] = get_flash_32(i);
/* set 0xBEC0ABCD copy FW code */ /* set 0xBEC0ABCD copy FW code */
for (uint8_t i = 0; i < 3; ++i) for (uint8_t i = 0; i < 3; ++i)
......
Markdown is supported
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