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

📄 hy29lv160.c

📁 ADS模拟JTAG口烧写FLASH的工具
💻 C
字号:
//------------------------------------------------------------------------------//------------------------------------------------------------------------------//******************************************************************************//// 庆歹 沥狼////******************************************************************************#include <sys/types.h>#include <sys/stat.h>#include <stdio.h>#include <stdlib.h>#include <asm/io.h>#include <unistd.h>#include <string.h>#include <memory.h>#include "jtag.h"#include "arm7tdmi.h"#include "hy29lv160.h"int progress_pos = 0;unsigned int *HY29LV160_SA;	unsigned int HY29LV160T_SA[] ={	0x00000,    0x08000,    0x10000,    0x18000,    0x20000,    0x28000,    0x30000,    0x38000,    0x40000,    0x48000,    0x50000,    0x58000,    0x60000,    0x68000,    0x70000,    0x78000,    0x80000,    0x88000,    0x90000,    0x98000,    0xA0000,    0xA8000,    0xB0000,    0xB8000,    0xC0000,    0xC8000,    0xD0000,    0xD8000,    0xE0000,    0xE8000,    0xF0000,    0xF8000,    0xFC000,    0xFD000,    0xFE000,    0x100000};unsigned int HY29LV160B_SA[] ={	0x00000,    0x02000,    0x03000,    0x04000,    0x08000,    0x10000,    0x18000,    0x20000,    0x28000,    0x30000,    0x38000,    0x40000,    0x48000,    0x50000,    0x58000,    0x60000,    0x68000,    0x70000,    0x78000,    0x80000,    0x88000,    0x90000,    0x98000,    0xA0000,    0xA8000,    0xB0000,    0xB8000,    0xC0000,    0xC8000,    0xD0000,    0xD8000,    0xE0000,    0xE8000,    0xF0000,    0xF8000,    0x100000};void Flash_Write_Halfword(unsigned int vaddress, unsigned int vdata){	JTAG_Write_Memory(vaddress<<1, vdata, HALFWORD);}unsigned int Flash_Read_Halfword(unsigned int vaddress){	unsigned int vdata;		JTAG_Read_Memory(vaddress<<1, &vdata, HALFWORD);		return(vdata);}unsigned int Flash_Read_Word(unsigned int vaddress){	unsigned int vdata;		JTAG_Read_Memory(vaddress<<1, &vdata, WORD);		return(vdata);}//------------------------------------------------------------------------------//------------------------------------------------------------------------------void HY29LV160_UpdateProgress(char *title, unsigned int cur, unsigned int max){	int dpywidth = 40;	char bar[] =		"==============================================================="		"===============================================================";	char spaces[] =		"                                                               "		"                                                               ";	char spinner[] = "\\|/-";	unsigned int i, percent;	progress_pos = (progress_pos+1) & 3;	percent = (cur * 100) / max;	i = ((percent * dpywidth) + 50) / 100;	printf("%s: |%s%s", title,		bar + (sizeof(bar) - (i+1)),		spaces + (sizeof(spaces) - (dpywidth - i + 1)));	if(percent == 100)	{		printf("|");	}	else	{		printf("%c", spinner[progress_pos & 3] );	}	printf(" %4d%%   \r", percent);	if(percent == 100)	/* clear prog bar */	{		printf("%s\r", spaces + (sizeof(spaces) - 80));	}}	//-----------------------------------------------------------------------------//------------------------------------------------------------------------------void HY29LV160_Cmd_Reset(void){   		Flash_Write_Halfword(0x0, 0xF0);}       //------------------------------------------------------------------------------//-----------------------------------------------------------------------------void HY29LV160_Cmd_ReadID(void){       Flash_Write_Halfword(0x555, 0xAA);    Flash_Write_Halfword(0x2AA, 0x55);    Flash_Write_Halfword(0x555, 0x90);}       //------------------------------------------------------------------------------void HY29LV160_Cmd_Write(unsigned int vaddress, unsigned int vdata){       Flash_Write_Halfword(0x555, 0xAA);    Flash_Write_Halfword(0x2AA, 0x55);    Flash_Write_Halfword(0x555, 0xA0);    Flash_Write_Halfword(vaddress, vdata);}       //------------------------------------------------------------------------------//-----------------------------------------------------------------------------void HY29LV160_Cmd_Erase_Sector(unsigned int vaddress){    Flash_Write_Halfword(0x555, 0xAA);    Flash_Write_Halfword(0x2AA, 0x55);    Flash_Write_Halfword(0x555, 0x80);    Flash_Write_Halfword(0x555, 0xAA);    Flash_Write_Halfword(0x2AA, 0x55);    Flash_Write_Halfword(vaddress, 0x30);}//------------------------------------------------------------------------//------------------------------------------------------------------------unsigned int HY29LV160_GetStatus(unsigned int vaddress){	unsigned int firststate, secondstate;		while(1)	{	 	firststate = Flash_Read_Halfword(vaddress);							// 霉锅掳 单捞鸥甫 佬绰促. 	 	secondstate = firststate ^ Flash_Read_Halfword(vaddress);			// 滴锅

⌨️ 快捷键说明

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