The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 146:22da6e220af6 1 /* mbed Microcontroller Library
AnnaBridge 146:22da6e220af6 2 * Copyright (c) 2006-2013 ARM Limited
AnnaBridge 146:22da6e220af6 3 *
AnnaBridge 146:22da6e220af6 4 * Licensed under the Apache License, Version 2.0 (the "License");
AnnaBridge 146:22da6e220af6 5 * you may not use this file except in compliance with the License.
AnnaBridge 146:22da6e220af6 6 * You may obtain a copy of the License at
AnnaBridge 146:22da6e220af6 7 *
AnnaBridge 146:22da6e220af6 8 * http://www.apache.org/licenses/LICENSE-2.0
AnnaBridge 146:22da6e220af6 9 *
AnnaBridge 146:22da6e220af6 10 * Unless required by applicable law or agreed to in writing, software
AnnaBridge 146:22da6e220af6 11 * distributed under the License is distributed on an "AS IS" BASIS,
AnnaBridge 146:22da6e220af6 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AnnaBridge 146:22da6e220af6 13 * See the License for the specific language governing permissions and
AnnaBridge 146:22da6e220af6 14 * limitations under the License.
AnnaBridge 146:22da6e220af6 15 */
AnnaBridge 146:22da6e220af6 16 #ifndef MBED_GPIO_OBJECT_H
AnnaBridge 146:22da6e220af6 17 #define MBED_GPIO_OBJECT_H
AnnaBridge 146:22da6e220af6 18
AnnaBridge 146:22da6e220af6 19 #include "mbed_assert.h"
AnnaBridge 146:22da6e220af6 20
AnnaBridge 146:22da6e220af6 21 #include "nrf_gpio.h"
AnnaBridge 146:22da6e220af6 22
AnnaBridge 146:22da6e220af6 23 #ifdef __cplusplus
AnnaBridge 146:22da6e220af6 24 extern "C" {
AnnaBridge 146:22da6e220af6 25 #endif
AnnaBridge 146:22da6e220af6 26
AnnaBridge 146:22da6e220af6 27 typedef struct {
AnnaBridge 146:22da6e220af6 28 PinName pin;
AnnaBridge 146:22da6e220af6 29 } gpio_t;
AnnaBridge 146:22da6e220af6 30
AnnaBridge 146:22da6e220af6 31 static inline void gpio_write(gpio_t *obj, int value) {
AnnaBridge 146:22da6e220af6 32 MBED_ASSERT(obj->pin != (PinName)NC);
AnnaBridge 146:22da6e220af6 33 if (value) {
AnnaBridge 146:22da6e220af6 34 nrf_gpio_pin_set(obj->pin);
AnnaBridge 146:22da6e220af6 35 } else {
AnnaBridge 146:22da6e220af6 36 nrf_gpio_pin_clear(obj->pin);
AnnaBridge 146:22da6e220af6 37 }
AnnaBridge 146:22da6e220af6 38 }
AnnaBridge 146:22da6e220af6 39
AnnaBridge 146:22da6e220af6 40 static inline int gpio_is_connected(const gpio_t *obj) {
AnnaBridge 146:22da6e220af6 41 return obj->pin != (PinName)NC;
AnnaBridge 146:22da6e220af6 42 }
AnnaBridge 146:22da6e220af6 43
AnnaBridge 146:22da6e220af6 44 #ifdef __cplusplus
AnnaBridge 146:22da6e220af6 45 }
AnnaBridge 146:22da6e220af6 46 #endif
AnnaBridge 146:22da6e220af6 47
AnnaBridge 146:22da6e220af6 48 #endif