#ifndef __MB85RS16_h__ #define __MB85RS16_h__ /* File start ***************************************************************/ #if ENABLE_USE_MB85RS16 /****************************************************************************/ //--------------------------------------------------------------------------- #define BYTE_MAX 2048 //--------------------------------------------------------------------------- //register #define FRAM_WREN 0x06 // 0000 0110B Set Write Enable Latch #define FRAM_WRDI 0x04 // 0000 0100B Reset Write Enable Latch #define FRAM_RDSR 0x05 // 0000 0101B Read Status Register #define FRAM_WRSR 0x01 // 0000 0001B Write Status Register #define FRAM_READ 0x03 // 0000 0011B Read Memory Code #define FRAM_WRITE 0x02 // 0000 0010B Write Memory Code #define FRAM_RDID 0x9f // 1001 1111B Read Device ID //Status Register #define WPEN 0x80 #define BP1 0x08 #define BP0 0x04 #define WEL 0x02 #define NO_PROTECTION 0 #define QUARTER_ARRAY_PROTECTION BP0 #define HALF_ARRAY_PROTECTION BP1 #define FULL_ARRAY_PROTECTION (BP1 + BP0) /******************************************************************************/ #define FRAM_WP_OUTPUT() EnableOutput(FRAM_WP_GPIO, FRAM_WP_PINPOS) #define SET_FRAM_WP() SET_PIN(FRAM_WP_GPIO, FRAM_WP_PIN) #define CLR_FRAM_WP() CLR_PIN(FRAM_WP_GPIO, FRAM_WP_PIN) #define EnableFRAMWrite() CLR_FRAM_WP() #define DisableFRAMWrite() SET_FRAM_WP() #define FRAM_CS_OUTPUT() EnableOutput(FRAM_CS_GPIO, FRAM_CS_PINPOS) #define SET_FRAM_CS() SET_PIN(FRAM_CS_GPIO, FRAM_CS_PIN) #define CLR_FRAM_CS() CLR_PIN(FRAM_CS_GPIO, FRAM_CS_PIN) #define EnableFRAM() CLR_FRAM_WP() #define DisableFRAM() SET_FRAM_WP() /******************************************************************************/ void FRAMInit(void); void ProtectFRAM(void); void UnProtectFRAM(void); void WriteByteToFRAM(u16 address, u8 data); u8 ReadByteFromFRAM(u16 address); void WriteMultiByteToFRAM(u16 address, u8 *pointer, u8 length); void ReadMultiByteFromFRAM(u16 address, u8 *pointer, u8 length); u8 ReadFRAMDeviceID(void); /* File end *****************************************************************/ #endif /****************************************************************************/ /* .h end *******************************************************************/ #endif /****************************************************************************/