1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/periph_common: add periph_init_leds to init all on-board LEDs

This commit is contained in:
Benjamin Valentin 2022-01-28 11:18:41 +01:00
parent 726c461cb5
commit 982598a199
6 changed files with 142 additions and 1 deletions

View File

@ -1327,7 +1327,7 @@ boards/common/nucleo144/include/arduino_pinmap\.h:[0-9]+: warning: Member ARDUIN
boards/common/nucleo144/include/arduino_pinmap\.h:[0-9]+: warning: Member ARDUINO_PIN_A4 \(macro definition\) of file arduino_pinmap\.h is not documented\.
boards/common/nucleo144/include/arduino_pinmap\.h:[0-9]+: warning: Member ARDUINO_PIN_A5 \(macro definition\) of file arduino_pinmap\.h is not documented\.
boards/common/nucleo144/include/arduino_pinmap\.h:[0-9]+: warning: end of file with unbalanced grouping commands
boards/common/nucleo144/include/board\.h:[0-9]+: warning: Member AUTO_INIT_LED0 \(macro definition\) of group boards_common_nucleo144 is not documented\.
boards/common/nucleo144/include/board\.h:[0-9]+: warning: Member PERIPH_INIT_LED0 \(macro definition\) of group boards_common_nucleo144 is not documented\.
boards/common/nucleo144/include/board\.h:[0-9]+: warning: Member BTN0_MODE \(macro definition\) of group boards_common_nucleo144 is not documented\.
boards/common/nucleo144/include/board\.h:[0-9]+: warning: Member BTN0_PIN \(macro definition\) of group boards_common_nucleo144 is not documented\.
boards/common/nucleo144/include/board\.h:[0-9]+: warning: Member LED0_MASK \(macro definition\) of group boards_common_nucleo144 is not documented\.

View File

@ -115,6 +115,7 @@ config MODULE_PERIPH_INIT_QDEC
default y if MODULE_PERIPH_INIT
depends on MODULE_PERIPH_QDEC
rsource "Kconfig.leds"
rsource "Kconfig.rtc"
config MODULE_PERIPH_RTT

View File

@ -0,0 +1,69 @@
# Copyright (c) 2022 Inria
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
config MODULE_PERIPH_INIT_LEDS
bool
default y
depends on TEST_KCONFIG
help
Enable auto initialization of board leds
config MODULE_PERIPH_INIT_LED0
bool
default y
depends on MODULE_PERIPH_INIT_LEDS
help
Enable auto initialization of LED0 if present
config MODULE_PERIPH_INIT_LED1
bool
default y
depends on MODULE_PERIPH_INIT_LEDS
help
Enable auto initialization of LED1 if present
config MODULE_PERIPH_INIT_LED2
bool
default y
depends on MODULE_PERIPH_INIT_LEDS
help
Enable auto initialization of LED2 if present
config MODULE_PERIPH_INIT_LED3
bool
default y
depends on MODULE_PERIPH_INIT_LEDS
help
Enable auto initialization of LED3 if present
config MODULE_PERIPH_INIT_LED4
bool
default y
depends on MODULE_PERIPH_INIT_LEDS
help
Enable auto initialization of LED4 if present
config MODULE_PERIPH_INIT_LED5
bool
default y
depends on MODULE_PERIPH_INIT_LEDS
help
Enable auto initialization of LED5 if present
config MODULE_PERIPH_INIT_LED6
bool
default y
depends on MODULE_PERIPH_INIT_LEDS
help
Enable auto initialization of LED6 if present
config MODULE_PERIPH_INIT_LED7
bool
default y
depends on MODULE_PERIPH_INIT_LEDS
help
Enable auto initialization of LED7 if present

View File

@ -22,6 +22,7 @@
#define USB_H_USER_IS_RIOT_INTERNAL
#include "kernel_defines.h"
#include "periph_cpu.h"
#ifdef MODULE_PERIPH_INIT
@ -54,6 +55,11 @@
void periph_init(void)
{
#ifdef MODULE_PERIPH_INIT
/* initialize leds */
if (IS_USED(MODULE_PERIPH_INIT_LEDS)) {
extern void led_init(void);
led_init();
}
/* initialize configured I2C devices */
#ifdef MODULE_PERIPH_INIT_I2C
for (unsigned i = 0; i < I2C_NUMOF; i++) {

View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2022 ML!PA Consulting GmbH
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup drivers_periph_init
* @{
*
* @file
* @brief Init on board LEDs
*
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
* @}
*/
#include "board.h"
#include "periph/gpio.h"
#include "kernel_defines.h"
#define LED_INIT(x) do { \
if (IS_ACTIVE(MODULE_PERIPH_INIT_LED##x)) { \
gpio_init(LED##x##_PIN, GPIO_OUT); \
LED##x##_OFF; \
} \
} while (0)
__attribute__ ((weak))
void led_init(void)
{
if (!IS_USED(MODULE_PERIPH_GPIO)) {
return;
}
#ifdef LED0_PIN
LED_INIT(0);
#endif
#ifdef LED1_PIN
LED_INIT(1);
#endif
#ifdef LED2_PIN
LED_INIT(2);
#endif
#ifdef LED3_PIN
LED_INIT(3);
#endif
#ifdef LED4_PIN
LED_INIT(4);
#endif
#ifdef LED5_PIN
LED_INIT(5);
#endif
#ifdef LED6_PIN
LED_INIT(6);
#endif
#ifdef LED7_PIN
LED_INIT(7);
#endif
}

View File

@ -0,0 +1,3 @@
MODULE = periph_init_leds
include $(RIOTMAKE)/auto_init.inc.mk