Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
light_ws2812_arch.c File Reference
#include <hal.h>
#include "modules/light/light_ws2812_arch.h"
#include "mcu_periph/hal_stm32_dma.h"
#include "mcu_periph/gpio.h"
#include "mcu_periph/sys_time_arch.h"
#include "mcu_periph/ram_arch.h"
#include <BOARD_CONFIG>
Include dependency graph for light_ws2812_arch.c:

Go to the source code of this file.

Data Structures

struct  WS2812Config
 Configuration structure. More...
struct  WS2812Driver
 Driver structure. More...

Macros

#define WS2812_SERVO_HZ   800000
#define WS2812_PWM_FREQUENCY   (STM32_SYSCLK/2)
#define WS2812_DUTYCYCLE_0   (WS2812_PWM_FREQUENCY/(1000000000/350))
#define WS2812_DUTYCYCLE_1   (WS2812_PWM_FREQUENCY/(1000000000/800))
#define WS2812_RESET_BIT_N   (50)
#define WS2812_COLOR_BIT_N   (WS2812_NB_LEDS * 24)
#define WS2812_BIT_N   (WS2812_COLOR_BIT_N + WS2812_RESET_BIT_N)
#define WS2812_GPIO   WS2812D1_GPIO
#define WS2812_PIN   WS2812D1_PIN
#define WS2812_AF   WS2812D1_AF
#define WS2812_CFG_DEF   WS2812D1_CFG_DEF
#define WS2812_DMA_IRQ_PRIORITY   6
#define WS2812_BIT(led, byte, bit)
#define WS2812_RED_BIT(led, bit)
#define WS2812_GREEN_BIT(led, bit)
#define WS2812_BLUE_BIT(led, bit)

Functions

static IN_DMA_SECTION_CLEAR (uint32_t ws2812_buf[WS2812_BIT_N+1])
void light_ws2812_arch_init (void)
void light_ws2812_arch_set (uint32_t led_number, uint8_t r, uint8_t g, uint8_t b)
 set color RGB color of one led

Variables

static WS2812Config WS2812CFG = WS2812_CFG_DEF
static WS2812Driver WS2812D

Data Structure Documentation

◆ WS2812Config

struct WS2812Config

Configuration structure.

Definition at line 70 of file light_ws2812_arch.c.

Data Fields
uint8_t dma_channel
uint8_t dma_priority
uint32_t dma_stream
uint8_t pwm_channel
PWMDriver * pwmp

◆ WS2812Driver

struct WS2812Driver

Driver structure.

Definition at line 88 of file light_ws2812_arch.c.

Collaboration diagram for WS2812Driver:
Data Fields
const WS2812Config * config
DMAConfig dma_conf
DMADriver dmap
PWMConfig pwm_conf

Macro Definition Documentation

◆ WS2812_AF

#define WS2812_AF   WS2812D1_AF

Definition at line 61 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init().

◆ WS2812_BIT

#define WS2812_BIT ( led,
byte,
bit )
Value:
(24*(led) + 8*(byte) + (7 - (bit)))

Definition at line 173 of file light_ws2812_arch.c.

◆ WS2812_BIT_N

#define WS2812_BIT_N   (WS2812_COLOR_BIT_N + WS2812_RESET_BIT_N)

Definition at line 55 of file light_ws2812_arch.c.

Referenced by IN_DMA_SECTION_CLEAR(), and light_ws2812_arch_init().

◆ WS2812_BLUE_BIT

#define WS2812_BLUE_BIT ( led,
bit )
Value:
WS2812_BIT((led), 2, (bit))
#define WS2812_BIT(led, byte, bit)

Definition at line 176 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_set().

◆ WS2812_CFG_DEF

#define WS2812_CFG_DEF   WS2812D1_CFG_DEF

Definition at line 62 of file light_ws2812_arch.c.

◆ WS2812_COLOR_BIT_N

#define WS2812_COLOR_BIT_N   (WS2812_NB_LEDS * 24)

Definition at line 54 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init().

◆ WS2812_DMA_IRQ_PRIORITY

#define WS2812_DMA_IRQ_PRIORITY   6

Definition at line 65 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init().

◆ WS2812_DUTYCYCLE_0

#define WS2812_DUTYCYCLE_0   (WS2812_PWM_FREQUENCY/(1000000000/350))

Definition at line 50 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init(), and light_ws2812_arch_set().

◆ WS2812_DUTYCYCLE_1

#define WS2812_DUTYCYCLE_1   (WS2812_PWM_FREQUENCY/(1000000000/800))

Definition at line 51 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_set().

◆ WS2812_GPIO

#define WS2812_GPIO   WS2812D1_GPIO

Definition at line 59 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init().

◆ WS2812_GREEN_BIT

#define WS2812_GREEN_BIT ( led,
bit )
Value:
WS2812_BIT((led), 0, (bit))

Definition at line 175 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_set().

◆ WS2812_PIN

#define WS2812_PIN   WS2812D1_PIN

Definition at line 60 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init().

◆ WS2812_PWM_FREQUENCY

#define WS2812_PWM_FREQUENCY   (STM32_SYSCLK/2)

Definition at line 48 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init().

◆ WS2812_RED_BIT

#define WS2812_RED_BIT ( led,
bit )
Value:
WS2812_BIT((led), 1, (bit))

Definition at line 174 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_set().

◆ WS2812_RESET_BIT_N

#define WS2812_RESET_BIT_N   (50)

Definition at line 53 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init().

◆ WS2812_SERVO_HZ

#define WS2812_SERVO_HZ   800000

Definition at line 47 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init().

Function Documentation

◆ IN_DMA_SECTION_CLEAR()

IN_DMA_SECTION_CLEAR ( uint32_t ws2812_buf[WS2812_BIT_N+1])
static

References WS2812_BIT_N.

◆ light_ws2812_arch_init()

void light_ws2812_arch_init ( void )

◆ light_ws2812_arch_set()

void light_ws2812_arch_set ( uint32_t led_number,
uint8_t r,
uint8_t g,
uint8_t b )

set color RGB color of one led

Definition at line 178 of file light_ws2812_arch.c.

References b, g, WS2812_BLUE_BIT, WS2812_DUTYCYCLE_0, WS2812_DUTYCYCLE_1, WS2812_GREEN_BIT, WS2812_NB_LEDS, and WS2812_RED_BIT.

Referenced by light_scheduler_periodic(), light_scheduler_set(), and light_scheduler_sparkle().

Here is the caller graph for this function:

Variable Documentation

◆ WS2812CFG

WS2812Config WS2812CFG = WS2812_CFG_DEF
static

Definition at line 83 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init().

◆ WS2812D

WS2812Driver WS2812D
static

Definition at line 96 of file light_ws2812_arch.c.

Referenced by light_ws2812_arch_init().