the do / gr-peach-opencv-project

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Thu Jun 29 11:01:39 2017 +0000
Revision:
167:1657b442184c
Opencv 3.1 project on GR-PEACH board, 4 apps

Who changed what in which revision?

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