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

converting zephyr driver led_ws2812 to run on nrf9160

In the nrfConnect SDK 1.4 there is a sample for chainable RGB LEDs ../ncs/zephyr/samples/drivers/led_ws2812

I want to use this with nrf9160 so I created nrf9160dk_nrf9160ns.overlay by copying and editing the nrf52 one:

```

/*
* Copyright (c) 2019, Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "../nrf52-bindings.h"

&spi2 {
  led_strip: ws2812@0 {
    mosi-pin = <31>;
    compatible = "worldsemi,ws2812-spi";
    label = "WS2812";

    /* SPI */
    reg = <0>; /* ignored, but necessary for SPI bindings */
    spi-max-frequency = <SPI_FREQ>;

    /* WS2812 */
    chain-length = <10>; /* arbitrary; change at will */
    spi-one-frame = <ONE_FRAME>;
    spi-zero-frame = <ZERO_FRAME>;
  };
};

/ {
  aliases {
    led-strip = &led_strip;
  };
};

```

When I try to build that west gives:

```

Error: nrf9160dk_nrf9160ns.dts.pre.tmp:587.25-26 syntax error

FATAL ERROR: Unable to parse input tree

CMake Error at /Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/cmake/dts.cmake:213 (message):

  command failed with return code: 1

Call Stack (most recent call first):

  /Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/cmake/app/boilerplate.cmake:590 (include)

  /Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)

  /Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)

  CMakeLists.txt:5 (find_package)

-- Configuring incomplete, errors occurred!

FATAL ERROR: command exited with status 1: /usr/local/bin/cmake -DWEST_PYTHON=/usr/local/opt/python/bin/python3.7 -B/Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/samples/drivers/led_ws2812/build -S/Users/paul_tanner/Nordic/nrfsrc/ncs/zephyr/samples/drivers/led_ws2812 -GNinja -DBOARD=nrf9160dk_nrf9160ns

```

Note: the file named nrf52-bindings.h does not look as though it needs to be changed so I did not rename i

Perhaps I need to do more to convert this for nrf9160?

There's a note in the README.rst: create a ``led-strip`` :ref:`devicetree alias <dt-alias-chosen>` ... I'm not sure what's needed.

Regards.

Parents
  • Hi,

    I don't have the hardware to test, but looks like this compiles. Pin31 was already assigned to i2c2, so had to disable it.

    Kenneth

    /*
     * Copyright (c) 2019, Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include "../nrf52-bindings.h"
    
    &i2c2 {
    	status = "disabled";
    };
    
    &spi2 { /* MOSI on D11 / P0.23 */
    	mosi-pin = <31>;
    	sck-pin = <30>;
    	miso-pin = <29>;
    	status = "okay";
    	compatible = "nordic,nrf-spim";	
    	led_strip: ws2812@0 {		
    		compatible = "worldsemi,ws2812-spi";
    		label = "WS2812";
    
    		/* SPI */
    		reg = <0>; /* ignored, but necessary for SPI bindings */
    		spi-max-frequency = <SPI_FREQ>;
    
    		/* WS2812 */
    		chain-length = <16>; /* arbitrary; change at will */
    		spi-one-frame = <ONE_FRAME>;
    		spi-zero-frame = <ZERO_FRAME>;
    	};
    };
    
    / {
    	aliases {
    		led-strip = &led_strip;
    	};
    };

    Or this:

    /*
     * Copyright (c) 2019, Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include "../nrf52-bindings.h"
    
    &i2c2 {
    	status = "disabled";
    };
    
    &spi3 { /* MOSI on D11 / P0.23 */
    	mosi-pin = <31>;	
    	compatible = "nordic,nrf-spim";	
    	led_strip: ws2812@0 {		
    		compatible = "worldsemi,ws2812-spi";
    		label = "WS2812";
    
    		/* SPI */
    		reg = <0>; /* ignored, but necessary for SPI bindings */
    		spi-max-frequency = <SPI_FREQ>;
    
    		/* WS2812 */
    		chain-length = <16>; /* arbitrary; change at will */
    		spi-one-frame = <ONE_FRAME>;
    		spi-zero-frame = <ZERO_FRAME>;
    	};
    };
    
    / {
    	aliases {
    		led-strip = &led_strip;
    	};
    };
    

Reply
  • Hi,

    I don't have the hardware to test, but looks like this compiles. Pin31 was already assigned to i2c2, so had to disable it.

    Kenneth

    /*
     * Copyright (c) 2019, Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include "../nrf52-bindings.h"
    
    &i2c2 {
    	status = "disabled";
    };
    
    &spi2 { /* MOSI on D11 / P0.23 */
    	mosi-pin = <31>;
    	sck-pin = <30>;
    	miso-pin = <29>;
    	status = "okay";
    	compatible = "nordic,nrf-spim";	
    	led_strip: ws2812@0 {		
    		compatible = "worldsemi,ws2812-spi";
    		label = "WS2812";
    
    		/* SPI */
    		reg = <0>; /* ignored, but necessary for SPI bindings */
    		spi-max-frequency = <SPI_FREQ>;
    
    		/* WS2812 */
    		chain-length = <16>; /* arbitrary; change at will */
    		spi-one-frame = <ONE_FRAME>;
    		spi-zero-frame = <ZERO_FRAME>;
    	};
    };
    
    / {
    	aliases {
    		led-strip = &led_strip;
    	};
    };

    Or this:

    /*
     * Copyright (c) 2019, Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include "../nrf52-bindings.h"
    
    &i2c2 {
    	status = "disabled";
    };
    
    &spi3 { /* MOSI on D11 / P0.23 */
    	mosi-pin = <31>;	
    	compatible = "nordic,nrf-spim";	
    	led_strip: ws2812@0 {		
    		compatible = "worldsemi,ws2812-spi";
    		label = "WS2812";
    
    		/* SPI */
    		reg = <0>; /* ignored, but necessary for SPI bindings */
    		spi-max-frequency = <SPI_FREQ>;
    
    		/* WS2812 */
    		chain-length = <16>; /* arbitrary; change at will */
    		spi-one-frame = <ONE_FRAME>;
    		spi-zero-frame = <ZERO_FRAME>;
    	};
    };
    
    / {
    	aliases {
    		led-strip = &led_strip;
    	};
    };
    

Children
Related