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

📄 am29xxxx.h

📁 Coldfire MCF5282 DBug bootloader
💻 H
📖 第 1 页 / 共 2 页
字号:
	if (S == 0)      I = 0x00000000; 	\
	else if (S == 1) I = 0x00002000;	\
	else if (S == 2) I = 0x00003000;	\
	else if (S == 3) I = 0x00004000;	\
	else I = ((S - 3) * (AM29XXXX_SECTOR_SIZE>>1))
#define AM29XXXX_sector_size(S,SZ)	\
	if (S == 0)      SZ = 0x00002000; 	\
	else if (S == 1) SZ = 0x00001000;	\
	else if (S == 2) SZ = 0x00001000;	\
	else if (S == 3) SZ = 0x00020000;	\
	else SZ = (AM29XXXX_SECTOR_SIZE>>1)
/********************************************************************/

/*
 * AM29LV160DB16 - Bottom boot block in 16-bit mode
 */
#elif	(defined(AM29XXXX_AM29LV160DB16))
#define AM29XXXX_SECTOR_SIZE		(64 * 1024)
#define AM29XXXX_SECTORS			(35)
#define AM29XXXX_sectors			(32)
#define AM29XXXX_device_code		(0x49)
#define AM29XXXX_VARIABLE_SECTOR
#define AM29XXXX_sector_index(S,I)	\
	if (S == 0)      I = 0x00000000; 	\
	else if (S == 1) I = 0x00002000;	\
	else if (S == 2) I = 0x00003000;	\
	else if (S == 3) I = 0x00004000;	\
	else I = ((S - 3) * (AM29XXXX_SECTOR_SIZE>>1))
#define AM29XXXX_sector_size(S,SZ)	\
	if (S == 0)      SZ = 0x00002000; 	\
	else if (S == 1) SZ = 0x00001000;	\
	else if (S == 2) SZ = 0x00001000;	\
	else if (S == 3) SZ = 0x00004000;	\
	else SZ = (AM29XXXX_SECTOR_SIZE>>1)
/********************************************************************/

/*
 * AM29BDD160G - Bottom boot block in 32-bit mode
 */
#elif	(defined(AM29XXXX_AM29BDD160GB32))
#define AM29XXXX_SECTOR_SIZE		(64 * 1024)
#define AM29XXXX_SECTORS			(46)
#define AM29XXXX_sectors			(32)
#define AM29XXXX_device_code		(0x7E)
#define AM29XXXX_VARIABLE_SECTOR
#define AM29XXXX_sector_index(S,I)	\
	if (S == 0)      I = 0x00000000; 	\
	else if (S == 1) I = 0x00000800;	\
	else if (S == 2) I = 0x00001000;	\
	else if (S == 3) I = 0x00001800;	\
	else if (S == 4) I = 0x00002000;	\
	else if (S == 5) I = 0x00002800;	\
	else if (S == 6) I = 0x00003000;	\
	else if (S == 7) I = 0x00003800;	\
	else if (S == 38) I = 0x0007C000;	\
	else if (S == 39) I = 0x0007C800;	\
	else if (S == 40) I = 0x0007D000;	\
	else if (S == 41) I = 0x0007D800;	\
	else if (S == 42) I = 0x0007E000;	\
	else if (S == 43) I = 0x0007E800;	\
	else if (S == 44) I = 0x0007F000;	\
	else if (S == 45) I = 0x0007F800;	\
	else I = ((S - 7) * (AM29XXXX_SECTOR_SIZE>>2))
#define AM29XXXX_sector_size(S,SZ)	\
	if (S == 0 || S == 1 || S == 2 || S == 3 || \
		S == 4 || S == 5 || S == 6 || S == 7 || \
		S == 38 || S == 39 || S == 40 || S == 41 || \
		S == 42 || S == 43 || S == 44 || S == 45)      SZ = 0x00000800; 	\
	else  SZ = (AM29XXXX_SECTOR_SIZE>>2);
	
/********************************************************************/

#else
#error "Error: Unsupported AM29XXXX type"
#endif

#ifndef AM29XXXX_sectors
#define AM29XXXX_sectors AM29XXXX_SECTORS
#endif

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

#define AM29XXXX_addr1				(0x555)
#define AM29XXXX_addr2				(0x2AA)

#define AM29XXXX_read_cmd1			(0xAA)
#define AM29XXXX_read_cmd2			(0x55)
#define AM29XXXX_read_cmd3			(0xF0)

#define AM29XXXX_autoselect_cmd1	(0xAA)
#define AM29XXXX_autoselect_cmd2	(0x55)
#define AM29XXXX_autoselect_cmd3	(0x90)

#define AM29XXXX_byteprog_cmd1		(0xAA)
#define AM29XXXX_byteprog_cmd2		(0x55)
#define AM29XXXX_byteprog_cmd3		(0xA0)

#define AM29XXXX_chiperase_cmd1		(0xAA)
#define AM29XXXX_chiperase_cmd2		(0x55)
#define AM29XXXX_chiperase_cmd3		(0x80)
#define AM29XXXX_chiperase_cmd4		(0xAA)
#define AM29XXXX_chiperase_cmd5		(0x55)
#define AM29XXXX_chiperase_cmd6		(0x10)

#define AM29XXXX_sectorerase_cmd1	(0xAA)
#define AM29XXXX_sectorerase_cmd2	(0x55)
#define AM29XXXX_sectorerase_cmd3	(0x80)
#define AM29XXXX_sectorerase_cmd4	(0xAA)
#define AM29XXXX_sectorerase_cmd5	(0x55)
#define AM29XXXX_sectorerase_cmd6	(0x30)

#define AM29XXXX_amd_code			(0x01)
#define AM29XXXX_sectorerase_done	(0x80)
#define AM29XXXX_data_poll_mask		(0x80)
#define AM29XXXX_time_exceeded		(0x20)

/********************************************************************
if one device defined then the am29xxxx_value funtion changes

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

/*
 * AM29XXXX Flash arranged for 8-bit wide port
 */
#if		(defined(AM29XXXX_8BIT))

#define AM29XXXX_width 8

#define AM29XXXX_value(VALUE) ((uint8)VALUE)
#define AM29XXXX_port_value(VALUE) ((uint8)VALUE)

#ifndef AM29XXXX_wr
#define AM29XXXX_wr(ADDR, VALUE)	\
	*(volatile uint8 *)(ADDR) = VALUE
#endif

#ifndef AM29XXXX_rd
#define AM29XXXX_rd(ADDR)	\
	(*(volatile uint8 *)(ADDR))
#endif

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

/*
 * AM29XXXX Flash arranged for 16-bit wide port
 */
#elif	(defined(AM29XXXX_16BIT))

#define AM29XXXX_width 16

#define AM29XXXX_value(VALUE) ((uint16)((VALUE << 8) | VALUE))

#define AM29XXXX_port_value(VALUE) ((uint16)((VALUE << 8) | VALUE))

#ifndef AM29XXXX_wr
#define AM29XXXX_wr(ADDR, VALUE)	\
	*(volatile uint16 *)(ADDR) = VALUE
#endif

#ifndef AM29XXXX_rd
#define AM29XXXX_rd(ADDR)	\
	(*(volatile uint16 *)(ADDR))
#endif

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

/*
 * AM29XXXX Flash arranged for 32-bit wide port
 */
#elif	(defined(AM29XXXX_32BIT))

#define AM29XXXX_width 32

//#define AM29XXXX_value(VALUE)	\
//		((uint32)((VALUE << 24) | (VALUE << 16) | (VALUE << 8) | VALUE))
#warning "Michael hacked this. Go back and fix this"
#define AM29XXXX_value(VALUE)	(VALUE)

#define AM29XXXX_port_value(VALUE) \
		((uint32)((VALUE << 24) | (VALUE << 16) | (VALUE << 8) | VALUE))

#ifndef AM29XXXX_wr
#define AM29XXXX_wr(ADDR, VALUE)	\
	*(volatile uint32 *)(ADDR) = VALUE
#endif

#ifndef AM29XXXX_rd
#define AM29XXXX_rd(ADDR)	\
	(*(volatile uint32 *)(ADDR))
#endif

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

#else
#error "Error: Unsupported AM29XXXX width"
#endif

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

#define AM29XXXX_wr_addr1(BASE, VALUE)	\
	AM29XXXX_wr(BASE + AM29XXXX_addr1, AM29XXXX_value(VALUE))
#define AM29XXXX_wr_addr2(BASE, VALUE)	\
	AM29XXXX_wr(BASE + AM29XXXX_addr2, AM29XXXX_value(VALUE))

#define AM29XXXX_AMD_CODE			AM29XXXX_value(AM29XXXX_amd_code)
#define AM29XXXX_DEVICE_CODE		AM29XXXX_value(AM29XXXX_device_code)
#define AM29XXXX_SECTORERASE_DONE	AM29XXXX_value(AM29XXXX_sectorerase_done)
#define AM29XXXX_DATA_POLL_MASK		AM29XXXX_value(AM29XXXX_data_poll_mask)
#define AM29XXXX_TIME_EXCEEDED		AM29XXXX_value(AM29XXXX_time_exceeded)
#define AM29XXXX_SECTORERASE_CMD6	AM29XXXX_value(AM29XXXX_sectorerase_cmd6)

#define AM29XXXX_cat(X,Y)			AM29XXXX_cat2(X,Y)
#define AM29XXXX_cat2(X,Y)			X ## Y

#ifndef AM29XXXX_SUFFIX
#define AM29XXXX_SUFFIX 		AM29XXXX_width
#endif

#define AM29XXXX_START			AM29XXXX_cat(AM29XXXX_start_,AM29XXXX_SUFFIX)
#define AM29XXXX_WRITE			AM29XXXX_cat(AM29XXXX_write_,AM29XXXX_SUFFIX)
#define AM29XXXX_STOP			AM29XXXX_cat(AM29XXXX_stop_,AM29XXXX_SUFFIX)
#define AM29XXXX_CELL			AM29XXXX_cat(volatile uint,AM29XXXX_width)
#define AM29XXXX				AM29XXXX_CELL

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

/*
 * Cell access macros
 */
#define AM29XXXX_WR_CELL(BASE, CELL, VALUE)	\
	AM29XXXX_wr(BASE + CELL, VALUE)

#define AM29XXXX_RD_CELL(BASE, CELL)		\
	AM29XXXX_rd(BASE + CELL)

/*
 * Autoselect sequence commands
 */
#define AM29XXXX_WR_CMD1_AUTOSELECT(BASE)	\
	AM29XXXX_wr_addr1(BASE, AM29XXXX_autoselect_cmd1)

#define AM29XXXX_WR_CMD2_AUTOSELECT(BASE)	\
	AM29XXXX_wr_addr2(BASE, AM29XXXX_autoselect_cmd2)

#define AM29XXXX_WR_CMD3_AUTOSELECT(BASE)	\
	AM29XXXX_wr_addr1(BASE, AM29XXXX_autoselect_cmd3)

#define AM29XXXX_RD_MANUF(BASE)	\
	AM29XXXX_rd(BASE + 0)

#define AM29XXXX_RD_ID(BASE)	\
	AM29XXXX_rd(BASE + 1)

/*
 * Read sequence commands
 */
#define AM29XXXX_WR_CMD1_READ(BASE)			\
	AM29XXXX_wr_addr1(BASE, AM29XXXX_read_cmd1)

#define AM29XXXX_WR_CMD2_READ(BASE)			\
	AM29XXXX_wr_addr2(BASE, AM29XXXX_read_cmd2)

#define AM29XXXX_WR_CMD3_READ(BASE)			\
	AM29XXXX_wr_addr1(BASE, AM29XXXX_read_cmd3)

/*
 * Sector Erase sequence commands
 */
#define AM29XXXX_WR_CMD1_SECTORERASE(BASE)	\
	AM29XXXX_wr_addr1(BASE, AM29XXXX_sectorerase_cmd1)
#define AM29XXXX_WR_CMD2_SECTORERASE(BASE)	\
	AM29XXXX_wr_addr2(BASE, AM29XXXX_sectorerase_cmd2)
#define AM29XXXX_WR_CMD3_SECTORERASE(BASE)	\
	AM29XXXX_wr_addr1(BASE, AM29XXXX_sectorerase_cmd3)
#define AM29XXXX_WR_CMD4_SECTORERASE(BASE)	\
	AM29XXXX_wr_addr1(BASE, AM29XXXX_sectorerase_cmd4)
#define AM29XXXX_WR_CMD5_SECTORERASE(BASE)	\
	AM29XXXX_wr_addr2(BASE, AM29XXXX_sectorerase_cmd5)

/*
 * Byte Program sequence commands
 */
#define AM29XXXX_WR_CMD1_BYTEPROG(BASE)	\
	AM29XXXX_wr_addr1(BASE, AM29XXXX_byteprog_cmd1)
#define AM29XXXX_WR_CMD2_BYTEPROG(BASE)	\
	AM29XXXX_wr_addr2(BASE, AM29XXXX_byteprog_cmd2)
#define AM29XXXX_WR_CMD3_BYTEPROG(BASE)	\
	AM29XXXX_wr_addr1(BASE, AM29XXXX_byteprog_cmd3)

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

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

void 
am29xxxx_start (void);

int
am29xxxx_write (AM29XXXX *,
				FLASH *,
				void (*)(void),
				void (*)(int));

void
am29xxxx_end (void);

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

#endif /* _COMMON_FIRMWARE_AM29XXXX_H */

⌨️ 快捷键说明

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