pdock 60 test task
This commit is contained in:
@ -1,88 +0,0 @@
|
||||
#ifndef GS_UTIL_DRIVERS_I2C_COMMON_H
|
||||
#define GS_UTIL_DRIVERS_I2C_COMMON_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Common (master and slave) I2C definitions.
|
||||
*/
|
||||
|
||||
#include <gs/util/log.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Default log group for I2C driver.
|
||||
*/
|
||||
GS_LOG_GROUP_EXTERN(gs_i2c_log);
|
||||
|
||||
/**
|
||||
I2C mode.
|
||||
*/
|
||||
typedef enum {
|
||||
//! Master mode
|
||||
GS_I2C_MASTER = 0,
|
||||
//! Multimaster mode
|
||||
GS_I2C_MULTI_MASTER = 1,
|
||||
//! Slave mode
|
||||
GS_I2C_SLAVE = 2,
|
||||
} gs_i2c_mode_t;
|
||||
|
||||
/**
|
||||
Cross-platform I2C configuration.
|
||||
*/
|
||||
typedef struct {
|
||||
//! Data order, True: MSB first, False: LSB first (default = True)
|
||||
bool data_order_msb;
|
||||
//! Device mode (master, multimaster, or slave)
|
||||
gs_i2c_mode_t mode;
|
||||
//! Address of node in multimaster and slave mode (not used in master mode)
|
||||
uint16_t addr;
|
||||
//! Bits per second (default is #GS_I2C_DEFAULT_BPS)
|
||||
uint32_t bps;
|
||||
//! Address size in bits, 7, 8 or 10 bits (default/prefered is #GS_I2C_DEFAULT_ADDRESS_SIZE)
|
||||
uint8_t addrbits;
|
||||
} gs_i2c_config_t;
|
||||
|
||||
/**
|
||||
Cross-platform I2C configuration.
|
||||
@deprecated use gs_i2c_config_t.
|
||||
*/
|
||||
typedef gs_i2c_config_t gs_i2c_bus_config_t;
|
||||
|
||||
/**
|
||||
Default bit-rate.
|
||||
*/
|
||||
#define GS_I2C_DEFAULT_BPS 100000
|
||||
|
||||
/**
|
||||
Default address size.
|
||||
*/
|
||||
#define GS_I2C_DEFAULT_ADDRESS_SIZE 7
|
||||
|
||||
/**
|
||||
Default data order (MSB).
|
||||
*/
|
||||
#define GS_I2C_DEFAULT_DATA_ORDER_MSB 1
|
||||
|
||||
/**
|
||||
Speed (command line sub-option).
|
||||
*/
|
||||
#define GS_I2C_COMMAND_LINE_SPEED "speed"
|
||||
|
||||
/**
|
||||
Device (command line sub-option).
|
||||
*/
|
||||
#define GS_I2C_COMMAND_LINE_DEVICE "device"
|
||||
|
||||
/**
|
||||
Address (command line sub-option).
|
||||
*/
|
||||
#define GS_I2C_COMMAND_LINE_ADDRESS "address"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,32 +0,0 @@
|
||||
#ifndef GS_UTIL_DRIVERS_I2C_MASTER_H
|
||||
#define GS_UTIL_DRIVERS_I2C_MASTER_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
I2C master interface.
|
||||
*/
|
||||
|
||||
#include <gs/util/drivers/i2c/common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Perform transaction to I2C slave.
|
||||
@param[in] device hardware device (bus)
|
||||
@param[in] addr slave address
|
||||
@param[in] tx transmit buffer
|
||||
@param[in] txlen number of bytes to transmit
|
||||
@param[out] rx receive buffer - can be NULL.
|
||||
@param[in] rxlen number of bytes to receive.
|
||||
@param[in] timeout_ms timeout in milliseconds, primarily for locking the I2C channel.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_i2c_master_transaction(uint8_t device, uint8_t addr, const void * tx, size_t txlen, void * rx, size_t rxlen, int timeout_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,79 +0,0 @@
|
||||
#ifndef GS_UTIL_DRIVERS_I2C_SLAVE_H
|
||||
#define GS_UTIL_DRIVERS_I2C_SLAVE_H
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
I2C slave interface.
|
||||
*/
|
||||
|
||||
#include <gs/util/drivers/i2c/common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Start/enable I2C bus reception.
|
||||
|
||||
Reception should not automatically be enabled by their init() functions, as this will complicate adding additional layers/hooks.
|
||||
|
||||
@param[in] device I2C bus (handle)
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_i2c_slave_start(uint8_t device);
|
||||
|
||||
/**
|
||||
Rx callback.
|
||||
|
||||
Function called when data has been received on the bus (I2C write operation complete).
|
||||
|
||||
@param[in] device I2C bus (handle).
|
||||
@param[in] rx receive buffer.
|
||||
@param[in] rx_length number of bytes received.
|
||||
@param_cswitch
|
||||
*/
|
||||
typedef void (* gs_i2c_slave_receive_t)(uint8_t device, const uint8_t * rx, size_t rx_length, gs_context_switch_t * cswitch);
|
||||
|
||||
/**
|
||||
Set rx callback.
|
||||
|
||||
@param[in] device I2C bus (handle).
|
||||
@param[in] rx Rx callback.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_i2c_slave_set_rx(uint8_t device, gs_i2c_slave_receive_t rx);
|
||||
|
||||
/**
|
||||
Get rx buffer callback.
|
||||
|
||||
Function called from driver, for getting a pointer to the rx buffer.
|
||||
|
||||
@param[in] device I2C bus (handle).
|
||||
*/
|
||||
typedef void * (* gs_i2c_slave_get_rx_buf_t)(uint8_t device);
|
||||
|
||||
/**
|
||||
Set rx buffer get callback.
|
||||
|
||||
@param[in] device I2C bus (handle).
|
||||
@param[in] get_rx_buf get rx buffer callback.
|
||||
@param[in] buf_length length of buffer retrieved with this callback.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_i2c_slave_set_get_rx_buf(uint8_t device, gs_i2c_slave_get_rx_buf_t get_rx_buf, size_t buf_length);
|
||||
|
||||
/**
|
||||
Set response data.
|
||||
|
||||
@param[in] device I2C bus (handle).
|
||||
@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] tx_length length of data.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_i2c_slave_set_response(uint8_t device, const uint8_t * tx, size_t tx_length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
Reference in New Issue
Block a user