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

📄 amd_flash.h

📁 motorola自己开发的针对coldfire 5272的Dbug bootloader程序
💻 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

/********************************************************************/

void
amd_flash_init(ADDRESS);

int
amd_flash_erase(ADDRESS, int, void(*)(char));

int 
amd_flash_program(ADDRESS, ADDRESS, int, int, void(*)(void), void(*)(char));

ADDRESS 
amd_flash_sector_start(ADDRESS);

ADDRESS 
amd_flash_sector_end(ADDRESS);

/********************************************************************/

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

/********************************************************************/
/* 
 * Am29PL160C - 16-bit Mode 
 */
#ifdef 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

/*
 * Am29LV640MH - 16-bit Mode
 */
#elif defined(AMD_FLASH_AM29LV640MH_16BIT)

#define AMD_FLASH_16BIT
#define AMD_FLASH_SECTORS 		128
#define AMD_FLASH_UNLOCK_BYPASS

#else
#error "Unsupported Flash device"
#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 			uint8
		#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 			uint16
		#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 			uint32
		#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 			uint16
		#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			uint32
		#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 			uint32
		#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

/********************************************************************/

#endif /* _AMD_FLASH_H */

⌨️ 快捷键说明

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