This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

device_get_binding device name of the device changes

What I want to do is do UART communication (UART_1) between nRF52840 and nRF9160.

From the nRF52840 side, uart_poll_out is OK,
From the nRF9160 side, uart_poll_out examined because it was not.

Binding is performed on both:
uart_dev = device_get_binding("UART_1");

z_impl_device_get_binding the device name of the device is stopped with a matching for statement,
On the nRF52840 side UART_1 remains intact.
On the nRF9160 side, UART_0 possible.

On the nRF 52840 side, if it continues, it becomes RNG.
Continuing on the nRF9160 side I2C_2 operation.

Is prj.conf set up wrong?

Parents
  • Hi!

    Thanks for reaching out. Are you getting any error messages from device_get_binding("UART_1") on the nRF9160? In addition to configuring the UART in prj.conf you must also enable it in thingy91_nrf9160ns.overlay file. You can see an example on how this is done in the boards folder lte_ble_gateway sample.

    Best regards,
    Carl Richard

  • hello

    i am trying to do the same (uart between nrf9160 and nrf52840 on thingy 91)

    I started with coping lpuart-code to asset tracket code on nrf9160ns

    i added this changes to prj file:

    CONFIG_UART_ASYNC_API=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_1_ASYNC=y
    CONFIG_UART_1_INTERRUPT_DRIVEN=y

    my overlay file is:

    thingy91_nrf9160ns.overlay
    / {
    chosen {
    zephyr,console = &uart0;
    zephyr,shell-uart = &uart0;
    zephyr,uart-mcumgr = &uart0;
    };
    };

    &uart1 {
    current-speed = <1000000>;
    status = "okay";
    tx-pin = <22>;
    rx-pin = <23>;
    rts-pin = <24>;
    cts-pin = <25>;
    };

    in my main.c:

    err = uart_callback_set(uart0_dev, uart_callback, (void *)uart0_dev);

    __ASSERT(err == 0, "Failed to set callback");




    void main(void)
    {
    LOG_INF("Asset tracker started");


    const struct device *uart0_dev;

    k_msleep(1000);
    uart0_dev = device_get_binding("UART_1");
    //lpuart = device_get_binding("LPUART");
    __ASSERT(uart0_dev, "Failed to get the device");

    if (IS_ENABLED(CONFIG_NRF_SW_LPUART_INT_DRIVEN)) {
    interrupt_driven(uart0_dev);
    } else {
    async(uart0_dev);
    }


    I get Failed to set callback, can you help me to fix it?


Reply
  • hello

    i am trying to do the same (uart between nrf9160 and nrf52840 on thingy 91)

    I started with coping lpuart-code to asset tracket code on nrf9160ns

    i added this changes to prj file:

    CONFIG_UART_ASYNC_API=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_1_ASYNC=y
    CONFIG_UART_1_INTERRUPT_DRIVEN=y

    my overlay file is:

    thingy91_nrf9160ns.overlay
    / {
    chosen {
    zephyr,console = &uart0;
    zephyr,shell-uart = &uart0;
    zephyr,uart-mcumgr = &uart0;
    };
    };

    &uart1 {
    current-speed = <1000000>;
    status = "okay";
    tx-pin = <22>;
    rx-pin = <23>;
    rts-pin = <24>;
    cts-pin = <25>;
    };

    in my main.c:

    err = uart_callback_set(uart0_dev, uart_callback, (void *)uart0_dev);

    __ASSERT(err == 0, "Failed to set callback");




    void main(void)
    {
    LOG_INF("Asset tracker started");


    const struct device *uart0_dev;

    k_msleep(1000);
    uart0_dev = device_get_binding("UART_1");
    //lpuart = device_get_binding("LPUART");
    __ASSERT(uart0_dev, "Failed to get the device");

    if (IS_ENABLED(CONFIG_NRF_SW_LPUART_INT_DRIVEN)) {
    interrupt_driven(uart0_dev);
    } else {
    async(uart0_dev);
    }


    I get Failed to set callback, can you help me to fix it?


Children
No Data
Related