nRF5340 SPI Slave NRFX sample

Hi!

I'm trying to run SPI slave on nRF5340 - doesn't work - project doesn't even build,
the SPI master is running.

Can I see an example of NRFX SPI Slave for nRF5340?

  • Hi

    Here are some SPI slave examples (NCS v2.0.0) made by one of my colleagues:

    I hope one or both of them will be helpful to you. If you struggle with building a project, please share the build log so we can see where it is failing exactly.

    Best regards,

    Simon

  • Hello Simon.
    Thanks for the great zephyre sample. They didn't help me at all.
    Perhaps you still have an example for nRF5340 SPI Slave nrfx api?
    Perhaps you have a file "nrf5340.h" or similar that has NRF_SPI_Type defined for nRF5340?
  • Hi

    Adding CONFIG_SPI=y and CONFIG_NRFX_SPIM1=y will make the Zephyr API use the nrfx Zephyr port for an enabled instance. Here you can see the nrfx peripheral resource sharing example in Zephyr.

    My colleague Håkon also uploaded some nrfx SPI projects for the nRF Connect SDK in this ticket, and also explains how to configure and set up an SPI device for the nRF5340 here.

    Best regards,

    Simon

  • Hi, Simon!
    Your advice helped me a lot!
    Thank you!

    But your spi Slave code is not going to the same :)

    This my code:
    #define ALT_SPI_SLAVE        DT_LABEL( DT_NODELABEL( alt_spi3_slave ) )      
    static const struct device  *spi3_s_dev_alt;
    ......
    spi3_s_dev_alt = device_get_binding( ALT_SPI_SLAVE );
    if( spi3_s_dev_alt == NULL )
    {
        return ERR_NO_INIT;
    }
    .....
    "nrf5340dk_nrf5340_cpuapp.overlay":
    /* SPI3 for slave mode
     */
    alt_spi3_slave: &spi3 {
        compatible = "nordic,nrf-spis";
        status = "okay";
        pinctrl-0 = <&spi3_default>;
        pinctrl-1 = <&spi3_sleep>;
        def-char = <0x00>;
    };

    "prj.conf":

    # This is needed for using another SPIM instance via the Zephyr SPI driver.
    CONFIG_SPI=y
    CONFIG_SPI_ASYNC=y
    CONFIG_SPI_SLAVE=y
    Build fails:
    C:\ncs\v2.1.1\zephyr\include\zephyr\devicetree.h:177:29: note: in expansion of macro 'DT_CAT'
    177 | #define DT_NODELABEL(label) DT_CAT(DT_N_NODELABEL_, label)
    | ^~~~~~
    c:\nRF_prj\myApp\myApp1\src\app_spi3_s.c:18:34: note: in expansion of macro 'DT_NODELABEL'
    18 | #define ALT_SPI_SLAVE DT_LABEL( DT_NODELABEL( my_spi3_slave ) )
    | ^~~~~~~~~~~~
    c:\nRF_prj\myApp\myApp1\src\app_spi3_s.c:46:39: note: in expansion of macro 'ALT_SPI_SLAVE'
    46 | spi3_s_dev_alt = device_get_binding( ALT_SPI_SLAVE );
    | ^~~~~~~~~~~~~
    c:\nRF_prj\myApp\myApp1\build_1\zephyr\include\generated\devicetree_unfixed.h:11795:38: note: each undeclared identifier is reported only once for each function it appears in
    11795 | #define DT_N_NODELABEL_my_spi3_slave DT_N_S_soc_S_peripheral_50000000_S_spi_c000
    Do not tell me what could be the problem?

    Best regards,
    Sergii

Related