save failed integration state

This commit is contained in:
2020-11-26 10:24:23 +01:00
parent 77970418d8
commit 17fc4b0de1
194 changed files with 45450 additions and 2 deletions

View File

@ -0,0 +1,146 @@
#ifndef GS_UTIL_LINUX_DRIVERS_GPIO_H
#define GS_UTIL_LINUX_DRIVERS_GPIO_H
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
/**
@file
@brief GPIO interface
GPIO interface provides a generic interface where specific GPIO drivers can be plugged in.
*/
#include <gs/util/error.h>
#include <gs/util/drivers/gpio/gpio.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
GomSpace linux driver GPIO get value
@param[in] gpio The gpio to read
@param[in] value Returned GPIO value (true/false = High/Low)
@param[in] driver_data data to specific driver
@return_gs_error_t
*/
typedef gs_error_t (*gs_gpio_get_t)(gs_gpio_t gpio, bool *value, void * driver_data);
/**
GomSpace linux driver GPIO get value without error check
@param[in] gpio The gpio to read
@param[in] driver_data data to specific driver
@return GPIO value (true/false = High/Low)
*/
typedef bool (*gs_gpio_get_nc_t)(gs_gpio_t gpio, void * driver_data);
/**
GomSpace linux driver GPIO set value
@param[in] gpio The gpio to set
@param[in] value GPIO value (true/false = High/Low)
@param[in] driver_data data to specific driver
@return_gs_error_t
*/
typedef gs_error_t (*gs_gpio_set_t)(gs_gpio_t gpio, bool value, void * driver_data);
/**
GomSpace linux driver GPIO set value without error check
@param[in] gpio The gpio to set
@param[in] value GPIO value (true/false = High/Low)
@param[in] driver_data data to specific driver
*/
typedef void (*gs_gpio_set_nc_t)(gs_gpio_t gpio, bool value, void * driver_data);
/**
GomSpace linux driver initialize GPIO as an external interrupt pin
@param[in] gpio The gpio to configure
@param[in] conf Configuration of interrupt pin
@param[in] driver_data data to specific driver
@return_gs_error_t
*/
typedef gs_error_t (*gs_gpio_init_as_interrupt_t)(gs_gpio_t gpio, const gs_interrupt_conf_t * conf, void * driver_data);
/**
Every port.
*/
#define GS_GPIO_ALL_PORTS UINT16_MAX
/**
Every pin.
*/
#define GS_GPIO_ALL_PINS UINT16_MAX
/**
GPIO driver.
*/
typedef struct {
/**
Function for handling GPIO get.
*/
gs_gpio_get_t get_handler;
/**
Function for handling GPIO get no check.
*/
gs_gpio_get_nc_t get_nc_handler;
/**
Function for handling GPIO set.
*/
gs_gpio_set_t set_handler;
/**
Function for handling GPIO set no check.
*/
gs_gpio_set_nc_t set_nc_handler;
/**
Function for handling GPIO initialize as interrupt.
*/
gs_gpio_init_as_interrupt_t init_as_interrupt_handler;
} gs_gpio_driver_t;
/**
GPIO driver entry
*/
typedef struct {
/**
GPIO port, to which the driver is used (if GS_GPIO_ALL_PORTS, then all ports uses this driver).
*/
uint16_t port;
/**
GPIO pin, to which the driver is used (if GS_GPIO_ALL_PINS, then all pins uses this driver).
*/
uint16_t pin;
/**
GPIO driver.
*/
const gs_gpio_driver_t * driver;
/**
Driver specific data.
*/
void * driver_data;
} gs_gpio_driver_entry_t;
/**
Register a driver.
A specific driver can be assigned to a port and pin or it can be assigned to all pins and/or all ports.
The latest registered driver, which fit the GPIO, is the one used.
@param[in] driver_entry driver and configuration to be registered
@return_gs_error_t
*/
gs_error_t gs_gpio_register_driver(const gs_gpio_driver_entry_t * driver_entry);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,91 @@
#ifndef LIB_LIBUTIL_INCLUDE_GS_UTIL_LINUX_DRIVERS_GPIO_GPIO_SYSFS_H_
#define LIB_LIBUTIL_INCLUDE_GS_UTIL_LINUX_DRIVERS_GPIO_GPIO_SYSFS_H_
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
/**
@file
@brief Linux GPIO driver based on sysfs.
This driver needs to be registered in the generic GPIO linux driver @see 'gs/util/linux/drivers/gpio/gpio.h'
*/
#include <gs/util/linux/drivers/gpio/gpio.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
GPIO sysfs driver data.
@note Driver takes no driver data, so a NULL pointer is valid
*/
typedef void * gs_gpio_sysfs_driver_data_t;
/**
GPIO sysfs driver interface.
*/
extern const gs_gpio_driver_t gs_gpio_sysfs_driver;
/**
GPIO sysfs initialize
@param[in] gpio The gpio to initialize
@param[in] output Direction of pin (True/False = Output/Input)
@param[in] init_value Pin state if configured as output (True/False = High/Low)
@param[in] active_low if set pin is configured as active low (so a gs_gpio_sysfs_set with 1 will actually set value low)
@return_gs_error_t
*/
gs_error_t gs_gpio_sysfs_initialize(gs_gpio_t gpio, bool output, bool init_value, bool active_low);
/**
GPIO sysfs get value
@param[in] gpio The gpio to read
@param[in] value Returned GPIO value (true/false = High/Low)
@param[in] driver_data data to driver (not used)
@return_gs_error_t
*/
gs_error_t gs_gpio_sysfs_get(gs_gpio_t gpio, bool *value, void * driver_data);
/**
GPIO sysfs get value without error check
@param[in] gpio The gpio to read
@param[in] driver_data data to driver (not used)
@return GPIO value (true/false = High/Low)
*/
bool gs_gpio_sysfs_get_nc(gs_gpio_t gpio, void * driver_data);
/**
GPIO sysfs set value
@param[in] gpio The gpio to set
@param[in] value GPIO value (true/false = High/Low)
@param[in] driver_data data to driver (not used)
@return_gs_error_t
*/
gs_error_t gs_gpio_sysfs_set(gs_gpio_t gpio, bool value, void * driver_data);
/**
GPIO sysfs set value without error check
@param[in] gpio The gpio to set
@param[in] value GPIO value (true/false = High/Low)
@param[in] driver_data data to driver (not used)
*/
void gs_gpio_sysfs_set_nc(gs_gpio_t gpio, bool value, void * driver_data);
/**
Initialize GPIO sysfs as an external interrupt pin
@param[in] gpio The gpio to configure
@param[in] conf Configuration of interrupt pin
@param[in] driver_data data to driver (not used)
@return_gs_error_t
*/
gs_error_t gs_gpio_sysfs_init_as_interrupt(gs_gpio_t gpio, const gs_interrupt_conf_t * conf, void * driver_data);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,125 @@
#ifndef LIB_LIBUTIL_INCLUDE_GS_UTIL_LINUX_DRIVERS_GPIO_GPIO_VIRTUAL_H_
#define LIB_LIBUTIL_INCLUDE_GS_UTIL_LINUX_DRIVERS_GPIO_GPIO_VIRTUAL_H_
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
/**
@file
@brief Linux GPIO driver to be used in unit tests.
This driver needs to be registered in the generic GPIO linux driver @see 'gs/util/linux/drivers/gpio/gpio.h'
*/
#include <gs/util/linux/drivers/gpio/gpio.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
GPIO virtual driver data.
@note Driver takes no driver data, so a NULL pointer is valid
*/
typedef void * gs_gpio_virtual_driver_data_t;
/**
GPIO virtual driver interface.
*/
extern const gs_gpio_driver_t gs_gpio_virtual_driver;
/**
GPIO virtual driver entry, where all ports and pins are routed to virtual driver
*/
extern const gs_gpio_driver_entry_t gs_gpio_virtual_driver_entry_all;
/**
GPIO virtual initialize
@param[in] gpio The gpio to initialize
@param[in] output Direction of pin (True/False = Output/Input)
@param[in] value Pin state if configured as output (True/False = High/Low)
@return_gs_error_t
*/
gs_error_t gs_gpio_virtual_initialize(gs_gpio_t gpio, bool output, bool value);
/**
GPIO virtual get value
@param[in] gpio The gpio to read
@param[in] value Returned GPIO value (true/false = High/Low)
@param[in] driver_data data to driver (not used)
@return_gs_error_t
*/
gs_error_t gs_gpio_virtual_get(gs_gpio_t gpio, bool *value, void * driver_data);
/**
GPIO virtual get value without error check
@param[in] gpio The gpio to read
@param[in] driver_data data to driver (not used)
@return GPIO value (true/false = High/Low)
*/
bool gs_gpio_virtual_get_nc(gs_gpio_t gpio, void * driver_data);
/**
GPIO virtual set value
@param[in] gpio The gpio to set
@param[in] value GPIO value (true/false = High/Low)
@param[in] driver_data data to driver (not used)
@return_gs_error_t
*/
gs_error_t gs_gpio_virtual_set(gs_gpio_t gpio, bool value, void * driver_data);
/**
GPIO virtual set value without error check
@param[in] gpio The gpio to set
@param[in] value GPIO value (true/false = High/Low)
@param[in] driver_data data to driver (not used)
*/
void gs_gpio_virtual_set_nc(gs_gpio_t gpio, bool value, void * driver_data);
/**
Initialize GPIO virtual as an external interrupt pin
@param[in] gpio The gpio to configure
@param[in] conf Configuration of interrupt pin
@param[in] driver_data data to driver (not used)
@return_gs_error_t
*/
gs_error_t gs_gpio_virtual_init_as_interrupt(gs_gpio_t gpio, const gs_interrupt_conf_t * conf, void * driver_data);
/**
Force set a pin
This sets a pin regardless if it is configured as input, output or interrupt
If the pin is configured as interrupt, the registered ISR's will be called within this function,
if the transition matches (rising/falling)
@note This function is specific to this driver and is should not be registered.
@param[in] gpio The gpio to set
@param[in] value GPIO value (true/false = High/Low)
@return_gs_error_t
*/
gs_error_t gs_gpio_virtual_force_set(gs_gpio_t gpio, bool value);
/**
Get transitions
This gives the number of transitions ((high -> low) + (low -> high)),
since last time this function was called at this pin. This function resets the counter of the pin.
An even number means, that the pin has the same state as it was initialized to.
@note This function is specific to this driver and should not be registered
@param[in] gpio The gpio, of which transitions are given
@param[out] transitions Number of transitions
@return
*/
gs_error_t gs_gpio_virtual_get_transistions(gs_gpio_t gpio, uint32_t * transitions);
#ifdef __cplusplus
}
#endif
#endif