Update platform drivers
inc/gpio.h@8:70fc373a5f46, 2020-02-26 (annotated)
- Committer:
- mahphalke
- Date:
- Wed Feb 26 06:09:13 2020 +0000
- Revision:
- 8:70fc373a5f46
- Child:
- 9:9e247b9c9abf
Structured platform drivers similar to github version by splitting functionality from single file into multiple modules.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mahphalke | 8:70fc373a5f46 | 1 | /***************************************************************************//** |
mahphalke | 8:70fc373a5f46 | 2 | * @file gpio.h |
mahphalke | 8:70fc373a5f46 | 3 | * @author DBogdan (dragos.bogdan@analog.com) |
mahphalke | 8:70fc373a5f46 | 4 | ******************************************************************************** |
mahphalke | 8:70fc373a5f46 | 5 | * Copyright 2019(c) Analog Devices, Inc. |
mahphalke | 8:70fc373a5f46 | 6 | * |
mahphalke | 8:70fc373a5f46 | 7 | * All rights reserved. |
mahphalke | 8:70fc373a5f46 | 8 | * |
mahphalke | 8:70fc373a5f46 | 9 | * Redistribution and use in source and binary forms, with or without |
mahphalke | 8:70fc373a5f46 | 10 | * modification, are permitted provided that the following conditions are met: |
mahphalke | 8:70fc373a5f46 | 11 | * - Redistributions of source code must retain the above copyright |
mahphalke | 8:70fc373a5f46 | 12 | * notice, this list of conditions and the following disclaimer. |
mahphalke | 8:70fc373a5f46 | 13 | * - Redistributions in binary form must reproduce the above copyright |
mahphalke | 8:70fc373a5f46 | 14 | * notice, this list of conditions and the following disclaimer in |
mahphalke | 8:70fc373a5f46 | 15 | * the documentation and/or other materials provided with the |
mahphalke | 8:70fc373a5f46 | 16 | * distribution. |
mahphalke | 8:70fc373a5f46 | 17 | * - Neither the name of Analog Devices, Inc. nor the names of its |
mahphalke | 8:70fc373a5f46 | 18 | * contributors may be used to endorse or promote products derived |
mahphalke | 8:70fc373a5f46 | 19 | * from this software without specific prior written permission. |
mahphalke | 8:70fc373a5f46 | 20 | * - The use of this software may or may not infringe the patent rights |
mahphalke | 8:70fc373a5f46 | 21 | * of one or more patent holders. This license does not release you |
mahphalke | 8:70fc373a5f46 | 22 | * from the requirement that you obtain separate licenses from these |
mahphalke | 8:70fc373a5f46 | 23 | * patent holders to use this software. |
mahphalke | 8:70fc373a5f46 | 24 | * - Use of the software either in source or binary form, must be run |
mahphalke | 8:70fc373a5f46 | 25 | * on or directly connected to an Analog Devices Inc. component. |
mahphalke | 8:70fc373a5f46 | 26 | * |
mahphalke | 8:70fc373a5f46 | 27 | * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR |
mahphalke | 8:70fc373a5f46 | 28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
mahphalke | 8:70fc373a5f46 | 29 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
mahphalke | 8:70fc373a5f46 | 30 | * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, |
mahphalke | 8:70fc373a5f46 | 31 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
mahphalke | 8:70fc373a5f46 | 32 | * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR |
mahphalke | 8:70fc373a5f46 | 33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mahphalke | 8:70fc373a5f46 | 34 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mahphalke | 8:70fc373a5f46 | 35 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mahphalke | 8:70fc373a5f46 | 36 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mahphalke | 8:70fc373a5f46 | 37 | *******************************************************************************/ |
mahphalke | 8:70fc373a5f46 | 38 | |
mahphalke | 8:70fc373a5f46 | 39 | #ifndef GPIO_H_ |
mahphalke | 8:70fc373a5f46 | 40 | #define GPIO_H_ |
mahphalke | 8:70fc373a5f46 | 41 | |
mahphalke | 8:70fc373a5f46 | 42 | /******************************************************************************/ |
mahphalke | 8:70fc373a5f46 | 43 | /***************************** Include Files **********************************/ |
mahphalke | 8:70fc373a5f46 | 44 | /******************************************************************************/ |
mahphalke | 8:70fc373a5f46 | 45 | |
mahphalke | 8:70fc373a5f46 | 46 | #include <stdint.h> |
mahphalke | 8:70fc373a5f46 | 47 | |
mahphalke | 8:70fc373a5f46 | 48 | /******************************************************************************/ |
mahphalke | 8:70fc373a5f46 | 49 | /********************** Macros and Constants Definitions **********************/ |
mahphalke | 8:70fc373a5f46 | 50 | /******************************************************************************/ |
mahphalke | 8:70fc373a5f46 | 51 | |
mahphalke | 8:70fc373a5f46 | 52 | #define GPIO_OUT 0x01 |
mahphalke | 8:70fc373a5f46 | 53 | #define GPIO_IN 0x00 |
mahphalke | 8:70fc373a5f46 | 54 | |
mahphalke | 8:70fc373a5f46 | 55 | #define GPIO_HIGH 0x01 |
mahphalke | 8:70fc373a5f46 | 56 | #define GPIO_LOW 0x00 |
mahphalke | 8:70fc373a5f46 | 57 | |
mahphalke | 8:70fc373a5f46 | 58 | /******************************************************************************/ |
mahphalke | 8:70fc373a5f46 | 59 | /*************************** Types Declarations *******************************/ |
mahphalke | 8:70fc373a5f46 | 60 | /******************************************************************************/ |
mahphalke | 8:70fc373a5f46 | 61 | |
mahphalke | 8:70fc373a5f46 | 62 | typedef struct gpio_init_param { |
mahphalke | 8:70fc373a5f46 | 63 | uint8_t number; |
mahphalke | 8:70fc373a5f46 | 64 | void *extra; |
mahphalke | 8:70fc373a5f46 | 65 | } gpio_init_param; |
mahphalke | 8:70fc373a5f46 | 66 | |
mahphalke | 8:70fc373a5f46 | 67 | typedef struct gpio_desc { |
mahphalke | 8:70fc373a5f46 | 68 | uint8_t number; |
mahphalke | 8:70fc373a5f46 | 69 | void *extra; |
mahphalke | 8:70fc373a5f46 | 70 | } gpio_desc; |
mahphalke | 8:70fc373a5f46 | 71 | |
mahphalke | 8:70fc373a5f46 | 72 | /******************************************************************************/ |
mahphalke | 8:70fc373a5f46 | 73 | /************************ Functions Declarations ******************************/ |
mahphalke | 8:70fc373a5f46 | 74 | /******************************************************************************/ |
mahphalke | 8:70fc373a5f46 | 75 | |
mahphalke | 8:70fc373a5f46 | 76 | /* Obtain the GPIO decriptor. */ |
mahphalke | 8:70fc373a5f46 | 77 | int32_t gpio_get(struct gpio_desc **desc, |
mahphalke | 8:70fc373a5f46 | 78 | const gpio_init_param *param); |
mahphalke | 8:70fc373a5f46 | 79 | |
mahphalke | 8:70fc373a5f46 | 80 | /* Free the resources allocated by gpio_get() */ |
mahphalke | 8:70fc373a5f46 | 81 | int32_t gpio_remove(struct gpio_desc *desc); |
mahphalke | 8:70fc373a5f46 | 82 | |
mahphalke | 8:70fc373a5f46 | 83 | /* Enable the input direction of the specified GPIO. */ |
mahphalke | 8:70fc373a5f46 | 84 | int32_t gpio_direction_input(struct gpio_desc *desc); |
mahphalke | 8:70fc373a5f46 | 85 | |
mahphalke | 8:70fc373a5f46 | 86 | /* Enable the output direction of the specified GPIO. */ |
mahphalke | 8:70fc373a5f46 | 87 | int32_t gpio_direction_output(struct gpio_desc *desc, |
mahphalke | 8:70fc373a5f46 | 88 | uint8_t value); |
mahphalke | 8:70fc373a5f46 | 89 | |
mahphalke | 8:70fc373a5f46 | 90 | /* Get the direction of the specified GPIO. */ |
mahphalke | 8:70fc373a5f46 | 91 | int32_t gpio_get_direction(struct gpio_desc *desc, |
mahphalke | 8:70fc373a5f46 | 92 | uint8_t *direction); |
mahphalke | 8:70fc373a5f46 | 93 | |
mahphalke | 8:70fc373a5f46 | 94 | /* Set the value of the specified GPIO. */ |
mahphalke | 8:70fc373a5f46 | 95 | int32_t gpio_set_value(struct gpio_desc *desc, |
mahphalke | 8:70fc373a5f46 | 96 | uint8_t value); |
mahphalke | 8:70fc373a5f46 | 97 | |
mahphalke | 8:70fc373a5f46 | 98 | /* Get the value of the specified GPIO. */ |
mahphalke | 8:70fc373a5f46 | 99 | int32_t gpio_get_value(struct gpio_desc *desc, |
mahphalke | 8:70fc373a5f46 | 100 | uint8_t *value); |
mahphalke | 8:70fc373a5f46 | 101 | |
mahphalke | 8:70fc373a5f46 | 102 | #endif // GPIO_H_ |