Skip to content

Commit de84e4c

Browse files
committed
Change storage API to avoid armgcc warning
1 parent 3835a97 commit de84e4c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

source/board/microbitv2/microbitv2.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,14 +812,17 @@ static uint32_t erase_storage_sector(uint32_t adr)
812812
return status;
813813
}
814814

815-
static uint32_t program_storage_page(uint32_t adr, uint32_t sz, uint32_t *buf)
815+
static uint32_t program_storage_page(uint32_t adr, uint32_t sz, uint8_t *buf)
816816
{
817-
int status = FLASH_Program(&g_flash, adr, buf, sz);
817+
/* Verify data is word aligned */
818+
util_assert(!((uint32_t)buf & 0x3));
819+
820+
int status = FLASH_Program(&g_flash, adr, (uint32_t *) buf, sz);
818821
if (status == kStatus_Success)
819822
{
820823
// Must use kFlashMargin_User, or kFlashMargin_Factory for verify program
821824
status = FLASH_VerifyProgram(&g_flash, adr, sz,
822-
buf, kFLASH_marginValueUser,
825+
(uint32_t *) buf, kFLASH_marginValueUser,
823826
NULL, NULL);
824827
}
825828
return status;
@@ -844,7 +847,7 @@ static void i2c_write_flash_callback(uint8_t* pData, uint8_t size) {
844847
/* Validate length field matches with I2C Write data */
845848
if (size == length + 8) {
846849
/* Address range and alignment validation done inside program_storage_page() */
847-
status = program_storage_page(address, length, (uint32_t *) data);
850+
status = program_storage_page(address, length, (uint8_t *) data);
848851

849852
if (0 != status) {
850853
pI2cCommand->cmdId = gFlashError_c;
@@ -989,7 +992,7 @@ static void i2c_write_flash_callback(uint8_t* pData, uint8_t size) {
989992
pI2cCommand->cmdId = gFlashError_c;
990993
}
991994
else {
992-
status = program_storage_page(FLASH_CONFIG_ADDRESS, sizeof(flashConfig_t), (uint32_t *) &gflashConfig);
995+
status = program_storage_page(FLASH_CONFIG_ADDRESS, sizeof(flashConfig_t), (uint8_t *) &gflashConfig);
993996
}
994997
}
995998
i2c_fillBuffer((uint8_t*) pI2cCommand, 0, 1);

0 commit comments

Comments
 (0)