📄 spi_flash.h
字号:
/*! * \file spi_flash.h * \brief Defines for standard SPI Flash commands * \version $Revision: 1.1 $ * \author Michael Norman */ #ifndef __SPI_FLASH_H__#define __SPI_FLASH_H__/********************************************************************//* Instruction/Command Codes */#define SPIFLASH_WREN 0x06#define SPIFLASH_WRDI 0x04#define SPIFLASH_RDID 0x9F#define SPIFLASH_RDSR 0x05#define SPIFLASH_WRSR 0x01#define SPIFLASH_READ 0x03#define SPIFLASH_FAST_READ 0x0B#define SPIFLASH_PP 0x02#define SPIFLASH_SE 0xD8#define SPIFLASH_BE 0xC7#define SPIFLASH_DP 0xB9#define SPIFLASH_RES 0xAB/* Serial Flash Status Register */#define SPIFLASH_SR_SRWD 0x80#define SPIFLASH_SR_BP2 0x10#define SPIFLASH_SR_BP1 0x08#define SPIFLASH_SR_BP0 0x04#define SPIFLASH_SR_WEL 0x02#define SPIFLASH_SR_WIP 0x01#define SPIFLASH_SR_BP(x) ((x & 0x7) << 2)/* Device Specific Info */#define SSIZE(n) (0x10000) /* sector size */#define SOFFSET(n) (SSIZE(n) * n) /* sector address offset */#define PSIZE(n) (256) /* page size */#define POFFSET(n) (SSIZE(n) * n) /* page address offset */#define SPIFLASH_SECTORS 32#define SPIFLASH_PAGES 8192/*! * \struct Device Identification Data */typedef struct spi_flash_device_id{ uint8 manuf_id; /*!< Manufacturer ID */ uint8 mem_type; /*!< Device ID: Memory Type */ uint8 mem_cap; /*!< Device ID: Memory Capacity */} SPI_FLASH_DEVICE_ID;/* * Function prototypes */intspi_flash_init (void);static intspi_flash_write_enable (void);static intspi_flash_write_disable (void);SPI_FLASH_DEVICE_ID*spi_flash_read_id (void);uint8spi_flash_read_sr (void);intspi_flash_write_sr (uint8 sr);intspi_flash_read (ADDRESS address, int length, uint8 *buffer);intspi_flash_fast_read (ADDRESS address, int length, uint8 *buffer);intspi_flash_page_program (ADDRESS address, int length, uint8 *buffer);intspi_flash_sector_erase (ADDRESS address);intspi_flash_bulk_erase (void);intspi_flash_power_down (void);intspi_flash_wake_up (void);intspi_flash_erase(ADDRESS start, int bytes, int print);intspi_flash_program(ADDRESS dest, ADDRESS src, int bytes, int erase, int print);voidspi_flash_dump (ADDRESS addr, int bytes);voidspi_flash_dump_id (void);voidspi_flash_test (void);/********************************************************************/#endif /* __SPI_FLASH_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -