]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/SmbusLib.h
Coding style fix.
[mirror_edk2.git] / MdePkg / Include / Library / SmbusLib.h
index c74e40acd061ee4bde1c536b3ec3760851eff82d..d766b297acadccad7cf8768c802f76adc15f9010 100644 (file)
 #ifndef __SMBUS_LIB__\r
 #define __SMBUS_LIB__\r
 \r
-//\r
-// PEC BIT is bit 22 in SMBUS address\r
-//\r
-#define SMBUS_LIB_PEC_BIT   (1 << 22)\r
-\r
 /**\r
   Macro that converts SMBUS slave address, SMBUS command, SMBUS data length,\r
   and PEC to a value that can be passed to the SMBUS Library functions.\r
 \r
 **/\r
 #define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec)  \\r
-  ( ((Pec) ? SMBUS_LIB_PEC_BIT: 0)      | \\r
+  ( ((Pec) ? BIT22: 0)                  | \\r
     (((SlaveAddress) & 0x7f) << 1)      | \\r
     (((Command)      & 0xff) << 8)      | \\r
     (((Length)       & 0x3f) << 16)       \\r
   )\r
 \r
+/**\r
+  Macro that returns the SMBUS Slave Address value from an SmBusAddress Parameter value.\r
+  \r
+  @param SmBusAddress   Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC \r
+**/\r
+#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress)      (((SmBusAddress) >> 1)  & 0x7f)\r
+\r
+/**\r
+  Macro that returns the SMBUS Command value from an SmBusAddress Parameter value.\r
+  \r
+  @param SmBusAddress   Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC\r
+**/\r
+#define SMBUS_LIB_COMMAND(SmBusAddress)            (((SmBusAddress) >> 8)  & 0xff)\r
+\r
+/**\r
+  Macro that returns the SMBUS Data Length value from an SmBusAddress Parameter value.\r
+  \r
+  @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC \r
+**/\r
+#define SMBUS_LIB_LENGTH(SmBusAddress)             (((SmBusAddress) >> 16) & 0x3f)\r
+\r
+/**\r
+  Macro that returns the SMBUS PEC value from an SmBusAddress Parameter value.\r
+  \r
+  @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC   \r
+**/\r
+#define SMBUS_LIB_PEC(SmBusAddress)                ((BOOLEAN) (((SmBusAddress) & BIT22) != 0))\r
+\r
+/**\r
+  Macro that returns the set of reserved bits from an SmBusAddress Parameter value.\r
+  \r
+  @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC   \r
+**/\r
+#define SMBUS_LIB_RESERVED(SmBusAddress)           ((SmBusAddress) & ~(((1 << 22) - 2) | BIT22))\r
+\r
 /**\r
   Executes an SMBUS quick read command.\r
 \r