[11U68]fix P0_11 to use GPIO
Fork of mbed-src by
Diff: targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_api.c
- Revision:
- 227:7bd0639b8911
- Parent:
- 207:05668db47a72
- Child:
- 398:7a7127adb6e8
--- a/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_api.c Wed Jun 11 09:45:09 2014 +0100 +++ b/targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_api.c Wed Jun 11 16:00:09 2014 +0100 @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "gpio_api.h" #include "pinmap.h" @@ -26,6 +27,7 @@ } uint32_t gpio_set(PinName pin) { + MBED_ASSERT(pin != (PinName)NC); if (!gpio_enabled) gpio_enable(); @@ -39,13 +41,14 @@ } void gpio_init(gpio_t *obj, PinName pin) { - if(pin == NC) return; - obj->pin = pin; + if (pin == (PinName)NC) + return; + obj->mask = gpio_set(pin); unsigned int port = (unsigned int)(pin >> PORT_SHIFT); - + obj->reg_set = &LPC_GPIO_PORT->SET[port]; obj->reg_clr = &LPC_GPIO_PORT->CLR[port]; obj->reg_in = &LPC_GPIO_PORT->PIN[port]; @@ -57,8 +60,13 @@ } void gpio_dir(gpio_t *obj, PinDirection direction) { + MBED_ASSERT(obj->pin != (PinName)NC); switch (direction) { - case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; - case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; + case PIN_INPUT : + *obj->reg_dir &= ~obj->mask; + break; + case PIN_OUTPUT: + *obj->reg_dir |= obj->mask; + break; } }