Simplified access to Ramtron (Cypress) FM24Vxx F-RAM devices
Diff: FM24Vxx_IDs.h
- Revision:
- 0:fa858f79d48d
- Child:
- 1:6a16bddd7222
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FM24Vxx_IDs.h Sat Mar 23 15:54:01 2013 +0000 @@ -0,0 +1,67 @@ +/* mbed simplified access to RAMTRON FV24xx Serial 3V F-RAM Memory (I2C) + * Copyright (c) 2013 ygarcia, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#if !defined(__FM24VXX_IDS_H__) +#define __FM24VXX_IDS_H__ + +#include <mbed.h> + +namespace _FM24VXX_I2C { + +/** + * Device ID description + * @remark See Figure 14. Manufacturer and Product ID + */ +class CFM24VXX_IDs { + + /** Device ID description + */ + struct { + unsigned char manufacturerID; + union { + unsigned char id; + struct { + unsigned char variation:4; + unsigned char density:4; + } vd; + } productID; + unsigned char dieRevision; + } _deviceID; + + public: + inline CFM24VXX_IDs(const unsigned char manufacturerID, const unsigned char productID, const unsigned char dieRevision) { + _deviceID.manufacturerID = manufacturerID; + _deviceID.productID.id = productID; + _deviceID.dieRevision = dieRevision; + } // End of Constructor + + inline unsigned char GetManufacturerID() const { return _deviceID.manufacturerID; }; + + inline unsigned char GetProductID() const { return _deviceID.productID.id; }; + + inline unsigned char GetRevisionID() const { return _deviceID.dieRevision; }; + + inline unsigned char GetDensity() const { return _deviceID.productID.vd.density >> 4; }; + + inline unsigned char GetVariation() const { return _deviceID.productID.vd.variation; }; + +}; // End of class CFM24VXX_IDs + +} // End of namespace _FM24VXX_I2C + +#endif // __FM24VXX_IDS_H__