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

boards/nrf52840-mdk-dongle: configure RGB LED as PWM

This commit is contained in:
Benjamin Valentin 2020-11-13 18:38:29 +01:00
parent 4f28bd3482
commit 081c600901
6 changed files with 73 additions and 0 deletions

View File

@ -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

View File

@ -1,5 +1,6 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
USEMODULE += saul_pwm
endif
include $(RIOTBOARD)/common/nrf52/bootloader_nrfutil.dep.mk

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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 <benpicco@googlemail.com>
*/
#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 */
/** @} */