This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TDES954:如何从 tser953(输入)读取 GPIO 状态、然后通过 tdes954 上的 GPIO 输出该状态。

Guru**** 2668435 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/interface-group/interface/f/interface-forum/1588010/tdes954-how-to-read-a-gpio-state-from-tser953-input-then-output-that-state-through-gpio-on-tdes954

部件号: TDES954

我们有一个脚本、允许我们将 GPIO 从解锁器切换至指定器、但我们还需要执行相反的操作、其中串行器读取 GPIO 引脚、然后解串器需要将该 GPIO 状态匹配为输出、以便我们的处理器可以从解锁器读取引脚状态。 我们需要它成为解析器上的输出。

import smbus
import time

I2C_BUS = 1
DESER_ADDR = 0x30
SER_ADDR = 0x32
GPIO1_CTRL = 0x0D  # GPIO1 control/direction register
GPIO1_OUT = 0x0E   # GPIO1 output data register

def toggle_gpio_out(state):
    reg = 0x80
    if state:
        reg = 0x90
    bus.write_byte_data(DESER_ADDR, 0x6E, reg)

bus = smbus.SMBus(I2C_BUS)

bus.write_byte_data(DESER_ADDR, 0x18, 0x00)

bus.write_byte_data(DESER_ADDR, GPIO1_CTRL, 0xF0)


bus.write_byte_data(SER_ADDR, GPIO1_CTRL, 0xF0)
bus.write_byte_data(SER_ADDR, GPIO1_OUT, 0x3C)

toggle_gpio_out(True)
time.sleep(1)
toggle_gpio_out(False)


bus.close()
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Anthony、

    您似乎想要设置正向通道 GPIO 传输。 请参阅此示例脚本、该脚本从串行器获取 GPIO2 并将其带到解串器上的 GPIO4。 根据系统需要修改寄存器。

    import time 
    
    ## *********************************************
    ## Set up Variables
    ## *********************************************
    serAddr = 0x18
    desAddr = 0x60
    
    # GPIO config
    
    # DES
    board.WriteI2C(desAddr,0x0F,0x6F) # Enable output for GPIO4
    board.WriteI2C(desAddr,0x14,0x41) # Set output source of DES GPIO4 to be GPIO2 on the serializer at RX Port 0
    
    # SER
    board.WriteI2C(serAddr,0x0E,0x0F) # All GPIO pins configured for input
    board.WriteI2C(serAddr,0x33,0x07) # Enable all GPIOs to be forwarded to DES