📄 flash.h
字号:
/******************************************************************************** * Copyright Statement: * -------------------- * This software is protected by Copyright and the information contained herein * is confidential. The software may not be copied and the information * contained herein may not be used or disclosed except with the written * permission of INFOMAX COMMUNICATION CO.,LTD. * * MODULE NAME: * DESCRIPTION: * AUTHOR: * BEGIN DATE: * LAST MODIFICATION: *******************************************************************************/ #ifndef FLASH_H#define FLASH_H/******************************************************************************* Header files *******************************************************************************/#include "common_var_types.h"#include "magic_reg_defs.h"/******************************************************************************* Constant/Marco *******************************************************************************//* ST xxxx */#define FLASH_BASE 0x10000000#define FLASH_SIZE (8*1024*1024) /* 16 MB */#define FLASH_CMD_BLOCK_ERASE 0x20#define FLASH_CMD_WRITE 0x40#define FLASH_CMD_CONFIGURATION 0x60#define FLASH_CMD_LOCK 0x01#define FLASH_CMD_UNLOCK 0xD0#define FLASH_CMD_LOCK_DOWN 0x2F#define FLASH_CMD_READ_ELECTRONIC_SIGNATURE 0x90#define FLASH_CMD_READ 0xFF#define FLASH_BLOCK_PROTECTION_LOCKED 0x1#define FLASH_BLOCK_PROTECTION_UNLOCKED 0x0#define FLASH_BLOCK_PROTECTION_LOCK_DOWN_LOCKED 0x3#define FLASH_BLOCK_PROTECTION_LOCK_DOWN_UNLOCKED 0x2#define SR0 (0x1)#define SR1 (0x1 << 1)#define SR2 (0x1 << 2)#define SR3 (0x1 << 3)#define SR4 (0x1 << 4)#define SR5 (0x1 << 5)#define SR6 (0x1 << 6)#define SR7 (0x1 << 7)#define FLASH_NORMAL_BLOCK_SIZE (64*2*1024) /* 128KBytes = 64KWords(16-bit) */#define FLASH_PARAMETER_BLOCK_SIZE (16*2*1024) /* 32KBytes = 16KWords(16-bit) */#define FLASH_NORMAL_BLOCK_NUM (127) /* 128KBytes = 64KWords(16-bit) */#define FLASH_PARAMETER_BLOCK_NUM (4) /* 32KBytes = 16KWords(16-bit) */#define FLASH_TOTAL_BLOCK_NUM (FLASH_NORMAL_BLOCK_NUM + FLASH_PARAMETER_BLOCK_NUM) /******************************************************************************* Structure/Union/Enum/Typedef *******************************************************************************/ enum{ FLASH_OPERATION_LOCK, FLASH_OPERATION_UNLOCK, //FLASH_OPERATION_LOCK_DOWN, FLASH_OPERATION_MAX};/******************************************************************************* Function Prototypes *******************************************************************************/ /** @Desc Description for function_name @Param parameter 1 Put parameter 1 description here @Param parameter 2 Put parameter 2 description here @Return Return value 1 and it description @Return Return value 1 and it description */void flash_init(void);void flash_read(unsigned int flash_offset, unsigned int read_size, unsigned short *read_buf_ptr);unsigned int flash_write(unsigned int flash_offset, unsigned int write_size, unsigned short *write_buf_ptr,unsigned int lock_block);void flash_sector_earse(unsigned int flash_offset, unsigned int read_size, unsigned short *write_buf_ptr);unsigned int flash_block_unlock(unsigned int flash_offset,unsigned int lock_block);unsigned int flash_block_lock(unsigned int flash_offset,unsigned int lock_block);unsigned int flash_find_block_address(unsigned int flash_offset,unsigned int lock_block);void ghdi_flash_block_erase(UINT32 BlockNumber);int nor_flash_sector_erase (unsigned int addr);void nor_flash_write (unsigned int addr, unsigned short *data, unsigned int length);unsigned int flash_block_cntl(unsigned int sys_addr_within_block, unsigned int operation);unsigned int flash_get_block_addr_base(unsigned int sys_addr_within_block);unsigned int flash_get_block_addr_base_from_id(unsigned int block_id);unsigned int flash_get_block_size_from_id(unsigned int block_id);#endif /* #ifndef FLASH_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -