Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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