mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge #19357
19357: boards/adafruit-itsybitsy-m4: turn off APA102 LED on startup r=benpicco a=benpicco Co-authored-by: Benjamin Valentin <benjamin.valentin@bht-berlin.de>
This commit is contained in:
commit
c4400e8964
@ -53,3 +53,39 @@ static mtd_spi_nor_t samd51_nor_dev = {
|
|||||||
|
|
||||||
mtd_dev_t *mtd0 = (mtd_dev_t *)&samd51_nor_dev;
|
mtd_dev_t *mtd0 = (mtd_dev_t *)&samd51_nor_dev;
|
||||||
#endif /* MODULE_MTD */
|
#endif /* MODULE_MTD */
|
||||||
|
|
||||||
|
static inline void _toggle(unsigned n)
|
||||||
|
{
|
||||||
|
n *= 2;
|
||||||
|
while (--n) {
|
||||||
|
/* This might break if the GPIO driver gets more optimized, but
|
||||||
|
* with the current implementation the toggle is slow enough :) */
|
||||||
|
gpio_toggle(APA102_PARAM_CLK_PIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void board_init(void)
|
||||||
|
{
|
||||||
|
/* if the real driver is used, it will deal with the LED */
|
||||||
|
if (IS_USED(MODULE_APA102)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* bootloader leaves on an annoyingly bright LED - turn it off manually */
|
||||||
|
gpio_init(APA102_PARAM_DATA_PIN, GPIO_OUT);
|
||||||
|
gpio_init(APA102_PARAM_CLK_PIN, GPIO_OUT);
|
||||||
|
|
||||||
|
/* start frame - 32 zero bits */
|
||||||
|
gpio_clear(APA102_PARAM_DATA_PIN);
|
||||||
|
_toggle(32);
|
||||||
|
|
||||||
|
/* LED frame: 3 start bits (1), 5 alpha bits (0), 24 color bits (0) */
|
||||||
|
gpio_set(APA102_PARAM_DATA_PIN);
|
||||||
|
_toggle(3);
|
||||||
|
gpio_clear(APA102_PARAM_DATA_PIN);
|
||||||
|
_toggle(29); /* 5 alpha + 8 red + 8 green + 8 blue */
|
||||||
|
|
||||||
|
/* end frame - 32 one bits */
|
||||||
|
gpio_set(APA102_PARAM_DATA_PIN);
|
||||||
|
_toggle(32);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user