Heey,
I'm currently trying to implement a w2812 on my custom nrf9160 board. For this I want to use my SPi bus to instruct the ws2812 leds. Because I've already implemented something similar for a different project I've copied the code to my current project. But for some reason the first LED always seems to be off.
After doing some research I've noted that the MOSI starts high before the clock starts. The ws2812 is a one wire protocol, meaning that the MOSI starting high will influence the first bit sent to the ws2812.
Until now I haven't found any settings regarding the MOSI starting off as high. So I'm wondering if there is any possibility to force the MOSI to start low before the first bit.
These are my SPI settings:
struct spi_config spi_flash_cfg = { .slave = 3,
.operation = SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB | SPI_LINES_SINGLE | (8 << SPI_WORD_SIZE_SHIFT),
.frequency = 10000000 }; /*10MHz is used for ws2812*/
These are the board file settings regarding SPI
spi_flash: &spi3 {
status = "okay";
compatible = "nordic,nrf-spim";
cs-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>,
<&gpio0 26 GPIO_ACTIVE_LOW>,
<&gpio0 7 GPIO_ACTIVE_LOW>;
pinctrl-0 = <&SPI_FLASH_default>;
pinctrl-1 = <&SPI_FLASH_sleep>;
pinctrl-names = "default", "sleep";
sgt1001: spi-dev-sgt1001@0 {
reg = <0>;
};
mx25r64: mx25r6435f@1 {
status = "okay";
compatible = "jedec,spi-nor";
reg = <1>;
spi-max-frequency = <8000000>;
jedec-id = [ c2 28 17 ];
size = <0x04000000>;
mxicy,mx25r-power-mode = "high-performance";
partitions{
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
slot1_partition: partition@0 {
label = "image-1";
reg = <0x00000000 0xdf000>;
};
};
};
ws2812: spi-dev-ws2812@2 {
/* SPI */
reg = <2>;
};
};
For this test I have defined the other SPI devices, but there are currently not used.
I do know that there is a zephyr implementation of the ws2812, but I would prefer using my own implementation. I also haven't found how the zephyr implemenation circumvented this high signal on the MOSI before sending data.
Thanks in advance