📄 w29c040drv.c
字号:
#include <stdio.h>
#include <reg52.h>
#include "ext_var.h"
#include "comm.h"
#include "SerialPort.h"
#include "w29c040drv.h"
// FLASH W29C020 Tester
// Wei Cheng Hung
// 2007-2
//#include <REGX51.H>
/*
W29C040 共 512K,分8段,每段64K,每段又有256页,每页256字节.
*/
#define Sector_Addr_Port P3 //ADDR17_Port=P3_5,ADDR16_Port=P3_4
#define Page_Addr_Port P2
#define InPage_Addr_Port P0
#define Data_Port P1
//#define Flash_CE P3_3
//#define Flash_WE P3_6
//#define Flash_OE P3_7
//#define IO6 P1_6
sbit Flash_CE = P3^3;
sbit Flash_WE = P3^6;
sbit Flash_OE = P3^7;
sbit IO6 = P1^6;
sbit P3_0=P3^0;
sbit P3_1=P3^1;
/**********************************************************************
* 函 数 名: WriteState
* 功能描述: 写状态
* 函数说明:
* 调用函数:
* 全局变量:
* 输 入: 无
* 返 回: 无
* 设 计 者: wangyong 日期:2007-03-29
* 修 改 者: wangyong 日期:2007-03-29
* 版 本:
**********************************************************************/
void WriteState(void)
{
bit new_bit,old_bit;
IO6=1; // Set IO6 for Input
Flash_CE=0;
Flash_OE=0;
new_bit=IO6;
Flash_OE=1;
Flash_CE=1;
do
{
old_bit=new_bit;
Flash_CE=0;
Flash_OE=0;
new_bit=IO6;
Flash_OE=1;
Flash_CE=1;
}
while(new_bit!=old_bit);
}
/**********************************************************************
* 函 数 名: WriteByte
* 功能描述: 写一个字节
* 函数说明:
* 调用函数:
* 全局变量:
* 输 入: SectorAddr--段地址
PageAddr--页地址
InPageAddr--页内地址
* 返 回: 无
* 设 计 者: wangyong 日期:2007-03-29
* 修 改 者: wangyong 日期:2007-03-29
* 版 本:
**********************************************************************/
void WriteByte(uchar SectorAddr,uchar PageAddr,uchar InPageAddr,uchar WriteData)
{
uchar ADDR;
ADDR=SectorAddr<<4;//盢ADDR17,ADDR16
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -