|
apa102 1.0
apa102 driver library
|
Implementation of LED control functions using SPI interface. More...
#include "apa102.h"
Functions | |
| void | apa102_init (void) |
| Initialize the LED control interface and hardware. | |
| void | apa102_xof (APA102_Transmission type) |
| Transmit a specified value repeatedly over SPI to form a data frame. | |
| void | apa102_led (const GFX_RGBA_Color *color) |
| Send an LED data frame with specified color and intensity. | |
| void | apa102_leds (const GFX_RGBA_Color *color) |
| Send an LED data frame to all LEDs with specified color and intensity. | |
| void | apa102_led_off (void) |
| Send an LED data frame to a single LED to turn it off. | |
| void | apa102_leds_off (void) |
| Disable all LEDs by sending sleep commands (if supported) and turning off the SPI peripheral. | |
Implementation of LED control functions using SPI interface.
This source file provides functions to initialize and control addressable APA102 LEDs, including setting colors and turning LEDs on or off. It utilizes the SPI communication peripheral to send LED data frames.
| void apa102_init | ( | void | ) |
Initialize the LED control interface and hardware.
This function initializes the SPI peripheral to communicate with the LEDs using most significant bit (MSB) first, with clock polarity and phase set to rising edges. After SPI initialization, it sends a start-of-frame (SOF) signal followed by initializing all configured LEDs with the enable flag and zero color data (LEDs initially off). Finally, it sends an end-of-frame (EOF) signal to mark completion of the initialization sequence. This setup prepares the LEDs for subsequent color and blink control operations by configuring the communication and initial states.
| void apa102_led | ( | const GFX_RGBA_Color * | color | ) |
Send an LED data frame with specified color and intensity.
| color | LED_Data structure containing intensity and RGB color values. |
This function constructs and transmits a single LED data frame over SPI, combining the LED enable flag with the masked intensity value, followed by the blue, green, and red color components. The intensity value is masked with 0x3F to limit it to valid bits.
The frame format is:
| void apa102_led_off | ( | void | ) |
Send an LED data frame to a single LED to turn it off.
This function constructs and transmits a single LED data frame covered with zeroes over SPI to a single LED, combining the LED enable flag with the minimum intensity value to switch the LED off.
The frame format is:

| void apa102_leds | ( | const GFX_RGBA_Color * | color | ) |
Send an LED data frame to all LEDs with specified color and intensity.
| color | LED_Data structure containing intensity and RGB color values. |
This function constructs and transmits a single LED data frame over SPI to multiple LEDs, combining the LED enable flag with the masked intensity value, followed by the blue, green, and red color components. The intensity value is masked with 0x3F to limit it to valid bits.
The frame format is:
| void apa102_leds_off | ( | void | ) |
Disable all LEDs by sending sleep commands (if supported) and turning off the SPI peripheral.
This function sends sleep commands (if supported) to all configured LEDs to put them into a low power state and disables all leds.
This operation is used to safely turn off the LEDs and reduce power consumption when LED functionality is not needed.

| void apa102_xof | ( | APA102_Transmission | type | ) |
Transmit a specified value repeatedly over SPI to form a data frame.
| value | The byte value to be sent repeatedly. |
This function sends the given value repeatedly for LED_FRAME_SIZE times via SPI using the spi_transfer function. It is commonly used to send start or stop frames for LED data sequences to synchronize communication with the LED hardware.
