nrf52840 with NOR memory

https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/drivers/spi_flash/src/main.c#L36

may I know where I can find the pin connections used in this example 

"const struct device *flash_dev = DEVICE_DT_GET_ONE(SPI_FLASH_COMPAT);" 

#if DT_HAS_COMPAT_STATUS_OKAY(jedec_spi_nor)
#define SPI_FLASH_COMPAT jedec_spi_nor

I checked jedec yaml file but no pins is defined there as well 

Parents Reply
  • #define SPIOP SPI_WORD_SET(8) | SPI_TRANSFER_MSB

    struct spi_dt_spec spispec = SPI_DT_SPEC_GET(DT_NODELABEL(w25m02g), SPIOP, 0);

    const struct device *spi_dev = DEVICE_DT_GET(DT_NODELABEL(spi1));

    &spi1 {
        compatible = "nordic,nrf-spim";
        status = "okay";
        pinctrl-0 = <&spi1_default>;
        pinctrl-1 = <&spi1_sleep>;
        pinctrl-names = "default", "sleep";
        cs-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
    
        w25m02g: w25m02g@0 {
            compatible = "winbond,w25m02g";
            reg = <0>;
            spi-max-frequency = <80000000>;
            size = <2147483648>;
            wp-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
            hold-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
        };
    };

    May I ask if the SPI_DT_SPEC_GET and DEVICE_DT_GET can change with each other? Are they serving the same purpose? 

    Can both work with spi_transceive?  how about flash_write? 

Children
  • No. They both have different purposes. It's true that both are used to get the device information from the dts.

    SPI_DT_SPEC_GET is used to get information regarding SPI from the dts. This macro is used when you need to perform operations like spi_transcieve_dt, spi_read_dt, etc. It returns a spi_dt_spec struct which includes the SPI device instance and it's configuration.

    DEVICE_DT_GET is used to get a pointer to the device structure for a given device from the dts. And this macro is used when you need to perform operations like flash_write or flash_read. 

    Hope these clarify your doubts. I would suggest you to create a new ticket for further queries if the initial topic for the ticket is solved, as this will help keep devzone clean and help future seekers when they search for specific topics.

    -Priyanka

Related