Tim Barry / mbed_blinky_offset
Committer:
timbobazza
Date:
Sat Oct 04 09:07:08 2014 +0000
Revision:
0:2173789ea697
First version

Who changed what in which revision?

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