meh
Fork of mbed by
TARGET_ARCH_PRO/TARGET_NXP/TARGET_LPC176X/gpio_object.h@86:04dd9b1680ae, 2014-07-02 (annotated)
- Committer:
- bogdanm
- Date:
- Wed Jul 02 13:22:23 2014 +0100
- Revision:
- 86:04dd9b1680ae
- Parent:
- 85:024bf7f99721
- Child:
- 93:e188a91d3eaa
Release 86 of the mbed library
Main changes:
- bug fixes in various backends
- mbed "error" replaced by assert logic (mbed_assert)
- new ST Nucleo targets
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 85:024bf7f99721 | 1 | /* mbed Microcontroller Library |
bogdanm | 85:024bf7f99721 | 2 | * Copyright (c) 2006-2013 ARM Limited |
bogdanm | 85:024bf7f99721 | 3 | * |
bogdanm | 85:024bf7f99721 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
bogdanm | 85:024bf7f99721 | 5 | * you may not use this file except in compliance with the License. |
bogdanm | 85:024bf7f99721 | 6 | * You may obtain a copy of the License at |
bogdanm | 85:024bf7f99721 | 7 | * |
bogdanm | 85:024bf7f99721 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
bogdanm | 85:024bf7f99721 | 9 | * |
bogdanm | 85:024bf7f99721 | 10 | * Unless required by applicable law or agreed to in writing, software |
bogdanm | 85:024bf7f99721 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
bogdanm | 85:024bf7f99721 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
bogdanm | 85:024bf7f99721 | 13 | * See the License for the specific language governing permissions and |
bogdanm | 85:024bf7f99721 | 14 | * limitations under the License. |
bogdanm | 85:024bf7f99721 | 15 | */ |
bogdanm | 85:024bf7f99721 | 16 | #ifndef MBED_GPIO_OBJECT_H |
bogdanm | 85:024bf7f99721 | 17 | #define MBED_GPIO_OBJECT_H |
bogdanm | 85:024bf7f99721 | 18 | |
bogdanm | 86:04dd9b1680ae | 19 | #include "mbed_assert.h" |
bogdanm | 86:04dd9b1680ae | 20 | |
bogdanm | 85:024bf7f99721 | 21 | #ifdef __cplusplus |
bogdanm | 85:024bf7f99721 | 22 | extern "C" { |
bogdanm | 85:024bf7f99721 | 23 | #endif |
bogdanm | 85:024bf7f99721 | 24 | |
bogdanm | 85:024bf7f99721 | 25 | typedef struct { |
bogdanm | 85:024bf7f99721 | 26 | PinName pin; |
bogdanm | 85:024bf7f99721 | 27 | uint32_t mask; |
bogdanm | 85:024bf7f99721 | 28 | |
bogdanm | 85:024bf7f99721 | 29 | __IO uint32_t *reg_dir; |
bogdanm | 85:024bf7f99721 | 30 | __IO uint32_t *reg_set; |
bogdanm | 85:024bf7f99721 | 31 | __IO uint32_t *reg_clr; |
bogdanm | 85:024bf7f99721 | 32 | __I uint32_t *reg_in; |
bogdanm | 85:024bf7f99721 | 33 | } gpio_t; |
bogdanm | 85:024bf7f99721 | 34 | |
bogdanm | 85:024bf7f99721 | 35 | static inline void gpio_write(gpio_t *obj, int value) { |
bogdanm | 86:04dd9b1680ae | 36 | MBED_ASSERT(obj->pin != (PinName)NC); |
bogdanm | 85:024bf7f99721 | 37 | if (value) |
bogdanm | 85:024bf7f99721 | 38 | *obj->reg_set = obj->mask; |
bogdanm | 85:024bf7f99721 | 39 | else |
bogdanm | 85:024bf7f99721 | 40 | *obj->reg_clr = obj->mask; |
bogdanm | 85:024bf7f99721 | 41 | } |
bogdanm | 85:024bf7f99721 | 42 | |
bogdanm | 85:024bf7f99721 | 43 | static inline int gpio_read(gpio_t *obj) { |
bogdanm | 86:04dd9b1680ae | 44 | MBED_ASSERT(obj->pin != (PinName)NC); |
bogdanm | 85:024bf7f99721 | 45 | return ((*obj->reg_in & obj->mask) ? 1 : 0); |
bogdanm | 85:024bf7f99721 | 46 | } |
bogdanm | 85:024bf7f99721 | 47 | |
bogdanm | 85:024bf7f99721 | 48 | #ifdef __cplusplus |
bogdanm | 85:024bf7f99721 | 49 | } |
bogdanm | 85:024bf7f99721 | 50 | #endif |
bogdanm | 85:024bf7f99721 | 51 | |
bogdanm | 85:024bf7f99721 | 52 | #endif |