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

📄 at25f512_drv.h~

📁 CodeVision AT25F512 + ATmega168 Driver
💻 H~
字号:
/*H**************************************************************
/ Function: at25f512_drv.h
/----------------------------------------------------------------
/ Description: ATMEL AT25F512A Flash driver header
/----------------------------------------------------------------                                                       
/ Note:
/----------------------------------------------------------------
/ Author:
/ Version:
/ Date:
*****************************************************************/
/*_____________M A R C O________________________________________*/
/*_____________D E F I N A T I O N______________________________*/
#define AT25F512A_CS    PORTB.2

/* Block write Protect bit */
#define WPB_MASK     0x1C
#define NONE        (0x00 << 2)
#define ALL         (0x01 << 2)
                        
/* Instruction Codes */
#define WREN            0x06
#define WRDI            0x04
#define RDSR            0x05
#define WRSR            0x01
#define READ            0x03
#define PROGRAM         0x02
#define SECTOR_ERASE    0x52
#define CHIP_ERASE      0x62
#define RDID            0x15

/* Address Space */
#define BANK0_ADDR      0x007FFF    /* Serial memory Low address */
#define BANK1_ADDR      0x00FFFF    /* Serial memory High address */
#define TOP_ADDR        0x00FFFF    /* Memeory - TOP Address */

/* Address 3-byte mode */
#define NB_ADDR_BYTE    3

/* Status Register Bit */
#define RDY             0           /* Busy Indicator Bit */
#define WEN             1           /* Write Enable Bit */
#define BP0             2           /* Block Write Protect Bit */
#define WPEN            7           /* Software Write Protect Enable Bit */

/* Interrupt Service Status */                                                                          
#define INSTRUCTION     0x01         /* The op_code has been transferred */
#define ADDRESS         0x02         /* One of the address bytes has been transferred */
#define DATA            0x04         /* The current data byte has been transferred */
#define READY_TO_SEND   0x00         /* The SPI interface is ready to send */

/*Access Status */
#define TRANSFER_STARTED    0x00    /* The write access is started whithout error */
#define TRANSFER_COMPLETED  0x01    /* The read access is completed whithout error */
#define OUT_OF_RANGE        0xFD    /* The address is out of range of available memory */
#define DATA_WR_PROTECTED   0xFE    /* The write access aborted due to write protection */
#define BUSY                0xFF    /* The SPI memory or the SPI interface is busy */

/* Error code */
#define WRITE_PROTECTED     0x1     /* The address matches a write protected location. */
#define WRITE_ALLOWED       0x0     /* The address does not matche a write protected location. */
#define HW_PROTECTED        0x2     /* The serial memory is hardware write protected. */
/*_____________D E F - F U N C T I O N__________________________*/

void at25f512_initial(void);
unsigned char write_command(unsigned char op_code);
unsigned char read_status_register(unsigned char *status);
unsigned char write_status_register(unsigned char status_register);
unsigned char get_char_array(unsigned long address, unsigned long nb_of_byte, unsigned char* destination);
unsigned char put_char_array(unsigned long start_add, unsigned char nb_of_byte, unsigned char* source);
unsigned char erase_sector(unsigned long long_add);
unsigned char erase_chip(void);
unsigned char get_mem_id(unsigned char *mem_id);
unsigned char test_write_protect(unsigned long address, unsigned int status_register);
unsigned char set_write_protected_area(unsigned char area);










/*_____________E N D____________________________________________*/

⌨️ 快捷键说明

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