RTC auf true
hal/mbed_gpio.c@0:38ceb79fef03, 2018-11-28 (annotated)
- Committer:
- kevman
- Date:
- Wed Nov 28 15:10:15 2018 +0000
- Revision:
- 0:38ceb79fef03
RTC modified
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kevman | 0:38ceb79fef03 | 1 | /* mbed Microcontroller Library |
kevman | 0:38ceb79fef03 | 2 | * Copyright (c) 2006-2013 ARM Limited |
kevman | 0:38ceb79fef03 | 3 | * |
kevman | 0:38ceb79fef03 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kevman | 0:38ceb79fef03 | 5 | * you may not use this file except in compliance with the License. |
kevman | 0:38ceb79fef03 | 6 | * You may obtain a copy of the License at |
kevman | 0:38ceb79fef03 | 7 | * |
kevman | 0:38ceb79fef03 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
kevman | 0:38ceb79fef03 | 9 | * |
kevman | 0:38ceb79fef03 | 10 | * Unless required by applicable law or agreed to in writing, software |
kevman | 0:38ceb79fef03 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
kevman | 0:38ceb79fef03 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kevman | 0:38ceb79fef03 | 13 | * See the License for the specific language governing permissions and |
kevman | 0:38ceb79fef03 | 14 | * limitations under the License. |
kevman | 0:38ceb79fef03 | 15 | */ |
kevman | 0:38ceb79fef03 | 16 | #include "hal/gpio_api.h" |
kevman | 0:38ceb79fef03 | 17 | |
kevman | 0:38ceb79fef03 | 18 | static inline void _gpio_init_in(gpio_t *gpio, PinName pin, PinMode mode) |
kevman | 0:38ceb79fef03 | 19 | { |
kevman | 0:38ceb79fef03 | 20 | gpio_init(gpio, pin); |
kevman | 0:38ceb79fef03 | 21 | if (pin != NC) { |
kevman | 0:38ceb79fef03 | 22 | gpio_dir(gpio, PIN_INPUT); |
kevman | 0:38ceb79fef03 | 23 | gpio_mode(gpio, mode); |
kevman | 0:38ceb79fef03 | 24 | } |
kevman | 0:38ceb79fef03 | 25 | } |
kevman | 0:38ceb79fef03 | 26 | |
kevman | 0:38ceb79fef03 | 27 | static inline void _gpio_init_out(gpio_t *gpio, PinName pin, PinMode mode, int value) |
kevman | 0:38ceb79fef03 | 28 | { |
kevman | 0:38ceb79fef03 | 29 | gpio_init(gpio, pin); |
kevman | 0:38ceb79fef03 | 30 | if (pin != NC) { |
kevman | 0:38ceb79fef03 | 31 | gpio_write(gpio, value); |
kevman | 0:38ceb79fef03 | 32 | gpio_dir(gpio, PIN_OUTPUT); |
kevman | 0:38ceb79fef03 | 33 | gpio_mode(gpio, mode); |
kevman | 0:38ceb79fef03 | 34 | } |
kevman | 0:38ceb79fef03 | 35 | } |
kevman | 0:38ceb79fef03 | 36 | |
kevman | 0:38ceb79fef03 | 37 | void gpio_init_in(gpio_t *gpio, PinName pin) |
kevman | 0:38ceb79fef03 | 38 | { |
kevman | 0:38ceb79fef03 | 39 | gpio_init_in_ex(gpio, pin, PullDefault); |
kevman | 0:38ceb79fef03 | 40 | } |
kevman | 0:38ceb79fef03 | 41 | |
kevman | 0:38ceb79fef03 | 42 | void gpio_init_in_ex(gpio_t *gpio, PinName pin, PinMode mode) |
kevman | 0:38ceb79fef03 | 43 | { |
kevman | 0:38ceb79fef03 | 44 | _gpio_init_in(gpio, pin, mode); |
kevman | 0:38ceb79fef03 | 45 | } |
kevman | 0:38ceb79fef03 | 46 | |
kevman | 0:38ceb79fef03 | 47 | void gpio_init_out(gpio_t *gpio, PinName pin) |
kevman | 0:38ceb79fef03 | 48 | { |
kevman | 0:38ceb79fef03 | 49 | gpio_init_out_ex(gpio, pin, 0); |
kevman | 0:38ceb79fef03 | 50 | } |
kevman | 0:38ceb79fef03 | 51 | |
kevman | 0:38ceb79fef03 | 52 | void gpio_init_out_ex(gpio_t *gpio, PinName pin, int value) |
kevman | 0:38ceb79fef03 | 53 | { |
kevman | 0:38ceb79fef03 | 54 | _gpio_init_out(gpio, pin, PullNone, value); |
kevman | 0:38ceb79fef03 | 55 | } |
kevman | 0:38ceb79fef03 | 56 | |
kevman | 0:38ceb79fef03 | 57 | void gpio_init_inout(gpio_t *gpio, PinName pin, PinDirection direction, PinMode mode, int value) |
kevman | 0:38ceb79fef03 | 58 | { |
kevman | 0:38ceb79fef03 | 59 | if (direction == PIN_INPUT) { |
kevman | 0:38ceb79fef03 | 60 | _gpio_init_in(gpio, pin, mode); |
kevman | 0:38ceb79fef03 | 61 | if (pin != NC) { |
kevman | 0:38ceb79fef03 | 62 | gpio_write(gpio, value); // we prepare the value in case it is switched later |
kevman | 0:38ceb79fef03 | 63 | } |
kevman | 0:38ceb79fef03 | 64 | } else { |
kevman | 0:38ceb79fef03 | 65 | _gpio_init_out(gpio, pin, mode, value); |
kevman | 0:38ceb79fef03 | 66 | } |
kevman | 0:38ceb79fef03 | 67 | } |