Hi
First the fundamentals, I am using:
- nRF52840-DK
- nRF Connect for VS Code:
v2024.7.13
I am trying to create a demonstration project, where I need both SPI and TXI/I2C.
Here is a copy of the essentials:
prj.conf:
CONFIG_EVENTS=y CONFIG_SETTINGS=y CONFIG_HEAP_MEM_POOL_SIZE=1024 CONFIG_DK_LIBRARY=y CONFIG_LOG=y CONFIG_SPI=y CONFIG_I2C=y #CONFIG_NRFX_SPIM1=y #CONFIG_NRFX_TWI0=y
nrf52840dk_nrf52840.overlay:
&spi1 { status = "okay"; compatible = "nordic,nrf-spim"; pinctrl-0 = <&spi1_default>; }; &i2c0 { status = "okay"; compatible = "nordic,nrf-twim"; pinctrl-0 = <&i2c0_default>; };
twi code:
#include <zephyr/kernel.h> #include <zephyr/drivers/gpio.h> #include <zephyr/drivers/i2c.h> #include <nrfx_twim.h> #define TWIM_INST_IDX 0 static nrfx_twim_t twim_inst = NRFX_TWIM_INSTANCE(TWIM_INST_IDX); // Comile error: 'NRFX_TWIM0_INST_IDX' undeclared here (not in a function)
spi code:
#include <zephyr/kernel.h> #include <zephyr/drivers/spi.h> #include <nrfx_spim.h> #define SPIM_INST_IDX 1 static nrfx_spim_t spim_inst = NRFX_SPIM_INSTANCE(SPIM_INST_IDX); // compile error: 'NRFX_SPIM1_INST_IDX' undeclared here (not in a function)
In my first attempts with only SPI interface enabled, I got it working by using the CONFIG_NRFX_SPIM1=y line in the prj.conf file. But I do not thick that it was the right way.
What do I miss? Do I need more includes? Or some other changes to the project?
I have tried to look at the examples, e.g. "nrfx_spim basic non-blocking example.", here only the CONFIG_NRFX_SPI1=y is used, but the error detector in the editor expects an error (just As in my application), but it does compile:
CONFIG_NRFX_SPIM1 was assigned the value y, but got the value n. Missing dependencies: n SPIM1 driver instance Type: bool Value: n
Thanks in advance.
Kasper