Skip to content

Commit a58acfc

Browse files
committed
Configuring i2c
1 parent 10cbee4 commit a58acfc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

utils/i2c_helper.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
import smbus2
33

44
# Create a new SMBus instance on line 2
5-
bus = smbus2.SMBus(2)
5+
bus = smbus2.SMBus(1)
66

77
if __name__ == "__main__":
88

99
if sys.argv[1] == "set_rtcm":
1010
# Device i2c write address
11-
device_address_write = 0xA2
12-
device_address_read = 0xA3
11+
device_address = 0x51
1312

1413
# Register address
1514
register_address = 0x28
1615

1716
# First, we need to read the current value of the register
18-
current_value = bus.read_byte_data(device_address_read, register_address)
17+
current_value = bus.read_byte_data(device_address, register_address)
1918

2019
# Then, we need to clear the fourth bit (fifth from the left, little endian starting at 0)
2120
# We can do this by creating a mask where all bits are 1, except for the fourth bit, which is 0.
@@ -24,5 +23,5 @@
2423
new_value = current_value & mask
2524

2625
# Write the new value back to the register
27-
bus.write_byte_data(device_address_write, register_address, new_value)
26+
bus.write_byte_data(device_address, register_address, new_value)
2827

0 commit comments

Comments
 (0)