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

Adding uart functionality to a project

I don't know if this something I'm doing wrong, a Segger stupidity, or something else.  I'm using SES and copied the examples/ble_central/ble_app_blink_c project to another directory and changed all the include paths (why is this the way to create new projects -- ugly).  I got it to compile fine.  

Now I'm trying to add uart functionality so I added the uart files in components/libraries/uart (didn't add app_uart.c -- I'm using app_uart_fifo.c) and added this directory to the preprocessor include path.

I then did the same thing with the components/libraries/fifo folder (add files, added to path) because it's apparently needed.

No matter what I do, SES complains that it can't find app_fifo.h. app_fifo.c compiled.  If I go to app_fifo.c and right click on the include of app_fifo.h and select "Go to Definition" it opens app_fifo.h.  If I do that from app_uart_fifo.c, it can't find the file.  Both of these files are in the project.

What I have tried:

1) adding file paths to common preprocessor options for user includes

2) adding file paths to common preprocessor options for system includes

3) adding file paths to debug (which I'm trying to build) for user & system includes.

4) adding "/" after the ends of the paths.

5) I have also added this to the sdk_config.h file.

// </h> 
//==========================================================

// </e>

// <e> APP_UART_ENABLED - app_uart - UART driver
//==========================================================
#ifndef APP_UART_ENABLED
#define APP_UART_ENABLED 1
#endif
// <o> APP_UART_DRIVER_INSTANCE  - UART instance used
 
// <0=> 0 

#ifndef APP_UART_DRIVER_INSTANCE
#define APP_UART_DRIVER_INSTANCE 0
#endif

// </h> 
//==========================================================

// <h> nRF_Libraries 

//==========================================================
// <q> APP_FIFO_ENABLED  - app_fifo - Software FIFO implementation
 

#ifndef APP_FIFO_ENABLED
#define APP_FIFO_ENABLED 1
#endif

If I right click on app_fifo.c in the project explorer and select compile, it compiles with no errors/warnings and it includes the file app_fifo.h.  It's in the same directory so maybe that is why it works.  The project build still fails on app_uart_fifo.c which includes app_fifo.h.

Finally a question/suggestion.  Why am I having to add .c and .h files and paths?  This is silly.  Why are these libraries not built into a lib (e.g. .a files) for the different platforms and included with include directories?  

  • I was able to make this work with another example (but the approach should be the same), I did the following:

    1. Moved ..\nRF5_SDK_16.0.0_98a08e2\examples\peripheral\blinky to ..\Desktop\blinky
    2. Followed this approach
    3. Opened ..\Desktop\blinky\pca10040\s132\ses\blinky_pca10040_s132.emProject and added $(SDK)/components/libraries/fifo; to c_user_include_directories
    4. Added the following to ..\Desktop\blinky\pca10040\blank\config\sdk_config.hOpened ..\Desktop\blinky\pca10040\blank\ses\blinky_pca10040.emProject in SES
      //==========================================================
      // <q> APP_FIFO_ENABLED  - app_fifo - Software FIFO implementation
       
      
      #ifndef APP_FIFO_ENABLED
      #define APP_FIFO_ENABLED 1
      #endif
      
      // <e> APP_UART_ENABLED - app_uart - UART driver
      //==========================================================
      #ifndef APP_UART_ENABLED
      #define APP_UART_ENABLED 1
      #endif
      // <o> APP_UART_DRIVER_INSTANCE  - UART instance used
       
      // <0=> 0 
      
      #ifndef APP_UART_DRIVER_INSTANCE
      #define APP_UART_DRIVER_INSTANCE 0
      #endif
      
      // </e>
    5. In SES, I added ..\nRF5_SDK\nRF5_SDK_16.0.0_98a08e2\components\libraries\uart\app_uart_fifo.c and ..\nRF5_SDK_16.0.0_98a08e2\components\libraries\fifo\app_fifo.c to Project 'Blinky_pca10040' → nRF_Drivers
    6. Remove Desktop\blinky\pca10040\blank\ses\blinky_pca10040.emProject and Desktop\blinky\pca10040\blank\ses\blinky_pca10040.emSession
    7. Build project from SES
    8. Right click on #include "app_fifo.h" in app_uart_fifo.c and click on Go to included file... and it shoud work

    Best regards,

    Simon

  • I took a quick look over this now and it seems like I made some mistakes:

    • In step 3 I think it should be ..\Desktop\blinky\pca10040\blank\ses.. and not ..\Desktop\blinky\pca10040\s132\ses..
    • In step 6, I don't think you should remove blank\ses\blinky_pca10040.emProject.

    I will go through it again when I get the time and update the text.

    Best regards,

    Simon

  • It looks like if I edit the project file directly, it works.  Not sure why I have to do that...

Related