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.

Committer:
emilmont
Date:
Fri Feb 14 14:36:43 2014 +0000
Revision:
77:869cf507173a
Release 77 of the mbed library

Main changes:
* Add target NUCLEO_F030R8
* Add target NUCLEO_F401RE
* Add target NUCLEO_F103RB
* Add target NUCLEO_L152RE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 77:869cf507173a 1 /* mbed Microcontroller Library
emilmont 77:869cf507173a 2 * Copyright (c) 2006-2013 ARM Limited
emilmont 77:869cf507173a 3 *
emilmont 77:869cf507173a 4 * Licensed under the Apache License, Version 2.0 (the "License");
emilmont 77:869cf507173a 5 * you may not use this file except in compliance with the License.
emilmont 77:869cf507173a 6 * You may obtain a copy of the License at
emilmont 77:869cf507173a 7 *
emilmont 77:869cf507173a 8 * http://www.apache.org/licenses/LICENSE-2.0
emilmont 77:869cf507173a 9 *
emilmont 77:869cf507173a 10 * Unless required by applicable law or agreed to in writing, software
emilmont 77:869cf507173a 11 * distributed under the License is distributed on an "AS IS" BASIS,
emilmont 77:869cf507173a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
emilmont 77:869cf507173a 13 * See the License for the specific language governing permissions and
emilmont 77:869cf507173a 14 * limitations under the License.
emilmont 77:869cf507173a 15 */
emilmont 77:869cf507173a 16 #ifndef MBED_GPIO_OBJECT_H
emilmont 77:869cf507173a 17 #define MBED_GPIO_OBJECT_H
emilmont 77:869cf507173a 18
emilmont 77:869cf507173a 19 #ifdef __cplusplus
emilmont 77:869cf507173a 20 extern "C" {
emilmont 77:869cf507173a 21 #endif
emilmont 77:869cf507173a 22
emilmont 77:869cf507173a 23 typedef struct {
emilmont 77:869cf507173a 24 PinName pin;
emilmont 77:869cf507173a 25 uint32_t mask;
emilmont 77:869cf507173a 26
emilmont 77:869cf507173a 27 __IO uint32_t *reg_dir;
emilmont 77:869cf507173a 28 __IO uint32_t *reg_set;
emilmont 77:869cf507173a 29 __IO uint32_t *reg_clr;
emilmont 77:869cf507173a 30 __I uint32_t *reg_in;
emilmont 77:869cf507173a 31 } gpio_t;
emilmont 77:869cf507173a 32
emilmont 77:869cf507173a 33 static inline void gpio_write(gpio_t *obj, int value) {
emilmont 77:869cf507173a 34 if (value)
emilmont 77:869cf507173a 35 *obj->reg_set = obj->mask;
emilmont 77:869cf507173a 36 else
emilmont 77:869cf507173a 37 *obj->reg_clr = obj->mask;
emilmont 77:869cf507173a 38 }
emilmont 77:869cf507173a 39
emilmont 77:869cf507173a 40 static inline int gpio_read(gpio_t *obj) {
emilmont 77:869cf507173a 41 return ((*obj->reg_in & obj->mask) ? 1 : 0);
emilmont 77:869cf507173a 42 }
emilmont 77:869cf507173a 43
emilmont 77:869cf507173a 44 #ifdef __cplusplus
emilmont 77:869cf507173a 45 }
emilmont 77:869cf507173a 46 #endif
emilmont 77:869cf507173a 47
emilmont 77:869cf507173a 48 #endif