mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_object.h@52:a51c77007319, 2013-12-02 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Dec 02 11:30:05 2013 +0000
- Revision:
- 52:a51c77007319
- Child:
- 70:c1fbde68b492
Synchronized with git revision 49df530ae72ce97ccc773d1f2c13b38e868e6abd
Full URL: https://github.com/mbedmicro/mbed/commit/49df530ae72ce97ccc773d1f2c13b38e868e6abd/
Add STMicroelectronics NUCLEO_F103RB target
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 52:a51c77007319 | 1 | /* mbed Microcontroller Library |
mbed_official | 52:a51c77007319 | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 52:a51c77007319 | 3 | * |
mbed_official | 52:a51c77007319 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 52:a51c77007319 | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 52:a51c77007319 | 6 | * You may obtain a copy of the License at |
mbed_official | 52:a51c77007319 | 7 | * |
mbed_official | 52:a51c77007319 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 52:a51c77007319 | 9 | * |
mbed_official | 52:a51c77007319 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 52:a51c77007319 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 52:a51c77007319 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 52:a51c77007319 | 13 | * See the License for the specific language governing permissions and |
mbed_official | 52:a51c77007319 | 14 | * limitations under the License. |
mbed_official | 52:a51c77007319 | 15 | */ |
mbed_official | 52:a51c77007319 | 16 | #ifndef MBED_GPIO_OBJECT_H |
mbed_official | 52:a51c77007319 | 17 | #define MBED_GPIO_OBJECT_H |
mbed_official | 52:a51c77007319 | 18 | |
mbed_official | 52:a51c77007319 | 19 | #include "cmsis.h" |
mbed_official | 52:a51c77007319 | 20 | #include "PortNames.h" |
mbed_official | 52:a51c77007319 | 21 | #include "PeripheralNames.h" |
mbed_official | 52:a51c77007319 | 22 | #include "PinNames.h" |
mbed_official | 52:a51c77007319 | 23 | |
mbed_official | 52:a51c77007319 | 24 | #ifdef __cplusplus |
mbed_official | 52:a51c77007319 | 25 | extern "C" { |
mbed_official | 52:a51c77007319 | 26 | #endif |
mbed_official | 52:a51c77007319 | 27 | |
mbed_official | 52:a51c77007319 | 28 | typedef struct { |
mbed_official | 52:a51c77007319 | 29 | PinName pin; |
mbed_official | 52:a51c77007319 | 30 | uint32_t mask; |
mbed_official | 52:a51c77007319 | 31 | __IO uint32_t *reg_in; |
mbed_official | 52:a51c77007319 | 32 | __IO uint32_t *reg_set; |
mbed_official | 52:a51c77007319 | 33 | __IO uint32_t *reg_clr; |
mbed_official | 52:a51c77007319 | 34 | } gpio_t; |
mbed_official | 52:a51c77007319 | 35 | |
mbed_official | 52:a51c77007319 | 36 | static inline void gpio_write(gpio_t *obj, int value) { |
mbed_official | 52:a51c77007319 | 37 | if (value) { |
mbed_official | 52:a51c77007319 | 38 | *obj->reg_set = obj->mask; |
mbed_official | 52:a51c77007319 | 39 | } |
mbed_official | 52:a51c77007319 | 40 | else { |
mbed_official | 52:a51c77007319 | 41 | *obj->reg_clr = obj->mask; |
mbed_official | 52:a51c77007319 | 42 | } |
mbed_official | 52:a51c77007319 | 43 | } |
mbed_official | 52:a51c77007319 | 44 | |
mbed_official | 52:a51c77007319 | 45 | static inline int gpio_read(gpio_t *obj) { |
mbed_official | 52:a51c77007319 | 46 | return ((*obj->reg_in & obj->mask) ? 1 : 0); |
mbed_official | 52:a51c77007319 | 47 | } |
mbed_official | 52:a51c77007319 | 48 | |
mbed_official | 52:a51c77007319 | 49 | #ifdef __cplusplus |
mbed_official | 52:a51c77007319 | 50 | } |
mbed_official | 52:a51c77007319 | 51 | #endif |
mbed_official | 52:a51c77007319 | 52 | |
mbed_official | 52:a51c77007319 | 53 | #endif |