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: mbed_blinky-bmd-200 bmd-200_accel_demo firstRig
Fork of mbed-src by
targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/gpio_object.h@592:5e2eb8beba71, 2015-07-10 (annotated)
- Committer:
- dcnichols
- Date:
- Fri Jul 10 17:36:27 2015 +0000
- Revision:
- 592:5e2eb8beba71
- Parent:
- 458:8bc3a354916d
updating to latest mbed-src
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 324:406fd2029f23 | 1 | /* mbed Microcontroller Library |
mbed_official | 324:406fd2029f23 | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 324:406fd2029f23 | 3 | * |
mbed_official | 324:406fd2029f23 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 324:406fd2029f23 | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 324:406fd2029f23 | 6 | * You may obtain a copy of the License at |
mbed_official | 324:406fd2029f23 | 7 | * |
mbed_official | 324:406fd2029f23 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 324:406fd2029f23 | 9 | * |
mbed_official | 324:406fd2029f23 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 324:406fd2029f23 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 324:406fd2029f23 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 324:406fd2029f23 | 13 | * See the License for the specific language governing permissions and |
mbed_official | 324:406fd2029f23 | 14 | * limitations under the License. |
mbed_official | 324:406fd2029f23 | 15 | */ |
mbed_official | 324:406fd2029f23 | 16 | #ifndef MBED_GPIO_OBJECT_H |
mbed_official | 324:406fd2029f23 | 17 | #define MBED_GPIO_OBJECT_H |
mbed_official | 324:406fd2029f23 | 18 | |
mbed_official | 324:406fd2029f23 | 19 | #include "mbed_assert.h" |
mbed_official | 324:406fd2029f23 | 20 | #include "fsl_gpio_hal.h" |
mbed_official | 324:406fd2029f23 | 21 | // #include "cmsis.h" |
mbed_official | 324:406fd2029f23 | 22 | |
mbed_official | 324:406fd2029f23 | 23 | #ifdef __cplusplus |
mbed_official | 324:406fd2029f23 | 24 | extern "C" { |
mbed_official | 324:406fd2029f23 | 25 | #endif |
mbed_official | 324:406fd2029f23 | 26 | |
mbed_official | 324:406fd2029f23 | 27 | typedef struct { |
mbed_official | 458:8bc3a354916d | 28 | PinName pin; |
mbed_official | 324:406fd2029f23 | 29 | } gpio_t; |
mbed_official | 324:406fd2029f23 | 30 | |
mbed_official | 324:406fd2029f23 | 31 | static inline void gpio_write(gpio_t *obj, int value) { |
mbed_official | 458:8bc3a354916d | 32 | MBED_ASSERT(obj->pin != (PinName)NC); |
mbed_official | 458:8bc3a354916d | 33 | uint32_t port = obj->pin >> GPIO_PORT_SHIFT; |
mbed_official | 458:8bc3a354916d | 34 | uint32_t pin = obj->pin & 0xFF; |
mbed_official | 324:406fd2029f23 | 35 | uint32_t gpio_addrs[] = GPIO_BASE_ADDRS; |
mbed_official | 324:406fd2029f23 | 36 | |
mbed_official | 324:406fd2029f23 | 37 | GPIO_HAL_WritePinOutput(gpio_addrs[port], pin, value); |
mbed_official | 324:406fd2029f23 | 38 | } |
mbed_official | 324:406fd2029f23 | 39 | |
mbed_official | 324:406fd2029f23 | 40 | static inline int gpio_read(gpio_t *obj) { |
mbed_official | 458:8bc3a354916d | 41 | MBED_ASSERT(obj->pin != (PinName)NC); |
mbed_official | 458:8bc3a354916d | 42 | uint32_t port = obj->pin >> GPIO_PORT_SHIFT; |
mbed_official | 458:8bc3a354916d | 43 | uint32_t pin = obj->pin & 0xFF; |
mbed_official | 324:406fd2029f23 | 44 | uint32_t gpio_addrs[] = GPIO_BASE_ADDRS; |
mbed_official | 324:406fd2029f23 | 45 | |
mbed_official | 324:406fd2029f23 | 46 | return (int)GPIO_HAL_ReadPinInput(gpio_addrs[port], pin); |
mbed_official | 324:406fd2029f23 | 47 | } |
mbed_official | 324:406fd2029f23 | 48 | |
mbed_official | 458:8bc3a354916d | 49 | static inline int gpio_is_connected(const gpio_t *obj) { |
mbed_official | 458:8bc3a354916d | 50 | return obj->pin != (PinName)NC; |
mbed_official | 458:8bc3a354916d | 51 | } |
mbed_official | 458:8bc3a354916d | 52 | |
mbed_official | 324:406fd2029f23 | 53 | #ifdef __cplusplus |
mbed_official | 324:406fd2029f23 | 54 | } |
mbed_official | 324:406fd2029f23 | 55 | #endif |
mbed_official | 324:406fd2029f23 | 56 | |
mbed_official | 324:406fd2029f23 | 57 | #endif |