I need to add DEVICE_API in my code. How can I do that? Currently, I’m using NCS v2.6.1.
I need to add DEVICE_API in my code. How can I do that? Currently, I’m using NCS v2.6.1.
Hi Chirag,
Could you clarify what you are trying to achieve here? I need more information.
Best regards,
Benjamin
Hi,
I want to use the flash driver.
Initially, I defined the API like this:
static const struct flash_driver_api micron_spi_nand_api = {
.read = micron_spi_nand_read,
.write = micron_spi_nand_write,
.erase = micron_spi_nand_erase,
.get_parameters = flash_nand_get_parameters,
.read_jedec_id = micron_spi_nand_read_jedec_id,
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
.page_layout = micron_spi_nand_pages_layout,
#endif
};
When I tried to change this to use the DEVICE_API() macro:
// static DEVICE_API(flash, micron_spi_nand_api) = {
the build failed with an error. I also noticed that DEVICE_API is not defined in zephyr/include/zephyr/device.h in NCS v2.6.1.
So my question is: how can I correctly use the device API mechanism in NCS v2.6.1?
Are you trying to implement a custom flash driver?
DEVICE_API is a macro used to declare device API structs inside iterable sections. Your NCS version of Zephyr does not support this.
Declaring the flash driver API with static const struct flash_driver_api is correct. If you want to use iterable sections, you need to update NCS.
Best regards,
Benjamin
Hi,
without update of the ncs is there any way to used the DEVICE_API?
The DEVICE_API macro doesn’t exist in your NCS version. Could you explain what you’re trying to achieve by using it? That way I can suggest the right approach.
The DEVICE_API macro doesn’t exist in your NCS version. Could you explain what you’re trying to achieve by using it? That way I can suggest the right approach.
Hi,
We have two products: one uses the old NVS version (already launched) and the other uses the latest version. To maintain consistency, we need to implement the same API for both firmware versions. For this purpose, we are using the device API as shown below.
Hi Chriaq,
The already launched version is the one that uses NCS v2.6.1 or is NCS v2.6.1 what you mean by newest version?
Benjamin
Hi,
newest version is the 3.0.2
Yes, in v3.0.2 you can use the DEVICE_API macro. You cannot use it in v2.6.1, because it does not exist in Zephyr.