How to add RS‑485 DE pin control to console/shell UART on nRF52840?

Hello,

On my board I implemented an RS-485 interface using the ST4E1216IDT transceiver. The DE (Driver Enable) and RE (Receiver Enable) pins are tied together and connected to a pin (de pin) of the nRF52840, in order to act as a tx data enable pin. On my application I am able to use the RS-485 UART by setting the de pin HIGH just before transmission, and then LOW on UART_TX_DONE event. Using this, I have validated that by board is operational.

Bellow is a code snippet that described this operation:

/* UART Callback to handle transmission completion */
static void uart_cb(const struct device *dev, struct uart_event *evt, void *user_data)
{
    switch (evt->type) {
    case UART_TX_DONE:
        /* Set DE pin LOW when transmission is finished */
        gpio_pin_set_dt(&uart_depin_dev, 0);
        break;
    default:
        break;
    }
}

    // Set DE pin HIGH to enable the transmitter
    gpio_pin_set_dt(&uart_depin_dev, 1);

    // Start asynchronous UART transfer
    ret = uart_tx(uart, tx_buf, sizeof(tx_buf), SYS_FOREVER_MS);

What I would like to achieve is to connect the zephyr console and the shell on that UART (RS-485). In order to do that the UART should support a DE hw control pin, because the backend should change the state of the DE pin depending on transmitting or receiving, since the RS-485 is a half duplex serial protocol.

Is there a way to achieve the console and shell UART to have an RS-485 operation.

Thank you in advance

Avgerinos

Parents Reply Children
No Data
Related