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

nrf_block_dev_sdc.h c++ compability

Hi,

A project I'm working on can be seen as a collector of data from many different sources. To keep I an overview I've decided to use C++ objects rather than C (in other words: a C++ project).

I'm now implementing the data storage part of the project, which will be on a SD card. However, I can't get the SD card part to work (with my limited C++ programming knowledge).

The following bit gives an error:

NRF_BLOCK_DEV_SDC_DEFINE(
    m_block_dev_sdc,
    NRF_BLOCK_DEV_SDC_CONFIG(
            SDC_SECTOR_SIZE,
            APP_SDCARD_CONFIG(SD_PIN_MOSI, SD_PIN_MISO, SD_PIN_SCK, SD_PIN_CS)
     ),
     NFR_BLOCK_DEV_INFO_CONFIG("Nordic", "SDC", "1.00")
);

Error: ...nrf_block_dev_sdc.h:93:5: error: cannot convert 'const nrf_block_dev_ops_t {aka const nrf_block_dev_ops_s}' to 'const nrf_block_dev_s::nrf_block_dev_ops_s*' in initialization**.

This code can also be seen in the fatfs example, and by changing the extension of main.c to main.cpp and executing "make" you can reproduce the error.

How can this be solved?

Parents
  • For anyone else interested: I got a PM from Jørgen that no quick fix would be coming out soon.

    The SD part was crucial to my project, so I did some research. Turns out the barebone FatFs library is very easy to implement: elm-chan.org/.../00index_e.html.

    However, do take into account that nrf_drv_spi_transfer transfers a maximum amount of 255 bytes, while "disk_write" may require more than 255 to be written. I used SPI in blocking mode, so I simply wrote a for loop to request multiple write of 255 bytes when needed. Same story applies to reading of course.

Reply
  • For anyone else interested: I got a PM from Jørgen that no quick fix would be coming out soon.

    The SD part was crucial to my project, so I did some research. Turns out the barebone FatFs library is very easy to implement: elm-chan.org/.../00index_e.html.

    However, do take into account that nrf_drv_spi_transfer transfers a maximum amount of 255 bytes, while "disk_write" may require more than 255 to be written. I used SPI in blocking mode, so I simply wrote a for loop to request multiple write of 255 bytes when needed. Same story applies to reading of course.

Children
No Data
Related