/* * flash_prog.h * * Created: 12/20/2021 2:30:07 PM * Author: david */ #ifndef FLASH_PROG_H_ #define FLASH_PROG_H_ #define FLASH_LITTLE_SECTOR_SIZE (0x00002000u) #define FLASH_LARGER_SECTOR_SIZE (0x0001C000u) #define FLASH_SECTOR_SIZE (0x00020000u) #define LEN_USER_SIG_BYTES (512u) typedef enum { Flash_No_Error = 0, Flash_Lock_Error, Flash_Command_Error, Flash_Verify_Error, Flash_Address_Error, Flash_Size_Error, Flash_CRC_Error } Flash_Error_T; typedef enum { Flash_Config_Clear, Flash_Config_Set }Flash_Config_Set_T; typedef enum _Flash_Erase_Size { Flash_Erase_8kB, Flash_Erase_16kB, Flash_Erase_Sector }Flash_Erase_Size_T; typedef enum { Flash_Command_GetDescriptor = 0x00u, Flash_Command_WritePage = 0x01u, Flash_Command_WritePageAndLock = 0x02u, Flash_Command_EraseThenWritePage = 0x03u, Flash_Command_EraseThenWritePageAndLock = 0x04u, Flash_Command_EraseAll = 0x05u, Flash_Command_ErasePages = 0x07u, Flash_Command_SetLockBit = 0x08u, Flash_Command_ClearLockBit = 0x09u, Flash_Command_GetLockBit = 0x0Au, Flash_Command_SetGPNVM = 0x0Bu, Flash_Command_ClearGPNVM = 0x0Cu, Flash_Command_GetGPNVM = 0x0Du, Flash_Command_StartReadUniqueID = 0x0Eu, Flash_Command_StopReadUniqueID = 0x0Fu, Flash_Command_GetCALIB = 0x10u, Flash_Command_EraseSector = 0x11u, Flash_Command_WriteUserSig = 0x12u, Flash_Command_EraseUserSig = 0x13u, Flash_Command_StartReadUserSig = 0x14u, Flash_Command_StopReadUserSig = 0x15u, } Flash_Cmd_T; Flash_Error_T flash_erase_bl_region(void); Flash_Error_T flash_erase(uint32_t start_addr, Flash_Erase_Size_T erase_size); Flash_Error_T flash_program(uint32_t start_addr, uint32_t len_bytes, uint32_t* data); Flash_Error_T flash_change_NVM_bits(uint16_t bitmask, Flash_Config_Set_T set_or_clear); Flash_Error_T flash_read_NVM_bits(uint32_t* config_bits); Flash_Error_T flash_erase_signature(void); Flash_Error_T flash_program_signature(uint32_t* data); Flash_Error_T flash_read_signature(uint32_t* data); #endif /* FLASH_PROG_H_ */