Simplified access to Ramtron (Cypress) FM24Vxx F-RAM devices

Dependents:   FM24Vxx_I2CApp

Committer:
Yann
Date:
Sat Apr 13 14:23:41 2013 +0000
Revision:
2:bf7d1264d3ff
Parent:
1:6a16bddd7222
Added new Read method from Reed Kimble request

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Yann 0:fa858f79d48d 1 /* mbed simplified access to RAMTRON FV24xx Serial 3V F-RAM Memory (I2C)
Yann 0:fa858f79d48d 2 * Copyright (c) 2013 ygarcia, MIT License
Yann 0:fa858f79d48d 3 *
Yann 0:fa858f79d48d 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Yann 0:fa858f79d48d 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
Yann 0:fa858f79d48d 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
Yann 0:fa858f79d48d 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Yann 0:fa858f79d48d 8 * furnished to do so, subject to the following conditions:
Yann 0:fa858f79d48d 9 *
Yann 0:fa858f79d48d 10 * The above copyright notice and this permission notice shall be included in all copies or
Yann 0:fa858f79d48d 11 * substantial portions of the Software.
Yann 0:fa858f79d48d 12 *
Yann 0:fa858f79d48d 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Yann 0:fa858f79d48d 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Yann 0:fa858f79d48d 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Yann 0:fa858f79d48d 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Yann 0:fa858f79d48d 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Yann 0:fa858f79d48d 18 */
Yann 0:fa858f79d48d 19 #if !defined(__FM24VXX_IDS_H__)
Yann 0:fa858f79d48d 20 #define __FM24VXX_IDS_H__
Yann 0:fa858f79d48d 21
Yann 0:fa858f79d48d 22 #include <mbed.h>
Yann 0:fa858f79d48d 23
Yann 0:fa858f79d48d 24 namespace _FM24VXX_I2C {
Yann 0:fa858f79d48d 25
Yann 0:fa858f79d48d 26 /**
Yann 0:fa858f79d48d 27 * Device ID description
Yann 1:6a16bddd7222 28 * @remark See FM24V10_ds Figure 14. Manufacturer and Product ID
Yann 0:fa858f79d48d 29 */
Yann 0:fa858f79d48d 30 class CFM24VXX_IDs {
Yann 0:fa858f79d48d 31
Yann 0:fa858f79d48d 32 /** Device ID description
Yann 0:fa858f79d48d 33 */
Yann 1:6a16bddd7222 34 struct { // FM24V10_ds Figure 14. Manufacturer and Product ID
Yann 0:fa858f79d48d 35 unsigned char manufacturerID;
Yann 0:fa858f79d48d 36 union {
Yann 0:fa858f79d48d 37 unsigned char id;
Yann 0:fa858f79d48d 38 struct {
Yann 0:fa858f79d48d 39 unsigned char variation:4;
Yann 0:fa858f79d48d 40 unsigned char density:4;
Yann 0:fa858f79d48d 41 } vd;
Yann 0:fa858f79d48d 42 } productID;
Yann 1:6a16bddd7222 43 struct {
Yann 1:6a16bddd7222 44 unsigned char dierev:3;
Yann 1:6a16bddd7222 45 unsigned char reserved:5;
Yann 1:6a16bddd7222 46 } dieRevision;
Yann 0:fa858f79d48d 47 } _deviceID;
Yann 0:fa858f79d48d 48
Yann 0:fa858f79d48d 49 public:
Yann 0:fa858f79d48d 50 inline CFM24VXX_IDs(const unsigned char manufacturerID, const unsigned char productID, const unsigned char dieRevision) {
Yann 0:fa858f79d48d 51 _deviceID.manufacturerID = manufacturerID;
Yann 0:fa858f79d48d 52 _deviceID.productID.id = productID;
Yann 1:6a16bddd7222 53 _deviceID.dieRevision.dierev = dieRevision & 0x07; // FM24V10_ds Figure 14. Manufacturer and Product ID
Yann 0:fa858f79d48d 54 } // End of Constructor
Yann 0:fa858f79d48d 55
Yann 0:fa858f79d48d 56 inline unsigned char GetManufacturerID() const { return _deviceID.manufacturerID; };
Yann 0:fa858f79d48d 57
Yann 0:fa858f79d48d 58 inline unsigned char GetProductID() const { return _deviceID.productID.id; };
Yann 0:fa858f79d48d 59
Yann 1:6a16bddd7222 60 inline unsigned char GetRevisionID() const { return _deviceID.dieRevision.dierev; };
Yann 0:fa858f79d48d 61
Yann 0:fa858f79d48d 62 inline unsigned char GetDensity() const { return _deviceID.productID.vd.density >> 4; };
Yann 0:fa858f79d48d 63
Yann 0:fa858f79d48d 64 inline unsigned char GetVariation() const { return _deviceID.productID.vd.variation; };
Yann 0:fa858f79d48d 65
Yann 0:fa858f79d48d 66 }; // End of class CFM24VXX_IDs
Yann 0:fa858f79d48d 67
Yann 0:fa858f79d48d 68 } // End of namespace _FM24VXX_I2C
Yann 0:fa858f79d48d 69
Yann 0:fa858f79d48d 70 #endif // __FM24VXX_IDS_H__