// sermem.h - Copyright 1998 (c) Kevin W Ross, all rights reserved // // Accompanies sermem.c and defines some of the basic information needed to // deal with the serial EEPROM memories. // // // Device Profiles - Here are the variables needed for each specific type of // chip. Some have different page sizes and data sizes // #ifdef AT25128 #define SERMEM_PAGE_SIZE 64 #define SERMEM_SIZE 16384 #endif #ifdef AT25256 #define SERMEM_PAGE_SIZE 64 #define SERMEM_SIZE 32768 #endif #ifdef M25C640 #define SERMEM_PAGE_SIZE 32 #define SERMEM_SIZE 8192 #endif #define SERMEM_PAGE_MASK (SERMEM_PAGE_SIZE-1) // // Here are the command opcodes for the serial EEPROM // #define SERMEM_INST_WREN 0x06 // 0b00000110 #define SERMEM_INST_WRDI 0x04 // 0b00000100 #define SERMEM_INST_RDSR 0x05 // 0b00000101 #define SERMEM_INST_WRSR 0x01 // 0b00000001 #define SERMEM_INST_READ 0x03 // 0b00000011 #define SERMEM_INST_WRITE 0x02 // 0b00000010 unsigned char sermem_byte_command(unsigned char byte); void sermem_Initialize(); #define sermem_WriteEnable() sermem_byte_command(SERMEM_INST_WREN) #define sermem_WriteDisable() sermem_byte_command(SERMEM_INST_WRDI) void sermem_BlockProtection(unsigned char byte); void sermem_StartRead(int iAddress); void sermem_Read(unsigned char *pBuf,int cBuf); void sermem_StopRead(void); void sermem_ReadBlock(int iAddress,unsigned char *pBuf,int cBuf); void sermem_StartWrite(int iAddress); void sermem_Write(unsigned char *pBuf,int cBuf); void sermem_StopWrite(void); void sermem_WriteBlock(int iAddress,unsigned char *pBuf,int cBuf); void sermem_Fill(int iAddress,unsigned char byte,int count); #ifdef DEBUG extern int sermem_fVerbose; #endif