哦!你的意思是第二种是用了SPI接口来控制的?那它怎么控制flash的7个引脚。flash.c的宏定义如下,麻烦你帮我解释下!多谢!
#ifdef SUPPORT_FLASH_BY_BUS #ifdef SUPPORT_GPIO_BUS_FUNCTION #define FLASH_CLE (1 << 1) #define FLASH_ALE (1 << 2) #define FLASH_WP (1 << 3) #define FLASH_CLE_LOW (Bus1SetBit(FLASH_CLE, 0)) #define FLASH_CLE_HIGH (Bus1SetBit(FLASH_CLE, 1)) #define FLASH_ALE_LOW (Bus1SetBit(FLASH_ALE, 0)) #define FLASH_ALE_HIGH (Bus1SetBit(FLASH_ALE, 1)) #define FLASH_WP_LOW (Bus1SetBit(FLASH_WP, 0)) #define FLASH_WP_HIGH (Bus1SetBit(FLASH_WP, 1))
#define FLASH_CE 100 #define FLASH_WE 4 #define FLASH_RE 5 #define FLASH_RB 6 #define FLASH_CE_LOW (GPIO_O_SET(FLASH_CE, 0)) #define FLASH_CE_HIGH (GPIO_O_SET(FLASH_CE, 1)) #define FLASH_WE_LOW (GPIO_O_SET(FLASH_WE, 0)) #define FLASH_WE_HIGH (GPIO_O_SET(FLASH_WE, 1)) #define FLASH_RE_LOW (GPIO_O_SET(FLASH_RE, 0)) #define FLASH_RE_HIGH (GPIO_O_SET(FLASH_RE, 1)) #define FLASH_RB_READ (GPIO_I_GET(FLASH_RB)) #else #define FLASH_CLE 16 #define FLASH_ALE 17 #define FLASH_WP 18 #define FLASH_CE 100 #ifdef IC_8202D #define FLASH_WE 66 #define FLASH_RE 67 #define FLASH_RB 68 #else #define FLASH_WE 0 #define FLASH_RE 1 #define FLASH_RB 2 #endif
#define FLASH_CLE_LOW (GPIO_O_SET(FLASH_CLE, 0)) #define FLASH_CLE_HIGH (GPIO_O_SET(FLASH_CLE, 1)) #define FLASH_ALE_LOW (GPIO_O_SET(FLASH_ALE, 0)) #define FLASH_ALE_HIGH (GPIO_O_SET(FLASH_ALE, 1)) #define FLASH_WP_LOW (GPIO_O_SET(FLASH_WP, 0)) #define FLASH_WP_HIGH (GPIO_O_SET(FLASH_WP, 1)) #define FLASH_CE_LOW (GPIO_O_SET(FLASH_CE, 0)) #define FLASH_CE_HIGH (GPIO_O_SET(FLASH_CE, 1)) #define FLASH_WE_LOW (GPIO_O_SET(FLASH_WE, 0)) #define FLASH_WE_HIGH (GPIO_O_SET(FLASH_WE, 1)) #define FLASH_RE_LOW (GPIO_O_SET(FLASH_RE, 0)) #define FLASH_RE_HIGH (GPIO_O_SET(FLASH_RE, 1)) #define FLASH_RB_READ (GPIO_I_GET(FLASH_RB)) #endif
#define CMD_RESET 0xFF #define CMD_ERASE_1st 0x60 #define CMD_ERASE_2nd 0xD0 #define CMD_PROGRAM_1st 0x80 #define CMD_PROGRAM_2nd 0x10 #define CMD_READ_1_0 0x00 #define CMD_READ_1_1 0x01 #define CMD_READ_2 0x50 #define CMD_READ_3 0x30 #define CMD_READ_ID 0x90 #define CMD_READ_STATUS 0x70
#define FLASH_ID_SAMSUNG 0xEC #define FLASH_ID_TOSHIBA 0x98 #define FLASH_ID_HYNIX 0xAD
#define FLASH_TYPE_32MB 0x01 #define FLASH_TYPE_64MB 0x02 #define FLASH_TYPE_128MB 0x03 #define FLASH_TYPE_256MB 0x04 #define FLASH_TYPE_512MB 0x05 #define FLASH_TYPE_1GB 0x06
#define FLASH_TABLE_ID1 0xCF #define FLASH_TABLE_ID2 0x70 #define FLASH_TABLE_ID3 0x12
#else // Flash controlled by MCU
#define FLASH_CS 41 #define FLASH_SCK 42 #define FLASH_SI 12 #define FLASH_SO 13
#define FLASH_CS_LOW (GPIO_O_SET(FLASH_CS, 0)) #define FLASH_CS_HIGH (GPIO_O_SET(FLASH_CS, 1)) #define FLASH_SCK_LOW (GPIO_O_SET(FLASH_SCK, 0)) #define FLASH_SCK_HIGH (GPIO_O_SET(FLASH_SCK, 1)) #define FLASH_SO_LOW (GPIO_O_SET(FLASH_SO, 0)) #define FLASH_SO_HIGH (GPIO_O_SET(FLASH_SO, 1)) #define FLASH_SI_READ (GPIO_I_GET(FLASH_SI))
#define CMD_MEMORY_PAGE_BUF1 0xa1 #define CMD_MEMORY_ARRAY_READ 0xb2 #define CMD_MEMORY_ERASE_BUF 0xc3 #define CMD_STATUS_REG_READ 0x28
#define STATUS_NOT_BUSY 0x82 #endif |