Erste version der Software für der Prototyp

Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
0:380207fcb5c1
commentar

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:380207fcb5c1 1
borlanic 0:380207fcb5c1 2 /** \addtogroup hal */
borlanic 0:380207fcb5c1 3 /** @{*/
borlanic 0:380207fcb5c1 4 /* mbed Microcontroller Library
borlanic 0:380207fcb5c1 5 * Copyright (c) 2006-2013 ARM Limited
borlanic 0:380207fcb5c1 6 *
borlanic 0:380207fcb5c1 7 * Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:380207fcb5c1 8 * you may not use this file except in compliance with the License.
borlanic 0:380207fcb5c1 9 * You may obtain a copy of the License at
borlanic 0:380207fcb5c1 10 *
borlanic 0:380207fcb5c1 11 * http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:380207fcb5c1 12 *
borlanic 0:380207fcb5c1 13 * Unless required by applicable law or agreed to in writing, software
borlanic 0:380207fcb5c1 14 * distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:380207fcb5c1 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:380207fcb5c1 16 * See the License for the specific language governing permissions and
borlanic 0:380207fcb5c1 17 * limitations under the License.
borlanic 0:380207fcb5c1 18 */
borlanic 0:380207fcb5c1 19 #ifndef MBED_GPIO_API_H
borlanic 0:380207fcb5c1 20 #define MBED_GPIO_API_H
borlanic 0:380207fcb5c1 21
borlanic 0:380207fcb5c1 22 #include <stdint.h>
borlanic 0:380207fcb5c1 23 #include "device.h"
borlanic 0:380207fcb5c1 24
borlanic 0:380207fcb5c1 25 #ifdef __cplusplus
borlanic 0:380207fcb5c1 26 extern "C" {
borlanic 0:380207fcb5c1 27 #endif
borlanic 0:380207fcb5c1 28
borlanic 0:380207fcb5c1 29 /**
borlanic 0:380207fcb5c1 30 * \defgroup hal_gpio GPIO HAL functions
borlanic 0:380207fcb5c1 31 * @{
borlanic 0:380207fcb5c1 32 */
borlanic 0:380207fcb5c1 33
borlanic 0:380207fcb5c1 34 /** Set the given pin as GPIO
borlanic 0:380207fcb5c1 35 *
borlanic 0:380207fcb5c1 36 * @param pin The pin to be set as GPIO
borlanic 0:380207fcb5c1 37 * @return The GPIO port mask for this pin
borlanic 0:380207fcb5c1 38 **/
borlanic 0:380207fcb5c1 39 uint32_t gpio_set(PinName pin);
borlanic 0:380207fcb5c1 40 /* Checks if gpio object is connected (pin was not initialized with NC)
borlanic 0:380207fcb5c1 41 * @param pin The pin to be set as GPIO
borlanic 0:380207fcb5c1 42 * @return 0 if port is initialized with NC
borlanic 0:380207fcb5c1 43 **/
borlanic 0:380207fcb5c1 44 int gpio_is_connected(const gpio_t *obj);
borlanic 0:380207fcb5c1 45
borlanic 0:380207fcb5c1 46 /** Initialize the GPIO pin
borlanic 0:380207fcb5c1 47 *
borlanic 0:380207fcb5c1 48 * @param obj The GPIO object to initialize
borlanic 0:380207fcb5c1 49 * @param pin The GPIO pin to initialize
borlanic 0:380207fcb5c1 50 */
borlanic 0:380207fcb5c1 51 void gpio_init(gpio_t *obj, PinName pin);
borlanic 0:380207fcb5c1 52
borlanic 0:380207fcb5c1 53 /** Set the input pin mode
borlanic 0:380207fcb5c1 54 *
borlanic 0:380207fcb5c1 55 * @param obj The GPIO object
borlanic 0:380207fcb5c1 56 * @param mode The pin mode to be set
borlanic 0:380207fcb5c1 57 */
borlanic 0:380207fcb5c1 58 void gpio_mode(gpio_t *obj, PinMode mode);
borlanic 0:380207fcb5c1 59
borlanic 0:380207fcb5c1 60 /** Set the pin direction
borlanic 0:380207fcb5c1 61 *
borlanic 0:380207fcb5c1 62 * @param obj The GPIO object
borlanic 0:380207fcb5c1 63 * @param direction The pin direction to be set
borlanic 0:380207fcb5c1 64 */
borlanic 0:380207fcb5c1 65 void gpio_dir(gpio_t *obj, PinDirection direction);
borlanic 0:380207fcb5c1 66
borlanic 0:380207fcb5c1 67 /** Set the output value
borlanic 0:380207fcb5c1 68 *
borlanic 0:380207fcb5c1 69 * @param obj The GPIO object
borlanic 0:380207fcb5c1 70 * @param value The value to be set
borlanic 0:380207fcb5c1 71 */
borlanic 0:380207fcb5c1 72 void gpio_write(gpio_t *obj, int value);
borlanic 0:380207fcb5c1 73
borlanic 0:380207fcb5c1 74 /** Read the input value
borlanic 0:380207fcb5c1 75 *
borlanic 0:380207fcb5c1 76 * @param obj The GPIO object
borlanic 0:380207fcb5c1 77 * @return An integer value 1 or 0
borlanic 0:380207fcb5c1 78 */
borlanic 0:380207fcb5c1 79 int gpio_read(gpio_t *obj);
borlanic 0:380207fcb5c1 80
borlanic 0:380207fcb5c1 81 // the following functions are generic and implemented in the common gpio.c file
borlanic 0:380207fcb5c1 82 // TODO: fix, will be moved to the common gpio header file
borlanic 0:380207fcb5c1 83
borlanic 0:380207fcb5c1 84 /** Init the input pin and set mode to PullDefault
borlanic 0:380207fcb5c1 85 *
borlanic 0:380207fcb5c1 86 * @param gpio The GPIO object
borlanic 0:380207fcb5c1 87 * @param pin The pin name
borlanic 0:380207fcb5c1 88 */
borlanic 0:380207fcb5c1 89 void gpio_init_in(gpio_t* gpio, PinName pin);
borlanic 0:380207fcb5c1 90
borlanic 0:380207fcb5c1 91 /** Init the input pin and set the mode
borlanic 0:380207fcb5c1 92 *
borlanic 0:380207fcb5c1 93 * @param gpio The GPIO object
borlanic 0:380207fcb5c1 94 * @param pin The pin name
borlanic 0:380207fcb5c1 95 * @param mode The pin mode to be set
borlanic 0:380207fcb5c1 96 */
borlanic 0:380207fcb5c1 97 void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode);
borlanic 0:380207fcb5c1 98
borlanic 0:380207fcb5c1 99 /** Init the output pin as an output, with predefined output value 0
borlanic 0:380207fcb5c1 100 *
borlanic 0:380207fcb5c1 101 * @param gpio The GPIO object
borlanic 0:380207fcb5c1 102 * @param pin The pin name
borlanic 0:380207fcb5c1 103 * @return An integer value 1 or 0
borlanic 0:380207fcb5c1 104 */
borlanic 0:380207fcb5c1 105 void gpio_init_out(gpio_t* gpio, PinName pin);
borlanic 0:380207fcb5c1 106
borlanic 0:380207fcb5c1 107 /** Init the pin as an output and set the output value
borlanic 0:380207fcb5c1 108 *
borlanic 0:380207fcb5c1 109 * @param gpio The GPIO object
borlanic 0:380207fcb5c1 110 * @param pin The pin name
borlanic 0:380207fcb5c1 111 * @param value The value to be set
borlanic 0:380207fcb5c1 112 */
borlanic 0:380207fcb5c1 113 void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value);
borlanic 0:380207fcb5c1 114
borlanic 0:380207fcb5c1 115 /** Init the pin to be in/out
borlanic 0:380207fcb5c1 116 *
borlanic 0:380207fcb5c1 117 * @param gpio The GPIO object
borlanic 0:380207fcb5c1 118 * @param pin The pin name
borlanic 0:380207fcb5c1 119 * @param direction The pin direction to be set
borlanic 0:380207fcb5c1 120 * @param mode The pin mode to be set
borlanic 0:380207fcb5c1 121 * @param value The value to be set for an output pin
borlanic 0:380207fcb5c1 122 */
borlanic 0:380207fcb5c1 123 void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value);
borlanic 0:380207fcb5c1 124
borlanic 0:380207fcb5c1 125 /**@}*/
borlanic 0:380207fcb5c1 126
borlanic 0:380207fcb5c1 127 #ifdef __cplusplus
borlanic 0:380207fcb5c1 128 }
borlanic 0:380207fcb5c1 129 #endif
borlanic 0:380207fcb5c1 130
borlanic 0:380207fcb5c1 131 #endif
borlanic 0:380207fcb5c1 132
borlanic 0:380207fcb5c1 133 /** @}*/