Yann Garcia / FM24Vxx_I2C

Dependents:   FM24Vxx_I2CApp

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FM24Vxx_IDs.h Source File

FM24Vxx_IDs.h

00001 /* mbed simplified access to RAMTRON FV24xx Serial 3V F-RAM Memory (I2C)
00002  * Copyright (c) 2013 ygarcia, MIT License
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
00005  * and associated documentation files (the "Software"), to deal in the Software without restriction, 
00006  * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
00007  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in all copies or 
00011  * substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
00014  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
00015  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
00016  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
00017  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018  */
00019 #if !defined(__FM24VXX_IDS_H__)
00020 #define __FM24VXX_IDS_H__
00021 
00022 #include <mbed.h>
00023 
00024 namespace _FM24VXX_I2C {
00025 
00026 /**
00027  * Device ID description
00028  * @remark See FM24V10_ds Figure 14. Manufacturer and Product ID
00029  */
00030 class CFM24VXX_IDs {
00031 
00032     /** Device ID description
00033      */
00034     struct { // FM24V10_ds Figure 14. Manufacturer and Product ID
00035         unsigned char manufacturerID;
00036         union {
00037             unsigned char id;
00038             struct {
00039                 unsigned char variation:4;
00040                 unsigned char density:4;
00041             } vd;
00042         } productID;
00043         struct {
00044             unsigned char dierev:3;
00045             unsigned char reserved:5;
00046         } dieRevision;
00047     } _deviceID;
00048     
00049     public:
00050         inline CFM24VXX_IDs(const unsigned char manufacturerID, const unsigned char productID, const unsigned char dieRevision) {
00051             _deviceID.manufacturerID = manufacturerID;
00052             _deviceID.productID.id = productID;
00053             _deviceID.dieRevision.dierev = dieRevision & 0x07; // FM24V10_ds Figure 14. Manufacturer and Product ID
00054         } // End of Constructor
00055         
00056         inline unsigned char GetManufacturerID() const { return _deviceID.manufacturerID; };
00057         
00058         inline unsigned char GetProductID() const { return _deviceID.productID.id; };
00059         
00060         inline unsigned char GetRevisionID() const { return _deviceID.dieRevision.dierev; };
00061         
00062         inline unsigned char GetDensity() const { return _deviceID.productID.vd.density >> 4; };
00063         
00064         inline unsigned char GetVariation() const { return _deviceID.productID.vd.variation; };
00065         
00066 }; // End of class CFM24VXX_IDs
00067 
00068 } // End of namespace _FM24VXX_I2C
00069 
00070 #endif // __FM24VXX_IDS_H__