mirror of https://github.com/ARMmbed/mbed-os.git
backport of Issue: Pinology #808
parent
6d0c61a6ad
commit
fa21094284
|
@ -29,6 +29,9 @@ void gpio_init(gpio_t *obj, PinName pin) {
|
||||||
if (pin == (PinName)NC)
|
if (pin == (PinName)NC)
|
||||||
return;
|
return;
|
||||||
obj->pin = pin;
|
obj->pin = pin;
|
||||||
|
if (pin == (PinName)NC)
|
||||||
|
return;
|
||||||
|
|
||||||
obj->mask = gpio_set(pin);
|
obj->mask = gpio_set(pin);
|
||||||
|
|
||||||
LPC_GPIO_TypeDef *port_reg = (LPC_GPIO_TypeDef *) ((int)pin & ~0x1F);
|
LPC_GPIO_TypeDef *port_reg = (LPC_GPIO_TypeDef *) ((int)pin & ~0x1F);
|
||||||
|
|
|
@ -48,6 +48,10 @@ static inline int gpio_read(gpio_t *obj) {
|
||||||
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int gpio_is_connected(const gpio_t *obj) {
|
||||||
|
return obj->pin != (PinName)NC;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue