This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to configure and setup an SPI device to nRF5340

Hello,

I am trying to setup a device (Semtech LR1110) connected to SPI 1 peripheral on the nRF5340pdk.

I have a driver code for it. My question is this.

How can I set it up in the .dts file and keep the code that drives it with my source code on my local drive without having to put it the C:\Zypher\v1.3.0\zephyr\drivers\LR1110?

Q1/ Will the proposed Device Tree fragment do the job?
...
...
spi1: spi@9000 {
   compatible = "nordic,nrf5340";
   status = "okay";
   reg = < 0x9000 0x1000 >;
   interrupts = < 0x9 0x1 >;
   label = "SPI_1";
   sck-pin = < 0x?? >;
   mosi-pin = < 0x?? >;
   miso-pin = < 0x?? >;
};      
Q2/ How do I get the device binding to work?
Will this work?
device_get_binding( DT_PROP( DT_NODELABEL(spi1), label );

Thank you.

Kind regards

Parents
  • Hi,

     

    I would recommend that you check with semtech if they have a native driver that they recommend. There are drivers for semtech ICs in zephyr already, but I'm not familiar with their devices.

     

    Will the proposed Device Tree fragment do the job?

     You can set up SPI1 like this in a $(BOARD).overlay file:

    &spi1 {
            compatible = "nordic,nrf-spim";
            status = "okay";
            sck-pin = <10>;
            mosi-pin = <11>;
            miso-pin = <12>;
    };

     

    Then enable it in prj.conf:

    CONFIG_SPI=y
    CONFIG_SPI_1=y

     

     

    How do I get the device binding to work?

    Like this for instance: 

    	const char* const spiName = "SPI_1";
    	spi_dev = device_get_binding(spiName);

     

    All those DT_ aliases basically boil down to an ascii string, like above.

     

    Here's a test example with overlay for nrf5340pdk_nrf5340_cpuapp:

    7357.spi_test.zip

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    I would recommend that you check with semtech if they have a native driver that they recommend. There are drivers for semtech ICs in zephyr already, but I'm not familiar with their devices.

     

    Will the proposed Device Tree fragment do the job?

     You can set up SPI1 like this in a $(BOARD).overlay file:

    &spi1 {
            compatible = "nordic,nrf-spim";
            status = "okay";
            sck-pin = <10>;
            mosi-pin = <11>;
            miso-pin = <12>;
    };

     

    Then enable it in prj.conf:

    CONFIG_SPI=y
    CONFIG_SPI_1=y

     

     

    How do I get the device binding to work?

    Like this for instance: 

    	const char* const spiName = "SPI_1";
    	spi_dev = device_get_binding(spiName);

     

    All those DT_ aliases basically boil down to an ascii string, like above.

     

    Here's a test example with overlay for nrf5340pdk_nrf5340_cpuapp:

    7357.spi_test.zip

     

    Kind regards,

    Håkon

Children
Related