57 #include "../inc/hw_types.h" 58 #include "../inc/hw_flash.h" 59 #include "../inc/hw_memmap.h" 60 #include "../inc/hw_ints.h" 61 #include "../inc/hw_vims.h" 72 #define FAPI_STATUS_SUCCESS 0x00000000 73 #define FAPI_STATUS_FSM_BUSY 0x00000001 74 #define FAPI_STATUS_FSM_READY 0x00000002 75 #define FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH 0x00000003 76 #define FAPI_STATUS_FSM_ERROR 0x00000004 77 #define FAPI_STATUS_ADDRESS_ERROR 0x00000005 78 #define FAPI_STATUS_INVALID_KEY 0x00000010 85 #define FLASH_NO_PROTECT 0x00000000 86 #define FLASH_WRITE_PROTECT 0x00000001 99 return (FLASH_MAIN_SECTOR_SIZE);
114 return (FLASH_MAIN_SIZE);
145 if (address >= FLASH_MAIN_SIZE)
150 if (address < (32 * FLASH_MAIN_SECTOR_SIZE))
152 mask = (1 << (address / FLASH_MAIN_SECTOR_SIZE));
153 regOffset = VIMS_O_WEPRA;
155 else if (address < (256 * FLASH_MAIN_SECTOR_SIZE))
157 mask = (1 << ((address / (8 * FLASH_MAIN_SECTOR_SIZE))));
158 regOffset = VIMS_O_WEPRB0;
160 else if (address < (512 * FLASH_MAIN_SECTOR_SIZE))
162 mask = (1 << ((address / (8 * FLASH_MAIN_SECTOR_SIZE)) % 32));
163 regOffset = VIMS_O_WEPRB1;
171 if (HWREG(VIMS_BASE + regOffset) & mask)
208 if (HWREG(FLASH_BASE + FLASH_O_STATCMD) & FLASH_STATCMD_CMDPASS_M)
237 if (HWREG(FLASH_BASE + FLASH_O_STATCMD) & FLASH_STATCMD_CMDDONE_M)
276 uint32_t cchctl = HWREG(VIMS_BASE + VIMS_O_CCHCTL);
278 HWREG(VIMS_BASE + VIMS_O_CCHCTL) = (VIMS_CCHCTL_CCHEN_DIS | VIMS_CCHCTL_LINEN_DIS);
283 HWREG(VIMS_BASE + VIMS_O_CCHCTL) = cchctl;
313 uint32_t cchctl = HWREG(VIMS_BASE + VIMS_O_CCHCTL);
316 HWREG(VIMS_BASE + VIMS_O_CCHCTL) = (VIMS_CCHCTL_CCHEN_DIS | VIMS_CCHCTL_LINEN_DIS);
321 HWREG(VIMS_BASE + VIMS_O_CCHCTL) = cchctl;
362 uint32_t cchctl = HWREG(VIMS_BASE + VIMS_O_CCHCTL);
365 HWREG(VIMS_BASE + VIMS_O_CCHCTL) = (VIMS_CCHCTL_CCHEN_DIS | VIMS_CCHCTL_LINEN_DIS);
370 HWREG(VIMS_BASE + VIMS_O_CCHCTL) = cchctl;
406 #endif // __FLASH_H__ __STATIC_INLINE uint32_t FlashGetProtection(uint32_t address)
Returns the write/erase protection for a given main flash address.
Definition: flash.h:140
#define HapiFlashBankErase(key, bankSelect)
Erase the specified bank.
Definition: hapi.h:253
__STATIC_INLINE uint32_t FlashGetSize(void)
Get the size of the flash.
Definition: flash.h:111
__STATIC_INLINE uint32_t FlashCheckFsmForReady(void)
Checks if the Flash state machine is ready.
Definition: flash.h:235
__STATIC_INLINE uint32_t FlashProgram(uint8_t *dataBuffer, uint32_t address, uint32_t count)
Programs unprotected flash sectors in the main bank.
Definition: flash.h:359
#define HapiFlashSectorErase(key, addr)
Erase a flash sector.
Definition: hapi.h:231
__STATIC_INLINE uint32_t FlashCheckFsmForError(void)
Checks if the Flash state machine has detected an error.
Definition: flash.h:206
#define FLASH_NO_PROTECT
Sector not protected.
Definition: flash.h:85
#define FAPI_STATUS_SUCCESS
Function completed successfully.
Definition: flash.h:72
#define FAPI_STATUS_FSM_ERROR
Flash program/erase operation failed.
Definition: flash.h:76
__STATIC_INLINE uint32_t FlashGetSectorSize(void)
Get size of a flash sector in number of bytes.
Definition: flash.h:97
#define HapiFlashProgram(key, data, addr, nBytes)
Program to flash (FCFG, CCFG or MAIN)
Definition: hapi.h:291
#define FAPI_STATUS_FSM_READY
FSM is Ready.
Definition: flash.h:74
__STATIC_INLINE uint32_t FlashEraseSector(uint32_t sectorAddress)
Erase a flash sector.
Definition: flash.h:273
#define FLASH_WRITE_PROTECT
Sector is write / erase protected.
Definition: flash.h:86
#define FLASH_API_KEY
Definition: hapi.h:45
__STATIC_INLINE uint32_t FlashEraseBank(uint32_t bankSelect)
Erase all unprotected sectors in the selected flash main bank.
Definition: flash.h:310
#define __STATIC_INLINE
Definition: cmsis_gcc.h:47
#define FAPI_STATUS_FSM_BUSY
FSM is Busy.
Definition: flash.h:73
#define FAPI_STATUS_ADDRESS_ERROR
Address range or alignment error.
Definition: flash.h:77