diff --git a/boards/nrf52840-mdk-dongle/Kconfig b/boards/nrf52840-mdk-dongle/Kconfig index 0b1a192707..9f70b7ad03 100644 --- a/boards/nrf52840-mdk-dongle/Kconfig +++ b/boards/nrf52840-mdk-dongle/Kconfig @@ -12,6 +12,7 @@ config BOARD_NRF52840_MDK_DONGLE default y select BOARD_COMMON_NRF52 select CPU_MODEL_NRF52840XXAA + select HAS_PERIPH_PWM select HAS_PERIPH_UART select HAS_PERIPH_USBDEV select HAS_HIGHLEVEL_STDIO diff --git a/boards/nrf52840-mdk-dongle/Makefile.dep b/boards/nrf52840-mdk-dongle/Makefile.dep index b72178a1f7..f807e8222f 100644 --- a/boards/nrf52840-mdk-dongle/Makefile.dep +++ b/boards/nrf52840-mdk-dongle/Makefile.dep @@ -1,5 +1,6 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio + USEMODULE += saul_pwm endif include $(RIOTBOARD)/common/nrf52/bootloader_nrfutil.dep.mk diff --git a/boards/nrf52840-mdk-dongle/Makefile.features b/boards/nrf52840-mdk-dongle/Makefile.features index bf752d2741..bd678939fe 100644 --- a/boards/nrf52840-mdk-dongle/Makefile.features +++ b/boards/nrf52840-mdk-dongle/Makefile.features @@ -1,6 +1,7 @@ CPU_MODEL = nrf52840xxaa # Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev diff --git a/boards/nrf52840-mdk-dongle/include/gpio_params.h b/boards/nrf52840-mdk-dongle/include/gpio_params.h index 46dc3ccaa5..ecdaa250c3 100644 --- a/boards/nrf52840-mdk-dongle/include/gpio_params.h +++ b/boards/nrf52840-mdk-dongle/include/gpio_params.h @@ -31,6 +31,7 @@ extern "C" { */ static const saul_gpio_params_t saul_gpio_params[] = { +#ifndef MODULE_SAUL_PWM { .name = "LED Red", .pin = LED0_PIN, @@ -49,6 +50,7 @@ static const saul_gpio_params_t saul_gpio_params[] = .mode = GPIO_OUT, .flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR), }, +#endif { .name = "Reset", .pin = BTN0_PIN, diff --git a/boards/nrf52840-mdk-dongle/include/periph_conf.h b/boards/nrf52840-mdk-dongle/include/periph_conf.h index b933de4842..693317d31d 100644 --- a/boards/nrf52840-mdk-dongle/include/periph_conf.h +++ b/boards/nrf52840-mdk-dongle/include/periph_conf.h @@ -55,6 +55,20 @@ static const uart_conf_t uart_config[] = { #define UART_NUMOF ARRAY_SIZE(uart_config) /** @} */ +/** + * @name PWM configuration + * + * For the nRF52840-mdk-dongle board, the PWM0 module is set to drive the RGB LED. + * Other PWM outputs are not configured. + * + * @{ + */ +static const pwm_conf_t pwm_config[] = { + { NRF_PWM0, { GPIO_PIN(0, 23), GPIO_PIN(0, 22), GPIO_PIN(0, 24) } } +}; +#define PWM_NUMOF ARRAY_SIZE(pwm_config) +/** @} */ + #ifdef __cplusplus } #endif diff --git a/boards/nrf52840-mdk-dongle/include/pwm_params.h b/boards/nrf52840-mdk-dongle/include/pwm_params.h new file mode 100644 index 0000000000..2d464d8dd0 --- /dev/null +++ b/boards/nrf52840-mdk-dongle/include/pwm_params.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2020 Benjamin Valentin + * + * 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_nrf52840-mdk-dongle + * @{ + * + * @file + * @brief Configuration of SAUL mapped PWM channels + * + * @author Benjamin Valentin + */ + +#ifndef PWM_PARAMS_H +#define PWM_PARAMS_H + +#include "board.h" +#include "saul/periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief No individual LED that needs dimming + */ +#define SAUL_PWM_NO_DIMMER + +/** + * @brief The on-board RGB LED + */ +static const saul_pwm_rgb_params_t saul_pwm_rgb_params[] = +{ + { + .name = "RGB", + .channels = { + { PWM_DEV(0), 0, SAUL_PWM_INVERTED }, + { PWM_DEV(0), 1, SAUL_PWM_INVERTED }, + { PWM_DEV(0), 2, SAUL_PWM_INVERTED } + } + } +}; + +#ifdef __cplusplus +} +#endif + +#endif /* PWM_PARAMS_H */ +/** @} */