mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
updates based upon vDorst's feedback.
change i2c_read_rtl_gpio sleep tiemr to 1s update README.md Sorted port speed
This commit is contained in:
@@ -110,11 +110,16 @@ All scripts require:
|
|||||||
- Python 3
|
- Python 3
|
||||||
- `smbus2` Python package
|
- `smbus2` Python package
|
||||||
|
|
||||||
Install with:
|
(Depend upon Linux distribution) Install with:
|
||||||
|
```bash
|
||||||
|
pip3 install python3-smbus2
|
||||||
|
```
|
||||||
|
OR
|
||||||
```bash
|
```bash
|
||||||
pip3 install smbus2
|
pip3 install smbus2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Common Use Cases
|
## Common Use Cases
|
||||||
|
|
||||||
Both `i2c_read_rtl_gpio.py` and `i2c_dump_rtl_regs.py` shall run with the **original** firmware, not RTLPlayground firmware.
|
Both `i2c_read_rtl_gpio.py` and `i2c_dump_rtl_regs.py` shall run with the **original** firmware, not RTLPlayground firmware.
|
||||||
|
|||||||
@@ -41,26 +41,26 @@ print(f"{' '.join(ledstr)}")
|
|||||||
print(f".led_mux = {{ 0x{', 0x'.join(ledstr)} }},")
|
print(f".led_mux = {{ 0x{', 0x'.join(ledstr)} }},")
|
||||||
|
|
||||||
LED_TYPES = [
|
LED_TYPES = [
|
||||||
" 2G5",
|
" 10G", 16,
|
||||||
" TWO_1G",
|
" TWO_5G", 17,
|
||||||
" 1G",
|
" 5G", 18,
|
||||||
" 500M",
|
" TWO_2G5", 19,
|
||||||
" 100M",
|
" 2G5", 0,
|
||||||
" 10M",
|
" TWO_1G", 1,
|
||||||
" LINK",
|
" 1G", 2,
|
||||||
" LINK_FLASH",
|
" 500M", 3,
|
||||||
" ACT",
|
" 100M", 4,
|
||||||
" RX",
|
" 10M", 5,
|
||||||
" TX",
|
" LINK", 6,
|
||||||
" COL",
|
" LINK_FLASH", 7,
|
||||||
" DUPLEX",
|
" ACT", 8,
|
||||||
" TRAINING",
|
" RX", 9,
|
||||||
" MASTER",
|
" TX", 10,
|
||||||
"",
|
" COL", 11,
|
||||||
" 10G",
|
" DUPLEX", 12,
|
||||||
" TWO_5G",
|
" TRAINING", 13,
|
||||||
" 5G",
|
" MASTER", 14,
|
||||||
" TWO_2G5",
|
"", 15,
|
||||||
]
|
]
|
||||||
|
|
||||||
led_set = []
|
led_set = []
|
||||||
@@ -76,8 +76,8 @@ for i in range(4):
|
|||||||
val += valhi
|
val += valhi
|
||||||
idval.append(val)
|
idval.append(val)
|
||||||
valstr = "("
|
valstr = "("
|
||||||
for bit in range(20):
|
for bit in range(0,len(LED_TYPES),2):
|
||||||
if val & (1<<bit):
|
if val & (1<<(LED_TYPES[bit+1])):
|
||||||
valstr += LED_TYPES[bit]
|
valstr += LED_TYPES[bit]
|
||||||
valstr += ")"
|
valstr += ")"
|
||||||
idvalstr.append(valstr)
|
idvalstr.append(valstr)
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ from smbus2 import SMBus, i2c_msg
|
|||||||
I2C_BUS = 1
|
I2C_BUS = 1
|
||||||
DEVICE_ADDR = 0x5C # Replace with your device address
|
DEVICE_ADDR = 0x5C # Replace with your device address
|
||||||
NUM_BYTES = 8 # Bytes to read
|
NUM_BYTES = 8 # Bytes to read
|
||||||
SLEEP_INTERVAL = 2
|
SLEEP_INTERVAL = 1
|
||||||
|
|
||||||
# Handle command line arguments for ignored IOs
|
# Handle command line arguments for ignored IOs
|
||||||
IGNORED_IOS = [ 28, 31, 34, 44]
|
IGNORED_IOS = [ ]
|
||||||
|
|
||||||
# Setup argument parser
|
# Setup argument parser
|
||||||
parser = argparse.ArgumentParser(description='Read I2C data from RTL GPIO expander')
|
parser = argparse.ArgumentParser(description='Read I2C data from RTL GPIO expander')
|
||||||
@@ -21,7 +21,7 @@ parser.add_argument('--i2c-bus', '-b', type=int, default=1,
|
|||||||
parser.add_argument('--sleep-interval', '-s', type=int, default=2,
|
parser.add_argument('--sleep-interval', '-s', type=int, default=2,
|
||||||
help='Sleep interval in seconds (default: 2)')
|
help='Sleep interval in seconds (default: 2)')
|
||||||
parser.add_argument('--ignored-ios', '-i', nargs='*', type=int, default=[28, 31, 34, 44],
|
parser.add_argument('--ignored-ios', '-i', nargs='*', type=int, default=[28, 31, 34, 44],
|
||||||
help='List of GPIO pins to ignore (default: [28, 31, 34, 44])')
|
help='List of GPIO pins to ignore (default: [])')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
I2C_BUS = args.i2c_bus
|
I2C_BUS = args.i2c_bus
|
||||||
SLEEP_INTERVAL = args.sleep_interval
|
SLEEP_INTERVAL = args.sleep_interval
|
||||||
@@ -66,4 +66,4 @@ with SMBus(I2C_BUS) as bus:
|
|||||||
deltastr += f"\n{' ':8s}GPIO{idx}"
|
deltastr += f"\n{' ':8s}GPIO{idx}"
|
||||||
# deltastr = " ".join([ f"{x:02x}" for x in delta_data])
|
# deltastr = " ".join([ f"{x:02x}" for x in delta_data])
|
||||||
print(f"{addr:04x}: {datastr}{deltastr}")
|
print(f"{addr:04x}: {datastr}{deltastr}")
|
||||||
time.sleep(SLEEP_INTERVAL)
|
time.sleep(SLEEP_INTERVAL)
|
||||||
|
|||||||
Reference in New Issue
Block a user