Listing 2 Constants and Statics

#include <string.h>
#include "fmutl.h"

       /** all these magic numbers are from the AMD spec sheets: **/

       /* address and data for command writes: */
#define FM_ADDR1        0x5555   /* these are for the first "magic  */
#define FM_DATA1        0xAAAA   /*   write" of a command preamble    */
#define FM_ADDR2        0x2AAA   /* these are for the second "magic */
#define FM_DATA2        0x5555   /*   write" of a command preamble    */

       /* command codes: */
#define FMCMD_RESET     0xF0F0   /* "Read/Reset Command" */
#define FMCMD_AUTOSEL   0x9090   /* "Autoselect Command" */
#define FMCMD_WRITE     0xA0A0   /* "Byte Program Command" */
#define FMCMD_ERASE     0x8080   /* "Chip or Sector Erase Command" */

       /* use this to skip last step of a command preamble [see fm_cmd()]: */
#define FMCMD_NONE      0x0000   /* no command */

       /* secondary command codes for erase commands: */
#define FMCMD2_SECTOR   0x3030   /* "Sector Erase" */
#define FMCMD2_CHIP     0x1010   /* "Chip Erase" */

       /* miscellaneous other flash memory constants: */
#define FM_PROT_SECT_MASK 0x0101 /* protected sector indicator bit(s) */
#define FM_ERASE_VAL    0xFFFF   /* value of an erased location */
#define FM_TIMEOUT      0x2020   /* DQ5 - goes hi if device times out */
#define FM_NDATA_POLL   0x8080   /* DQ7 - inverse of final data */

       /* special address offsets for Autoselect command reads: */
#define FM_AO_MANUF     0    /* for manufacturer code readback */
#define FM_AO_DEVID     1    /* for device ID readback */
#define FM_AO_PROT_SECT 2    /* for protected sector readbacks */

FMERR fm_err;          /* global Flash error structure */

static char *ErrMsgs[] = [   /** fm_err.code and fm_err.pMsg values: **/
       "x?? Unknown err",   /* 0:. unused */
       "Bad devID codes",   /* 1: unknown/mismatched/missing/bad chips */
       "Erase fail-safe".   /* 2: sector erase fail-safe triggered */
       "Erase timed out",   /* 3: sector erase command timed out */
       "Write fail-safe",   /* 4: byte write fail-safe triggered */
       "Write timed out",   /* 5: byte write programming timed out */
       "fm_write params",   /* 6: address or length parameter was odd */
       "fm_write overfl",   /* 7: attempt to write past end of flash */
       };      /** see also ErrMsg[] in fm_error()**/

static FMINFO DevTable[] = {   /* known device data table: */
     /*  MfrID DevID EFS WFS NS SectSiz*2 TotSize*2 NP FP DevNameString */
       0x0101, 0x2020, 20, 90, 8, 0x04000*2, 0x20000*2, 0, 0, "AMD Am29F010",
       0x0101, 0xA4A4, 40, 90, 8, 0x10000*2, 0x80000*'2, 0, O, "AMD Am29F04*",
       };

       /* the routines in this module need to share this data: */
static unsigned volatile short *pBase;  /* ptr to the base address of Flash */
static FMINFO FMInfo;                   /* info specific to these chips */

/* End of File */