Hello,
I am looking for an example which uses nrf-spim driver in Zephyr environment. I am currently working with nrf9160 board, and this device has configured by default
Hello,
I am looking for an example which uses nrf-spim driver in Zephyr environment. I am currently working with nrf9160 board, and this device has configured by default
Hello,
Check out: https://github.com/too1/ncs-spi-master-slave-example
It's missing an .overlay file for the nRF9160DK, but you should be able to make that based on one of the other .overlay files that are there.
Kenneth
Hello,
Check out: https://github.com/too1/ncs-spi-master-slave-example
It's missing an .overlay file for the nRF9160DK, but you should be able to make that based on one of the other .overlay files that are there.
Kenneth
Hello Kenneth,
I have already found this example, and I adapted to nrf9160. The example that you provided is not compiling for the board nrf5340 which is closer to nrf9160 rather than nrf52832.
It throws the following error:
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:89:10: error: 'PINCTRL_STATE_DT_N_S_soc_S_peripheral_50000000_S_spi_b000_PINCTRL_IDX_0_UPPER_TOKEN' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_50000000_S_spi_a000_PINCTRL_IDX_0_UPPER_TOKEN'?
89 | _CONCAT(PINCTRL_STATE_, \
| ^~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:67:26: note: in definition of macro '__DEBRACKET'
67 | #define __DEBRACKET(...) __VA_ARGS__
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:59:2: note: in expansion of macro '__GET_ARG2_DEBRACKET'
59 | __GET_ARG2_DEBRACKET(one_or_two_args _if_code, _else_code)
| ^~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:54:2: note: in expansion of macro '__COND_CODE'
54 | __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_macro.h:157:2: note: in expansion of macro 'Z_COND_CODE_1'
157 | Z_COND_CODE_1(_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_macro.h:201:2: note: in expansion of macro 'COND_CODE_1'
201 | COND_CODE_1(_flag, _code, ())
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\drivers\spi\spi_nrfx_spis.c:298:2: note: in expansion of macro 'IF_ENABLED'
298 | IF_ENABLED(CONFIG_PINCTRL, (PINCTRL_DT_DEFINE(SPIS(idx)))); \
| ^~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:64:53: note: in expansion of macro '__DEBRACKET'
64 | #define __GET_ARG2_DEBRACKET(ignore_this, val, ...) __DEBRACKET val
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:59:2: note: in expansion of macro '__GET_ARG2_DEBRACKET'
59 | __GET_ARG2_DEBRACKET(one_or_two_args _if_code, _else_code)
| ^~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:54:2: note: in expansion of macro '__COND_CODE'
54 | __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_macro.h:157:2: note: in expansion of macro 'Z_COND_CODE_1'
157 | Z_COND_CODE_1(_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:154:2: note: in expansion of macro 'COND_CODE_1'
154 | COND_CODE_1(Z_PINCTRL_SKIP_STATE(state_idx, node_id), (), \
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\toolchain\common.h:133:23: note: in expansion of macro '_DO_CONCAT'
133 | #define _CONCAT(x, y) _DO_CONCAT(x, y)
| ^~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:89:2: note: in expansion of macro '_CONCAT'
89 | _CONCAT(PINCTRL_STATE_, \
| ^~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:156:9: note: in expansion of macro 'Z_PINCTRL_STATE_ID'
156 | .id = Z_PINCTRL_STATE_ID(state_idx, node_id), \
| ^~~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_loops.h:1086:2: note: in expansion of macro 'Z_PINCTRL_STATE_INIT'
1086 | F(0, __VA_ARGS__)
| ^
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_loops.h:1089:2: note: in expansion of macro 'Z_UTIL_LISTIFY_1'
1089 | Z_UTIL_LISTIFY_1(F, sep, __VA_ARGS__) __DEBRACKET sep \
| ^~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:99:36: note: in expansion of macro 'Z_UTIL_LISTIFY_2'
99 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
| ^
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:170:3: note: in expansion of macro 'LISTIFY'
170 | LISTIFY(DT_NUM_PINCTRL_STATES(node_id), \
| ^~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:240:2: note: in expansion of macro 'Z_PINCTRL_STATES_DEFINE'
240 | Z_PINCTRL_STATES_DEFINE(node_id) \
| ^~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\drivers\spi\spi_nrfx_spis.c:298:30: note: in expansion of macro 'PINCTRL_DT_DEFINE'
298 | IF_ENABLED(CONFIG_PINCTRL, (PINCTRL_DT_DEFINE(SPIS(idx)))); \
| ^~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\drivers\spi\spi_nrfx_spis.c:333:1: note: in expansion of macro 'SPI_NRFX_SPIS_DEFINE'
333 | SPI_NRFX_SPIS_DEFINE(2);
| ^~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:89:10: error: 'PINCTRL_STATE_DT_N_S_soc_S_peripheral_50000000_S_spi_b000_PINCTRL_IDX_1_UPPER_TOKEN' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_50000000_S_spi_a000_PINCTRL_IDX_1_UPPER_TOKEN'?
89 | _CONCAT(PINCTRL_STATE_, \
| ^~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:67:26: note: in definition of macro '__DEBRACKET'
67 | #define __DEBRACKET(...) __VA_ARGS__
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:59:2: note: in expansion of macro '__GET_ARG2_DEBRACKET'
59 | __GET_ARG2_DEBRACKET(one_or_two_args _if_code, _else_code)
| ^~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:54:2: note: in expansion of macro '__COND_CODE'
54 | __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_macro.h:157:2: note: in expansion of macro 'Z_COND_CODE_1'
157 | Z_COND_CODE_1(_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_macro.h:201:2: note: in expansion of macro 'COND_CODE_1'
201 | COND_CODE_1(_flag, _code, ())
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\drivers\spi\spi_nrfx_spis.c:298:2: note: in expansion of macro 'IF_ENABLED'
298 | IF_ENABLED(CONFIG_PINCTRL, (PINCTRL_DT_DEFINE(SPIS(idx)))); \
| ^~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:64:53: note: in expansion of macro '__DEBRACKET'
64 | #define __GET_ARG2_DEBRACKET(ignore_this, val, ...) __DEBRACKET val
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:59:2: note: in expansion of macro '__GET_ARG2_DEBRACKET'
59 | __GET_ARG2_DEBRACKET(one_or_two_args _if_code, _else_code)
| ^~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:54:2: note: in expansion of macro '__COND_CODE'
54 | __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_macro.h:157:2: note: in expansion of macro 'Z_COND_CODE_1'
157 | Z_COND_CODE_1(_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:154:2: note: in expansion of macro 'COND_CODE_1'
154 | COND_CODE_1(Z_PINCTRL_SKIP_STATE(state_idx, node_id), (), \
| ^~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\toolchain\common.h:133:23: note: in expansion of macro '_DO_CONCAT'
133 | #define _CONCAT(x, y) _DO_CONCAT(x, y)
| ^~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:89:2: note: in expansion of macro '_CONCAT'
89 | _CONCAT(PINCTRL_STATE_, \
| ^~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:156:9: note: in expansion of macro 'Z_PINCTRL_STATE_ID'
156 | .id = Z_PINCTRL_STATE_ID(state_idx, node_id), \
| ^~~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_loops.h:1090:2: note: in expansion of macro 'Z_PINCTRL_STATE_INIT'
1090 | F(1, __VA_ARGS__)
| ^
C:\ncs\v2.1.1\zephyr\include\zephyr\sys\util_internal.h:99:36: note: in expansion of macro 'Z_UTIL_LISTIFY_2'
99 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
| ^
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:170:3: note: in expansion of macro 'LISTIFY'
170 | LISTIFY(DT_NUM_PINCTRL_STATES(node_id), \
| ^~~~~~~
C:\ncs\v2.1.1\zephyr\include\zephyr\drivers\pinctrl.h:240:2: note: in expansion of macro 'Z_PINCTRL_STATES_DEFINE'
240 | Z_PINCTRL_STATES_DEFINE(node_id) \
| ^~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\drivers\spi\spi_nrfx_spis.c:298:30: note: in expansion of macro 'PINCTRL_DT_DEFINE'
298 | IF_ENABLED(CONFIG_PINCTRL, (PINCTRL_DT_DEFINE(SPIS(idx)))); \
| ^~~~~~~~~~~~~~~~~
C:\ncs\v2.1.1\zephyr\drivers\spi\spi_nrfx_spis.c:333:1: note: in expansion of macro 'SPI_NRFX_SPIS_DEFINE'
333 | SPI_NRFX_SPIS_DEFINE(2);
| ^~~~~~~~~~~~~~~~~~~~
[116/177] Building C object zephyr/drivers/timer/CMakeFiles/drivers__timer.dir/nrf_rtc_timer.c.obj
[117/177] Building C object modules/nrf/lib/fatal_error/CMakeFiles/..__nrf__lib__fatal_error.dir/fatal_error.c.obj
[118/177] Building C object zephyr/drivers/spi/CMakeFiles/drivers__spi.dir/spi_nrfx_spim.c.obj
[119/177] Building C object modules/nrf/drivers/hw_cc310/CMakeFiles/..__nrf__drivers__hw_cc310.dir/hw_cc310.c.obj
[120/177] Linking C static library zephyr\drivers\console\libdrivers__console.a
[121/177] Linking C static library zephyr\drivers\clock_control\libdrivers__clock_control.a
[122/177] Linking C static library zephyr\libzephyr.a
[123/177] Linking C static library zephyr\drivers\gpio\libdrivers__gpio.a
[124/177] Linking C static library zephyr\drivers\serial\libdrivers__serial.a
[125/177] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/nrfx_glue.c.obj
[126/177] Linking C static library zephyr\drivers\pinctrl\libdrivers__pinctrl.a
[127/177] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/ncs/v2.1.1/modules/hal/nordic/nrfx/helpers/nrfx_flag32_allocator.c.obj
[128/177] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/ncs/v2.1.1/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.1.1\opt\bin\cmake.EXE' --build 'c:\Users\M0146164\vs-workspace\ncs-spi-master-slave-example\build'
* The terminal process terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
Moreover, this example is not updated, it is using deprecated functions.
I have did the overlay for nrf9160 but I am facing the same issues as nrf5340 board.
Regards
Can you try to add: pinctrl-names = "default", "sleep";
To my_spi_slave in the overlay file.
Kenneth