diff --git a/boards/common/nrf52xxxdk/Kconfig b/boards/common/nrf52xxxdk/Kconfig index c839206247..f8cbf754e3 100644 --- a/boards/common/nrf52xxxdk/Kconfig +++ b/boards/common/nrf52xxxdk/Kconfig @@ -14,11 +14,12 @@ config BOARDS_COMMON_NRF52XXXDK select HAS_VDD_LC_FILTER_REG1 select HAVE_SAUL_GPIO + select HAVE_SAUL_PWM config MODULE_BOARDS_COMMON_NRF52XXXDK bool depends on TEST_KCONFIG help - Common code for boards based on nrf52xxxdk. + Common code for boards based on nrf52xxxdk. source "$(RIOTBOARD)/common/nrf52/Kconfig" diff --git a/boards/common/nrf52xxxdk/Makefile.dep b/boards/common/nrf52xxxdk/Makefile.dep index 7317b22d44..1eb2c763dc 100644 --- a/boards/common/nrf52xxxdk/Makefile.dep +++ b/boards/common/nrf52xxxdk/Makefile.dep @@ -1,5 +1,6 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio + USEMODULE += saul_pwm endif include $(RIOTBOARD)/common/nrf52/Makefile.dep diff --git a/boards/common/nrf52xxxdk/include/gpio_params.h b/boards/common/nrf52xxxdk/include/gpio_params.h index 7dbe1f650a..2929055107 100644 --- a/boards/common/nrf52xxxdk/include/gpio_params.h +++ b/boards/common/nrf52xxxdk/include/gpio_params.h @@ -7,7 +7,7 @@ */ /** - * @ingroup boards_common_nrf52 + * @ingroup boards_common_nrf52xxxdk * @{ * * @file @@ -28,40 +28,10 @@ extern "C" { #endif /** - * @brief LED configuration + * @brief Button configuration */ static const saul_gpio_params_t saul_gpio_params[] = { - { - .name = "LED 1", - .pin = LED0_PIN, - .mode = GPIO_OUT, - .flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR), - }, -#ifdef LED1_PIN - { - .name = "LED 2", - .pin = LED1_PIN, - .mode = GPIO_OUT, - .flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR), - }, -#endif -#ifdef LED2_PIN - { - .name = "LED 3", - .pin = LED2_PIN, - .mode = GPIO_OUT, - .flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR), - }, -#endif -#ifdef LED3_PIN - { - .name = "LED 4", - .pin = LED3_PIN, - .mode = GPIO_OUT, - .flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR), - }, -#endif #ifdef BTN0_PIN { .name = "Button 1", diff --git a/boards/common/nrf52xxxdk/include/periph_conf_common.h b/boards/common/nrf52xxxdk/include/periph_conf_common.h index 2de6c36ea0..0b7bbdd019 100644 --- a/boards/common/nrf52xxxdk/include/periph_conf_common.h +++ b/boards/common/nrf52xxxdk/include/periph_conf_common.h @@ -38,6 +38,7 @@ extern "C" { * @{ */ static const pwm_conf_t pwm_config[] = { + /* Beware: Keep pwm_params.h in sync with the definitions here */ { NRF_PWM0, { /* configure LED0 as PWM */ #ifdef LED0_PIN diff --git a/boards/common/nrf52xxxdk/include/pwm_params.h b/boards/common/nrf52xxxdk/include/pwm_params.h new file mode 100644 index 0000000000..3c070b110c --- /dev/null +++ b/boards/common/nrf52xxxdk/include/pwm_params.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2021 Otto-von-Guericke-Universität Magdeburg + * + * 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 boards_common_nrf52xxxdk + * @{ + * + * @file + * @brief Configuration of SAUL mapped PWM channels + * + * @author Marian Buschsieweke + */ + +#ifndef PWM_PARAMS_H +#define PWM_PARAMS_H + +#include "board.h" +#include "saul/periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define SAUL_PWM_NO_RGB /**< No RGB leds provided */ + +/** + * @brief LED configuration + */ +static const saul_pwm_dimmer_params_t saul_pwm_dimmer_params[] = +{ +#ifdef LED0_PIN + { + .name = "LED 1", + .channel = { PWM_DEV(0), 0, SAUL_PWM_INVERTED }, + }, +#endif +#ifdef LED1_PIN + { + .name = "LED 2", + .channel = { PWM_DEV(0), 1, SAUL_PWM_INVERTED }, + }, +#endif +#ifdef LED2_PIN + { + .name = "LED 3", + .channel = { PWM_DEV(0), 2, SAUL_PWM_INVERTED }, + }, +#endif +#ifdef LED3_PIN + { + .name = "LED 4", + .channel = { PWM_DEV(0), 3, SAUL_PWM_INVERTED }, + }, +#endif +}; + +#ifdef __cplusplus +} +#endif + +#endif /* PWM_PARAMS_H */ +/** @} */