from litex.soc.interconnect import stream
from litex.soc.interconnect.wishbonebridge import WishboneStreamingBridge
+# RS232 PHY ----------------------------------------------------------------------------------------
class RS232PHYInterface:
def __init__(self):
pads.sink_ready.eq(self.source.ready)
]
+# UART ---------------------------------------------------------------------------------------------
def _get_uart_fifo(depth, sink_cd="sys", source_cd="sys"):
if sink_cd != source_cd:
else:
return stream.SyncFIFO([("data", 8)], depth, buffered=True)
+def UARTPHY(pads, clk_freq, baudrate):
+ # FT245 async FIFO mode (baudrate ignored)
+ if hasattr(pads, "rd_n") and hasattr(pads, "wr_n"):
+ from litex.soc.cores.usb_fifo import FT245PHYAsynchronous
+ return FT245PHYAsynchronous(pads, clk_freq)
+ # FT245 sync FIFO mode (baudrate ignored)
+ if hasattr(pads, "rd_n") and hasattr(pads, "wr_n") and hasattr(pads, "oe_n"):
+ from litex.soc.cores.usb_fifo import FT245PHYSynchronous
+ return FT245PHYSynchronous(pads, clk_freq)
+ # RS232
+ else:
+ return RS232PHY(pads, clk_freq, baudrate)
class UART(Module, AutoCSR):
def __init__(self, phy,
if uart_stub:
self.submodules.uart = uart.UARTStub()
else:
- self.submodules.uart_phy = uart.RS232PHY(platform.request(uart_name), clk_freq, uart_baudrate)
+ self.submodules.uart_phy = uart.UARTPHY(platform.request(uart_name), clk_freq, uart_baudrate)
self.submodules.uart = ResetInserter()(uart.UART(self.uart_phy))
self.add_csr("uart_phy", allow_user_defined=True)
self.add_csr("uart", allow_user_defined=True)