Skip to content

Commit

Permalink
Jpo2023-Chimera-WS2812 (#3188)
Browse files Browse the repository at this point in the history
  • Loading branch information
amtcvx committed Nov 28, 2023
1 parent 9c1e21d commit 8751466
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
8 changes: 8 additions & 0 deletions conf/airframes/ENAC/rover_ostrich.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@

<module name="nav" type="rover_base"/>
<module name="guidance" type="rover_holonomic"/>

<!--Info: Tawaki(Auxa1):STM32_PWM_USE_TIM5, Apogee: PPMin, Chimera(Aux7/PC6) : TIM8 ch1 -->
<module name="light_scheduler">
<configure name="WS2812_TIM" value="TIM8"/>
<define name="WS2812_NB_LEDS" value="32"/>
<define name="WS2812_SEQUENCE" value="1"/>
</module>

</firmware>

<servos driver="OSTRICH">
Expand Down
14 changes: 14 additions & 0 deletions sw/airborne/boards/chimera/chibios/v1.0/chimera.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,5 +575,19 @@
#define ActuatorsDefaultInit() ActuatorsPwmInit()
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()

/**
* For WS2812
*/
#define WS2812D1_GPIO GPIOC
#define WS2812D1_PIN GPIO6
#define WS2812D1_AF 3
#define WS2812D1_CFG_DEF { \
.dma_stream = STM32_PWM8_UP_DMA_STREAM, \
.dma_channel = STM32_PWM8_UP_DMA_CHANNEL, \
.dma_priority = STM32_PWM8_UP_DMA_PRIORITY, \
.pwm_channel = 0, \
.pwmp = &PWMD8 \
}

#endif /* CONFIG_CHIMERA_1_00_H */

7 changes: 7 additions & 0 deletions sw/airborne/boards/chimera/chibios/v1.0/mcuconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@
#define STM32_PWM_USE_TIM4 TRUE
#endif
#define STM32_PWM_USE_TIM5 FALSE
#ifndef STM32_PWM_USE_TIM8
#define STM32_PWM_USE_TIM8 FALSE
#endif
#define STM32_PWM_USE_TIM9 FALSE
#define STM32_PWM_USE_TIM10 FALSE
#define STM32_PWM_USE_TIM11 FALSE
Expand All @@ -328,6 +330,11 @@
#define STM32_PWM_USE_TIM16 FALSE
#define STM32_PWM_USE_TIM17 FALSE

#define STM32_PWM8_UP_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
#define STM32_PWM8_UP_DMA_CHANNEL 7
#define STM32_PWM8_UP_DMA_IRQ_PRIORITY 6
#define STM32_PWM8_UP_DMA_PRIORITY 2

/*
* RTC driver system settings.
*/
Expand Down
14 changes: 12 additions & 2 deletions sw/airborne/modules/light/light_scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,18 @@ void light_scheduler_periodic(void)
{
uint32_t n, s0;
for (n = 0; n < WS2812_NB_LEDS; n++) {
s0 = s + 10 * n;
light_ws2812_arch_set(n, s0 % 255, (s0 + 85) % 255, (s0 + 170) % 255);
if (WS2812_NB_LEDS == 32) {
if (n<=7) light_ws2812_arch_set(n, 0,255,0); // LEFT = GREEN
else if (n<=15)
light_ws2812_arch_set(n, 0,0,255); // BACK = BLUE
else if (n<=23)
light_ws2812_arch_set(n, 255,0,0); // RIGHT = RED
else
light_ws2812_arch_set(n, 255,255,255); // FRONT = WHITE
} else {
s0 = s + 10 * n;
light_ws2812_arch_set(n, s0 % 255, (s0 + 85) % 255, (s0 + 170) % 255);
}
}
s += 10;
}
Expand Down

0 comments on commit 8751466

Please sign in to comment.