How to init 2nd UARTin nRF52840?

Hi All,

I'd like to init two uart in nRF52840.

However, i don't know how to init the 2nd uart.

Is there any example about that?

Thanks.

Parents
  • I think this is quite straight forward, could you try something like this:

    ...
    ...
    #define UART_0 DT_LABEL(DT_NODELABEL(uart0))
    #define UART_1 DT_LABEL(DT_NODELABEL(uart1))
    
    static const struct device *uart_dev_0;
    static const struct device *uart_dev_1;
    
    void main(void)
    {
        ...
        uart_dev_0 = device_get_binding(UART_0);
        uart_dev_1 = device_get_binding(UART_1);
        ...
        //Now use uart_dev_0 with the UART API to control UART0
        //and use uart_dev_1 with the UART API to control UART1
        ...
    }

    I haven't tested this, so let me know if you encounter any issues.

    Best regards,

    Simon

Reply
  • I think this is quite straight forward, could you try something like this:

    ...
    ...
    #define UART_0 DT_LABEL(DT_NODELABEL(uart0))
    #define UART_1 DT_LABEL(DT_NODELABEL(uart1))
    
    static const struct device *uart_dev_0;
    static const struct device *uart_dev_1;
    
    void main(void)
    {
        ...
        uart_dev_0 = device_get_binding(UART_0);
        uart_dev_1 = device_get_binding(UART_1);
        ...
        //Now use uart_dev_0 with the UART API to control UART0
        //and use uart_dev_1 with the UART API to control UART1
        ...
    }

    I haven't tested this, so let me know if you encounter any issues.

    Best regards,

    Simon

Children
No Data
Related