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:
Kojto
Date:
Wed Jul 19 16:46:19 2017 +0100
Revision:
147:a97add6d7e64
Parent:
99:dbbf35b96557
Release 147 of the mbed library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 99:dbbf35b96557 1 /*******************************************************************************
Kojto 99:dbbf35b96557 2 * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved.
Kojto 99:dbbf35b96557 3 *
Kojto 99:dbbf35b96557 4 * Permission is hereby granted, free of charge, to any person obtaining a
Kojto 99:dbbf35b96557 5 * copy of this software and associated documentation files (the "Software"),
Kojto 99:dbbf35b96557 6 * to deal in the Software without restriction, including without limitation
Kojto 99:dbbf35b96557 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Kojto 99:dbbf35b96557 8 * and/or sell copies of the Software, and to permit persons to whom the
Kojto 99:dbbf35b96557 9 * Software is furnished to do so, subject to the following conditions:
Kojto 99:dbbf35b96557 10 *
Kojto 99:dbbf35b96557 11 * The above copyright notice and this permission notice shall be included
Kojto 99:dbbf35b96557 12 * in all copies or substantial portions of the Software.
Kojto 99:dbbf35b96557 13 *
Kojto 99:dbbf35b96557 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
Kojto 99:dbbf35b96557 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Kojto 99:dbbf35b96557 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Kojto 99:dbbf35b96557 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
Kojto 99:dbbf35b96557 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
Kojto 99:dbbf35b96557 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Kojto 99:dbbf35b96557 20 * OTHER DEALINGS IN THE SOFTWARE.
Kojto 99:dbbf35b96557 21 *
Kojto 99:dbbf35b96557 22 * Except as contained in this notice, the name of Maxim Integrated
Kojto 99:dbbf35b96557 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
Kojto 99:dbbf35b96557 24 * Products, Inc. Branding Policy.
Kojto 99:dbbf35b96557 25 *
Kojto 99:dbbf35b96557 26 * The mere transfer of this software does not imply any licenses
Kojto 99:dbbf35b96557 27 * of trade secrets, proprietary technology, copyrights, patents,
Kojto 99:dbbf35b96557 28 * trademarks, maskwork rights, or any other form of intellectual
Kojto 99:dbbf35b96557 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
Kojto 99:dbbf35b96557 30 * ownership rights.
Kojto 99:dbbf35b96557 31 *******************************************************************************
Kojto 99:dbbf35b96557 32 */
Kojto 99:dbbf35b96557 33
Kojto 99:dbbf35b96557 34 #ifndef MBED_GPIO_OBJECT_H
Kojto 99:dbbf35b96557 35 #define MBED_GPIO_OBJECT_H
Kojto 99:dbbf35b96557 36
Kojto 99:dbbf35b96557 37 #include "mbed_assert.h"
Kojto 99:dbbf35b96557 38
Kojto 99:dbbf35b96557 39 #ifdef __cplusplus
Kojto 99:dbbf35b96557 40 extern "C" {
Kojto 99:dbbf35b96557 41 #endif
Kojto 99:dbbf35b96557 42
Kojto 99:dbbf35b96557 43 typedef struct {
Kojto 99:dbbf35b96557 44 PinName name;
Kojto 99:dbbf35b96557 45 __IO uint32_t *reg_out;
Kojto 99:dbbf35b96557 46 __I uint32_t *reg_in;
Kojto 99:dbbf35b96557 47 } gpio_t;
Kojto 99:dbbf35b96557 48
Kojto 99:dbbf35b96557 49 static inline void gpio_write(gpio_t *obj, int value)
Kojto 99:dbbf35b96557 50 {
Kojto 99:dbbf35b96557 51 MBED_ASSERT(obj->name != (PinName)NC);
Kojto 99:dbbf35b96557 52 *obj->reg_out = !!value;
Kojto 99:dbbf35b96557 53 }
Kojto 99:dbbf35b96557 54
Kojto 99:dbbf35b96557 55 static inline int gpio_read(gpio_t *obj)
Kojto 99:dbbf35b96557 56 {
Kojto 99:dbbf35b96557 57 MBED_ASSERT(obj->name != (PinName)NC);
Kojto 99:dbbf35b96557 58 return *obj->reg_in;
Kojto 99:dbbf35b96557 59 }
Kojto 99:dbbf35b96557 60
Kojto 99:dbbf35b96557 61 void pin_dir(PinName name, PinDirection direction);
Kojto 99:dbbf35b96557 62
Kojto 99:dbbf35b96557 63 static inline int gpio_is_connected(const gpio_t *obj) {
Kojto 99:dbbf35b96557 64 return obj->name != (PinName)NC;
Kojto 99:dbbf35b96557 65 }
Kojto 99:dbbf35b96557 66
Kojto 99:dbbf35b96557 67 #ifdef __cplusplus
Kojto 99:dbbf35b96557 68 }
Kojto 99:dbbf35b96557 69 #endif
Kojto 99:dbbf35b96557 70
Kojto 99:dbbf35b96557 71 #endif