pdock 60 test task
This commit is contained in:
@ -1,40 +0,0 @@
|
||||
#ifndef GS_UTIL_LINUX_ARGP_H
|
||||
#define GS_UTIL_LINUX_ARGP_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Extensions to GNU argp parser (convenience functions).
|
||||
*/
|
||||
|
||||
#include <argp.h>
|
||||
#include <gs/util/linux/exitcode.h>
|
||||
#include <gs/util/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Wrapper for argp_parse.
|
||||
|
||||
This function will call exit/terminate the process, if parsing fails.
|
||||
|
||||
\a argv may be re-organized.
|
||||
|
||||
@param[in] argp argp struct.
|
||||
@param[in] argc argument count, i.e. standard argc.
|
||||
@param[in] argv argument array, i.e. standard argv.
|
||||
@param[in] flags future use.
|
||||
@param[out] arg_index first unparsed option (-> argv modified).
|
||||
@param[in] revision program revision, e.g. 3.0.1-12-g0cf1b59+.
|
||||
*/
|
||||
void gs_argp_parse(const struct argp * argp,
|
||||
int argc, char ** argv,
|
||||
unsigned int flags, int * arg_index,
|
||||
const char * revision);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,42 +0,0 @@
|
||||
#ifndef GS_UTIL_LINUX_COMMAND_LINE_H
|
||||
#define GS_UTIL_LINUX_COMMAND_LINE_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Command line support.
|
||||
*/
|
||||
|
||||
#include <gs/util/linux/argp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Command line options for ignoring CTRL-C
|
||||
*/
|
||||
extern const struct argp_child gs_console_command_line_ignore_ctrlc_argp;
|
||||
|
||||
/**
|
||||
Command line options for adding -h (help).
|
||||
*/
|
||||
const struct argp_child gs_help_command_line_argp;
|
||||
|
||||
/**
|
||||
Return if ctrl-c ignored on command line.
|
||||
@return \a true i ctrl-c ignored.
|
||||
*/
|
||||
bool gs_command_line_ignore_ctrlc(void);
|
||||
|
||||
/**
|
||||
Return program name based on argv[0].
|
||||
@param[in] argv expected to be argv[0] amd point to the program name (possibly with full path).
|
||||
@return program name.
|
||||
*/
|
||||
const char * gs_command_line_program_name(const char * argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,29 +0,0 @@
|
||||
#ifndef GS_UTIL_LINUX_DRIVERS_CAN_CAN_H
|
||||
#define GS_UTIL_LINUX_DRIVERS_CAN_CAN_H
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Linux CAN interface.
|
||||
|
||||
@note Only 1 filter/mask can be set, using gs_can_set_standard_filter_mask() or gs_can_set_extended_filter_mask()
|
||||
*/
|
||||
|
||||
#include <gs/util/drivers/can/can.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Open and initialize a CAN handle.
|
||||
@param[in] ifname name of CAN interface.
|
||||
@param[out] handle opened CAN handle.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_can_open(const char * ifname, int * handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,146 +0,0 @@
|
||||
#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
|
@ -1,91 +0,0 @@
|
||||
#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
|
@ -1,125 +0,0 @@
|
||||
#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
|
@ -1,198 +0,0 @@
|
||||
#ifndef LIB_LIBUTIL_INCLUDE_GS_UTIL_LINUX_DRIVERS_I2C_I2C_H_
|
||||
#define LIB_LIBUTIL_INCLUDE_GS_UTIL_LINUX_DRIVERS_I2C_I2C_H_
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
@brief Linux I2C plugin driver
|
||||
*/
|
||||
|
||||
#include <gs/util/drivers/i2c/master.h>
|
||||
#include <gs/util/drivers/i2c/slave.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
GomSpace linux driver I2C master transaction.
|
||||
|
||||
@see 'gs/util/drivers/i2c/master.h'
|
||||
|
||||
@param[in] device I2C device
|
||||
@param[in] addr I2C address
|
||||
@param[in] tx tx buffer
|
||||
@param[in] txlen bytes to be sent
|
||||
@param[out] rx rx buffer
|
||||
@param[in] rxlen bytes to be received
|
||||
@param[in] timeout_ms timeout in milliseconds
|
||||
@param[in] driver_data data to specific driver
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (* gs_i2c_master_transaction_t)(uint8_t device, uint8_t addr, const void * tx, size_t txlen,
|
||||
void * rx, size_t rxlen, int timeout_ms, void * driver_data);
|
||||
|
||||
/**
|
||||
GomSpace linux driver I2C slave start.
|
||||
|
||||
@see 'gs/util/drivers/i2c/slave.h'
|
||||
|
||||
@param[in] device I2C device
|
||||
@param[in] driver_data data to specific driver
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (* gs_i2c_slave_start_t)(uint8_t device, void * driver_data);
|
||||
|
||||
/**
|
||||
GomSpace linux driver I2C set rx callback
|
||||
|
||||
@see 'gs/util/drivers/i2c/slave.h'
|
||||
|
||||
@param[in] device I2C device
|
||||
@param[in] rx rx callback
|
||||
@param[in] driver_data data to specific driver
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (* gs_i2c_slave_set_rx_t)(uint8_t device, gs_i2c_slave_receive_t rx, void * driver_data);
|
||||
|
||||
/**
|
||||
GomSpace linux driver I2C slave set 'get_rx_buffer' callback.
|
||||
|
||||
@see 'gs/util/drivers/i2c/slave.h'
|
||||
|
||||
@param[in] device I2C device
|
||||
@param[in] get_rx_buf get_rx_buf callback
|
||||
@param[in] buf_length length of buffer received by calling callback
|
||||
@param[in] driver_data data to specific driver
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (* gs_i2c_slave_set_get_rx_buf_t)(uint8_t device, gs_i2c_slave_get_rx_buf_t get_rx_buf, size_t buf_length, void * driver_data);
|
||||
|
||||
/**
|
||||
GomSpace linux driver I2C slave set slave response.
|
||||
|
||||
@see 'gs/util/drivers/i2c/slave.h'
|
||||
|
||||
@param[in] device I2C device
|
||||
@param[in] tx tx buffer
|
||||
@param[in] tx_length bytes to be send
|
||||
@param[in] driver_data data to specific driver
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (* gs_i2c_slave_set_response_t)(uint8_t device, const uint8_t * tx, size_t tx_length, void * driver_data);
|
||||
|
||||
/**
|
||||
Every I2C device ([0 : 254]).
|
||||
*/
|
||||
#define GS_I2C_ALL_DEVICES 255
|
||||
|
||||
/**
|
||||
Every I2C address (0 : 127]).
|
||||
*/
|
||||
#define GS_I2C_ALL_ADDR 255
|
||||
|
||||
/**
|
||||
I2C master driver.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
Function for handling master transactions.
|
||||
*/
|
||||
gs_i2c_master_transaction_t master_transaction_handler;
|
||||
} gs_i2c_master_driver_t;
|
||||
|
||||
|
||||
/**
|
||||
I2C master driver entry
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
I2C device, to which the driver is used (if GS_I2C_ALL_DEVICES, then all devices uses this driver).
|
||||
*/
|
||||
uint8_t device;
|
||||
/**
|
||||
I2C addr, to which the driver is used (if GS_I2C_ALL_ADDR, then all addr on given device uses this driver).
|
||||
*/
|
||||
uint8_t addr;
|
||||
/**
|
||||
I2C master driver.
|
||||
*/
|
||||
const gs_i2c_master_driver_t * driver;
|
||||
/**
|
||||
Driver specific data.
|
||||
*/
|
||||
void * driver_data;
|
||||
} gs_i2c_master_driver_entry_t;
|
||||
|
||||
|
||||
/**
|
||||
I2C slave driver
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
Function for handling slave start.
|
||||
*/
|
||||
gs_i2c_slave_start_t start_handler;
|
||||
/**
|
||||
Function for handling the 'setting of rx callback'.
|
||||
*/
|
||||
gs_i2c_slave_set_rx_t set_rx_handler;
|
||||
/**
|
||||
Function for handling setting of an 'rx buff get' function.
|
||||
*/
|
||||
gs_i2c_slave_set_get_rx_buf_t set_get_rx_buf_handler;
|
||||
/**
|
||||
Function for handling 'set response'.
|
||||
*/
|
||||
gs_i2c_slave_set_response_t set_response_handler;
|
||||
} gs_i2c_slave_driver_t;
|
||||
|
||||
|
||||
/**
|
||||
I2C slave driver entry.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
I2C device, to which the driver is used (if GS_I2C_ALL_DEVICES, then all devices uses this driver).
|
||||
*/
|
||||
uint8_t device;
|
||||
/**
|
||||
I2C slave driver.
|
||||
*/
|
||||
const gs_i2c_slave_driver_t * driver;
|
||||
/**
|
||||
Driver specific data.
|
||||
*/
|
||||
void * driver_data;
|
||||
} gs_i2c_slave_driver_entry_t;
|
||||
|
||||
|
||||
/**
|
||||
Register a master driver.
|
||||
|
||||
A specific driver can be assigned to a specific address and device
|
||||
or it can be registered to every address on a device or every address on every device.
|
||||
|
||||
The latest registered driver, which fit the device an address, is the one used.
|
||||
|
||||
@param[in] driver_entry driver and configuration to be registered
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_i2c_master_register_driver(const gs_i2c_master_driver_entry_t * driver_entry);
|
||||
|
||||
/**
|
||||
Register a slave driver
|
||||
|
||||
A specific driver can be assigned to a specific device or a driver can be assigned to every device.
|
||||
|
||||
The latest registered driver, which fit the device, is the one used.
|
||||
|
||||
@param[in] driver_entry driver and configuration to be registered
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_i2c_slave_register_driver(const gs_i2c_slave_driver_entry_t * driver_entry);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,175 +0,0 @@
|
||||
#ifndef LIB_LIBUTIL_INCLUDE_GS_UTIL_LINUX_DRIVERS_SPI_SPI_H_
|
||||
#define LIB_LIBUTIL_INCLUDE_GS_UTIL_LINUX_DRIVERS_SPI_SPI_H_
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Linux SPI plugin driver
|
||||
*/
|
||||
|
||||
#include <gs/util/drivers/spi/master.h>
|
||||
#include <gs/util/drivers/spi/slave.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Linux driver SPI master transactions.
|
||||
|
||||
@see 'gs/util/drivers/spi/master.h'
|
||||
|
||||
@param[in] slave SPI slave
|
||||
@param[in] trans Pointer to transactions
|
||||
@param[in] count Number of transactions (rx and/or tx) to complete
|
||||
@param[in] timeout_ms timeout in milliseconds, primarily for locking the SPI device.
|
||||
@param[in] driver_data data to specific driver
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (*gs_spi_master_transactions_t)(uint8_t slave, gs_spi_master_trans_t *trans, size_t count,
|
||||
int timeout_ms, void * driver_data);
|
||||
|
||||
/**
|
||||
Linux driver SPI slave start.
|
||||
|
||||
@see 'gs/util/drivers/spi/slave.h'
|
||||
|
||||
@param[in] device SPI device (handle)
|
||||
@param[in] driver_data data to specific driver
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (* gs_spi_slave_start_t)(uint8_t device, void * driver_data);
|
||||
|
||||
/**
|
||||
Linux driver SPI set rx callback
|
||||
|
||||
@see 'gs/util/drivers/spi/slave.h'
|
||||
|
||||
@param[in] device SPI device (handle).
|
||||
@param[in] rx Rx callback.
|
||||
@param[in] driver_data data to specific driver
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (* gs_spi_slave_set_rx_t)(uint8_t device, gs_spi_slave_receive_t rx, void * driver_data);
|
||||
|
||||
/**
|
||||
Linux driver SPI slave set slave response.
|
||||
|
||||
@see 'gs/util/drivers/spi/slave.h'
|
||||
|
||||
@param[in] device SPI device (handle).
|
||||
@param[in] offset offset (in bytes) for the response, counted from start of request, i.e. offset of 2 means data will be sent as the 3rd byte.
|
||||
@param[in] tx pointer to data. NOTE: data is not copied due to performance, so data must stay valid until the response has been sent.
|
||||
@param[in] size size of data.
|
||||
@param[in] driver_data data to specific driver
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (* gs_spi_slave_set_response_t)(uint8_t device, size_t offset, const uint8_t * tx, size_t size, void * driver_data);
|
||||
|
||||
/**
|
||||
Every SPI slave ([0 : 254]).
|
||||
*/
|
||||
#define GS_SPI_ALL_SLAVES 255
|
||||
|
||||
/**
|
||||
Every SPI device (0 : 254]).
|
||||
*/
|
||||
#define GS_SPI_ALL_DEVICES 255
|
||||
|
||||
|
||||
/**
|
||||
SPI master driver.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
Function for handling master transactions.
|
||||
*/
|
||||
gs_spi_master_transactions_t master_transactions_handler;
|
||||
} gs_spi_master_driver_t;
|
||||
|
||||
|
||||
/**
|
||||
SPI master driver entry
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
SPI slave, to which the driver is used (if #GS_SPI_ALL_SLAVES, then all slaves uses this driver).
|
||||
*/
|
||||
uint8_t slave;
|
||||
/**
|
||||
SPI master driver.
|
||||
*/
|
||||
const gs_spi_master_driver_t * driver;
|
||||
/**
|
||||
Driver specific data.
|
||||
*/
|
||||
void * driver_data;
|
||||
} gs_spi_master_driver_entry_t;
|
||||
|
||||
|
||||
/**
|
||||
SPI slave driver
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
Function for handling slave start.
|
||||
*/
|
||||
gs_spi_slave_start_t start_handler;
|
||||
/**
|
||||
Function for handling the 'setting of rx callback'.
|
||||
*/
|
||||
gs_spi_slave_set_rx_t set_rx_handler;
|
||||
/**
|
||||
Function for handling 'set response'.
|
||||
*/
|
||||
gs_spi_slave_set_response_t set_response_handler;
|
||||
} gs_spi_slave_driver_t;
|
||||
|
||||
|
||||
/**
|
||||
SPI slave driver entry.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
SPI device, to which the driver is used (if #GS_SPI_ALL_DEVICES, then all devices uses this driver).
|
||||
*/
|
||||
uint8_t device;
|
||||
/**
|
||||
SPI slave driver.
|
||||
*/
|
||||
const gs_spi_slave_driver_t * driver;
|
||||
/**
|
||||
Driver specific data.
|
||||
*/
|
||||
void * driver_data;
|
||||
} gs_spi_slave_driver_entry_t;
|
||||
|
||||
|
||||
/**
|
||||
Register a master driver.
|
||||
|
||||
A specific driver can be assigned to a slave or it can be assigned to every slave.
|
||||
|
||||
The latest registered driver, which fit the slave, is the one used.
|
||||
|
||||
@param[in] driver_entry driver and configuration to be registered
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_spi_master_register_driver(const gs_spi_master_driver_entry_t * driver_entry);
|
||||
|
||||
/**
|
||||
Register a slave driver
|
||||
|
||||
A specific driver can be assigned to a specific device or a driver can be assigned to every device.
|
||||
|
||||
The latest registered driver, which fit the device, is the one used.
|
||||
|
||||
@param[in] driver_entry driver and configuration to be registered
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_spi_slave_register_driver(const gs_spi_slave_driver_entry_t * driver_entry);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
#ifndef GS_UTIL_LINUX_EXITCODE_H
|
||||
#define GS_UTIL_LINUX_EXITCODE_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
"standard" Linux exit codes.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sysexits.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Program completed ok (from stdlib.h)
|
||||
*/
|
||||
#define GS_EXITCODE_OK EXIT_SUCCESS
|
||||
|
||||
/**
|
||||
Program terminated due to an error (from stdlib.h).
|
||||
*/
|
||||
#define GS_EXITCODE_ERROR EXIT_FAILURE
|
||||
|
||||
/**
|
||||
Program terminated due to invalid usage, eg argument (from sysexits.h).
|
||||
*/
|
||||
#define GS_EXITCODE_USAGE EX_USAGE
|
||||
|
||||
/**
|
||||
Program terminated due to a signal (from [TLDP](http://www.tldp.org/LDP/abs/html/exitcodes.html)).
|
||||
*/
|
||||
#define GS_EXITCODE_SIGNAL(sig) (128 + sig)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,49 +0,0 @@
|
||||
#ifndef GS_UTIL_LINUX_FUNCTION_H
|
||||
#define GS_UTIL_LINUX_FUNCTION_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Function interface - invokes a function by name.
|
||||
*/
|
||||
|
||||
#include <gs/util/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Function prototype.
|
||||
@param[in] arg argument provided to gs_function_invoke().
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (*gs_function_t)(void * arg);
|
||||
|
||||
/**
|
||||
Register \a function by name.
|
||||
|
||||
@param[in] short_name short name for function, used by gs_function_invoke() to find function to invoke.
|
||||
@param[in] long_name long name (unique) for function, used by gs_function_invoke() to find function to invoke.
|
||||
@param[in] function function to be invoked by gs_function_invoke()
|
||||
@return #GS_ERROR_FULL if registry is full.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_function_register(const char * short_name, const char * long_name, gs_function_t function);
|
||||
|
||||
/**
|
||||
Invoke \a function by name.
|
||||
|
||||
The return value is from the registered function, except for #GS_ERROR_NOT_IMPLEMENTED.
|
||||
|
||||
@param[in] name registered function name.
|
||||
@param[in] arg argument for function.
|
||||
@return #GS_ERROR_NOT_IMPLEMENTED if the \a name isn't found.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_function_invoke(const char * name, void * arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,28 +0,0 @@
|
||||
#ifndef GS_UTIL_LINUX_RTC_H
|
||||
#define GS_UTIL_LINUX_RTC_H
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Real Time Clock interface (linux).
|
||||
*/
|
||||
|
||||
#include <gs/util/rtc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Register Real Time Clock interface.
|
||||
@note Setting the RTC will normally require special permission.
|
||||
@param[in] get if true, get will be registered.
|
||||
@param[in] set if true, set will be registered.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_rtc_register_linux(bool get, bool set);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
#ifndef GS_UTIL_LINUX_SIGNAL_H
|
||||
#define GS_UTIL_LINUX_SIGNAL_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Signal helpers - catch and ignore.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <gs/util/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Standard Linux signal handler.
|
||||
*/
|
||||
typedef void (*gs_signal_handler)(int signal, siginfo_t *si, void *context);
|
||||
|
||||
/**
|
||||
Register/catch signal and invoke handler.
|
||||
@param[in] signal signal to catch.
|
||||
@param[in] handler signal handler. If \a handler is NULL, a default handler will be invoked, which calls exit(#GS_EXITCODE_SIGNAL + signal).
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_signal_catch(int signal, gs_signal_handler handler);
|
||||
|
||||
/**
|
||||
Ignore signal
|
||||
@param[in] signal signal to ignore.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_signal_ignore(int signal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,30 +0,0 @@
|
||||
#ifndef GS_UTIL_SYSFS_HELPER_H
|
||||
#define GS_UTIL_SYSFS_HELPER_H
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Sysfs interface.
|
||||
*/
|
||||
|
||||
#include <gs/util/types.h>
|
||||
#include <gs/util/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Sysfs write (GPIO).
|
||||
*/
|
||||
gs_error_t gs_sysfs_write_file(const char *path, const char *value);
|
||||
|
||||
/**
|
||||
Sysfs read (GPIO).
|
||||
*/
|
||||
gs_error_t gs_sysfs_read_file(const char *path, char *value, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
Reference in New Issue
Block a user