?? nand.c
字號:
#include "stdio.h"
#include "ccblkfn.h"
#include "sysreg.h"
#include <sys\exception.h>
#include <cdefBF533.h>
#include "CPLD.h"
#include "NAND_FLASH.h"
void Write_Command(unsigned char command)
{
Set_CE(0);
Set_CLE(1);
if(command == 0x10)
{
Write_NAND_FLASH(command);
}
else
{
Write_NAND_FLASH(command);
Set_CLE(0);
}
}
void Write_Address(unsigned char NAND_Address0,unsigned char NAND_Address1,
unsigned char NAND_Address2,
unsigned char NAND_Address3,
unsigned char Valid_Address)
{
Set_ALE(1);
if(Valid_Address == 1)
{
Write_NAND_FLASH(NAND_Address0);
}
else if(Valid_Address == 3)
{
Write_NAND_FLASH(NAND_Address0);
Write_NAND_FLASH(NAND_Address1);
Write_NAND_FLASH(NAND_Address2);
}
else
{
Write_NAND_FLASH(NAND_Address0);
Write_NAND_FLASH(NAND_Address1);
Write_NAND_FLASH(NAND_Address2);
Write_NAND_FLASH(NAND_Address3);
}
Set_ALE(0);
}
bool Wait_NAND_RADY(void)
{
while(*pFIO_FLAG_D != 0x0200)
{
*pFIO_INEN = 0x0000;
ssync();
*pFIO_FLAG_C = 0;
ssync();
*pFIO_INEN = 0x0200;
}
return true;
}
void NAND_Finish(void)
{
Set_CE(1);
Set_CLE(0);
Set_ALE(0);
Command_Status = 0;
}
/*****************************************************************/
void Write_NAND_FLASH(unsigned char Write_Data)
{
*pNAND_BaseaAddr = Write_Data;
delay(100);
}
void Set_CE(bool state)
{
if(!state)
{
Command_Status = Command_Status | CLR_CE1;
*pNAND_CtrlBaseaAddr = Command_Status;
}
else
{
Command_Status = Command_Status & SET_CE1;
*pNAND_CtrlBaseaAddr = Command_Status;
}
delay(100);
}
void Set_CLE(bool state)
{
delay(100);
if(!state)
{
Command_Status = Command_Status & CLR_CLE;
*pNAND_CtrlBaseaAddr = Command_Status;
}
if(state)
{
Command_Status = Command_Status | SET_CLE;
*pNAND_CtrlBaseaAddr = Command_Status;
}
delay(100);
}
void Set_ALE(bool state)
{
delay(100);
if(!state)
{
Command_Status = Command_Status & CLR_ALE;
*pNAND_CtrlBaseaAddr = Command_Status;
}
if(state)
{
Command_Status = Command_Status | SET_ALE;
*pNAND_CtrlBaseaAddr = Command_Status;
}
delay(100);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -