summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2017-02-22 04:00:54 -0600
committerDeepak Kodihalli <dkodihal@in.ibm.com>2017-02-22 04:52:15 -0600
commitc1b12a4d97e6fceb8206a46f43cf3d97ca070a19 (patch)
tree5375a7c4b6e284e707b08eaa1bd0ea96af0172c3
parentc8dca9e8b87adfec6401d6f26b28a7b991a08b2b (diff)
downloadphosphor-mrw-tools-c1b12a4d97e6fceb8206a46f43cf3d97ca070a19.tar.gz
phosphor-mrw-tools-c1b12a4d97e6fceb8206a46f43cf3d97ca070a19.zip
Util: Add adjustI2CAddress
adjustI2CAddress converts input MRW-format I2C address to the standard 7-bit format. Change-Id: I26328a7e8147b345b870be7798f7b5a6e66316d5 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rw-r--r--Util.pm18
1 files changed, 18 insertions, 0 deletions
diff --git a/Util.pm b/Util.pm
index c6245a4..b9b2aef 100644
--- a/Util.pm
+++ b/Util.pm
@@ -83,6 +83,19 @@ sub getDevicePath
return @devices;
}
+#Convert the MRW I2C address into the standard 7-bit format
+# $addr = the I2C Address
+sub adjustI2CAddress
+{
+ my $addr = shift;
+
+ #MRW holds the 8 bit value. We need the 7 bit one.
+ $addr = $addr >> 1;
+ $addr = sprintf("0x%X", $addr);
+ $addr = lc $addr;
+
+ return $addr;
+}
1;
@@ -116,6 +129,11 @@ undef if the Target name is not found.
=item getDevicePath(C<InventoryItems>, C<TargetsObj>, C<TargetType>)
#Returns the array of all the device path based on the C<TargetType>.
+=item adjustI2CAddress(C<I2CAddress>)
+
+Returns C<I2CAddress> converted from MRW format (8-bit) to the standard 7-bit
+format.
+
=back
=cut
OpenPOWER on IntegriCloud