Modified mbed library sources only for STM32F030K6, LQFP32 (0.8mm pitch) package, 32K Flash, 4K SRAM. Compiler target: Nucleo 32F030R8
Fork of mbed-src by
common/gpio.c@113:65a335a675de, 2014-03-10 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Mar 10 11:30:07 2014 +0000
- Revision:
- 113:65a335a675de
- Child:
- 127:ce7cebc0511f
Synchronized with git revision 423ddcb86e83e2e0d599ca7106d436eb3c47e6dd
Full URL: https://github.com/mbedmicro/mbed/commit/423ddcb86e83e2e0d599ca7106d436eb3c47e6dd/
proposed change of gpio_api (new update pull request)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 113:65a335a675de | 1 | /* mbed Microcontroller Library |
mbed_official | 113:65a335a675de | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 113:65a335a675de | 3 | * |
mbed_official | 113:65a335a675de | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 113:65a335a675de | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 113:65a335a675de | 6 | * You may obtain a copy of the License at |
mbed_official | 113:65a335a675de | 7 | * |
mbed_official | 113:65a335a675de | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 113:65a335a675de | 9 | * |
mbed_official | 113:65a335a675de | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 113:65a335a675de | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 113:65a335a675de | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 113:65a335a675de | 13 | * See the License for the specific language governing permissions and |
mbed_official | 113:65a335a675de | 14 | * limitations under the License. |
mbed_official | 113:65a335a675de | 15 | */ |
mbed_official | 113:65a335a675de | 16 | #include "gpio_api.h" |
mbed_official | 113:65a335a675de | 17 | |
mbed_official | 113:65a335a675de | 18 | static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode) |
mbed_official | 113:65a335a675de | 19 | { |
mbed_official | 113:65a335a675de | 20 | gpio_init(gpio, pin); |
mbed_official | 113:65a335a675de | 21 | gpio_mode(gpio, mode); |
mbed_official | 113:65a335a675de | 22 | gpio_dir(gpio, PIN_INPUT); |
mbed_official | 113:65a335a675de | 23 | } |
mbed_official | 113:65a335a675de | 24 | |
mbed_official | 113:65a335a675de | 25 | static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value) |
mbed_official | 113:65a335a675de | 26 | { |
mbed_official | 113:65a335a675de | 27 | gpio_init(gpio, pin); |
mbed_official | 113:65a335a675de | 28 | gpio_write(gpio, value); |
mbed_official | 113:65a335a675de | 29 | gpio_dir(gpio, PIN_OUTPUT); |
mbed_official | 113:65a335a675de | 30 | gpio_mode(gpio, mode); |
mbed_official | 113:65a335a675de | 31 | } |
mbed_official | 113:65a335a675de | 32 | |
mbed_official | 113:65a335a675de | 33 | void gpio_init_in(gpio_t* gpio, PinName pin) { |
mbed_official | 113:65a335a675de | 34 | gpio_init_in_ex(gpio, pin, PullDefault); |
mbed_official | 113:65a335a675de | 35 | } |
mbed_official | 113:65a335a675de | 36 | |
mbed_official | 113:65a335a675de | 37 | void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode) { |
mbed_official | 113:65a335a675de | 38 | _gpio_init_in(gpio, pin, mode); |
mbed_official | 113:65a335a675de | 39 | } |
mbed_official | 113:65a335a675de | 40 | |
mbed_official | 113:65a335a675de | 41 | void gpio_init_out(gpio_t* gpio, PinName pin) { |
mbed_official | 113:65a335a675de | 42 | gpio_init_out_ex(gpio, pin, 0); |
mbed_official | 113:65a335a675de | 43 | } |
mbed_official | 113:65a335a675de | 44 | |
mbed_official | 113:65a335a675de | 45 | void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value) { |
mbed_official | 113:65a335a675de | 46 | _gpio_init_out(gpio, pin, PullNone, value); |
mbed_official | 113:65a335a675de | 47 | } |
mbed_official | 113:65a335a675de | 48 | |
mbed_official | 113:65a335a675de | 49 | void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) { |
mbed_official | 113:65a335a675de | 50 | if (direction == PIN_INPUT) { |
mbed_official | 113:65a335a675de | 51 | _gpio_init_in(gpio, pin, mode); |
mbed_official | 113:65a335a675de | 52 | gpio_write(gpio, value); // we prepare the value in case it is switched later |
mbed_official | 113:65a335a675de | 53 | } else { |
mbed_official | 113:65a335a675de | 54 | _gpio_init_out(gpio, pin, mode, value); |
mbed_official | 113:65a335a675de | 55 | } |
mbed_official | 113:65a335a675de | 56 | } |