From e25cc40503b9177c92180eeb981f402e8bd82b86 Mon Sep 17 00:00:00 2001 From: Vladimir Zidar Date: Mon, 22 May 2017 16:31:13 +0200 Subject: [PATCH] LP-512 ws2811 led support for F3. --- flight/modules/Notify/notify.c | 9 +- flight/pios/inc/pios_helpers.h | 21 +- flight/pios/stm32f30x/inc/pios_ws2811_cfg.h | 78 +++++++ flight/pios/stm32f30x/pios_spi.c | 55 +++-- flight/pios/stm32f30x/pios_ws2811.c | 208 ++++++++++++++++++ .../{ => stm32f4xx}/inc/pios_ws2811_cfg.h | 2 +- flight/pios/stm32f4xx/pios_ws2811.c | 7 +- flight/targets/boards/ccf3d/pios_board.h | 5 + .../discoveryf4bare/firmware/pios_board.c | 8 +- .../boards/discoveryf4bare/pios_board.h | 5 + .../targets/boards/nucleof303re/pios_board.h | 6 + .../boards/revolution/firmware/pios_board.c | 6 +- flight/targets/boards/revolution/pios_board.h | 5 + .../boards/revonano/firmware/pios_board.c | 7 +- flight/targets/boards/revonano/pios_board.h | 5 + flight/targets/boards/revoproto/pios_board.h | 5 + .../boards/sparky2/firmware/pios_board.c | 6 +- flight/targets/boards/sparky2/pios_board.h | 5 + .../targets/boards/spracingf3/board_hw_defs.c | 13 ++ .../boards/spracingf3/firmware/Makefile | 2 +- .../spracingf3/firmware/inc/pios_config.h | 6 +- .../boards/spracingf3/firmware/pios_board.c | 7 + flight/targets/boards/spracingf3/pios_board.h | 5 + .../boards/spracingf3evo/board_hw_defs.c | 67 ++---- .../boards/spracingf3evo/firmware/Makefile | 2 +- .../spracingf3evo/firmware/inc/pios_config.h | 4 +- .../spracingf3evo/firmware/pios_board.c | 8 + .../targets/boards/spracingf3evo/pios_board.h | 5 + 28 files changed, 466 insertions(+), 96 deletions(-) create mode 100644 flight/pios/stm32f30x/inc/pios_ws2811_cfg.h create mode 100644 flight/pios/stm32f30x/pios_ws2811.c rename flight/pios/{ => stm32f4xx}/inc/pios_ws2811_cfg.h (97%) diff --git a/flight/modules/Notify/notify.c b/flight/modules/Notify/notify.c index ed3f7ded2..56bde610d 100644 --- a/flight/modules/Notify/notify.c +++ b/flight/modules/Notify/notify.c @@ -37,7 +37,6 @@ #include "inc/notify.h" #include "inc/sequences.h" #include -#include #define SAMPLE_PERIOD_MS 250 // private types @@ -54,13 +53,7 @@ static void checkAlarm(uint8_t alarm, uint8_t *last_alarm, uint32_t *last_alm_ti static AlarmStatus_t *alarmStatus; int32_t NotifyInitialize(void) { - uint8_t ws281xOutStatus; - - HwSettingsWS2811LED_OutGet(&ws281xOutStatus); - // Todo: Until further applications exists for WS2811 notify enabled status is tied to ws281x output configuration - bool enabled = ws281xOutStatus != HWSETTINGS_WS2811LED_OUT_DISABLED; - - if (enabled) { + if (PIOS_WS2811_DEVICE) { alarmStatus = (AlarmStatus_t *)pios_malloc(sizeof(AlarmStatus_t) * alarmsMapSize); for (uint8_t i = 0; i < alarmsMapSize; i++) { alarmStatus[i].lastAlarm = SYSTEMALARMS_ALARM_OK; diff --git a/flight/pios/inc/pios_helpers.h b/flight/pios/inc/pios_helpers.h index ba902ada4..3f626f29f 100644 --- a/flight/pios/inc/pios_helpers.h +++ b/flight/pios/inc/pios_helpers.h @@ -34,14 +34,31 @@ * @return number of elements in x. * */ -#define NELEMENTS(x) (sizeof(x) / sizeof((x)[0])) +#define NELEMENTS(x) (sizeof(x) / sizeof((x)[0])) +/** + * @brief preprocessor magic + * + */ + +#define _CONCAT5(a, b, c, d, e) a##b##c##d##e +#define _EVAL5(a, b, c, d, e) _CONCAT5(a, b, c, d, e) + +#define _CONCAT4(a, b, c, d) a##b##c##d +#define _EVAL4(a, b, c, d) _CONCAT4(a, b, c, d) + +#define _CONCAT3(a, b, c) a##b##c +#define _EVAL3(a, b, c) _CONCAT3(a, b, c) + +#define _CONCAT2(a, b) a##b +#define _EVAL2(a, b) _CONCAT4(a, b) + /** * @brief Compiler barrier: Disables compiler load/store reordering across the barrier * */ -#define COMPILER_BARRIER() asm volatile ("" ::: "memory") +#define COMPILER_BARRIER() asm volatile ("" ::: "memory") // Memory barriers: // Note that on single core Cortex M3 & M4, the is generally no need to use a processor memory barrier instruction such as DMB. diff --git a/flight/pios/stm32f30x/inc/pios_ws2811_cfg.h b/flight/pios/stm32f30x/inc/pios_ws2811_cfg.h new file mode 100644 index 000000000..27aa8a4b6 --- /dev/null +++ b/flight/pios/stm32f30x/inc/pios_ws2811_cfg.h @@ -0,0 +1,78 @@ +/** + ****************************************************************************** + * + * @file pios_ws2811_cfg.h + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017. + * @brief A driver for ws2811 rgb led controller. + * this is a port of the CleanFlight/BetaFlight implementation. + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef PIOS_WS2811_CFG_H_ +#define PIOS_WS2811_CFG_H_ + + +struct pios_ws2811_cfg { + TIM_TypeDef *timer; + uint8_t timer_chan; + + struct stm32_gpio pin; + uint32_t remap; + + + uint16_t timer_dma_source; + + DMA_Channel_TypeDef *dma_chan; + + uint32_t dma_tcif; + + uint8_t dma_irqn; +}; + + +#define PIOS_WS2811_CONFIG(_timer, _channel, _gpio, _pin) \ + { \ + .timer = _timer, \ + .timer_chan = TIM_Channel_##_channel, \ + .pin = { \ + .gpio = GPIO##_gpio, \ + .init = { \ + .GPIO_Pin = GPIO_Pin_##_pin, \ + .GPIO_Speed = GPIO_Speed_2MHz, \ + .GPIO_Mode = GPIO_Mode_AF, \ + .GPIO_OType = GPIO_OType_PP, \ + .GPIO_PuPd = GPIO_PuPd_UP \ + }, \ + .pin_source = GPIO_PinSource##_pin, \ + }, \ + .remap = GPIO_AF_P##_gpio##_pin##_##_timer, \ + .timer_dma_source = TIM_DMA_CC##_channel, \ + .dma_chan = _EVAL4(DMA, _timer##_CH##_channel##_DMA_INSTANCE, _Channel, _timer##_CH##_channel##_DMA_CHANNEL), \ + .dma_tcif = _EVAL4(DMA, _timer##_CH##_channel##_DMA_INSTANCE, _IT_TC, _timer##_CH##_channel##_DMA_CHANNEL), \ + .dma_irqn = _EVAL5(DMA, _timer##_CH##_channel##_DMA_INSTANCE, _Channel, _timer##_CH##_channel##_DMA_CHANNEL, _IRQn), \ + } + +#define DMA0_Channel0 0 +#define DMA0_IT_TC0 0 +#define DMA0_Channel0_IRQn 0 + +void PIOS_WS2811_Init(uint32_t *dev_id, const struct pios_ws2811_cfg *ws2811_cfg); + +void PIOS_WS2811_DMA_irq_handler(); + +#endif /* PIOS_WS2811_CFG_H_ */ diff --git a/flight/pios/stm32f30x/pios_spi.c b/flight/pios/stm32f30x/pios_spi.c index 87f119e97..b10583665 100644 --- a/flight/pios/stm32f30x/pios_spi.c +++ b/flight/pios/stm32f30x/pios_spi.c @@ -39,6 +39,8 @@ #include +#define SPI_MAX_BLOCK_PIO 12800 + static bool PIOS_SPI_validate(__attribute__((unused)) struct pios_spi_dev *com_dev) { /* Should check device magic here */ @@ -168,16 +170,20 @@ int32_t PIOS_SPI_Init(uint32_t *spi_id, const struct pios_spi_cfg *cfg) break; } + bool use_dma = spi_dev->cfg->dma.rx.channel && spi_dev->cfg->dma.tx.channel; + /* Enable DMA clock */ - RCC_AHBPeriphClockCmd(spi_dev->cfg->dma.ahb_clk, ENABLE); + if (use_dma) { + RCC_AHBPeriphClockCmd(spi_dev->cfg->dma.ahb_clk, ENABLE); - /* Configure DMA for SPI Rx */ - DMA_Cmd(spi_dev->cfg->dma.rx.channel, DISABLE); - DMA_Init(spi_dev->cfg->dma.rx.channel, (DMA_InitTypeDef *)&(spi_dev->cfg->dma.rx.init)); + /* Configure DMA for SPI Rx */ + DMA_Cmd(spi_dev->cfg->dma.rx.channel, DISABLE); + DMA_Init(spi_dev->cfg->dma.rx.channel, (DMA_InitTypeDef *)&(spi_dev->cfg->dma.rx.init)); - /* Configure DMA for SPI Tx */ - DMA_Cmd(spi_dev->cfg->dma.tx.channel, DISABLE); - DMA_Init(spi_dev->cfg->dma.tx.channel, (DMA_InitTypeDef *)&(spi_dev->cfg->dma.tx.init)); + /* Configure DMA for SPI Tx */ + DMA_Cmd(spi_dev->cfg->dma.tx.channel, DISABLE); + DMA_Init(spi_dev->cfg->dma.tx.channel, (DMA_InitTypeDef *)&(spi_dev->cfg->dma.tx.init)); + } /* Initialize the SPI block */ SPI_I2S_DeInit(spi_dev->cfg->regs); @@ -197,7 +203,9 @@ int32_t PIOS_SPI_Init(uint32_t *spi_id, const struct pios_spi_cfg *cfg) SPI_Cmd(spi_dev->cfg->regs, ENABLE); /* Enable SPI interrupts to DMA */ - SPI_I2S_DMACmd(spi_dev->cfg->regs, SPI_I2S_DMAReq_Tx | SPI_I2S_DMAReq_Rx, ENABLE); + if (use_dma) { + SPI_I2S_DMACmd(spi_dev->cfg->regs, SPI_I2S_DMAReq_Tx | SPI_I2S_DMAReq_Rx, ENABLE); + } /* Configure DMA interrupt */ NVIC_Init((NVIC_InitTypeDef *)&(spi_dev->cfg->dma.irq.init)); @@ -455,6 +463,7 @@ int32_t PIOS_SPI_TransferByte(uint32_t spi_id, uint8_t b) return rx_byte; } + /** * Transfers a block of bytes via PIO. * @@ -467,15 +476,10 @@ int32_t PIOS_SPI_TransferByte(uint32_t spi_id, uint8_t b) * \return >= 0 if no error during transfer * \return -1 if disabled SPI port selected */ -int32_t PIOS_SPI_TransferBlock(uint32_t spi_id, const uint8_t *send_buffer, uint8_t *receive_buffer, uint16_t len, __attribute__((unused)) void *callback) +static int32_t PIOS_SPI_TransferBlock_PIO(struct pios_spi_dev *spi_dev, const uint8_t *send_buffer, uint8_t *receive_buffer, uint16_t len, __attribute__((unused)) void *callback) { - struct pios_spi_dev *spi_dev = (struct pios_spi_dev *)spi_id; uint8_t b; - bool valid = PIOS_SPI_validate(spi_dev); - - PIOS_Assert(valid) - while (len--) { /* get the byte to send */ b = send_buffer ? *(send_buffer++) : 0xff; @@ -527,14 +531,8 @@ int32_t PIOS_SPI_TransferBlock(uint32_t spi_id, const uint8_t *send_buffer, uint * \return -1 if disabled SPI port selected * \return -3 if function has been called during an ongoing DMA transfer */ -int32_t _PIOS_SPI_TransferBlock(uint32_t spi_id, const uint8_t *send_buffer, uint8_t *receive_buffer, uint16_t len, void *callback) +static int32_t PIOS_SPI_TransferBlock_DMA(struct pios_spi_dev *spi_dev, const uint8_t *send_buffer, uint8_t *receive_buffer, uint16_t len, void *callback) { - struct pios_spi_dev *spi_dev = (struct pios_spi_dev *)spi_id; - - bool valid = PIOS_SPI_validate(spi_dev); - - PIOS_Assert(valid) - DMA_InitTypeDef dma_init; /* Exit if ongoing transfer */ @@ -659,6 +657,21 @@ int32_t _PIOS_SPI_TransferBlock(uint32_t spi_id, const uint8_t *send_buffer, uin return 0; } +int32_t PIOS_SPI_TransferBlock(uint32_t spi_id, const uint8_t *send_buffer, uint8_t *receive_buffer, uint16_t len, void *callback) +{ + struct pios_spi_dev *spi_dev = (struct pios_spi_dev *)spi_id; + + bool valid = PIOS_SPI_validate(spi_dev); + + PIOS_Assert(valid) + + if ((len > SPI_MAX_BLOCK_PIO) && spi_dev->cfg->dma.rx.channel && spi_dev->cfg->dma.tx.channel) { + return PIOS_SPI_TransferBlock_DMA(spi_dev, send_buffer, receive_buffer, len, callback); + } + + return PIOS_SPI_TransferBlock_PIO(spi_dev, send_buffer, receive_buffer, len, callback); +} + /** * Check if a transfer is in progress * \param[in] spi SPI number (0 or 1) diff --git a/flight/pios/stm32f30x/pios_ws2811.c b/flight/pios/stm32f30x/pios_ws2811.c new file mode 100644 index 000000000..83230d0cb --- /dev/null +++ b/flight/pios/stm32f30x/pios_ws2811.c @@ -0,0 +1,208 @@ +/** + ****************************************************************************** + * + * @file pios_ws2811.c + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017. + * @brief A driver for ws2811 rgb led controller. + * this is a port of the CleanFlight/BetaFlight implementation. + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "pios.h" +#include "pios_ws2811.h" +#include "pios_ws2811_cfg.h" + +#define WS2811_BITS_PER_LED 24 +// for 50us delay +#define WS2811_DELAY_BUFFER_LENGTH 42 + +#define WS2811_DATA_BUFFER_SIZE (WS2811_BITS_PER_LED * PIOS_WS2811_NUMLEDS) +// number of bytes needed is #LEDs * 24 bytes + 42 trailing bytes) +#define WS2811_DMA_BUFFER_SIZE (WS2811_DATA_BUFFER_SIZE + WS2811_DELAY_BUFFER_LENGTH) + +#define WS2811_TIMER_HZ 24000000 +#define WS2811_TIMER_PERIOD 29 +// timer compare value for logical 1 +#define BIT_COMPARE_1 17 +// timer compare value for logical 0 +#define BIT_COMPARE_0 9 + +#define PIOS_WS2811_MAGIC 0x00281100 + +struct pios_ws2811_dev { + uint32_t magic; + const struct pios_ws2811_cfg *config; + uint8_t dma_buffer[WS2811_DMA_BUFFER_SIZE]; + bool dma_active; +}; + +struct pios_ws2811_dev *ws2811_dev; + +void PIOS_WS2811_Init(uint32_t *dev_id, const struct pios_ws2811_cfg *ws2811_cfg) +{ + if (ws2811_dev) { + return; + } + + ws2811_dev = (struct pios_ws2811_dev *)pios_malloc(sizeof(*ws2811_dev)); + + PIOS_Assert(ws2811_dev); + + memset(ws2811_dev, 0, sizeof(*ws2811_dev)); + + ws2811_dev->magic = PIOS_WS2811_MAGIC; + ws2811_dev->config = ws2811_cfg; + + + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + TIM_OCInitTypeDef TIM_OCInitStructure; + DMA_InitTypeDef DMA_InitStructure; + + GPIO_Init(ws2811_cfg->pin.gpio, (GPIO_InitTypeDef *)&ws2811_cfg->pin.init); + + GPIO_PinAFConfig(ws2811_cfg->pin.gpio, ws2811_cfg->pin.pin_source, ws2811_cfg->remap); + + /* Compute the prescaler value */ + uint16_t prescalerValue = (uint16_t)(SystemCoreClock / WS2811_TIMER_HZ) - 1; + /* Time base configuration */ + TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); + TIM_TimeBaseStructure.TIM_Period = WS2811_TIMER_PERIOD; // 800kHz + TIM_TimeBaseStructure.TIM_Prescaler = prescalerValue; + TIM_TimeBaseStructure.TIM_ClockDivision = 0; + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; + TIM_TimeBaseInit(ws2811_cfg->timer, &TIM_TimeBaseStructure); + + /* PWM1 Mode configuration: Channel1 */ + TIM_OCStructInit(&TIM_OCInitStructure); + TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; + TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; + TIM_OCInitStructure.TIM_Pulse = 0; + TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; + + switch (ws2811_cfg->timer_chan) { + case TIM_Channel_1: + TIM_OC1Init(ws2811_cfg->timer, &TIM_OCInitStructure); + TIM_OC1PreloadConfig(ws2811_cfg->timer, TIM_OCPreload_Enable); + break; + case TIM_Channel_2: + TIM_OC2Init(ws2811_cfg->timer, &TIM_OCInitStructure); + TIM_OC2PreloadConfig(ws2811_cfg->timer, TIM_OCPreload_Enable); + break; + case TIM_Channel_3: + TIM_OC3Init(ws2811_cfg->timer, &TIM_OCInitStructure); + TIM_OC3PreloadConfig(ws2811_cfg->timer, TIM_OCPreload_Enable); + break; + case TIM_Channel_4: + TIM_OC4Init(ws2811_cfg->timer, &TIM_OCInitStructure); + TIM_OC4PreloadConfig(ws2811_cfg->timer, TIM_OCPreload_Enable); + break; + } + + + TIM_CtrlPWMOutputs(ws2811_cfg->timer, ENABLE); + + /* configure DMA */ + // NVIC setup here + NVIC_InitTypeDef NVIC_InitStructure; + + NVIC_InitStructure.NVIC_IRQChannel = ws2811_cfg->dma_irqn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + + DMA_DeInit(ws2811_cfg->dma_chan); + + DMA_StructInit(&DMA_InitStructure); + DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ws2811_cfg->timer->CCR1 + ws2811_cfg->timer_chan; + DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)ws2811_dev->dma_buffer; + DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; + DMA_InitStructure.DMA_BufferSize = WS2811_DMA_BUFFER_SIZE; + DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; + DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; + DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; + DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; + DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; + DMA_InitStructure.DMA_Priority = DMA_Priority_High; + DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; + + DMA_Init(ws2811_cfg->dma_chan, &DMA_InitStructure); + + TIM_DMACmd(ws2811_cfg->timer, ws2811_cfg->timer_dma_source, ENABLE); + + DMA_ITConfig(ws2811_cfg->dma_chan, DMA_IT_TC, ENABLE); + + *dev_id = (uint32_t) ws2811_dev; +} + +void PIOS_WS2811_DMA_irq_handler() +{ + if (!ws2811_dev) { + return; + } + + if (DMA_GetITStatus(ws2811_dev->config->dma_tcif)) { + ws2811_dev->dma_active = false; + DMA_Cmd(ws2811_dev->config->dma_chan, DISABLE); + + DMA_ClearITPendingBit(ws2811_dev->config->dma_tcif); + } +} + + +/** + * Set a led color + * @param c color + * @param led led number + * @param update Perform an update after changing led color + */ +void PIOS_WS2811_setColorRGB(Color_t c, uint8_t led, bool update) +{ + if (!ws2811_dev || (led >= PIOS_WS2811_NUMLEDS)) { + return; + } + + int offset = led * WS2811_BITS_PER_LED; + + uint32_t grb = (c.G << 16) | (c.R << 8) | (c.B); + + for (int bit = (WS2811_BITS_PER_LED - 1); bit >= 0; --bit) { + ws2811_dev->dma_buffer[offset++] = (grb & (1 << bit)) ? BIT_COMPARE_1 : BIT_COMPARE_0; + } + + if (update) { + PIOS_WS2811_Update(); + } +} + +void PIOS_WS2811_Update() +{ + if (!ws2811_dev || ws2811_dev->dma_active) { + return; + } + + ws2811_dev->dma_active = true; + + DMA_SetCurrDataCounter(ws2811_dev->config->dma_chan, WS2811_DMA_BUFFER_SIZE); // load number of bytes to be transferred + TIM_SetCounter(ws2811_dev->config->timer, 0); + TIM_Cmd(ws2811_dev->config->timer, ENABLE); + + DMA_Cmd(ws2811_dev->config->dma_chan, ENABLE); +} diff --git a/flight/pios/inc/pios_ws2811_cfg.h b/flight/pios/stm32f4xx/inc/pios_ws2811_cfg.h similarity index 97% rename from flight/pios/inc/pios_ws2811_cfg.h rename to flight/pios/stm32f4xx/inc/pios_ws2811_cfg.h index a4a6b5739..af3876519 100644 --- a/flight/pios/inc/pios_ws2811_cfg.h +++ b/flight/pios/stm32f4xx/inc/pios_ws2811_cfg.h @@ -130,7 +130,7 @@ struct pios_ws2811_cfg { struct stm32_irq irq; }; -void PIOS_WS2811_Init(const struct pios_ws2811_cfg *ws2811_cfg, const struct pios_ws2811_pin_cfg *ws2811_pin_cfg); +void PIOS_WS2811_Init(uint32_t *dev_id, const struct pios_ws2811_cfg *ws2811_cfg, const struct pios_ws2811_pin_cfg *ws2811_pin_cfg); void PIOS_WS2811_DMA_irq_handler(); #endif /* PIOS_WS2811_H_ */ diff --git a/flight/pios/stm32f4xx/pios_ws2811.c b/flight/pios/stm32f4xx/pios_ws2811.c index f0a9ddf29..d28f704da 100644 --- a/flight/pios/stm32f4xx/pios_ws2811.c +++ b/flight/pios/stm32f4xx/pios_ws2811.c @@ -163,7 +163,9 @@ static void genericTIM_OCxPreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreloa * */ -void PIOS_WS2811_Init(const struct pios_ws2811_cfg *ws2811_cfg, const struct pios_ws2811_pin_cfg *ws2811_pin_cfg) +#define PIOS_WS2811_MAGIC 0x00281100 + +void PIOS_WS2811_Init(uint32_t *dev_id, const struct pios_ws2811_cfg *ws2811_cfg, const struct pios_ws2811_pin_cfg *ws2811_pin_cfg) { assert_param(ws2811_cfg); assert_param(ws2811_pin_cfg); @@ -184,6 +186,9 @@ void PIOS_WS2811_Init(const struct pios_ws2811_cfg *ws2811_cfg, const struct pio // Setup timers setupTimer(); setupDMA(); + + // + *dev_id = PIOS_WS2811_MAGIC; } void setupTimer() diff --git a/flight/targets/boards/ccf3d/pios_board.h b/flight/targets/boards/ccf3d/pios_board.h index 75b29db17..0c34b4c34 100644 --- a/flight/targets/boards/ccf3d/pios_board.h +++ b/flight/targets/boards/ccf3d/pios_board.h @@ -163,6 +163,11 @@ extern uint32_t pios_com_msp_id; extern uint32_t pios_com_mavlink_id; #define PIOS_COM_MAVLINK (pios_com_mavlink_id) +#ifdef PIOS_INCLUDE_WS2811 +extern uint32_t pios_ws2811_id; +#define PIOS_WS2811_DEVICE (pios_ws2811_id) +#endif + // ------------------------- // ADC // PIOS_ADC_PinGet(0) = Gyro Z diff --git a/flight/targets/boards/discoveryf4bare/firmware/pios_board.c b/flight/targets/boards/discoveryf4bare/firmware/pios_board.c index 4791d9bad..b40deb990 100644 --- a/flight/targets/boards/discoveryf4bare/firmware/pios_board.c +++ b/flight/targets/boards/discoveryf4bare/firmware/pios_board.c @@ -51,10 +51,13 @@ */ #include "../board_hw_defs.c" - uintptr_t pios_uavo_settings_fs_id; uintptr_t pios_user_fs_id; +#ifdef PIOS_INCLUDE_WS2811 +uint32_t pios_ws2811_id; +#endif + static const PIOS_BOARD_IO_UART_Function flexiio_function_map[] = { [HWSETTINGS_RM_RCVRPORT_PPMTELEMETRY] = PIOS_BOARD_IO_UART_TELEMETRY, [HWSETTINGS_RM_RCVRPORT_PPMDEBUGCONSOLE] = PIOS_BOARD_IO_UART_DEBUGCONSOLE, @@ -239,7 +242,6 @@ void PIOS_Board_Init(void) PIOS_BOARD_IO_Configure_USB(); #endif - /* Configure main USART port */ uint8_t hwsettings_mainport; HwSettingsRM_MainPortGet(&hwsettings_mainport); @@ -323,7 +325,7 @@ void PIOS_Board_Init(void) PIOS_BOARD_Sensors_Configure(); #ifdef PIOS_INCLUDE_WS2811 - PIOS_WS2811_Init(&pios_ws2811_cfg, &pios_ws2811_pin_cfg); + PIOS_WS2811_Init(&pios_ws2811_id, &pios_ws2811_cfg, &pios_ws2811_pin_cfg); #endif // PIOS_INCLUDE_WS2811 #ifdef PIOS_INCLUDE_ADC diff --git a/flight/targets/boards/discoveryf4bare/pios_board.h b/flight/targets/boards/discoveryf4bare/pios_board.h index 926887822..70c902dbd 100644 --- a/flight/targets/boards/discoveryf4bare/pios_board.h +++ b/flight/targets/boards/discoveryf4bare/pios_board.h @@ -134,6 +134,11 @@ extern uint32_t pios_i2c_flexiport_adapter_id; // ------------------------- #define PIOS_COM_MAX_DEVS 4 +#ifdef PIOS_INCLUDE_WS2811 +extern uint32_t pios_ws2811_id; +#define PIOS_WS2811_DEVICE (pios_ws2811_id) +#endif + // ------------------------- // Packet Handler // ------------------------- diff --git a/flight/targets/boards/nucleof303re/pios_board.h b/flight/targets/boards/nucleof303re/pios_board.h index 00d8338ce..670893707 100644 --- a/flight/targets/boards/nucleof303re/pios_board.h +++ b/flight/targets/boards/nucleof303re/pios_board.h @@ -163,6 +163,12 @@ extern uint32_t pios_com_msp_id; extern uint32_t pios_com_mavlink_id; #define PIOS_COM_MAVLINK (pios_com_mavlink_id) + +#ifdef PIOS_INCLUDE_WS2811 +extern uint32_t pios_ws2811_id; +#define PIOS_WS2811_DEVICE (pios_ws2811_id) +#endif + // ------------------------- // ADC // PIOS_ADC_PinGet(0) = Current sensor diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index 92db65637..273d4a052 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -54,6 +54,10 @@ uintptr_t pios_uavo_settings_fs_id; uintptr_t pios_user_fs_id; +#ifdef PIOS_INCLUDE_WS2811 +uint32_t pios_ws2811_id; +#endif + static const PIOS_BOARD_IO_UART_Function flexiio_function_map[] = { [HWSETTINGS_RM_RCVRPORT_PPMTELEMETRY] = PIOS_BOARD_IO_UART_TELEMETRY, [HWSETTINGS_RM_RCVRPORT_PPMDEBUGCONSOLE] = PIOS_BOARD_IO_UART_DEBUGCONSOLE, @@ -325,7 +329,7 @@ void PIOS_Board_Init(void) HwSettingsWS2811LED_OutGet(&ws2811_pin_settings); if (ws2811_pin_settings != HWSETTINGS_WS2811LED_OUT_DISABLED && ws2811_pin_settings < NELEMENTS(pios_ws2811_pin_cfg)) { - PIOS_WS2811_Init(&pios_ws2811_cfg, &pios_ws2811_pin_cfg[ws2811_pin_settings]); + PIOS_WS2811_Init(&pios_ws2811_id, &pios_ws2811_cfg, &pios_ws2811_pin_cfg[ws2811_pin_settings]); } #endif // PIOS_INCLUDE_WS2811 diff --git a/flight/targets/boards/revolution/pios_board.h b/flight/targets/boards/revolution/pios_board.h index c58bf75e0..2e3da0bef 100644 --- a/flight/targets/boards/revolution/pios_board.h +++ b/flight/targets/boards/revolution/pios_board.h @@ -154,6 +154,11 @@ extern uint32_t pios_i2c_flexiport_adapter_id; // ------------------------- #define PIOS_COM_MAX_DEVS 4 +#ifdef PIOS_INCLUDE_WS2811 +extern uint32_t pios_ws2811_id; +#define PIOS_WS2811_DEVICE (pios_ws2811_id) +#endif + // ------------------------- // Packet Handler // ------------------------- diff --git a/flight/targets/boards/revonano/firmware/pios_board.c b/flight/targets/boards/revonano/firmware/pios_board.c index 5bbf3f237..050652a1a 100644 --- a/flight/targets/boards/revonano/firmware/pios_board.c +++ b/flight/targets/boards/revonano/firmware/pios_board.c @@ -56,6 +56,10 @@ uintptr_t pios_uavo_settings_fs_id; uintptr_t pios_user_fs_id; +#ifdef PIOS_INCLUDE_WS2811 +uint32_t pios_ws2811_id; +#endif + static SystemAlarmsExtendedAlarmStatusOptions RevoNanoConfigHook(); static void ActuatorSettingsUpdatedCb(UAVObjEvent *ev); @@ -203,7 +207,6 @@ void PIOS_Board_Init(void) PIOS_BOARD_IO_Configure_UART(&pios_usart_flexi_cfg, flexi_function_map[hwsettings_flexiport]); } - /* Configure main USART port */ uint8_t hwsettings_mainport; HwSettingsRM_MainPortGet(&hwsettings_mainport); @@ -263,7 +266,7 @@ void PIOS_Board_Init(void) // No other choices but servo pin 1 on nano if (ws2811_pin_settings != HWSETTINGS_WS2811LED_OUT_DISABLED) { pios_tim_servoport_all_pins[0] = dummmy_timer; // free timer 1 - PIOS_WS2811_Init(&pios_ws2811_cfg, &pios_ws2811_pin_cfg[0]); + PIOS_WS2811_Init(&pios_ws2811_id, &pios_ws2811_cfg, &pios_ws2811_pin_cfg[0]); } #endif // PIOS_INCLUDE_WS2811 diff --git a/flight/targets/boards/revonano/pios_board.h b/flight/targets/boards/revonano/pios_board.h index 47940f961..69d10689b 100644 --- a/flight/targets/boards/revonano/pios_board.h +++ b/flight/targets/boards/revonano/pios_board.h @@ -130,6 +130,11 @@ extern uint32_t pios_i2c_flexiport_adapter_id; #define PIOS_I2C_MS4525DO_ADAPTER (PIOS_I2C_FLEXI_ADAPTER) #define PIOS_I2C_EXTERNAL_ADAPTER (PIOS_I2C_FLEXI_ADAPTER) +#ifdef PIOS_INCLUDE_WS2811 +extern uint32_t pios_ws2811_id; +#define PIOS_WS2811_DEVICE (pios_ws2811_id) +#endif + // ------------------------- // PIOS_USART // diff --git a/flight/targets/boards/revoproto/pios_board.h b/flight/targets/boards/revoproto/pios_board.h index 3e778e780..bc5873972 100644 --- a/flight/targets/boards/revoproto/pios_board.h +++ b/flight/targets/boards/revoproto/pios_board.h @@ -137,6 +137,11 @@ extern uint32_t pios_i2c_flexiport_adapter_id; // ------------------------- #define PIOS_COM_MAX_DEVS 4 +#ifdef PIOS_INCLUDE_WS2811 +extern uint32_t pios_ws2811_id; +#define PIOS_WS2811_DEVICE (pios_ws2811_id) +#endif + // ------------------------ // TELEMETRY // ------------------------ diff --git a/flight/targets/boards/sparky2/firmware/pios_board.c b/flight/targets/boards/sparky2/firmware/pios_board.c index 80d0e0d7b..3843d0f25 100644 --- a/flight/targets/boards/sparky2/firmware/pios_board.c +++ b/flight/targets/boards/sparky2/firmware/pios_board.c @@ -56,6 +56,10 @@ uintptr_t pios_uavo_settings_fs_id; uintptr_t pios_user_fs_id; +#ifdef PIOS_INCLUDE_WS2811 +uint32_t pios_ws2811_id; +#endif + static const PIOS_BOARD_IO_UART_Function rcvr_function_map[] = { [HWSETTINGS_SPK2_RCVRPORT_SBUS] = PIOS_BOARD_IO_UART_SBUS, [HWSETTINGS_SPK2_RCVRPORT_DSM] = PIOS_BOARD_IO_UART_DSM_RCVR, @@ -283,7 +287,7 @@ void PIOS_Board_Init(void) HwSettingsWS2811LED_OutGet(&ws2811_pin_settings); if (ws2811_pin_settings != HWSETTINGS_WS2811LED_OUT_DISABLED && ws2811_pin_settings < NELEMENTS(pios_ws2811_pin_cfg)) { - PIOS_WS2811_Init(&pios_ws2811_cfg, &pios_ws2811_pin_cfg[ws2811_pin_settings]); + PIOS_WS2811_Init(&pios_ws2811_id, &pios_ws2811_cfg, &pios_ws2811_pin_cfg[ws2811_pin_settings]); } #endif // PIOS_INCLUDE_WS2811 diff --git a/flight/targets/boards/sparky2/pios_board.h b/flight/targets/boards/sparky2/pios_board.h index 9213d1d6e..2addf201c 100644 --- a/flight/targets/boards/sparky2/pios_board.h +++ b/flight/targets/boards/sparky2/pios_board.h @@ -156,6 +156,11 @@ extern uint32_t pios_i2c_flexiport_adapter_id; // ------------------------- #define PIOS_COM_MAX_DEVS 4 +#ifdef PIOS_INCLUDE_WS2811 +extern uint32_t pios_ws2811_id; +#define PIOS_WS2811_DEVICE (pios_ws2811_id) +#endif + // ------------------------- // Packet Handler // ------------------------- diff --git a/flight/targets/boards/spracingf3/board_hw_defs.c b/flight/targets/boards/spracingf3/board_hw_defs.c index 5d633f5a7..9e83de971 100644 --- a/flight/targets/boards/spracingf3/board_hw_defs.c +++ b/flight/targets/boards/spracingf3/board_hw_defs.c @@ -502,6 +502,8 @@ static const struct pios_tim_clock_cfg tim_17_cfg = { #define GPIO_AF_PA2_TIM15 GPIO_AF_9 #define GPIO_AF_PA3_TIM15 GPIO_AF_9 +#define TIM1_CH1_DMA_INSTANCE 1 +#define TIM1_CH1_DMA_CHANNEL 2 static const struct pios_tim_channel pios_tim_servoport_io1_io2_pins[] = { TIM_SERVO_CHANNEL_CONFIG(TIM16, 1, A, 6), // bank 1 @@ -793,6 +795,17 @@ void PIOS_I2C_er_irq_handler(void) #endif /* PIOS_INCLUDE_RCVR */ +#if defined(PIOS_INCLUDE_WS2811) +#include "pios_ws2811_cfg.h" + +static const struct pios_ws2811_cfg pios_ws2811_cfg = PIOS_WS2811_CONFIG(TIM1, 1, A, 8); + +void DMA1_Channel2_IRQHandler() +{ + PIOS_WS2811_DMA_irq_handler(); +} + +#endif /* PIOS_INCLUDE_WS2811 */ #if defined(PIOS_INCLUDE_ADC) #include "pios_adc_priv.h" diff --git a/flight/targets/boards/spracingf3/firmware/Makefile b/flight/targets/boards/spracingf3/firmware/Makefile index 05a2a7817..4f736ea44 100644 --- a/flight/targets/boards/spracingf3/firmware/Makefile +++ b/flight/targets/boards/spracingf3/firmware/Makefile @@ -48,7 +48,7 @@ MODULES += FirmwareIAP #MODULES += Osd/osdoutout #MODULES += Logging MODULES += Telemetry -#MODULES += Notify +MODULES += Notify OPTMODULES += Airspeed OPTMODULES += AutoTune diff --git a/flight/targets/boards/spracingf3/firmware/inc/pios_config.h b/flight/targets/boards/spracingf3/firmware/inc/pios_config.h index ba0bc8274..1d271f991 100644 --- a/flight/targets/boards/spracingf3/firmware/inc/pios_config.h +++ b/flight/targets/boards/spracingf3/firmware/inc/pios_config.h @@ -96,6 +96,8 @@ #define PIOS_SENSOR_RATE 500.0f +#define PIOS_INCLUDE_WS2811 + /* PIOS receiver drivers */ #define PIOS_INCLUDE_PWM #define PIOS_INCLUDE_PPM @@ -149,7 +151,7 @@ /* #define PIOS_INCLUDE_COM_AUX */ /* #define PIOS_TELEM_PRIORITY_QUEUE */ #define PIOS_INCLUDE_GPS -//#define PIOS_GPS_MINIMAL +// #define PIOS_GPS_MINIMAL #define PIOS_INCLUDE_GPS_NMEA_PARSER #define PIOS_INCLUDE_GPS_UBX_PARSER #define PIOS_INCLUDE_GPS_DJI_PARSER @@ -173,7 +175,7 @@ #define PIOS_ACTUATOR_STACK_SIZE 800 #define PIOS_MANUAL_STACK_SIZE 935 #define PIOS_RECEIVER_STACK_SIZE 840 -#define PIOS_SYSTEM_STACK_SIZE 1536 +#define PIOS_SYSTEM_STACK_SIZE 1536 /* #define PIOS_STABILIZATION_STACK_SIZE 400 */ diff --git a/flight/targets/boards/spracingf3/firmware/pios_board.c b/flight/targets/boards/spracingf3/firmware/pios_board.c index b91611099..6ec6d4ba1 100644 --- a/flight/targets/boards/spracingf3/firmware/pios_board.c +++ b/flight/targets/boards/spracingf3/firmware/pios_board.c @@ -70,6 +70,10 @@ static void hwSPRacingF3SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *e uintptr_t pios_uavo_settings_fs_id; uintptr_t pios_user_fs_id = 0; +#ifdef PIOS_INCLUDE_WS2811 +uint32_t pios_ws2811_id; +#endif + /** * PIOS_Board_Init() * initializes all the core subsystems on this specific hardware @@ -242,6 +246,9 @@ void PIOS_Board_Init(void) switch (boardHwSettings.LEDPort) { case HWSPRACINGF3SETTINGS_LEDPORT_WS2811: +#if defined(PIOS_INCLUDE_WS2811) + PIOS_WS2811_Init(&pios_ws2811_id, &pios_ws2811_cfg); +#endif break; case HWSPRACINGF3SETTINGS_LEDPORT_OUTPUT: break; diff --git a/flight/targets/boards/spracingf3/pios_board.h b/flight/targets/boards/spracingf3/pios_board.h index 828d99d01..9ab0b2bf8 100644 --- a/flight/targets/boards/spracingf3/pios_board.h +++ b/flight/targets/boards/spracingf3/pios_board.h @@ -134,6 +134,11 @@ extern uint32_t pios_i2c_id; // ------------------------- #define PIOS_COM_MAX_DEVS 3 +#ifdef PIOS_INCLUDE_WS2811 +extern uint32_t pios_ws2811_id; +#define PIOS_WS2811_DEVICE (pios_ws2811_id) +#endif + // ------------------------- // ADC // PIOS_ADC_PinGet(0) = Current sensor diff --git a/flight/targets/boards/spracingf3evo/board_hw_defs.c b/flight/targets/boards/spracingf3evo/board_hw_defs.c index 8b352e269..828061529 100644 --- a/flight/targets/boards/spracingf3evo/board_hw_defs.c +++ b/flight/targets/boards/spracingf3evo/board_hw_defs.c @@ -64,10 +64,6 @@ const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused)) /* Gyro interface */ -void PIOS_SPI_MPU9250_irq_handler(void); -void DMA1_Channel2_IRQHandler() __attribute__((alias("PIOS_SPI_MPU9250_irq_handler"))); -void DMA1_Channel3_IRQHandler() __attribute__((alias("PIOS_SPI_MPU9250_irq_handler"))); - static const struct pios_spi_cfg pios_spi_mpu9250_cfg = { .regs = SPI1, .init = { @@ -82,48 +78,6 @@ static const struct pios_spi_cfg pios_spi_mpu9250_cfg = { .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16, /* 10 Mhz */ }, .use_crc = false, - .dma = { - .ahb_clk = RCC_AHBPeriph_DMA1, - - .irq = { - .flags = (DMA1_FLAG_TC2 | DMA1_FLAG_TE2 | DMA1_FLAG_HT2 | DMA1_FLAG_GL2), - .init = { - .NVIC_IRQChannel = DMA1_Channel2_IRQn, - .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID, - .NVIC_IRQChannelSubPriority = 0, - .NVIC_IRQChannelCmd = ENABLE, - }, - }, - - .rx = { - .channel = DMA1_Channel2, - .init = { - .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR), - .DMA_DIR = DMA_DIR_PeripheralSRC, - .DMA_PeripheralInc = DMA_PeripheralInc_Disable, - .DMA_MemoryInc = DMA_MemoryInc_Enable, - .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte, - .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte, - .DMA_Mode = DMA_Mode_Normal, - .DMA_Priority = DMA_Priority_Medium, - .DMA_M2M = DMA_M2M_Disable, - }, - }, - .tx = { - .channel = DMA1_Channel3, - .init = { - .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR), - .DMA_DIR = DMA_DIR_PeripheralDST, - .DMA_PeripheralInc = DMA_PeripheralInc_Disable, - .DMA_MemoryInc = DMA_MemoryInc_Enable, - .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte, - .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte, - .DMA_Mode = DMA_Mode_Normal, - .DMA_Priority = DMA_Priority_Medium, - .DMA_M2M = DMA_M2M_Disable, - }, - }, - }, .remap = GPIO_AF_5, .sclk = { .gpio = GPIOB, @@ -171,11 +125,6 @@ static const struct pios_spi_cfg pios_spi_mpu9250_cfg = { }; uint32_t pios_spi_mpu9250_id; -void PIOS_SPI_MPU9250_irq_handler(void) -{ - /* Call into the generic code to handle the IRQ for this specific device */ - PIOS_SPI_IRQ_Handler(pios_spi_mpu9250_id); -} /* SDCARD Interface * @@ -449,6 +398,11 @@ static const struct pios_tim_clock_cfg tim_17_cfg = { #define GPIO_AF_PA3_TIM15 GPIO_AF_9 #define GPIO_AF_PA6_TIM3 GPIO_AF_2 #define GPIO_AF_PA7_TIM3 GPIO_AF_2 +#define GPIO_AF_PA10_TIM2 GPIO_AF_10 + + +#define TIM1_CH1_DMA_INSTANCE 1 +#define TIM1_CH1_DMA_CHANNEL 2 static const struct pios_tim_channel pios_tim_servoport_pins[] = { TIM_SERVO_CHANNEL_CONFIG(TIM2, 1, A, 0), // bank 1 @@ -714,6 +668,17 @@ const struct pios_usb_cfg *PIOS_BOARD_HW_DEFS_GetUsbCfg(__attribute__((unused)) } #endif /* PIOS_INCLUDE_USB */ +#if defined(PIOS_INCLUDE_WS2811) +#include "pios_ws2811_cfg.h" + +static const struct pios_ws2811_cfg pios_ws2811_cfg = PIOS_WS2811_CONFIG(TIM1, 1, A, 8); + +void DMA1_Channel2_IRQHandler() +{ + PIOS_WS2811_DMA_irq_handler(); +} + +#endif /* PIOS_INCLUDE_WS2811 */ #if defined(PIOS_INCLUDE_ADC) #include "pios_adc_priv.h" diff --git a/flight/targets/boards/spracingf3evo/firmware/Makefile b/flight/targets/boards/spracingf3evo/firmware/Makefile index 30686b69a..3ca5de286 100644 --- a/flight/targets/boards/spracingf3evo/firmware/Makefile +++ b/flight/targets/boards/spracingf3evo/firmware/Makefile @@ -46,7 +46,7 @@ MODULES += FirmwareIAP #MODULES += Osd/osdoutout #MODULES += Logging MODULES += Telemetry -#MODULES += Notify +MODULES += Notify OPTMODULES += Airspeed OPTMODULES += AutoTune diff --git a/flight/targets/boards/spracingf3evo/firmware/inc/pios_config.h b/flight/targets/boards/spracingf3evo/firmware/inc/pios_config.h index cb3e07b0e..9e099d1ca 100644 --- a/flight/targets/boards/spracingf3evo/firmware/inc/pios_config.h +++ b/flight/targets/boards/spracingf3evo/firmware/inc/pios_config.h @@ -99,6 +99,8 @@ #define PIOS_SENSOR_RATE 500.0f +#define PIOS_INCLUDE_WS2811 + /* PIOS receiver drivers */ #define PIOS_INCLUDE_PWM #define PIOS_INCLUDE_PPM @@ -174,7 +176,7 @@ #define PIOS_ACTUATOR_STACK_SIZE 800 #define PIOS_MANUAL_STACK_SIZE 935 #define PIOS_RECEIVER_STACK_SIZE 840 -#define PIOS_SYSTEM_STACK_SIZE 1536 +#define PIOS_SYSTEM_STACK_SIZE 1536 /* #define PIOS_STABILIZATION_STACK_SIZE 400 */ #define PIOS_TELEM_STACK_SIZE 800 diff --git a/flight/targets/boards/spracingf3evo/firmware/pios_board.c b/flight/targets/boards/spracingf3evo/firmware/pios_board.c index c7719cb67..67de20db9 100644 --- a/flight/targets/boards/spracingf3evo/firmware/pios_board.c +++ b/flight/targets/boards/spracingf3evo/firmware/pios_board.c @@ -58,6 +58,11 @@ uintptr_t pios_uavo_settings_fs_id; uintptr_t pios_user_fs_id = 0; +#ifdef PIOS_INCLUDE_WS2811 +uint32_t pios_ws2811_id; +#endif + + static HwSPRacingF3EVOSettingsData boardHwSettings; static void hwSPRacingF3EVOSettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) @@ -223,6 +228,9 @@ void PIOS_Board_Init(void) switch (boardHwSettings.LEDPort) { case HWSPRACINGF3EVOSETTINGS_LEDPORT_WS2811: +#if defined(PIOS_INCLUDE_WS2811) + PIOS_WS2811_Init(&pios_ws2811_id, &pios_ws2811_cfg); +#endif break; case HWSPRACINGF3EVOSETTINGS_LEDPORT_OUTPUT: break; diff --git a/flight/targets/boards/spracingf3evo/pios_board.h b/flight/targets/boards/spracingf3evo/pios_board.h index fcb8092ba..36ddcc216 100644 --- a/flight/targets/boards/spracingf3evo/pios_board.h +++ b/flight/targets/boards/spracingf3evo/pios_board.h @@ -136,6 +136,11 @@ extern uint32_t pios_spi_mpu9250_id; #define PIOS_COM_MAX_DEVS 3 +#ifdef PIOS_INCLUDE_WS2811 +extern uint32_t pios_ws2811_id; +#define PIOS_WS2811_DEVICE (pios_ws2811_id) +#endif + // ------------------------- // ADC // PIOS_ADC_PinGet(0) = Current sensor