UART Bridge with I2C
We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The example below provides a basic demonstration of how to use the Binho Nova Multi-Protocol USB Host Adapter as both a UART bridge and an I2C controller to interact with the same DUT with both protocols.
1
from binhoHostAdapter import binhoHostAdapter
2
from binhoHostAdapter import binhoUtilities
3
4
binhoTesterCommPort = 'COM22'
5
6
# create the binhoHostAdapter object
7
binhoTester = binhoHostAdapter.binhoHostAdapter(binhoTesterCommPort)
8
9
print("Connecting to binho host adapter tester...")
10
print
11
12
print(binhoTester.setLEDColor('YELLOW'))
13
14
print(binhoTester.setOperationMode(0, 'UART'))
15
16
print(binhoTester.setBaudRateUART(0, 115200))
17
print(binhoTester.setDataBitsUART(0, 8))
18
print(binhoTester.setParityUART(0, 'NONE'))
19
print(binhoTester.setStopBitsUART(0, 1))
20
21
print(binhoTester.beginBridgeUART(0))
22
23
binhoTester.writeBridgeUART("Testing...")
24
binhoTester.writeBridgeUART("more more")
25
26
print(binhoTester.stopBridgeUART("+++UART0"))
27
print(binhoTester.ping())
28
29
binhoTester.setOperationMode(0, 'I2C')
30
binhoTester.setPullUpStateI2C(0, "EN")
31
binhoTester.setClockI2C(0, 400000)
32
33
print(binhoTester.startI2C(0, 100))
34
print(binhoTester.writeByteI2C(0, 15))
35
print(binhoTester.writeByteI2C(0, 25))
36
print(binhoTester.endI2C(0))
37
38
binhoTester.setOperationMode(0, 'UART')
39
print(binhoTester.beginBridgeUART(0))
40
41
binhoTester.writeBridgeUART("Second Burst")
42
binhoTester.writeBridgeUART("Same as the first")
43
binhoTester.writeBridgeUART("A whole lot louder")
44
binhoTester.writeBridgeUART("And a whole lot wurst")
45
46
print(binhoTester.stopBridgeUART("+++UART0"))
47
print(binhoTester.ping())
Copied!
Last modified 8mo ago
Copy link