1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 06:12:43 +01:00

boards/common/nrf52xxxdk: Expose LEDs via saul_pwm

This allows dimming the LEDs instead of only turning them on and off.
This commit is contained in:
Marian Buschsieweke 2021-12-14 20:36:29 +01:00
parent 0afed1de20
commit c118df3eb2
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94
5 changed files with 73 additions and 33 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <marian.buschsieweke@ovgu.de>
*/
#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 */
/** @} */