View source for C source code
You do not have permission to edit this page, for the following reason:
You can view and copy the source of this page.
Return to C source code.
You do not have permission to edit this page, for the following reason:
The action you have requested is limited to users in one of the groups: Administrators, Bureaucrats.
You can view and copy the source of this page.
Return to C source code.
The C source code is written in an implementation file and in a header file.
The files must be placed in a folder as follows:
The timing required for the WS2812B LEDs is generated by the SPI interface in master mode and using the MOSI pin only.
The C code exports three functions, which are briefly described below.
This function is used to initialize the target hardware. It should be called once during system setup.
The parameter channel is used to select the SPI bus and the corresponding MOSI pin:
channel = 0: SPI1 / MOSI pin PA7 (D11)
channel = 1: SPI2 / MOSI pin PB15 (D34)
This function takes a parameter for each layer. Each parameter sets the values for R, G and B between 0 and 255.
The parameters are of type uint32_t and RGB colors are are coded as follows:
0x00GGRRBB
This particular byte order was chosen, because the WS2812B LEDs require a specific bit order (MSB of green first, LSB of blue last)
This function should be called whenever an update of any of the LEDs is required.
Some important notes
This is a convenience function that sets all LEDs off.
Next - Part 2: Matlab/Simulink files