3360 |
kaklik |
1 |
#!/usr/bin/python |
|
|
2 |
|
|
|
3 |
# Python library for I2CHUB02A MLAB module with TCA9548A i2c bus expander. |
|
|
4 |
|
|
|
5 |
import smbus |
|
|
6 |
import time |
|
|
7 |
|
|
|
8 |
I2CHUB_address = 0x70 |
|
|
9 |
I2CHUB_bus_number = 6 |
|
|
10 |
|
|
|
11 |
i2c_channel_setup=0 |
|
|
12 |
|
|
|
13 |
I2C_ch_0 = 0b00000001 |
|
|
14 |
I2C_ch_1 = 0b00000010 |
|
|
15 |
I2C_ch_2 = 0b00000100 |
|
|
16 |
I2C_ch_3 = 0b00001000 |
|
|
17 |
I2C_ch_4 = 0b00010000 |
|
|
18 |
I2C_ch_5 = 0b00100000 |
|
|
19 |
I2C_ch_6 = 0b01000000 |
|
|
20 |
I2C_ch_7 = 0b10000000 |
|
|
21 |
|
|
|
22 |
|
|
|
23 |
def I2CHUB_setup(i2c_channel_setup): |
|
|
24 |
bus = smbus.SMBus(I2CHUB_bus_number) |
|
|
25 |
bus.write_byte(I2CHUB_address,i2c_channel_setup) |
|
|
26 |
time.sleep(0.1) |
|
|
27 |
print "I2C hub channel status: ", bin(bus.read_byte(I2CHUB_address)) |
|
|
28 |
return; |