USB Serial application

Fork of USBSerial_HelloWorld by Samuel Mokrani

Committer:
Zaitsev
Date:
Tue Jan 10 20:42:26 2017 +0000
Revision:
10:41552d038a69
USB Serial bi-directional bridge

Who changed what in which revision?

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