dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

Driver for WS2811 LEDs. Uses one timer (generally TIM1 advanced control timer) and two DMAs. First DMA sets the bit high at the beginning of each cycle. Next DMA picks one of two phases to lower the bit at. More...

Files

file  pios_ws2811.h
 
file  pios_ws2811_cfg.h
 A driver for ws2811 rgb led controller. this is a port of the CleanFlight/BetaFlight implementation, and in turn ported from LibrePilot.
 
file  pios_ws2811.c
 A driver for ws2811 rgb led controller. this is a port of the CleanFlight/BetaFlight implementation, and in turn ported from LibrePilot.
 

Data Structures

struct  pios_ws2811_cfg
 
struct  ws2811_dev_s
 

Macros

#define WS2811_BITS_PER_LED   24
 
#define WS2811_DELAY_BUFFER_LENGTH   42
 
#define WS2811_TIMER_HZ   24000000
 
#define WS2811_TIMER_PERIOD   29
 
#define BIT_COMPARE_1   17
 
#define BIT_COMPARE_0   9
 
#define PIOS_WS2811_MAGIC   0x00281100
 

Typedefs

typedef struct ws2811_dev_sws2811_dev_t
 

Functions

int PIOS_WS2811_init (ws2811_dev_t *dev_out, const struct pios_ws2811_cfg *cfg, int max_leds)
 Allocate and initialise WS2811 device. More...
 
void PIOS_WS2811_trigger_update (ws2811_dev_t dev)
 Trigger an update of the LED strand. More...
 
void PIOS_WS2811_set (ws2811_dev_t dev, int idx, uint8_t r, uint8_t g, uint8_t b)
 Set a given LED to a color value. More...
 
void PIOS_WS2811_set_all (ws2811_dev_t dev, uint8_t r, uint8_t g, uint8_t b)
 Sets all LEDs to a color value. More...
 
void PIOS_WS2811_dma_interrupt_handler (ws2811_dev_t dev)
 Handles a DMA completion interrupt on bit_clear_dma_stream. More...
 
int PIOS_WS2811_get_num_leds (ws2811_dev_t dev)
 Find out how many LEDs are configured on an interface. More...
 

Variables

TIM_TypeDef * pios_ws2811_cfg::timer
 
uint8_t pios_ws2811_cfg::timer_chan
 
GPIO_TypeDef * pios_ws2811_cfg::led_gpio
 
uint16_t pios_ws2811_cfg::gpio_pin
 
uint32_t pios_ws2811_cfg::remap
 
uint16_t pios_ws2811_cfg::timer_dma_source
 
DMA_Channel_TypeDef * pios_ws2811_cfg::dma_chan
 
uint32_t pios_ws2811_cfg::dma_tcif
 
uint8_t pios_ws2811_cfg::dma_irqn
 
uint32_t ws2811_dev_s::magic
 
const struct pios_ws2811_cfgws2811_dev_s::config
 
bool ws2811_dev_s::dma_active
 
int ws2811_dev_s::max_leds
 
int ws2811_dev_s::buffer_size
 
uint8_t ws2811_dev_s::dma_buffer []
 

Detailed Description

Driver for WS2811 LEDs. Uses one timer (generally TIM1 advanced control timer) and two DMAs. First DMA sets the bit high at the beginning of each cycle. Next DMA picks one of two phases to lower the bit at.

Macro Definition Documentation

#define BIT_COMPARE_0   9

Definition at line 48 of file pios_ws2811.c.

#define BIT_COMPARE_1   17

Definition at line 46 of file pios_ws2811.c.

#define PIOS_WS2811_MAGIC   0x00281100

Definition at line 50 of file pios_ws2811.c.

#define WS2811_BITS_PER_LED   24

Definition at line 39 of file pios_ws2811.c.

#define WS2811_DELAY_BUFFER_LENGTH   42

Definition at line 41 of file pios_ws2811.c.

#define WS2811_TIMER_HZ   24000000

Definition at line 43 of file pios_ws2811.c.

#define WS2811_TIMER_PERIOD   29

Definition at line 44 of file pios_ws2811.c.

Typedef Documentation

typedef struct ws2811_dev_s* ws2811_dev_t

Definition at line 37 of file pios_ws2811.h.

Function Documentation

void PIOS_WS2811_dma_interrupt_handler ( ws2811_dev_t  dev)

Handles a DMA completion interrupt on bit_clear_dma_stream.

Parameters
[in]devWS2811 device handle
int PIOS_WS2811_get_num_leds ( ws2811_dev_t  dev)

Find out how many LEDs are configured on an interface.

Parameters
[in]devWS2811 device handle
Returns
number of leds configured.

Definition at line 227 of file pios_ws2811.c.

int PIOS_WS2811_init ( ws2811_dev_t dev_out,
const struct pios_ws2811_cfg cfg,
int  max_leds 
)

Allocate and initialise WS2811 device.

Parameters
[out]dev_outDevice handle, only valid when return value is success
[in]cfgConfiguration structure
[in]max_ledsNumber of LEDs to update each update cycle.
Return values
0on success, else failure

Definition at line 64 of file pios_ws2811.c.

void PIOS_WS2811_set ( ws2811_dev_t  dev,
int  idx,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Set a given LED to a color value.

Parameters
[in]devWS2811 device handle
[in]idxindex of the led to update
[in]rthe red brightness value
[in]gthe green brightness value
[in]bthe blue brightness value

Definition at line 176 of file pios_ws2811.c.

void PIOS_WS2811_set_all ( ws2811_dev_t  dev,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Sets all LEDs to a color value.

Parameters
[in]devWS2811 device handle
[in]rthe red brightness value
[in]gthe green brightness value
[in]bthe blue brightness value

Definition at line 219 of file pios_ws2811.c.

void PIOS_WS2811_trigger_update ( ws2811_dev_t  dev)

Trigger an update of the LED strand.

Parameters
[in]devWS2811 device handle

Definition at line 197 of file pios_ws2811.c.

Variable Documentation

int ws2811_dev_s::buffer_size

Definition at line 59 of file pios_ws2811.c.

const struct pios_ws2811_cfg* ws2811_dev_s::config

Definition at line 54 of file pios_ws2811.c.

bool ws2811_dev_s::dma_active

Definition at line 56 of file pios_ws2811.c.

uint8_t ws2811_dev_s::dma_buffer[]

Definition at line 61 of file pios_ws2811.c.

DMA_Channel_TypeDef* pios_ws2811_cfg::dma_chan

Definition at line 50 of file pios_ws2811_cfg.h.

uint8_t pios_ws2811_cfg::dma_irqn

Definition at line 54 of file pios_ws2811_cfg.h.

uint32_t pios_ws2811_cfg::dma_tcif

Definition at line 52 of file pios_ws2811_cfg.h.

uint16_t pios_ws2811_cfg::gpio_pin

Definition at line 44 of file pios_ws2811_cfg.h.

GPIO_TypeDef * pios_ws2811_cfg::led_gpio

Definition at line 43 of file pios_ws2811_cfg.h.

uint32_t ws2811_dev_s::magic

Definition at line 53 of file pios_ws2811.c.

int ws2811_dev_s::max_leds

Definition at line 58 of file pios_ws2811.c.

uint32_t pios_ws2811_cfg::remap

Definition at line 46 of file pios_ws2811_cfg.h.

TIM_TypeDef * pios_ws2811_cfg::timer

Definition at line 40 of file pios_ws2811_cfg.h.

uint8_t pios_ws2811_cfg::timer_chan

Definition at line 41 of file pios_ws2811_cfg.h.

uint16_t pios_ws2811_cfg::timer_dma_source

Definition at line 48 of file pios_ws2811_cfg.h.