Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: CanNucleoF0_example
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_api.c
- Revision:
- 227:7bd0639b8911
- Parent:
- 181:a4cbdfbbd2f4
- Child:
- 250:a49055e7a707
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_api.c Wed Jun 11 09:45:09 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/gpio_api.c Wed Jun 11 16:00:09 2014 +0100
@@ -27,6 +27,7 @@
* 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"
@@ -34,15 +35,16 @@
extern uint32_t Set_GPIO_Clock(uint32_t port_idx);
uint32_t gpio_set(PinName pin) {
- if (pin == NC) return 0;
+ MBED_ASSERT(pin != (PinName)NC);
pin_function(pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 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(STM_MODE_OUTPUT_PP, GPIO_NOPULL, 0));
} else { // PIN_INPUT
