Skip to content

Commit a6eb48c

Browse files
author
Filip Jagodzinski
committed
Add HAL API for GPIO pinmap
1 parent b2abfc3 commit a6eb48c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

hal/gpio_api.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <stdint.h>
2424
#include "device.h"
25+
#include "pinmap.h"
2526

2627
#ifdef __cplusplus
2728
extern "C" {
@@ -135,6 +136,18 @@ void gpio_init_out_ex(gpio_t *gpio, PinName pin, int value);
135136
*/
136137
void gpio_init_inout(gpio_t *gpio, PinName pin, PinDirection direction, PinMode mode, int value);
137138

139+
/** Get the pins that support all GPIO tests
140+
*
141+
* Return a PinMap array of pins that support GPIO. The
142+
* array is terminated with {NC, NC, 0}.
143+
*
144+
* Targets should override the weak implementation of this
145+
* function to provide the actual pinmap for GPIO testing.
146+
*
147+
* @return PinMap array
148+
*/
149+
const PinMap *gpio_pinmap(void);
150+
138151
/**@}*/
139152

140153
#ifdef __cplusplus

hal/mbed_gpio.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
#include "hal/gpio_api.h"
18+
#include "platform/mbed_toolchain.h"
1819

1920
static inline void _gpio_init_in(gpio_t *gpio, PinName pin, PinMode mode)
2021
{
@@ -66,3 +67,11 @@ void gpio_init_inout(gpio_t *gpio, PinName pin, PinDirection direction, PinMode
6667
_gpio_init_out(gpio, pin, mode, value);
6768
}
6869
}
70+
71+
MBED_WEAK const PinMap *gpio_pinmap()
72+
{
73+
static const PinMap empty_gpio_pinmap[] = {
74+
{NC, NC, 0},
75+
};
76+
return empty_gpio_pinmap;
77+
}

0 commit comments

Comments
 (0)