mbed library sources(for async_print)

Dependents:   AsyncPrint

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Mar 19 17:15:21 2014 +0000
Revision:
127:ce7cebc0511f
Parent:
113:65a335a675de
Child:
160:6870f452afa4
Synchronized with git revision 92d3e97e186ceaa812d103009822fb1a21d797de

Full URL: https://github.com/mbedmicro/mbed/commit/92d3e97e186ceaa812d103009822fb1a21d797de/

Merge after reverting the python scripts to generating hex file with UICR

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 113:65a335a675de 1 /* mbed Microcontroller Library
mbed_official 113:65a335a675de 2 * Copyright (c) 2006-2013 ARM Limited
mbed_official 113:65a335a675de 3 *
mbed_official 113:65a335a675de 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbed_official 113:65a335a675de 5 * you may not use this file except in compliance with the License.
mbed_official 113:65a335a675de 6 * You may obtain a copy of the License at
mbed_official 113:65a335a675de 7 *
mbed_official 113:65a335a675de 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 113:65a335a675de 9 *
mbed_official 113:65a335a675de 10 * Unless required by applicable law or agreed to in writing, software
mbed_official 113:65a335a675de 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbed_official 113:65a335a675de 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 113:65a335a675de 13 * See the License for the specific language governing permissions and
mbed_official 113:65a335a675de 14 * limitations under the License.
mbed_official 113:65a335a675de 15 */
mbed_official 113:65a335a675de 16 #include "gpio_api.h"
mbed_official 113:65a335a675de 17
mbed_official 113:65a335a675de 18 static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode)
mbed_official 113:65a335a675de 19 {
mbed_official 127:ce7cebc0511f 20 gpio_init(gpio, pin);
mbed_official 127:ce7cebc0511f 21 gpio_dir(gpio, PIN_INPUT);
mbed_official 113:65a335a675de 22 gpio_mode(gpio, mode);
mbed_official 113:65a335a675de 23 }
mbed_official 113:65a335a675de 24
mbed_official 113:65a335a675de 25 static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value)
mbed_official 113:65a335a675de 26 {
mbed_official 113:65a335a675de 27 gpio_init(gpio, pin);
mbed_official 113:65a335a675de 28 gpio_write(gpio, value);
mbed_official 113:65a335a675de 29 gpio_dir(gpio, PIN_OUTPUT);
mbed_official 113:65a335a675de 30 gpio_mode(gpio, mode);
mbed_official 113:65a335a675de 31 }
mbed_official 113:65a335a675de 32
mbed_official 113:65a335a675de 33 void gpio_init_in(gpio_t* gpio, PinName pin) {
mbed_official 113:65a335a675de 34 gpio_init_in_ex(gpio, pin, PullDefault);
mbed_official 113:65a335a675de 35 }
mbed_official 113:65a335a675de 36
mbed_official 113:65a335a675de 37 void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode) {
mbed_official 113:65a335a675de 38 _gpio_init_in(gpio, pin, mode);
mbed_official 113:65a335a675de 39 }
mbed_official 113:65a335a675de 40
mbed_official 113:65a335a675de 41 void gpio_init_out(gpio_t* gpio, PinName pin) {
mbed_official 113:65a335a675de 42 gpio_init_out_ex(gpio, pin, 0);
mbed_official 113:65a335a675de 43 }
mbed_official 113:65a335a675de 44
mbed_official 113:65a335a675de 45 void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value) {
mbed_official 113:65a335a675de 46 _gpio_init_out(gpio, pin, PullNone, value);
mbed_official 113:65a335a675de 47 }
mbed_official 113:65a335a675de 48
mbed_official 113:65a335a675de 49 void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) {
mbed_official 113:65a335a675de 50 if (direction == PIN_INPUT) {
mbed_official 113:65a335a675de 51 _gpio_init_in(gpio, pin, mode);
mbed_official 113:65a335a675de 52 gpio_write(gpio, value); // we prepare the value in case it is switched later
mbed_official 113:65a335a675de 53 } else {
mbed_official 113:65a335a675de 54 _gpio_init_out(gpio, pin, mode, value);
mbed_official 113:65a335a675de 55 }
mbed_official 113:65a335a675de 56 }