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

  • Hi Hakon,

    I would recommend that you check with semtech if they have a native driver that they recommend.

    Thank you for your suggestions. As I said in my initial post I already have the source code to drive the Semtech LR1110 device. All I need to do is implement the low level HAL functions.

    I did not think the first line in prj.conf file was necessary so I commented it out.

    CONFIG_BOARD_ENABLE_CPUNET=n

    However, this caused the project to fail loading in SES. Is the default, 

    CONFIG_BOARD_ENABLE_CPUNET=y

    Could you please explain why the project failed to load?

    Kind regards

    Mohamed

  • Can you please share the error?

     

    It shouldn't cause it to fail. Which version of ncs and SES-NE are you using?

    I tested with SES-NE v5.10c (latest) and ncs v1.3.2, and it didn't have any impact at my end.

     

    Kind regards,

    Håkon

Reply Children
Related