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

nrf_libuarte_async_rx_free ?

Dear Member,

I want to call nrf_libuarte_async_rx_free from another file outside main.c

nrf_libuarte_async_rx_free(&libuarte1, (uint8_t *)&GPS.rxTmp, 1);

I got  

..\..\..\GPS-Lib\GPS_lib.c(35): error:  #20: identifier "libuarte1" is undefined

I have included 

#include "nrf_libuarte_async.h"

in GPS_lib.c

and

NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 1, 2, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

in main.c ,

How can I rectify it ?

Thanks

Parents
  • Hi,

    The NRF_LIBUARTE_ASYNC_DEFINE macro will declare libuarte1 in your main.c file as a static variable, which prevents you from accessing it outside of the file where it is declared (out-of-scope).

    You have some different options to resolve this:

    • Modify the NRF_LIBUARTE_ASYNC_DEFINE macro in nrf_libuarte_async.h to declare the nrf_libuarte_async_t object as non-static, then declare the variable as extern in the file where you want to use it.
    • Declare a pointer to libuarte1 in main.c, and declare the same pointer as extern in the file where you want to use it (see this post).
    • Implement a function in main.c that calls nrf_libuarte_async_rx_free() for you, and declare this function in a header-file (main.h) that you include in the file where you want to use the function.

    Best regards,
    Jørgen

  • extern const nrf_libuarte_async_t libuarte1; in main.c and

    I call

    nrf_libuarte_async_rx_free(&libuarte1, (uint8_t *)&GPS.rxTmp, 1); in GPS_lib.c

    Correct me  ? thanks

Reply Children
Related