// -*- C++ -*- // // Package: CrateSoftware // Module: FlashRam // // Description: Read/Write/Erase AM29E040B flash ram // // Usage: // // C Code: T.Wlodek 6-Apr-1998 // C++ified: Lipeles // Created: Wed May 27 14:22:32 EDT 1998 // #if !defined(CrateSoftware_FlashRam_H) #define CrateSoftware_FlashRam_H #include "vxWorks.h" #define FLASH_RAM_BASE_ADDR 0x00400000 #define FLASH_RAM_SIZE 0x00080000 #define FLASH_RAM_SECTOR_SIZE 0x00010000 #define FLASH_RAM_ALL_SECTORS -1 #define NUMBER_OF_SECTORS_IN_FLASH_RAM 8 class FlashRam { public: // VME Constructor FlashRam(UINT32 A32_Addr, UINT32 A32_AmCode); // Local Constructor FlashRam(UINT32* Local_Addr) : m_pBase(Local_Addr){} // Destructor ~FlashRam(){} // Reset void Reset(){ *m_pBase = 0xf0; } // Get Id UINT32 getManufacturerId(); UINT32 getDeviceId(); void setAutoSelect(); // Read from an address (address is 0 for first byte of flash,etc) // can also be read like normal memory UINT8 Read(UINT32 FlashAddress){return *(m_pBase+FlashAddress);} // Get local address that points to it volatile UINT32* getAddress(){ return m_pBase;} // Program (address is 0 for first byte of flash,etc) STATUS Program(UINT32 FlashAddress, UINT8 DataToWrite); // Erase Entire Chip STATUS ChipErase(); // Erase Sector of Chip (Sector = 0-7) STATUS SectorErase(int Sector = -1); // Verify Erase STATUS VerifyErase(int Sector = FLASH_RAM_ALL_SECTORS); // Perform a write and then read back of flash // (this destroys all the data in the flash!!!) STATUS ReadWriteTest(int Sector = FLASH_RAM_ALL_SECTORS); private: // Check Toggle Bits for operation completion STATUS CheckToggle(UINT8 Data,UINT32 FlashAddress = 0); volatile UINT32* const m_pBase; // get base pointer volatile UINT32* getBase(UINT32 A32_Addr, UINT32 A32_AmCode); }; #endif