update credits
[librepilot.git] / flight / pios / stm32f30x / inc / pios_ws2811_cfg.h
blob27aa8a4b648d52cc5ff207cdb237c39939a52104
1 /**
2 ******************************************************************************
4 * @file pios_ws2811_cfg.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
6 * @brief A driver for ws2811 rgb led controller.
7 * this is a port of the CleanFlight/BetaFlight implementation.
8 * @see The GNU Public License (GPL) Version 3
10 *****************************************************************************/
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #ifndef PIOS_WS2811_CFG_H_
27 #define PIOS_WS2811_CFG_H_
30 struct pios_ws2811_cfg {
31 TIM_TypeDef *timer;
32 uint8_t timer_chan;
34 struct stm32_gpio pin;
35 uint32_t remap;
38 uint16_t timer_dma_source;
40 DMA_Channel_TypeDef *dma_chan;
42 uint32_t dma_tcif;
44 uint8_t dma_irqn;
48 #define PIOS_WS2811_CONFIG(_timer, _channel, _gpio, _pin) \
49 { \
50 .timer = _timer, \
51 .timer_chan = TIM_Channel_##_channel, \
52 .pin = { \
53 .gpio = GPIO##_gpio, \
54 .init = { \
55 .GPIO_Pin = GPIO_Pin_##_pin, \
56 .GPIO_Speed = GPIO_Speed_2MHz, \
57 .GPIO_Mode = GPIO_Mode_AF, \
58 .GPIO_OType = GPIO_OType_PP, \
59 .GPIO_PuPd = GPIO_PuPd_UP \
60 }, \
61 .pin_source = GPIO_PinSource##_pin, \
62 }, \
63 .remap = GPIO_AF_P##_gpio##_pin##_##_timer, \
64 .timer_dma_source = TIM_DMA_CC##_channel, \
65 .dma_chan = _EVAL4(DMA, _timer##_CH##_channel##_DMA_INSTANCE, _Channel, _timer##_CH##_channel##_DMA_CHANNEL), \
66 .dma_tcif = _EVAL4(DMA, _timer##_CH##_channel##_DMA_INSTANCE, _IT_TC, _timer##_CH##_channel##_DMA_CHANNEL), \
67 .dma_irqn = _EVAL5(DMA, _timer##_CH##_channel##_DMA_INSTANCE, _Channel, _timer##_CH##_channel##_DMA_CHANNEL, _IRQn), \
70 #define DMA0_Channel0 0
71 #define DMA0_IT_TC0 0
72 #define DMA0_Channel0_IRQn 0
74 void PIOS_WS2811_Init(uint32_t *dev_id, const struct pios_ws2811_cfg *ws2811_cfg);
76 void PIOS_WS2811_DMA_irq_handler();
78 #endif /* PIOS_WS2811_CFG_H_ */