好的代码一定有好的数据结构
typedef struct
{
int port;
char *shadow;
char mask;
} sf_cspin;
typedef struct sf_device_st
{
struct sf_device_st *next; //next element in linked list
long pages; //number of usable pages in flash device
unsigned int pagesize; //size (in bytes) of pages in flash device
int addressbytes; // number of bytes used for page addressing
int pagebitshift; // number of 'don't care' bits following the page address
int write_state; // state for multi-page writes (used by filesystem)
long write_page; // page currently being written (used by filesystem)
sf_cspin cspin;
} sf_device;
#ifndef SFLASH_DEVTABLE_SIZE
#define SFLASH_DEVTABLE_SIZE 10
#endif
typedef struct {
int id_code;
long pages;
unsigned int pagesize;
int addressbytes;
int pagebitshift;
} sf_devtable_entry;
const sf_devtable_entry sf_devtable[SFLASH_DEVTABLE_SIZE] =
{
{0x001C, 2047L, 264, 3, 9}, // AT45DB041B
{0x0024, 4095L, 264, 3, 9}, // AT45DB081B
{0x0034, 8191L, 528, 3, 11}, // AT45DB321
{0x003C, 8191L, 1056, 3, 11}, // AT45DB642
{0x0010, 16383L, 1056, 4, 11}, // AT45DB1282
};
优点:方便以后定义新的类型。增强通用性