kinetis: Try to be safer about our FCCOB writes so the Flash controller's less likely to get mad

This commit is contained in:
dragonmux 2022-06-22 00:21:38 -04:00 committed by Piotr Esden-Tempski
parent 0c18fcefe3
commit 6f273cadd8
1 changed files with 5 additions and 3 deletions

View File

@ -407,13 +407,15 @@ static bool kinetis_fccob_cmd(target *t, uint8_t cmd, uint32_t addr, const uint3
} while (!(fstat & FTFx_FSTAT_CCIF)); } while (!(fstat & FTFx_FSTAT_CCIF));
/* Write command to FCCOB */ /* Write command to FCCOB */
addr &= 0xffffff; addr &= 0x00ffffffU;
addr |= (uint32_t)cmd << 24; addr |= cmd << 24U;
target_mem_write32(t, FTFx_FCCOB0, addr); target_mem_write32(t, FTFx_FCCOB0, addr);
if (data) { if (data && n_items) {
target_mem_write32(t, FTFx_FCCOB4, data[0]); target_mem_write32(t, FTFx_FCCOB4, data[0]);
if (n_items > 1) if (n_items > 1)
target_mem_write32(t, FTFx_FCCOB8, data[1]); target_mem_write32(t, FTFx_FCCOB8, data[1]);
else
target_mem_write32(t, FTFx_FCCOB8, 0);
} }
/* Enable execution by clearing CCIF */ /* Enable execution by clearing CCIF */