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.

Committer:
mbed_official
Date:
Tue Dec 16 08:15:08 2014 +0000
Revision:
440:8a0b45cd594f
Parent:
294:78f9587bb26d
Synchronized with git revision 67fbbf0b635d0c0d93fbe433306c537c2ad206aa

Full URL: https://github.com/mbedmicro/mbed/commit/67fbbf0b635d0c0d93fbe433306c537c2ad206aa/

Targets: nrf51 - updating app_timer.c from Norid'c SDKv7.1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 20:4263a77256ae 1 /* mbed Microcontroller Library
bogdanm 20:4263a77256ae 2 * Copyright (c) 2006-2013 ARM Limited
bogdanm 20:4263a77256ae 3 *
bogdanm 20:4263a77256ae 4 * Licensed under the Apache License, Version 2.0 (the "License");
bogdanm 20:4263a77256ae 5 * you may not use this file except in compliance with the License.
bogdanm 20:4263a77256ae 6 * You may obtain a copy of the License at
bogdanm 20:4263a77256ae 7 *
bogdanm 20:4263a77256ae 8 * http://www.apache.org/licenses/LICENSE-2.0
bogdanm 20:4263a77256ae 9 *
bogdanm 20:4263a77256ae 10 * Unless required by applicable law or agreed to in writing, software
bogdanm 20:4263a77256ae 11 * distributed under the License is distributed on an "AS IS" BASIS,
bogdanm 20:4263a77256ae 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bogdanm 20:4263a77256ae 13 * See the License for the specific language governing permissions and
bogdanm 20:4263a77256ae 14 * limitations under the License.
bogdanm 20:4263a77256ae 15 *
bogdanm 20:4263a77256ae 16 * Ported to NXP LPC43XX by Micromint USA <support@micromint.com>
bogdanm 20:4263a77256ae 17 */
mbed_official 227:7bd0639b8911 18 #include "mbed_assert.h"
bogdanm 20:4263a77256ae 19 #include "gpio_api.h"
bogdanm 20:4263a77256ae 20 #include "pinmap.h"
bogdanm 20:4263a77256ae 21
bogdanm 20:4263a77256ae 22 uint32_t gpio_set(PinName pin) {
mbed_official 227:7bd0639b8911 23 MBED_ASSERT(pin != (PinName)NC);
bogdanm 20:4263a77256ae 24 int f = 0;
bogdanm 20:4263a77256ae 25 unsigned int port = (unsigned int)MBED_GPIO_PORT(pin);
bogdanm 20:4263a77256ae 26
bogdanm 20:4263a77256ae 27 f = SCU_PINIO_FAST | ((port > 4) ? (4) : (0));
bogdanm 20:4263a77256ae 28 pin_function(pin, f);
bogdanm 20:4263a77256ae 29
bogdanm 20:4263a77256ae 30 return (1 << ((int)pin & 0x1F));
bogdanm 20:4263a77256ae 31 }
bogdanm 20:4263a77256ae 32
mbed_official 113:65a335a675de 33 void gpio_init(gpio_t *obj, PinName pin) {
bogdanm 20:4263a77256ae 34 obj->pin = pin;
mbed_official 227:7bd0639b8911 35 if (pin == (PinName)NC)
mbed_official 227:7bd0639b8911 36 return;
mbed_official 227:7bd0639b8911 37
bogdanm 20:4263a77256ae 38 obj->mask = gpio_set(pin);
bogdanm 20:4263a77256ae 39
mbed_official 294:78f9587bb26d 40 LPC_GPIO_T *port_reg = (LPC_GPIO_T *)(LPC_GPIO_PORT_BASE);
bogdanm 20:4263a77256ae 41 unsigned int port = (unsigned int)MBED_GPIO_PORT(pin);
bogdanm 20:4263a77256ae 42
bogdanm 20:4263a77256ae 43 obj->reg_set = &port_reg->SET[port];
bogdanm 20:4263a77256ae 44 obj->reg_clr = &port_reg->CLR[port];
bogdanm 20:4263a77256ae 45 obj->reg_in = &port_reg->PIN[port];
bogdanm 20:4263a77256ae 46 obj->reg_dir = &port_reg->DIR[port];
bogdanm 20:4263a77256ae 47 }
bogdanm 20:4263a77256ae 48
bogdanm 20:4263a77256ae 49 void gpio_mode(gpio_t *obj, PinMode mode) {
bogdanm 20:4263a77256ae 50 pin_mode(obj->pin, mode);
bogdanm 20:4263a77256ae 51 }
bogdanm 20:4263a77256ae 52
bogdanm 20:4263a77256ae 53 void gpio_dir(gpio_t *obj, PinDirection direction) {
mbed_official 227:7bd0639b8911 54 MBED_ASSERT(obj->pin != (PinName)NC);
bogdanm 20:4263a77256ae 55 switch (direction) {
mbed_official 227:7bd0639b8911 56 case PIN_INPUT :
mbed_official 227:7bd0639b8911 57 *obj->reg_dir &= ~obj->mask;
mbed_official 227:7bd0639b8911 58 break;
mbed_official 227:7bd0639b8911 59 case PIN_OUTPUT:
mbed_official 294:78f9587bb26d 60 *obj->reg_dir |= obj->mask;
mbed_official 227:7bd0639b8911 61 break;
bogdanm 20:4263a77256ae 62 }
bogdanm 20:4263a77256ae 63 }