Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Compile nRF5 SDK with C++

Hi,

I am programming for an nRF52840 chip. I am using Keil uVision with the ARM compiler in version 5. My codebase is in C++, this is why I have the Misc control "--cpp".

I want to use the uart library. But I do get compile errors, such as:

  static nrf_drv_uart_t app_uart_inst = NRF_DRV_UART_INSTANCE(APP_UART_DRIVER_INSTANCE);
C:\nordic\sdk_16.0\components\libraries\uart\app_uart.c(90): error:  #29: expected an expression

What do I have to do get rid of this? What I do understand is, that nRF5 SDK code base uses aggregate initialization for its structs, which the compiler does not like. Is there an SDK version that is C++ compatible? 

Changing the ARM compiler to version 6 yields errors such as.
C:\Keil_v5\ARM\CMSIS\Include\core_cmFunc.h(602): error: unknown register name 'vfpcc' in asm

Kind regards,
Kai

Parents
  • You need to explicitly initialize the struct members in the correct order rather than using the initialization macros. It should look something like the following:

    static nrf_drv_uart_t uart = {
        .inst_idx = 0, 
        .uarte = { 
            .p_reg = NRF_UARTE0, 
            .drv_inst_idx = NRFX_UARTE0_INST_IDX
            }
        }

    Hopefully I'm close, the UART driver has a couple more layers of macros that need to be expanded than the other peripherals I've worked with.

  • Thanks, but this does not solve the problem. Even, if I only use the nrfx_uart.c, which requires nrfx_prs.c, I get the errors mentioned above. Compiling nrfx_prs.c fails with the following errors:


    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(69): error:  #29: expected an expression
      PRS_BOX_DEFINE(0)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(69): error:  #29: expected an expression
      PRS_BOX_DEFINE(0)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(72): error:  #29: expected an expression
      PRS_BOX_DEFINE(1)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(72): error:  #29: expected an expression
      PRS_BOX_DEFINE(1)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(75): error:  #29: expected an expression
      PRS_BOX_DEFINE(2)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(75): error:  #29: expected an expression
      PRS_BOX_DEFINE(2)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(78): error:  #29: expected an expression
      PRS_BOX_DEFINE(3)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(78): error:  #29: expected an expression
      PRS_BOX_DEFINE(3)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(81): error:  #29: expected an expression
      PRS_BOX_DEFINE(4)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(81): error:  #29: expected an expression
      PRS_BOX_DEFINE(4)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c: 0 warnings, 10 errors

Reply
  • Thanks, but this does not solve the problem. Even, if I only use the nrfx_uart.c, which requires nrfx_prs.c, I get the errors mentioned above. Compiling nrfx_prs.c fails with the following errors:


    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(69): error:  #29: expected an expression
      PRS_BOX_DEFINE(0)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(69): error:  #29: expected an expression
      PRS_BOX_DEFINE(0)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(72): error:  #29: expected an expression
      PRS_BOX_DEFINE(1)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(72): error:  #29: expected an expression
      PRS_BOX_DEFINE(1)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(75): error:  #29: expected an expression
      PRS_BOX_DEFINE(2)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(75): error:  #29: expected an expression
      PRS_BOX_DEFINE(2)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(78): error:  #29: expected an expression
      PRS_BOX_DEFINE(3)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(78): error:  #29: expected an expression
      PRS_BOX_DEFINE(3)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(81): error:  #29: expected an expression
      PRS_BOX_DEFINE(4)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c(81): error:  #29: expected an expression
      PRS_BOX_DEFINE(4)
    C:\nordic\sdk_16.0\modules\nrfx\drivers\src\prs\nrfx_prs.c: 0 warnings, 10 errors

Children
No Data
Related