/***************************************************************************//** * @file bl_flash.h * @brief This file is the header file of bootloader flash. * @version V1.0.0 * @date May-2021 * @author Zhixin Semiconductor * * @note * Copyright (C) 2021 Zhixin Semiconductor Ltd. All rights reserved. * ******************************************************************************/ #ifndef BL_FLASH_H #define BL_FLASH_H #include "flash_drv.h" /* Disable interrupts, keep exceptions enabled */ #define BlInterruptsDisable() __asm( "cpsid i" ) #define BlInterruptsEnable() __asm( "cpsie i" ) /*#define WATCHDOG_ENABLE*/ #define BL_PFLASH_END_ADDR 0x1FFFFFU #define BL_DFLASH_END_ADDR 0x0101FFFFU #define BL_FLASH_IFR_END_ADDR 0x02007FFFU #define BL_SRAM_START_ADDR 0x1FFE0000U #define BL_SRAM_END_ADDR 0x2001FFFFU #define FLASH_PHRASE_LEN 16U #define FLASH_SECTOR_SIZE 0x2000U #define APP_INFO_ADDR 0x8000U #define FLASH_TEST_ADDR 0x00040000U #define WDOG ((wdog_reg_t *) WDOG_BASE_ADDR) /*!< watchdog Register */ #define WDOG_W ((wdog_reg_w_t *) WDOG_BASE_ADDR) /*!< watchdog Register */ #define ASSERT(xValue) #ifndef NULL_PTR #define NULL_PTR ((void *)0) #endif #define BL_FLASH_DRV_FROM_HOST typedef uint32_t tLogicalAddr; typedef struct { tLogicalAddr xBlockStartLogicalAddr; /* block start logical addr */ tLogicalAddr xBlockLength; /* block Length */ } BlockInfo_t; ResultStatus_t FlashVerifyPhrase(uint32_t addr); ResultStatus_t FlashEraseSector(uint32_t addr); ResultStatus_t FlashWriteWithPadding(const uint8_t data[], uint32_t len, uint32_t addr); FlagStatus_t FlashCheckValidAddr(uint32_t addr, uint32_t len); FlagStatus_t FlashCheckFlashDrvValid(void); ResultStatus_t FlashInit(void); void FeedWatchdog(void); bool FLASH_HAL_GetFlashDriverInfo(uint32_t *o_pFlashDriverAddrStart, uint32_t *o_pFlashDriverEndAddr); #ifdef BL_FLASH_DRV_FROM_HOST #define BL_FLASH_DRV_VALID_FLAG_ADDR 0x200003FCU #define BL_FLASH_DRV_VALID_FLAG_VALUE 0x6BFD8912U #define BL_FLASH_RAM_FUNC_NUM 3U void FlashSetFlashDrvFlag(FlagStatus_t flag); void InitFlashDrvAPI(void); #endif #endif/* BL_FLASH_H */