Skip to content

Commit b76fa82

Browse files
committed
boards/common/native: expose mock saul GPIO pins
When periph_gpio_mock is included, expose two LEDs via saul_gpio for testing purposes. This does not work with periph_gpio_linux because the hard-coded pins are more dynamic for the native board.
1 parent fdb532a commit b76fa82

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

‎boards/common/native/Makefile.dep‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ ifneq (,$(filter lvgl,$(USEPKG)))
2626
endif
2727

2828
USEMODULE += native_drivers
29+
30+
ifneq (,$(filter saul_default,$(USEMODULE)))
31+
ifneq (,$(filter periph_gpio_mock,$(USEMODULE)))
32+
USEMODULE += saul_gpio
33+
endif
34+
endif
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 Bas Stottelaar <basstottelaar@gmail.com>
3+
* SPDX-License-Identifier: LGPL-2.1-only
4+
*/
5+
6+
#pragma once
7+
8+
/**
9+
* @ingroup boards_common_native
10+
* @{
11+
*
12+
* @file
13+
* @brief Board specific configuration of direct mapped GPIOs
14+
*
15+
* @author Bas Stottelaar <basstottelaar@gmail.com>
16+
*/
17+
18+
#include "board.h"
19+
#include "saul/periph.h"
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
#if IS_USED(MODULE_PERIPH_GPIO_MOCK)
26+
/**
27+
* @brief GPIO pin configuration
28+
*
29+
* This is only used when MODULE_PERIPH_GPIO_MOCK is enabled to support
30+
* arbitrary GPIO pin configurations for testing purposes. Other GPIO drivers
31+
* would rely on pre-defined GPIO pin configurations, which are more dynamic
32+
* for the native board.
33+
*
34+
* There is no feedback when using this configuration because it is only used
35+
* to provide some mock SAUL GPIO capabilities.
36+
*/
37+
static const saul_gpio_params_t saul_gpio_params[] =
38+
{
39+
{
40+
.name = "LED 0 (mock)",
41+
.pin = GPIO_PIN(0, 0),
42+
.mode = GPIO_OUT
43+
},
44+
{
45+
.name = "LED 1 (mock)",
46+
.pin = GPIO_PIN(0, 1),
47+
.mode = GPIO_OUT
48+
}
49+
};
50+
#endif
51+
52+
#ifdef __cplusplus
53+
}
54+
#endif
55+
56+
/** @} */

0 commit comments

Comments
 (0)