Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
TARGET_SAMR21G18A/TOOLCHAIN_ARM_MICRO/gpio_object.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
 - AnnaBridge
 - Date:
 - Wed Feb 20 20:53:29 2019 +0000
 - Revision:
 - 172:65be27845400
 - Parent:
 - 171:3a7713b1edbc
 
mbed library release version 165
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| Kojto | 111:4336505e4b1c | 1 | /* mbed Microcontroller Library | 
| Kojto | 111:4336505e4b1c | 2 | * Copyright (c) 2006-2015 ARM Limited | 
| Kojto | 111:4336505e4b1c | 3 | * | 
| Kojto | 111:4336505e4b1c | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
| Kojto | 111:4336505e4b1c | 5 | * you may not use this file except in compliance with the License. | 
| Kojto | 111:4336505e4b1c | 6 | * You may obtain a copy of the License at | 
| Kojto | 111:4336505e4b1c | 7 | * | 
| Kojto | 111:4336505e4b1c | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | 
| Kojto | 111:4336505e4b1c | 9 | * | 
| Kojto | 111:4336505e4b1c | 10 | * Unless required by applicable law or agreed to in writing, software | 
| Kojto | 111:4336505e4b1c | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
| Kojto | 111:4336505e4b1c | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| Kojto | 111:4336505e4b1c | 13 | * See the License for the specific language governing permissions and | 
| Kojto | 111:4336505e4b1c | 14 | * limitations under the License. | 
| Kojto | 111:4336505e4b1c | 15 | */ | 
| Kojto | 111:4336505e4b1c | 16 | #ifndef MBED_GPIO_OBJECT_H | 
| Kojto | 111:4336505e4b1c | 17 | #define MBED_GPIO_OBJECT_H | 
| Kojto | 111:4336505e4b1c | 18 | |
| Kojto | 111:4336505e4b1c | 19 | #include "mbed_assert.h" | 
| Kojto | 111:4336505e4b1c | 20 | |
| Kojto | 111:4336505e4b1c | 21 | #ifdef __cplusplus | 
| Kojto | 111:4336505e4b1c | 22 | extern "C" { | 
| Kojto | 111:4336505e4b1c | 23 | #endif | 
| Kojto | 111:4336505e4b1c | 24 | |
| Kojto | 111:4336505e4b1c | 25 | typedef struct { | 
| Kojto | 111:4336505e4b1c | 26 | PinName pin; | 
| Kojto | 111:4336505e4b1c | 27 | uint32_t mask; | 
| Kojto | 111:4336505e4b1c | 28 | uint8_t powersave; | 
| Kojto | 111:4336505e4b1c | 29 | uint8_t mode; | 
| Kojto | 111:4336505e4b1c | 30 | uint8_t direction; | 
| Kojto | 111:4336505e4b1c | 31 | |
| Kojto | 111:4336505e4b1c | 32 | __IO uint32_t *OUTCLR; | 
| Kojto | 111:4336505e4b1c | 33 | __IO uint32_t *OUTSET; | 
| Kojto | 111:4336505e4b1c | 34 | __I uint32_t *IN; | 
| Kojto | 111:4336505e4b1c | 35 | __I uint32_t *OUT; | 
| Kojto | 111:4336505e4b1c | 36 | } gpio_t; | 
| Kojto | 111:4336505e4b1c | 37 | |
| Kojto | 111:4336505e4b1c | 38 | static inline void gpio_write(gpio_t *obj, int value) | 
| Kojto | 111:4336505e4b1c | 39 | { | 
| Kojto | 111:4336505e4b1c | 40 | MBED_ASSERT(obj->pin != (PinName)NC); | 
| Kojto | 111:4336505e4b1c | 41 | if (value) | 
| Kojto | 111:4336505e4b1c | 42 | *obj->OUTSET = obj->mask; | 
| Kojto | 111:4336505e4b1c | 43 | else | 
| Kojto | 111:4336505e4b1c | 44 | *obj->OUTCLR = obj->mask; | 
| Kojto | 111:4336505e4b1c | 45 | } | 
| Kojto | 111:4336505e4b1c | 46 | |
| Kojto | 111:4336505e4b1c | 47 | static inline int gpio_read(gpio_t *obj) | 
| Kojto | 111:4336505e4b1c | 48 | { | 
| Kojto | 111:4336505e4b1c | 49 | MBED_ASSERT(obj->pin != (PinName)NC); | 
| Kojto | 111:4336505e4b1c | 50 | if (obj->direction == PIN_INPUT) | 
| Kojto | 111:4336505e4b1c | 51 | return ((*obj->IN & obj->mask) ? 1 : 0); | 
| Kojto | 111:4336505e4b1c | 52 | else | 
| Kojto | 111:4336505e4b1c | 53 | return ((*obj->OUT & obj->mask) ? 1 : 0); | 
| Kojto | 111:4336505e4b1c | 54 | } | 
| Kojto | 111:4336505e4b1c | 55 | |
| Kojto | 111:4336505e4b1c | 56 | static inline int gpio_is_connected(const gpio_t *obj) | 
| Kojto | 111:4336505e4b1c | 57 | { | 
| Kojto | 111:4336505e4b1c | 58 | return obj->pin != (PinName)NC; | 
| Kojto | 111:4336505e4b1c | 59 | } | 
| Kojto | 111:4336505e4b1c | 60 | |
| Kojto | 111:4336505e4b1c | 61 | #ifdef __cplusplus | 
| Kojto | 111:4336505e4b1c | 62 | } | 
| Kojto | 111:4336505e4b1c | 63 | #endif | 
| Kojto | 111:4336505e4b1c | 64 | |
| Kojto | 111:4336505e4b1c | 65 | #endif | 


