BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Committer:
gustavatmel
Date:
Tue May 01 15:55:34 2018 +0000
Revision:
2:798925c9e4a8
Parent:
1:9c5af431a1f1
bluetooth

Who changed what in which revision?

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