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

📄 old_dataflash.h

📁 at91rm9200 的rom程序
💻 H
字号:
//*---------------------------------------------------------------------------
//*         ATMEL Microcontroller Software Support  -  ROUSSET  -
//*---------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*---------------------------------------------------------------------------
//* File Name           : dataflash.h
//* Object              : Data Flash Atmel Description File
//* Translator          :
//*
//* 1.0 03/04/01 HI		: Creation
//*---------------------------------------------------------------------------

#ifndef Dataflash_h
#define Dataflash_h
#include "periph/spi/lib_spi.h"

/*--------------------*/
/* Command Definition */
/*--------------------*/
/* READ COMMANDS */
#define DB_CONTINUOUS_ARRAY_READ       	0xE8		/* Continuous array read */
#define DB_BURST_ARRAY_READ            	0xE8		/* Burst array read */
#define DB_PAGE_READ                   	0xD2		/* Main memory page read */
#define DB_BUF1_READ                   	0xD4		/* Buffer 1 read */
#define DB_BUF2_READ                   	0xD6		/* Buffer 2 read */
#define DB_STATUS                      	0xD7		/* Status Register */

/* PROGRAM and ERASE COMMANDS */
#define DB_BUF1_WRITE                  	0x84		/* Buffer 1 write */
#define DB_BUF2_WRITE                  	0x87		/* Buffer 2 write */
#define DB_BUF1_PAGE_ERASE_PGM         	0x83		/* Buffer 1 to main memory page program with built-In erase */
#define DB_BUF1_PAGE_ERASE_FASTPGM     	0x93		/* Buffer 1 to main memory page program with built-In erase, Fast program */
#define DB_BUF2_PAGE_ERASE_PGM         	0x86		/* Buffer 2 to main memory page program with built-In erase */
#define DB_BUF2_PAGE_ERASE_FASTPGM     	0x96		/* Buffer 1 to main memory page program with built-In erase, Fast program */
#define DB_BUF1_PAGE_PGM               	0x88		/* Buffer 1 to main memory page program without built-In erase */
#define DB_BUF1_PAGE_FASTPGM           	0x98		/* Buffer 1 to main memory page program without built-In erase, Fast program*/
#define DB_BUF2_PAGE_PGM               	0x89		/* Buffer 2 to main memory page program without built-In erase */
#define DB_BUF2_PAGE_FASTPGM           	0x99		/* Buffer 1 to main memory page program without built-In erase, Fast program*/
#define DB_PAGE_ERASE                  	0x81		/* Page Erase */
#define DB_BLOCK_ERASE                 	0x50		/* Block Erase */
#define DB_PAGE_PGM_BUF1               	0x82		/* Main memory page through buffer 1 */
#define DB_PAGE_FASTPGM_BUF1           	0x92		/* Main memory page through buffer 1, Fast program */
#define DB_PAGE_PGM_BUF2               	0x85		/* Main memory page through buffer 2 */
#define DB_PAGE_FastPGM_BUF2           	0x95		/* Main memory page through buffer 2, Fast program */

/* ADDITIONAL COMMANDS */
#define DB_PAGE_2_BUF1_TRF             	0x53		/* Main memory page to buffer 1 transfert */
#define DB_PAGE_2_BUF2_TRF             	0x55		/* Main memory page to buffer 2 transfert */
#define DB_PAGE_2_BUF1_CMP             	0x60		/* Main memory page to buffer 1 compare */
#define DB_PAGE_2_BUF2_CMP             	0x61		/* Main memory page to buffer 2 compare */
#define DB_AUTO_PAGE_PGM_BUF1          	0x58		/* Auto page rewrite throught buffer 1 */
#define DB_AUTO_PAGE_PGM_BUF2          	0x59		/* Auto page rewrite throught buffer 2 */

/*DataFlash return value */
#define DATAFLASH_BUSY					0x00
#define DATAFLASH_OK					0x01
#define DATAFLASH_ERROR					0x02
#define DATAFLASH_MEMORY_OVERFLOW		0x03
#define DATAFLASH_BAD_COMMAND			0x04
#define DATAFLASH_BAD_ADDRESS			0x05

//#define SPI_CLK			        	MASTER_CLOCK / (2*DATAFLASH_CLK)
#define DATAFLASH_CLK           		15000000

/* Driver State */
#define     IDLE            			0x0
#define		BUSY						0x1
#define		ERROR						0x2

typedef struct _AT91S_DataflashDesc
{
	unsigned char			*tx_cmd_pt;
    unsigned int   			tx_cmd_size;
    unsigned char  			*rx_cmd_pt;
    unsigned int       		rx_cmd_size;
    unsigned char      		*tx_data_pt;
    unsigned int       		tx_data_size;
    unsigned char      		*rx_data_pt;
    unsigned int			rx_data_size;
    volatile unsigned char	state;

} AT91S_DataflashDesc, *AT91PS_DataflashDesc;

/*DataFlash device definition structure */
typedef struct _AT91S_Dataflash {
	int    			pages_number;	//* dataflash page number
	int				pages_size;		//* dataflash page size
	int				page_offset;	//* page offset in command
	int				byte_mask;		//* byte mask in command
	unsigned char	DeviceId;		//* dataflash device ID (read in the dataflash status register)
} AT91S_Dataflash, *AT91PS_Dataflash;

#endif

/*
	 7			 6			 5			 4			 3			 2			 1			 0
 _______________________________________________________________________________________________
|RDY/BUSY	|	COMP	|	M3		|	M2		|	M1		|	x		|	x		|	x		|        																				|
|___________|___________|___________|___________|___________|___________|___________|___________|

	COMP : Main memory page to buffer compare
		0: Data in main memory page matches the data in the buffer
		1: Data in main memory page doesn't match the data in the buffer
		
		M3		M2		M1
		1		1		1		AT45DB642
		1		1		0		AT45DB321B
		1		0		1		AT45DB161B
		1		0		0		AT45DB081B
		0		1		1		AT45DB041B
		0		1		0		AT45DB021B
		0		0		1		AT45DB011B
*/

/*DataFlash timeout return value */
/*#define DATAFLASH_TIMEOUT_ERROR			0x80
#define DATAFLASH_NO_TIMEOUT			0x40
#define DATAFLASH_TIMEOUT_MASK			0xC0


#define TIMEOUT_READ_DATAFLASH			30   		// timeout dataflash in ms 10
#define TIMEOUT_WRITE_DATAFLASH			30			
#define TIMEOUT_ERASE_DATAFLASH			30			// 15
#define TIMEOUT_WRITE_BUFFER			30			// 20
#define TIMEOUT_BLOCK_ERASE				30			// 20	
#define TIMEOUT_PAGE_ERASE				30			// 15
#define TIMEOUT_COMPARE					15			// 1
*/

/*
#define DATAFLASH_DEVICE_MASK		0x38

#define	AT45DB011B					(unsigned int)(1 << 3)
#define	AT45DB021B					(unsigned int)(2 << 3)
#define	AT45DB041B					(unsigned int)(3 << 3)
#define	AT45DB081B					(unsigned int)(4 << 3)
#define	AT45DB161B					(unsigned int)(5 << 3)
#define	AT45DB321B					(unsigned int)(6 << 3)
#define	AT45DB642					(unsigned int)(7 << 3)

#define PAGES_NUMBER_512			512
#define PAGES_NUMBER_1024			1024
#define PAGES_NUMBER_2048			2048
#define PAGES_NUMBER_4096			4096
#define PAGES_NUMBER_8192			8192

#define PAGES_SIZE_264				264
#define PAGES_SIZE_528				528
#define PAGES_SIZE_1056				1056*/

⌨️ 快捷键说明

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