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:
Wed Sep 30 17:00:09 2015 +0100
Revision:
635:a11c0372f0ba
Parent:
221:8276e3a4886f
Synchronized with git revision d29c98dae61be0946ddf3a3c641c7726056f9452

Full URL: https://github.com/mbedmicro/mbed/commit/d29c98dae61be0946ddf3a3c641c7726056f9452/

Added support for SAMW25

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 221:8276e3a4886f 20 gpio_init(gpio, pin);
mbed_official 221:8276e3a4886f 21 if (pin != NC) {
mbed_official 160:6870f452afa4 22 gpio_dir(gpio, PIN_INPUT);
mbed_official 160:6870f452afa4 23 gpio_mode(gpio, mode);
mbed_official 160:6870f452afa4 24 }
mbed_official 113:65a335a675de 25 }
mbed_official 221:8276e3a4886f 26
mbed_official 113:65a335a675de 27 static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value)
mbed_official 113:65a335a675de 28 {
mbed_official 113:65a335a675de 29 gpio_init(gpio, pin);
mbed_official 160:6870f452afa4 30 if (pin != NC) {
mbed_official 160:6870f452afa4 31 gpio_write(gpio, value);
mbed_official 160:6870f452afa4 32 gpio_dir(gpio, PIN_OUTPUT);
mbed_official 160:6870f452afa4 33 gpio_mode(gpio, mode);
mbed_official 160:6870f452afa4 34 }
mbed_official 113:65a335a675de 35 }
mbed_official 113:65a335a675de 36
mbed_official 113:65a335a675de 37 void gpio_init_in(gpio_t* gpio, PinName pin) {
mbed_official 113:65a335a675de 38 gpio_init_in_ex(gpio, pin, PullDefault);
mbed_official 113:65a335a675de 39 }
mbed_official 113:65a335a675de 40
mbed_official 113:65a335a675de 41 void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode) {
mbed_official 113:65a335a675de 42 _gpio_init_in(gpio, pin, mode);
mbed_official 113:65a335a675de 43 }
mbed_official 113:65a335a675de 44
mbed_official 113:65a335a675de 45 void gpio_init_out(gpio_t* gpio, PinName pin) {
mbed_official 113:65a335a675de 46 gpio_init_out_ex(gpio, pin, 0);
mbed_official 113:65a335a675de 47 }
mbed_official 113:65a335a675de 48
mbed_official 113:65a335a675de 49 void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value) {
mbed_official 113:65a335a675de 50 _gpio_init_out(gpio, pin, PullNone, value);
mbed_official 113:65a335a675de 51 }
mbed_official 113:65a335a675de 52
mbed_official 113:65a335a675de 53 void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) {
mbed_official 113:65a335a675de 54 if (direction == PIN_INPUT) {
mbed_official 113:65a335a675de 55 _gpio_init_in(gpio, pin, mode);
mbed_official 160:6870f452afa4 56 if (pin != NC)
mbed_official 160:6870f452afa4 57 gpio_write(gpio, value); // we prepare the value in case it is switched later
mbed_official 113:65a335a675de 58 } else {
mbed_official 113:65a335a675de 59 _gpio_init_out(gpio, pin, mode, value);
mbed_official 113:65a335a675de 60 }
mbed_official 113:65a335a675de 61 }