⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amd_flash.h

📁 Freescale MCF5445evb 参考测试代码
💻 H
字号:
/* * File:        amd_flash.h * Purpose:     Flash driver for programming all AMD Flash devices  * * Notes:       This driver supports a single type (AM29XXXX) and *              width of FLASH.  The type and width support is done *              at compilation.  It supports multiple banks of same- *              width Flash, as well as consecutive/contiguous banks. * * Modifications: * */#ifndef _AMD_FLASH_H#define _AMD_FLASH_H/********************************************************************/typedef struct {    uint32 size;    /* Sector size in bytes */    uint32 offset;  /* Offset from base of device */} AMD_FLASH_SECTOR_INFO;/********************************************************************/#ifndef AMD_FLASH_DEVICES#define AMD_FLASH_DEVICES 1#endif/********************************************************************//*  * Am29LV004B (8bit only) */#if (defined(AMD_FLASH_AM29LV004BT) || \     defined(AMD_FLASH_AM29LV004BB) || \     defined(ATMEL_FLASH_AT49BV040A))#define AMD_FLASH_8BIT#define AMD_FLASH_SECTORS       11/*  * Am29PL160C - 16-bit Mode  */#elif defined(AMD_FLASH_AM29PL160CB_16BIT)#define AMD_FLASH_16BIT#define AMD_FLASH_SECTORS       11#define AMD_FLASH_UNLOCK_BYPASS/*  * Am29PL160D - 16-bit Mode  */#elif defined(AMD_FLASH_AM29LV160DB_16BIT)#define AMD_FLASH_16BIT#define AMD_FLASH_SECTORS       35#define AMD_FLASH_UNLOCK_BYPASS /*  * Am29BDD160G - 32-bit Mode  */#elif defined(AMD_FLASH_AM29BDD160GB_32BIT)#define AMD_FLASH_32BIT#define AMD_FLASH_SECTORS       46#define AMD_FLASH_UNLOCK_BYPASS/*  * Am29BDD160G - 16-bit Mode  */#elif defined(AMD_FLASH_AM29BDD160GB_16BIT)#define AMD_FLASH_16BIT#define AMD_FLASH_SECTORS       46#define AMD_FLASH_UNLOCK_BYPASS/* Constants for autoselect mode */#define DEVADDR1    0x02            /* Address for byte 1 of device ID */#define DEVADDR2    0x1c            /* Address for byte 2 of device ID */#define DEVADDR3    0x1e            /* Address for byte 3 of device ID */#define BOOT_BLOCK_TOP    0#define BOOT_BLOCK_BOTTOM 1#define SECSI_PROTECT_ADDR (0x1A<<1) /* * Am29LV640MH/L - 16-bit Mode */#elif (defined(AMD_FLASH_AM29LV640M_16BIT)  || \       defined(AMD_FLASH_AM29LV640MH_16BIT) || \       defined(AMD_FLASH_AM29LV640ML_16BIT))#define AMD_FLASH_16BIT#define AMD_FLASH_SECTORS       128#define AMD_FLASH_UNLOCK_BYPASS/* * Am29LV128MH/L - 16-bit Mode */#elif (defined(AMD_FLASH_AM29LV128M_16BIT)  || \       defined(AMD_FLASH_AM29LV128MH_16BIT) || \       defined(AMD_FLASH_AM29LV128ML_16BIT))#define AMD_FLASH_16BIT#define AMD_FLASH_SECTORS       256#define AMD_FLASH_UNLOCK_BYPASS#else#error "Unsupported Flash device"#endif#ifndef ADDR1	#define ADDR1		0x555			/* These two defines are used as the */	#define ADDR2		0xAAA 			/* addresses for the command algorithms */#endif/********************************************************************//* * Defines used to correctly address the Flash device(s) * * AMD_FLASH_BUS_SHIFT  - Number of bits to right-shift the byte *                        offsets of the sectors * AMD_FLASH_CELL       - Port size of Flash device(s) * AMD_FLASH_CMD_DATA   - Format of data when issuing commands *                         */#if defined(AMD_FLASH_8BIT)    #if (AMD_FLASH_DEVICES == 1)        #define AMD_FLASH_BUS_SHIFT     0        #define AMD_FLASH_CELL          vuint8        #define AMD_FLASH_CELL_BYTES    1        #define AMD_FLASH_CELL_MASK     0x0        #define AMD_FLASH_CMD_DATA(x)   ((uint8)x)    #elif (AMD_FLASH_DEVICES == 2)        #define AMD_FLASH_BUS_SHIFT     1        #define AMD_FLASH_CELL          vuint16        #define AMD_FLASH_CELL_BYTES    2        #define AMD_FLASH_CELL_MASK     0x1        #define AMD_FLASH_CMD_DATA(x)   ((uint16)((x<<8)|x))    #elif (AMD_FLASH_DEVICES == 4)        #define AMD_FLASH_BUS_SHIFT     2        #define AMD_FLASH_CELL          vuint32        #define AMD_FLASH_CELL_BYTES    4        #define AMD_FLASH_CELL_MASK     0x3        #define AMD_FLASH_CMD_DATA(x)   ((uint32)((x<<24)|(x<<16)|(x<<8)|x))    #else    #error "Unsupported number of Flash devices"    #endif#elif defined(AMD_FLASH_16BIT)    #if (AMD_FLASH_DEVICES == 1)        #define AMD_FLASH_BUS_SHIFT     1        #define AMD_FLASH_CELL          vuint16        #define AMD_FLASH_CELL_BYTES    2        #define AMD_FLASH_CELL_MASK     0x1        #define AMD_FLASH_CMD_DATA(x)   ((uint16)x)    #elif (AMD_FLASH_DEVICES == 2)        #define AMD_FLASH_BUS_SHIFT     2        #define AMD_FLASH_CELL          vuint32        #define AMD_FLASH_CELL_BYTES    4        #define AMD_FLASH_CELL_MASK     0x3        #define AMD_FLASH_CMD_DATA(x)   ((uint32)((x<<16)|x))    #else    #error "Unsupported number of Flash devices"    #endif#elif defined(AMD_FLASH_32BIT)    #if (AMD_FLASH_DEVICES == 1)        #define AMD_FLASH_BUS_SHIFT     2        #define AMD_FLASH_CELL          vuint32        #define AMD_FLASH_CELL_BYTES    4        #define AMD_FLASH_CELL_MASK     0x3        #define AMD_FLASH_CMD_DATA(x)   ((uint32)x)    #else    #error "Unsupported number of Flash devices"    #endif#else#error "Unsupported Flash device size"#endif/********************************************************************/#if defined(__GNUC__)voidamd_flash_init(ADDRESS)    __attribute__ ((section(".code_relocation")));void amd_flash_sector_erase(int)    __attribute__ ((section(".code_relocation")));intamd_flash_erase(ADDRESS, int, void(*)(char))    __attribute__ ((section(".code_relocation")));intamd_flash_program_cell(AMD_FLASH_CELL *, AMD_FLASH_CELL)    __attribute__ ((section(".code_relocation")));int amd_flash_program(ADDRESS, ADDRESS, int, int, void(*)(void), void(*)(char))    __attribute__ ((section(".code_relocation")));intamd_flash_sector_number(ADDRESS)    __attribute__ ((section(".code_relocation")));ADDRESS amd_flash_sector_start(ADDRESS)    __attribute__ ((section(".code_relocation")));ADDRESS amd_flash_sector_end(ADDRESS)    __attribute__ ((section(".code_relocation")));    #elsevoidamd_flash_init(ADDRESS);AMD_FLASH_CELL amd_flash_product_id(int code);void amd_flash_sector_erase(int);intamd_flash_erase(ADDRESS, int, void(*)(char));intamd_flash_program_cell(AMD_FLASH_CELL *, AMD_FLASH_CELL);int amd_flash_program(ADDRESS, ADDRESS, int, int, void(*)(void), void(*)(char));intamd_flash_sector_number(ADDRESS);ADDRESS amd_flash_sector_start(ADDRESS);ADDRESS amd_flash_sector_end(ADDRESS);#endif /* defined(__GNUC__) *//********************************************************************/#endif /* _AMD_FLASH_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -