mbed library sources
Dependents: Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more
Superseded
This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.
Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.
If you are looking for a stable and tested release, please import one of the official mbed library releases:
Import librarymbed
The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
targets/hal/TARGET_NXP/TARGET_LPC11U6X/gpio_api.c@174:8bb9f3a33240, 2014-04-29 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Apr 29 11:15:07 2014 +0100
- Revision:
- 174:8bb9f3a33240
- Child:
- 207:05668db47a72
Synchronized with git revision 5bf985ebc651a2c31cefabd9d62c51dc465ef60a
Full URL: https://github.com/mbedmicro/mbed/commit/5bf985ebc651a2c31cefabd9d62c51dc465ef60a/
[NUCLEO_L152RE/F103RB] Add LSE configuration for RTC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 174:8bb9f3a33240 | 1 | /* mbed Microcontroller Library |
mbed_official | 174:8bb9f3a33240 | 2 | * Copyright (c) 2006-2014 ARM Limited |
mbed_official | 174:8bb9f3a33240 | 3 | * |
mbed_official | 174:8bb9f3a33240 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 174:8bb9f3a33240 | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 174:8bb9f3a33240 | 6 | * You may obtain a copy of the License at |
mbed_official | 174:8bb9f3a33240 | 7 | * |
mbed_official | 174:8bb9f3a33240 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 174:8bb9f3a33240 | 9 | * |
mbed_official | 174:8bb9f3a33240 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 174:8bb9f3a33240 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 174:8bb9f3a33240 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 174:8bb9f3a33240 | 13 | * See the License for the specific language governing permissions and |
mbed_official | 174:8bb9f3a33240 | 14 | * limitations under the License. |
mbed_official | 174:8bb9f3a33240 | 15 | */ |
mbed_official | 174:8bb9f3a33240 | 16 | #include "gpio_api.h" |
mbed_official | 174:8bb9f3a33240 | 17 | #include "pinmap.h" |
mbed_official | 174:8bb9f3a33240 | 18 | |
mbed_official | 174:8bb9f3a33240 | 19 | static int gpio_enabled = 0; |
mbed_official | 174:8bb9f3a33240 | 20 | |
mbed_official | 174:8bb9f3a33240 | 21 | static void gpio_enable(void) { |
mbed_official | 174:8bb9f3a33240 | 22 | gpio_enabled = 1; |
mbed_official | 174:8bb9f3a33240 | 23 | |
mbed_official | 174:8bb9f3a33240 | 24 | /* Enable AHB clock to the GPIO and IOCON domain. */ |
mbed_official | 174:8bb9f3a33240 | 25 | LPC_SYSCON->SYSAHBCLKCTRL |= ((1 << 16) | (1 << 6)); |
mbed_official | 174:8bb9f3a33240 | 26 | } |
mbed_official | 174:8bb9f3a33240 | 27 | |
mbed_official | 174:8bb9f3a33240 | 28 | uint32_t gpio_set(PinName pin) { |
mbed_official | 174:8bb9f3a33240 | 29 | |
mbed_official | 174:8bb9f3a33240 | 30 | if (!gpio_enabled) |
mbed_official | 174:8bb9f3a33240 | 31 | gpio_enable(); |
mbed_official | 174:8bb9f3a33240 | 32 | |
mbed_official | 174:8bb9f3a33240 | 33 | return (1UL << ((int)pin >> PIN_SHIFT & 0x1F)); |
mbed_official | 174:8bb9f3a33240 | 34 | } |
mbed_official | 174:8bb9f3a33240 | 35 | |
mbed_official | 174:8bb9f3a33240 | 36 | void gpio_init(gpio_t *obj, PinName pin) { |
mbed_official | 174:8bb9f3a33240 | 37 | if(pin == NC) return; |
mbed_official | 174:8bb9f3a33240 | 38 | |
mbed_official | 174:8bb9f3a33240 | 39 | obj->pin = pin; |
mbed_official | 174:8bb9f3a33240 | 40 | obj->mask = gpio_set(pin); |
mbed_official | 174:8bb9f3a33240 | 41 | |
mbed_official | 174:8bb9f3a33240 | 42 | unsigned int port = (unsigned int)(pin >> PORT_SHIFT); |
mbed_official | 174:8bb9f3a33240 | 43 | |
mbed_official | 174:8bb9f3a33240 | 44 | obj->reg_set = &LPC_GPIO_PORT->SET[port]; |
mbed_official | 174:8bb9f3a33240 | 45 | obj->reg_clr = &LPC_GPIO_PORT->CLR[port]; |
mbed_official | 174:8bb9f3a33240 | 46 | obj->reg_in = &LPC_GPIO_PORT->PIN[port]; |
mbed_official | 174:8bb9f3a33240 | 47 | obj->reg_dir = &LPC_GPIO_PORT->DIR[port]; |
mbed_official | 174:8bb9f3a33240 | 48 | } |
mbed_official | 174:8bb9f3a33240 | 49 | |
mbed_official | 174:8bb9f3a33240 | 50 | void gpio_mode(gpio_t *obj, PinMode mode) { |
mbed_official | 174:8bb9f3a33240 | 51 | pin_mode(obj->pin, mode); |
mbed_official | 174:8bb9f3a33240 | 52 | } |
mbed_official | 174:8bb9f3a33240 | 53 | |
mbed_official | 174:8bb9f3a33240 | 54 | void gpio_dir(gpio_t *obj, PinDirection direction) { |
mbed_official | 174:8bb9f3a33240 | 55 | switch (direction) { |
mbed_official | 174:8bb9f3a33240 | 56 | case PIN_INPUT : *obj->reg_dir &= ~obj->mask; break; |
mbed_official | 174:8bb9f3a33240 | 57 | case PIN_OUTPUT: *obj->reg_dir |= obj->mask; break; |
mbed_official | 174:8bb9f3a33240 | 58 | } |
mbed_official | 174:8bb9f3a33240 | 59 | } |