Skip to content

Commit 297522b

Browse files
committed
STM32: enable PinMap_GPIO table with GPIO_PINMAP_READY
If GPIO_PINMAP_READY is defined for the target, - PinMap_GPIO table is expected in PeripheralPins.c - weak gpio_get_capabilities function is implemented
1 parent 3213ea8 commit 297522b

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

targets/TARGET_STM/PeripheralPins.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
#include "pinmap.h"
3535
#include "PeripheralNames.h"
3636

37+
//*** GPIO ***
38+
#if GPIO_PINMAP_READY
39+
/* If this macro is defined, then PinMap_GPIO is present in PeripheralPins.c */
40+
extern const PinMap PinMap_GPIO[];
41+
#endif
42+
3743
//*** ADC ***
3844
#if DEVICE_ANALOGIN
3945
extern const PinMap PinMap_ADC[];

targets/TARGET_STM/gpio_api.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "pinmap.h"
3333
#include "mbed_error.h"
3434
#include "pin_device.h"
35+
#include "PeripheralPins.h"
3536

3637
extern const uint32_t ll_pin_defines[16];
3738

@@ -186,3 +187,35 @@ inline void gpio_dir(gpio_t *obj, PinDirection direction)
186187
#endif /* DUAL_CORE */
187188
}
188189

190+
#if GPIO_PINMAP_READY
191+
/* If this macro is defined, then PinMap_GPIO is present in PeripheralPins.c */
192+
const PinMap *gpio_pinmap()
193+
{
194+
return PinMap_GPIO;
195+
}
196+
197+
198+
void gpio_get_capabilities(gpio_t *obj, gpio_capabilities_t *cap)
199+
{
200+
switch (pinmap_find_function(obj->pin, PinMap_GPIO)) {
201+
case GPIO_NOPULL:
202+
cap->pull_none = 1;
203+
cap->pull_down = 1;
204+
cap->pull_up = 1;
205+
break;
206+
case GPIO_PULLUP:
207+
cap->pull_none = 1;
208+
cap->pull_down = 0;
209+
cap->pull_up = 1;
210+
break;
211+
case GPIO_PULLDOWN:
212+
cap->pull_none = 1;
213+
cap->pull_down = 1;
214+
cap->pull_up = 0;
215+
break;
216+
default:
217+
break;
218+
}
219+
}
220+
221+
#endif

0 commit comments

Comments
 (0)