Repository: incubator-mynewt-core Updated Branches: refs/heads/develop f7f305404 -> 43776f285
MYNEWT-580; call FLASH_Erase() with interrupts disabled. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/43776f28 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/43776f28 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/43776f28 Branch: refs/heads/develop Commit: 43776f2855095b8607904de1824464315829ba15 Parents: f7f3054 Author: Marko Kiiskila <ma...@runtime.io> Authored: Tue Jan 31 10:34:44 2017 -0800 Committer: Marko Kiiskila <ma...@runtime.io> Committed: Tue Jan 31 10:35:53 2017 -0800 ---------------------------------------------------------------------- hw/mcu/nxp/MK64F12/src/hal_flash.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43776f28/hw/mcu/nxp/MK64F12/src/hal_flash.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nxp/MK64F12/src/hal_flash.c b/hw/mcu/nxp/MK64F12/src/hal_flash.c index d7e1b75..9b3f9a0 100644 --- a/hw/mcu/nxp/MK64F12/src/hal_flash.c +++ b/hw/mcu/nxp/MK64F12/src/hal_flash.c @@ -27,6 +27,7 @@ #include <stdio.h> #include <assert.h> #include <hal/hal_flash_int.h> +#include <os/os.h> #include "MK64F12.h" #include "fsl_flash.h" @@ -112,9 +113,17 @@ mk64f12_flash_write(const struct hal_flash *dev, uint32_t address, static int mk64f12_flash_erase_sector(const struct hal_flash *dev, uint32_t sector_address) { - if (FLASH_Erase(&mk64f12_config, sector_address, mk64f12_config.PFlashSectorSize, - kFLASH_apiEraseKey) == kStatus_Success) + int sr; + int rc; + + OS_ENTER_CRITICAL(sr); + rc = FLASH_Erase(&mk64f12_config, sector_address, + mk64f12_config.PFlashSectorSize, + kFLASH_apiEraseKey); + OS_EXIT_CRITICAL(sr); + if (rc == kStatus_Success) { return 0; + } return -1; } @@ -122,7 +131,8 @@ static int mk64f12_flash_sector_info(const struct hal_flash *dev, int idx, uint32_t *addr, uint32_t *sz) { - *addr = mk64f12_config.PFlashBlockBase + (idx * mk64f12_config.PFlashSectorSize); + *addr = mk64f12_config.PFlashBlockBase + + (idx * mk64f12_config.PFlashSectorSize); *sz = mk64f12_config.PFlashSectorSize; return 0; } @@ -133,7 +143,8 @@ mk64f12_flash_init(const struct hal_flash *dev) if (FLASH_Init(&mk64f12_config) == kStatus_Success) { mk64f12_flash_dev.hf_base_addr = mk64f12_config.PFlashBlockBase; mk64f12_flash_dev.hf_size = mk64f12_config.PFlashTotalSize; - mk64f12_flash_dev.hf_sector_cnt = (mk64f12_config.PFlashTotalSize / mk64f12_config.PFlashSectorSize); + mk64f12_flash_dev.hf_sector_cnt = + (mk64f12_config.PFlashTotalSize / mk64f12_config.PFlashSectorSize); } return 0; }