uart: Make CTS active low, as per the standard

This commit is contained in:
Daniel Jobson 2025-10-17 10:05:04 +02:00
parent 74e3d74c11
commit 1a47a2266f
3 changed files with 9 additions and 4 deletions

View file

@ -24,6 +24,11 @@ in order to hit the center of the bits. For example, a clock of 18 MHz
and a target bit rate of 62500 bps yields:
Divisor = 18E6 / 62500 = 288
The UART core includes hardware flow control in the form of two CTS
lines. One input that the core will check before sending bytes, and
one output to signal to a connected device that the internal FIFO is
full. The CTS are active-low.
## API
```

View file

@ -227,7 +227,7 @@ module uart (
end
ADDR_TX_STATUS: begin
tmp_read_data = {31'h0, core_txd_ready & ch552_cts_reg[1]};
tmp_read_data = {31'h0, core_txd_ready & !ch552_cts_reg[1]};
end
default: begin

View file

@ -105,7 +105,7 @@ module uart_fifo (
out_ptr_reg <= 9'h0;
byte_ctr_reg <= 9'h0;
in_ack_reg <= 1'h0;
fpga_cts_reg <= 1'h1;
fpga_cts_reg <= 1'h0;
end
else begin
in_ack_reg <= in_ack_new;
@ -127,10 +127,10 @@ module uart_fifo (
end
if (byte_ctr_reg >= 9'd486) begin // FIFO is filled to ~95% or more
fpga_cts_reg <= 0; // Signal to not send more data
fpga_cts_reg <= 1; // Signal to not send more data
end
else begin
fpga_cts_reg <= 1; // Signal to send more data
fpga_cts_reg <= 0; // Signal to send more data
end
end