backport of Issue: Pinology #808

pull/1118/head
Dmitry Bogdanov 2015-05-08 20:21:14 +04:00
parent 6d0c61a6ad
commit fa21094284
2 changed files with 7 additions and 0 deletions

View File

@ -29,6 +29,9 @@ void gpio_init(gpio_t *obj, PinName pin) {
if (pin == (PinName)NC)
return;
obj->pin = pin;
if (pin == (PinName)NC)
return;
obj->mask = gpio_set(pin);
LPC_GPIO_TypeDef *port_reg = (LPC_GPIO_TypeDef *) ((int)pin & ~0x1F);

View File

@ -48,6 +48,10 @@ static inline int gpio_read(gpio_t *obj) {
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
}
#endif