SPI Slave NRF5340 Init Error

Hi all!
SPI3 Slave project is not built - error:
identifier "__device_dts_ord_DT_N_S_soc_S_peripheral_50000000_S_spi_c000_P_cs_gpios_IDX_0_PH_ORD" not determined

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_c000_PINCTRL_IDX_0_UPPER_TOKEN' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_50000000_S_spi_b000_PINCTRL_IDX_0_UPPER_TOKEN'?

What could be?
I ask for the help of a specialist.
Parents Reply Children
  • I tried for SPI2 - same error when building, 
    I am aware of the impossibility of using SPI3/I2C3 at the same time.

  • Are you working on some sample? Would you be able to share your project?

  • /*
     * app_spi3_s.c
     *
    */

    #include <zephyr/zephyr.h>
    #include <zephyr/drivers/gpio.h>
    #include <zephyr/drivers/spi.h>

    #include "app_spi3_s.h"

    /* Devicetree node corresponding to the peripheral to be used via Zephyr SPI
     * driver (SPIS3), in the background transfer.
     */
    #define SPI_DEV_NODE DT_NODELABEL( spi3 )

    const struct device *spi3_s_dev = DEVICE_DT_GET( SPI_DEV_NODE );

    static const struct spi_config spi3_s_dev_cfg = {
            .operation = SPI_OP_MODE_SLAVE |
                         SPI_WORD_SET(8) |
                         SPI_TRANSFER_MSB |
                         SPI_MODE_CPOL |
                         SPI_MODE_CPHA,
            .frequency = 500000,
            .slave = 1
    //      .cs = &spi3_s_dev_cs_ctrl ???
        };

    // Signal ------------------------------------------------------------------
    static struct k_poll_signal spi3_s_done_sig = K_POLL_SIGNAL_INITIALIZER( spi3_s_done_sig );

    // Value -------------------------------------------------------------------
    static struct spi_buf       tx_buf;
    static struct spi_buf_set   tx;

    static struct spi_buf       rx_buf;
    static struct spi_buf_set   rx;

    // SPI Slave **************************************************************

    // SPI Slave Init func ----------------------------------------------------
    uint8_t spi3_s_init( void )
    {
        if( !device_is_ready( spi3_s_dev ) )
        {
            return ERR_INIT_N_RDY;
        }



        return ERR_INIT_NO;
    }

    uint8_t spi3_s_transfer( uint8_t *tx_buffer, uint8_t *rx_buffer, uint16_t num_transfer )
    {
        int ret;

    //  printk( "-- Background transfer on \"%s\" --\n", spi3_s_dev->name );

        tx_buf.buf = (void*)tx_buffer;
        tx_buf.len = num_transfer;
        tx.buffers = &tx_buf;
        tx.count = 1;
       
        rx_buf.buf = (void*)rx_buffer;
        rx_buf.len = num_transfer;
        rx.buffers = &rx_buf;
        rx.count = 1;

        // Reset signal
        k_poll_signal_reset( &spi3_s_done_sig );

        // Start transaction
        ret = spi_transceive_async( spi3_s_dev, &spi3_s_dev_cfg, &tx, &rx, &spi3_s_done_sig );

        if( ret < 0 )
        {
    //      printk( "Background transfer failed: %d\n", ret );

            return TRANSFER_ERR;
        }

        return TRANSFER_RUN;
    }

    uint8_t spi3_s_check_transfer( void )
    {
        unsigned int signaled;
        int          result;

        k_poll_signal_check( &spi3_s_done_sig, &signaled, &result );
        if( signaled )
        {
            return TRANSFER_OK;
        }
        else
        {
            return TRANSFER_RUN;
        }
    }

    /*
     * app_spi3_s.h
     *
    */

    #ifndef _APP_SPI3_S_
    #define _APP_SPI3_S_

    #include <stdint.h>

    // Define ------------------------------------------------------------------
    #define ERR_INIT_NO     0
    #define ERR_INIT_N_RDY  1

    #define TRANSFER_OK     0
    #define TRANSFER_ERR    1
    #define TRANSFER_RUN    2

    // Prototype ---------------------------------------------------------------
    uint8_t spi3_s_init( void );
    uint8_t spi3_s_transfer( uint8_t *tx_buffer, uint8_t *rx_buffer, uint16_t num_transfer );
    uint8_t spi3_s_check_transfer( void );

    #endif  // _APP_SPI3_S_

    nrf5340dk_nrf5340_cpuapp.overlay
    -----------------------------------------------

    &pinctrl {
        spi3_default: spi3_default {
            group1 {
                psels = <NRF_PSEL(SPIS_SCK15)>,
                        <NRF_PSEL(SPIS_MOSI14)>,
                        <NRF_PSEL(SPIS_MISO11)>,
                        <NRF_PSEL(SPIS_CSN10)>;
            };
        };

        spi3_sleep: spi3_sleep {
            group1 {
                psels = <NRF_PSEL(SPIS_SCK15)>,
                        <NRF_PSEL(SPIS_MOSI14)>,
                        <NRF_PSEL(SPIS_MISO11)>,
                        <NRF_PSEL(SPIS_CSN10)>;
                low-power-enable;
            };
        };
    };

    /* SPI3 for slave mode
     */
    &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
    CONFIG_MAIN_STACK_SIZE=4096


Related