The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_KL05Z/gpio_object.h@78:ed8466a608b4, 2014-02-18 (annotated)
- Committer:
- emilmont
- Date:
- Tue Feb 18 15:02:39 2014 +0000
- Revision:
- 78:ed8466a608b4
Add KL05Z Target
Fix LPC11XX InterruptIn
Fix NUCLEO boards us_ticker
Fix NUCLEO_L152RE AnalogOut
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 78:ed8466a608b4 | 1 | /* mbed Microcontroller Library |
emilmont | 78:ed8466a608b4 | 2 | * Copyright (c) 2006-2013 ARM Limited |
emilmont | 78:ed8466a608b4 | 3 | * |
emilmont | 78:ed8466a608b4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
emilmont | 78:ed8466a608b4 | 5 | * you may not use this file except in compliance with the License. |
emilmont | 78:ed8466a608b4 | 6 | * You may obtain a copy of the License at |
emilmont | 78:ed8466a608b4 | 7 | * |
emilmont | 78:ed8466a608b4 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
emilmont | 78:ed8466a608b4 | 9 | * |
emilmont | 78:ed8466a608b4 | 10 | * Unless required by applicable law or agreed to in writing, software |
emilmont | 78:ed8466a608b4 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
emilmont | 78:ed8466a608b4 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
emilmont | 78:ed8466a608b4 | 13 | * See the License for the specific language governing permissions and |
emilmont | 78:ed8466a608b4 | 14 | * limitations under the License. |
emilmont | 78:ed8466a608b4 | 15 | */ |
emilmont | 78:ed8466a608b4 | 16 | #ifndef MBED_GPIO_OBJECT_H |
emilmont | 78:ed8466a608b4 | 17 | #define MBED_GPIO_OBJECT_H |
emilmont | 78:ed8466a608b4 | 18 | |
emilmont | 78:ed8466a608b4 | 19 | #ifdef __cplusplus |
emilmont | 78:ed8466a608b4 | 20 | extern "C" { |
emilmont | 78:ed8466a608b4 | 21 | #endif |
emilmont | 78:ed8466a608b4 | 22 | |
emilmont | 78:ed8466a608b4 | 23 | typedef struct { |
emilmont | 78:ed8466a608b4 | 24 | PinName pin; |
emilmont | 78:ed8466a608b4 | 25 | uint32_t mask; |
emilmont | 78:ed8466a608b4 | 26 | |
emilmont | 78:ed8466a608b4 | 27 | __IO uint32_t *reg_dir; |
emilmont | 78:ed8466a608b4 | 28 | __IO uint32_t *reg_set; |
emilmont | 78:ed8466a608b4 | 29 | __IO uint32_t *reg_clr; |
emilmont | 78:ed8466a608b4 | 30 | __I uint32_t *reg_in; |
emilmont | 78:ed8466a608b4 | 31 | } gpio_t; |
emilmont | 78:ed8466a608b4 | 32 | |
emilmont | 78:ed8466a608b4 | 33 | static inline void gpio_write(gpio_t *obj, int value) { |
emilmont | 78:ed8466a608b4 | 34 | if (value) |
emilmont | 78:ed8466a608b4 | 35 | *obj->reg_set = obj->mask; |
emilmont | 78:ed8466a608b4 | 36 | else |
emilmont | 78:ed8466a608b4 | 37 | *obj->reg_clr = obj->mask; |
emilmont | 78:ed8466a608b4 | 38 | } |
emilmont | 78:ed8466a608b4 | 39 | |
emilmont | 78:ed8466a608b4 | 40 | static inline int gpio_read(gpio_t *obj) { |
emilmont | 78:ed8466a608b4 | 41 | return ((*obj->reg_in & obj->mask) ? 1 : 0); |
emilmont | 78:ed8466a608b4 | 42 | } |
emilmont | 78:ed8466a608b4 | 43 | |
emilmont | 78:ed8466a608b4 | 44 | #ifdef __cplusplus |
emilmont | 78:ed8466a608b4 | 45 | } |
emilmont | 78:ed8466a608b4 | 46 | #endif |
emilmont | 78:ed8466a608b4 | 47 | |
emilmont | 78:ed8466a608b4 | 48 | #endif |