|
RocketLogger 2.1.3
|
#include <errno.h>#include <stdint.h>#include <string.h>#include <gpiod.h>#include <time.h>#include <unistd.h>#include "log.h"#include "rl.h"#include "gpio.h"
Include dependency graph for gpio.c:Go to the source code of this file.
Macros | |
| #define | GPIO_CHIP_COUNT 4 |
| Number of GPIO chips. | |
| #define | GPIO_LINES_PER_CHIP 32 |
| Number of GPIO lines per GPIO chip. | |
| #define | GPIO_DEBOUNCE_DELAY_US 50 |
| Minimal time a button needs to be pressed (in microseconds) | |
Functions | |
| int | gpio_init () |
| void | gpio_deinit () |
| gpio_t * | gpio_setup (int gpio_number, gpio_mode_t mode, const char *name) |
| void | gpio_release (gpio_t *gpio) |
| int | gpio_set_value (gpio_t *gpio, int value) |
| int | gpio_get_value (gpio_t *gpio) |
| gpio_t * | gpio_setup_interrupt (int gpio_number, gpio_interrupt_t edge, const char *name) |
| int | gpio_wait_interrupt (gpio_t *gpio, const struct timespec *timeout) |
Variables | |
| struct gpiod_chip * | gpio_chip [GPIO_CHIP_COUNT] = {NULL} |
| #define GPIO_CHIP_COUNT 4 |
Number of GPIO chips.
Copyright (c) 2016-2020, ETH Zurich, Computer Engineering Group All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition at line 46 of file gpio.c.
Referenced by gpio_deinit(), and gpio_init().
| #define GPIO_DEBOUNCE_DELAY_US 50 |
Minimal time a button needs to be pressed (in microseconds)
Definition at line 52 of file gpio.c.
Referenced by gpio_wait_interrupt().
| #define GPIO_LINES_PER_CHIP 32 |
| void gpio_deinit | ( | ) |
Denitialize GPIO module.
Definition at line 92 of file gpio.c.
References gpio_chip, and GPIO_CHIP_COUNT.
Referenced by hw_deinit(), and main().
| int gpio_get_value | ( | gpio_t * | gpio | ) |
| int gpio_init | ( | ) |
Initialize GPIO module.
Definition at line 77 of file gpio.c.
References ERROR, gpio_chip, GPIO_CHIP_COUNT, rl_log(), RL_LOG_ERROR, and SUCCESS.
Referenced by hw_init(), and main().
Here is the call graph for this function:| void gpio_release | ( | gpio_t * | gpio | ) |
Release an aquired GPIO resource.
| gpio | The GPIO resource to release |
Definition at line 130 of file gpio.c.
Referenced by hw_deinit(), and main().
| int gpio_set_value | ( | gpio_t * | gpio, |
| int | value ) |
Set the GPIO value.
| gpio | GPIO resource to set the output value |
| value | GPIO state to set (0 or 1) |
Definition at line 135 of file gpio.c.
References ERROR.
Referenced by hw_deinit(), hw_init(), hw_sample(), and main().
| gpio_t * gpio_setup | ( | int | gpio_number, |
| gpio_mode_t | mode, | ||
| const char * | name ) |
Set up a specific GPIO pin for input/output.
| gpio_number | Resource number of the GPIO to set up |
| mode | GPIO mode (input or output) to configure |
| name | Name to label the set up GPIO |
Definition at line 103 of file gpio.c.
References GPIO_MODE_IN, GPIO_MODE_OUT, rl_log(), and RL_LOG_ERROR.
Referenced by hw_init(), and main().
Here is the call graph for this function:| gpio_t * gpio_setup_interrupt | ( | int | gpio_number, |
| gpio_interrupt_t | edge, | ||
| const char * | name ) |
Set up a specific GPIO pin for interrupt event.
| gpio_number | Resource number of the GPIO to set up |
| edge | GPIO interrupt edge to configure |
| name | Name to label the set up GPIO |
Definition at line 148 of file gpio.c.
References GPIO_INTERRUPT_BOTH, GPIO_INTERRUPT_FALLING, GPIO_INTERRUPT_NONE, GPIO_INTERRUPT_RISING, rl_log(), and RL_LOG_ERROR.
Referenced by main().
Here is the call graph for this function:| int gpio_wait_interrupt | ( | gpio_t * | gpio, |
| const struct timespec * | timeout ) |
Wait for interrupt on GPIO pin.
| gpio | GPIO resource to wait for |
| timeout | Pointer to timeout timespec, NULL for infinite timeout |
Definition at line 187 of file gpio.c.
References ERROR, GPIO_DEBOUNCE_DELAY_US, rl_log(), and RL_LOG_ERROR.
Referenced by main().
Here is the call graph for this function:| struct gpiod_chip* gpio_chip[GPIO_CHIP_COUNT] = {NULL} |
Definition at line 54 of file gpio.c.
Referenced by gpio_deinit(), and gpio_init().