mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/periph_common: add periph_init_buttons to init on-board buttons
This commit is contained in:
parent
6cfbec4f8e
commit
bf34cc6b17
@ -28,6 +28,12 @@ config MODULE_PERIPH_INIT_ADC
|
||||
default y if MODULE_PERIPH_INIT
|
||||
depends on MODULE_PERIPH_ADC
|
||||
|
||||
config MODULE_PERIPH_INIT_BUTTONS
|
||||
bool
|
||||
depends on TEST_KCONFIG
|
||||
help
|
||||
Enable auto initialization of on-board buttons
|
||||
|
||||
config MODULE_PERIPH_CPUID
|
||||
bool "CPU unique ID"
|
||||
depends on HAS_PERIPH_CPUID
|
||||
|
@ -63,6 +63,11 @@ void periph_init(void)
|
||||
extern void led_init(void);
|
||||
led_init();
|
||||
}
|
||||
/* initialize buttonss */
|
||||
if (IS_USED(MODULE_PERIPH_INIT_BUTTONS)) {
|
||||
extern void button_init(void);
|
||||
button_init();
|
||||
}
|
||||
/* initialize configured I2C devices */
|
||||
#ifdef MODULE_PERIPH_INIT_I2C
|
||||
for (unsigned i = 0; i < I2C_NUMOF; i++) {
|
||||
|
55
drivers/periph_common/init_buttons.c
Normal file
55
drivers/periph_common/init_buttons.c
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 Buttons as input
|
||||
*
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "periph/gpio.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
__attribute__ ((weak))
|
||||
void button_init(void)
|
||||
{
|
||||
if (!IS_USED(MODULE_PERIPH_GPIO)) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BTN0_PIN
|
||||
gpio_init(BTN0_PIN, BTN0_MODE);
|
||||
#endif
|
||||
#ifdef BTN1_PIN
|
||||
gpio_init(BTN1_PIN, BTN1_MODE);
|
||||
#endif
|
||||
#ifdef BTN2_PIN
|
||||
gpio_init(BTN2_PIN, BTN2_MODE);
|
||||
#endif
|
||||
#ifdef BTN3_PIN
|
||||
gpio_init(BTN3_PIN, BTN3_MODE);
|
||||
#endif
|
||||
#ifdef BTN4_PIN
|
||||
gpio_init(BTN4_PIN, BTN4_MODE);
|
||||
#endif
|
||||
#ifdef BTN5_PIN
|
||||
gpio_init(BTN5_PIN, BTN5_MODE);
|
||||
#endif
|
||||
#ifdef BTN6_PIN
|
||||
gpio_init(BTN6_PIN, BTN6_MODE);
|
||||
#endif
|
||||
#ifdef BTN7_PIN
|
||||
gpio_init(BTN7_PIN, BTN7_MODE);
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user