mbed-os

Fork of mbed-os by erkin yucel

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

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