This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Zephyr peripheral pin remap with overlay file

My application uses a SPI LED driver, which I routed on a PCB to the most convenient pins for routing.

I have already tested my firmware on a nRF52833 DK with an Arduino shield. This uses the spi3 pin assignment on the default DTS.

arduino_spi: &spi3 {
status = "okay";
sck-pin = <23>;
miso-pin = <22>;
mosi-pin = <21>;
cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */
};

Now i want to remap this spi3 to the pins I used for routing. To do so I have included the following line on my CMakeLists.txt:

set(DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/nrf52833dk_nrf52833.overlay")

And my overlay file looks like this:

&spi3 {
status = "okay";
sck-pin = <26>; //P0.26
miso-pin = <40>; //P1.08
mosi-pin = <5>; //P0.05
cs-gpios = <31>; //P0.31
};

I tested this modification running some dupont cables to the appropiate pins, still with the nRF52833. What does work is changing the pin assignment on the code, for example using a custom structure like:

const struct spi_cs_control ctrl =
{
.gpio_dev = DEVICE_DT_GET(DT_NODELABEL(gpio0)),
.delay = 0,
.gpio_pin = 31,
.gpio_dt_flags = (GPIO_ACTIVE_LOW)
};

Which is the best way to get this to work?

It doesn't look like the overlay file is doing anything, as my code doesn't work. 

Parents Reply Children
  • Each time I'm making a change on the overlay file, should I run CMake again?

    On SES does build can be configured to run CMake each build?

    The macros solved the problem with the chip select issue, thanks.

  • Hi,

     

    Arturo Hache said:
    The macros solved the problem with the chip select issue, thanks.

    I'm glad to hear this! 

     

    Arturo Hache said:

    Each time I'm making a change on the overlay file, should I run CMake again?

    On SES does build can be configured to run CMake each build?

     .overlay changes isn't always picked up by the build system, so it is recommended that you re-import the project to ensure that the changes have been applied.

     

    Kind regards,

    Håkon

Related