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