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

📄 at45db321c.h

📁 使用C8051F040的硬件SPI口控制FLASH芯片AT45DB321,P0的0,1,2配置为3线SPI口,P6的0,1,2,3软件控制AT45DB321的状态引脚
💻 H
字号:
/*
   4M Byte Flash AT45DB321C Data Transmit Code
*/

#define _FlashBusy  P63
#define _FlashReset P62
#define _FlashWP P61
#define _FlashCS P60


void 	os_init(void);
void	port_init(void);
void 	spi_init(void);
void    _writeFLASHbyte(  );
void    _readFLASHbyte( );
void    FLASHWriteEnable( );
void    FLASHWriteDisable( );
void    WaitFLASHWriteEnd( );
unsigned char FLASHReadStatReg( );
void    FLASHWriteStatReg( unsigned char ucData );
//unsigned char FLASHRead( unsigned int address );
//void FLASHWrite( unsigned int address, unsigned char ucData );
//void FLASHWriteBlock(  unsigned int address,
//                     unsigned char num,
//                    unsigned char * aString );
//void FLASHReadBlock(   unsigned int address,
//                                unsigned char num,
//                                unsigned char *pBuffer );
void FlASHBufferWrite(	bit BufferNumber,		
						unsigned int BufferAddress,
						unsigned int num,
						unsigned char *pBuffer);
//Data written into either buffer 1 or buffer 2 can be programmed into the main memory.

void FlASHWriteViaBuffer(	bit BufferNumber,
					     	unsigned int PageAddress,
							unsigned int BufferAddress,
							unsigned int num,
					    	unsigned char *pBuffer);
//3Byte address comprised of one reserved bit, 13 page address
//bits (PA12-PA0) that select the page in the main memory where data is to be written, and
//10 buffer address bits (BFA9-BFA0)					    
//This operation is a combination of the Buffer Write and Buffer 
//to Main Memory Page Program with Built-in Erase operations 

void FlASHWriteFromBuffer (	bit BufferNumber,
					       	unsigned int PageAddress);
/*Data written into either buffer 1 or buffer 2 can be programmed into the main memory. To start
the operation, an 8-bit opcode, 83H for buffer 1 or 86H for buffer 2, must be clocked into the
device followed by three address bytes consisting of one reserved bit, 13 page address bits
(PA12-PA0) that specify the page in the main memory to be written and 10 don’t care bits. When
a low-to-high transition occurs on the CS pin, the part will first erase the selected page in main
memory (the erased state is a logic 1) and then program the data stored in the buffer into the
specified page in main memory. Both the erase and the programming of the page are internally
self-timed and should take place in a maximum time of tEP. During this time, the status register
and the RDY/BUSY pin will indicate that the part is busy.*/

void FLASHRead(bit ReadType,
               unsigned int PageAddress,
			   unsigned int BufferAddress,			   
               unsigned int num,
               unsigned char *pBuffer );
/*
the Continuous Array Read command can be utilized to sequentially read a continuous stream of data from the device by
simply providing a clock signal; no additional addressing information or control signals need to
be provided.
The Continuous Array Read bypasses both data buffers and leaves the contents
of the buffers unchanged.*/

void FLASHBufferRead(bit BufferNumber,                     
				     unsigned int BufferAddress,				     
                     unsigned int num,
                     unsigned char *pBuffer );

void FLASHErase(bit EraseType,unsigned int PageAddress);
void EnableSectorProtection();
void DisableSectorProtection();
void delay1us(void);

⌨️ 快捷键说明

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