Simplified access to Ramtron (Cypress) FM24Vxx F-RAM devices
Diff: FM24Vxx_I2C.h
- Revision:
- 1:6a16bddd7222
- Parent:
- 0:fa858f79d48d
- Child:
- 2:bf7d1264d3ff
diff -r fa858f79d48d -r 6a16bddd7222 FM24Vxx_I2C.h --- a/FM24Vxx_I2C.h Sat Mar 23 15:54:01 2013 +0000 +++ b/FM24Vxx_I2C.h Wed Apr 03 12:51:20 2013 +0000 @@ -23,6 +23,7 @@ #include <vector> #include "FM24Vxx_IDs.h" +#include "FM24Vxx_SN.h" #include "Debug.h" // Include mbed header + debug primitives. See DebugLibrary namespace _FM24VXX_I2C { @@ -50,9 +51,12 @@ /** An unique instance of I2C class */ I2C *_i2cInstance; - /** Device ID. Used for Sleep mode + /** Device ID */ CFM24VXX_IDs *_deviceID; + /** Serial number + */ + CFM24VXX_SN *_sn; public: /** Memory storage mode */ @@ -83,8 +87,15 @@ /** Used to return the unique device identifier */ - inline const CFM24VXX_IDs * GetDevideID() { return (const CFM24VXX_IDs *)_deviceID; }; + inline const CFM24VXX_IDs * GetDeviceID() { return (const CFM24VXX_IDs *)_deviceID; }; + /** + * Used to return the serial number + * Note This functionality is available only for the FM24VN10. In other case, it will return 0xff + * @remark See FM24V10_ds.pdf Page 10/16 Clause Unique Serial Number (FM24VN10 only) + */ + inline const CFM24VXX_SN * GetSerialNumber() { return (const CFM24VXX_SN *)_sn; }; + /** * Used to swith high speed mode * @param highSpeedMode Set to true to switch to high speed mode @@ -99,7 +110,7 @@ inline void EnterSleepMode() { /* FIXME To be done */ }; /** - * Used to enter in sleep mode + * Used to leave sleep mode * @remark See FM24V10_ds.pdf Page 8/16 Clause Sleep Mode */ inline void LeaveSpeedMode() { /* FIXME To be done */ }; @@ -109,7 +120,7 @@ * @param memoryPage The selected memory page (0 or 1) * @remark See FM24V10_ds.pdf Page 3/16 Clause Memory Architecture */ - inline void SelectMemoryPage(const unsigned char memoryPage) { _slaveAddress |= ((memoryPage & 0x01) << 1) | 0xa0; }; + inline void SelectMemoryPage(const unsigned char memoryPage) { _slaveAddress |= ((memoryPage & 0x01) << 1); }; /** Erase of memory area starting at the specified address, using the specified pattern to fill the memory area * @@ -338,12 +349,28 @@ std::string _internalId; private: - /** - * Retrieve device identifiers + + /** Retrieve device identifiers * @remark See FM24V10_ds.pdf Page 9/16 Clause Device ID */ - void GetDevideIDs(); + bool GetDevideIDs(); + /** + * Used to return the serial number + * Note This functionality is available only for the FM24VN10. In other case, it will return 0xff + * @remark See FM24V10_ds.pdf Page 10/16 Clause Unique Serial Number (FM24VN10 only) + */ + bool GetSerialNumbers(); + + /** + * Function to Calculate CRC + * @param pdatas The read Serial Number + * @param length The number of bytes in the pdatas array. Default: 7 bytes length + * @return The 8-bits length checksum + * @see See FM24V10_ds.pdf Page 10/16 Clause Unique Serial Number (FM24VN10 only) + */ + unsigned char ChecksumSN(const unsigned char *pdatas, const unsigned int length = 7); + }; // End of class CFM24VXX_I2C }; // End of namespace _FM24VXX_I2C