mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_api.c
- Revision:
- 227:7bd0639b8911
- Parent:
- 126:549ba18ddd81
- Child:
- 250:a49055e7a707
diff -r b062af740e40 -r 7bd0639b8911 targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_api.c --- a/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_api.c Wed Jun 11 09:45:09 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_DISCO_F100RB/gpio_api.c Wed Jun 11 16:00:09 2014 +0100 @@ -27,22 +27,24 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" #include "error.h" extern uint32_t Set_GPIO_Clock(uint32_t port_idx); -uint32_t gpio_set(PinName pin) { - if (pin == NC) return 0; +uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)); - return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } void gpio_init(gpio_t *obj, PinName pin) { - if (pin == NC) return; + obj->pin = pin; + if (pin == (PinName)NC) + return; uint32_t port_index = STM_PORT(pin); @@ -51,7 +53,6 @@ GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; // Fill GPIO object structure for future use - obj->pin = pin; obj->mask = gpio_set(pin); obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; @@ -63,6 +64,7 @@ } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); if (direction == PIN_OUTPUT) { pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_Out_PP, 0)); }