mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

Committer:
bogdanm
Date:
Mon Aug 19 18:17:02 2013 +0300
Revision:
19:398f4c622e1b
Sync with official mbed library release 66

Who changed what in which revision?

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