Error while trying to config SPI in VS code .

HI i am working with the nrf 52833 dk board using  nrf connect and trying to implement SPI ,

#define SPI3_NODE DT_NODELABEL(SPI_3)
static const struct spi_dt_spec* dev_spi = SPI_DT_SPEC_GET(SPI3_NODE,SPI_OP_MODE_MASTER,1);

I am getting this error - identifier "__device_dts_ord_DT_N_NODELABEL_SPI_3_BUS_ORD" is undefined. 

I am new to ncs and zephyr , so what is causing this error?

Parents Reply
  • Hi,

    I do not believe you get the SPI device successfully. You are creating a new spi_dev inside of spi_init(). Try the following instead:

    const struct device * spi_dev;
    
    static void spi_init(void)
    {
    	#define SPI_3 DT_NODELABEL(spi3)
    	spi_dev = device_get_binding(DT_LABEL(SPI_3));
    	if (spi_dev == NULL) {
    		printk("Could not get device\n");
    		return;
    	}
    }

    Then remove everything on lines 47 to 53, i.e. this part:

    nrf_gpio_cfg_output(CS_PIN);
    // GPIO_SetBits(SPI_CS_MS_DEMO_PIN);
    nrf_gpio_pin_set(CS_PIN);
    // GPIO_ResetBits(SPI_CS_MS_DEMO_PIN);
    nrf_gpio_pin_clear(CS_PIN);
    tx_buffer[0]=0x9F;
    // SPI_Send_Receive_Data(&a, &a1);

    And also remove nrf_gpio_pin_set(CS_PIN); on line 62.

    Best regards,

    Marte

Children
No Data
Related