pdock 60 test task
This commit is contained in:
@ -1,66 +0,0 @@
|
||||
#ifndef GS_UTIL_DRIVERS_SPI_COMMON_H
|
||||
#define GS_UTIL_DRIVERS_SPI_COMMON_H
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Common (master and slave) SPI definitions.
|
||||
*/
|
||||
|
||||
#include <gs/util/log.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Default log group for SPI driver.
|
||||
*/
|
||||
GS_LOG_GROUP_EXTERN(gs_spi_log);
|
||||
|
||||
/**
|
||||
SPI mode - clock polarity and phase.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
Polarity = 0, Phase = 0 (default).
|
||||
*/
|
||||
GS_SPI_MODE_CPOL0_CPHA0 = 0,
|
||||
/**
|
||||
Polarity = 0, Phase = 1.
|
||||
*/
|
||||
GS_SPI_MODE_CPOL0_CPHA1 = 1,
|
||||
/**
|
||||
Polarity = 1, Phase = 0.
|
||||
*/
|
||||
GS_SPI_MODE_CPOL1_CPHA0 = 2,
|
||||
/**
|
||||
Polarity = 1, Phase = 1.
|
||||
*/
|
||||
GS_SPI_MODE_CPOL1_CPHA1 = 3
|
||||
} gs_spi_mode_t;
|
||||
|
||||
/**
|
||||
Default bit-rate.
|
||||
*/
|
||||
#define GS_SPI_DEFAULT_BPS 400000
|
||||
|
||||
/**
|
||||
Speed (command line sub-option).
|
||||
*/
|
||||
#define GS_SPI_COMMAND_LINE_SPEED "speed"
|
||||
|
||||
/**
|
||||
Slave (command line sub-option).
|
||||
*/
|
||||
#define GS_SPI_COMMAND_LINE_SLAVE "slave"
|
||||
|
||||
/**
|
||||
Device (command line sub-option).
|
||||
*/
|
||||
#define GS_SPI_COMMAND_LINE_DEVICE "device"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,95 +0,0 @@
|
||||
#ifndef GS_UTIL_DRIVERS_SPI_MASTER_H
|
||||
#define GS_UTIL_DRIVERS_SPI_MASTER_H
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
SPI master interface.
|
||||
*/
|
||||
|
||||
#include <gs/util/drivers/spi/common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Cross-platform master SPI configuration.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
Data order, \a True: MSB first, \a False: LSB first
|
||||
Default: \a True.
|
||||
*/
|
||||
bool data_order_msb;
|
||||
/**
|
||||
Bits per second.
|
||||
Default: #GS_SPI_DEFAULT_BPS.
|
||||
*/
|
||||
uint32_t bps;
|
||||
/**
|
||||
Mode, specifying polarity and phase.
|
||||
Default: #GS_SPI_MODE_CPOL0_CPHA0.
|
||||
*/
|
||||
gs_spi_mode_t mode;
|
||||
/**
|
||||
Character size in bits, 8-16 bits.
|
||||
Default: 8 bits (prefered).
|
||||
*/
|
||||
uint8_t bits;
|
||||
} gs_spi_master_slave_config_t;
|
||||
|
||||
/**
|
||||
Single master transaction.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
Pointer to tx data, or NULL if no tx.
|
||||
*/
|
||||
const void *tx;
|
||||
/**
|
||||
Pointer to rx buffer, or NULL if no rx.
|
||||
*/
|
||||
void *rx;
|
||||
/**
|
||||
Size/length of rx/tx (bytes).
|
||||
*/
|
||||
size_t size;
|
||||
} gs_spi_master_trans_t;
|
||||
|
||||
/**
|
||||
Close/free slave.
|
||||
Freeing resources associated with the slave.
|
||||
@param[in] slave SPI slave
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_spi_master_close_slave(uint8_t slave);
|
||||
|
||||
/**
|
||||
Perform transaction to/from a pre-configured SPI slave.
|
||||
Basically for i < size: send tx[i] and receive rx[i].
|
||||
@note: 8 bit SPI character size required!
|
||||
@param[in] slave SPI slave
|
||||
@param[in] tx tx buffer
|
||||
@param[out] rx rx buffer - can be NULL.
|
||||
@param[in] size number of to send and also receive.
|
||||
@param[in] timeout_ms timeout in milliseconds, primarily for locking the SPI device.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_spi_master_transaction(uint8_t slave, const void * tx, void * rx, size_t size, int timeout_ms);
|
||||
|
||||
/**
|
||||
Perform N transaction to/from a pre-configured SPI slave within one chip selection
|
||||
@note: 8 bit SPI character size required!
|
||||
@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.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_spi_master_transactions(uint8_t slave, gs_spi_master_trans_t *trans, size_t count, int timeout_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,84 +0,0 @@
|
||||
#ifndef GS_UTIL_DRIVERS_SPI_SLAVE_H
|
||||
#define GS_UTIL_DRIVERS_SPI_SLAVE_H
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
SPI slave interface.
|
||||
*/
|
||||
|
||||
#include <gs/util/drivers/spi/common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Cross-platform slave SPI configuration.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
Data order, \a True: MSB first, \a False: LSB first
|
||||
Default: \a True.
|
||||
*/
|
||||
bool data_order_msb;
|
||||
/**
|
||||
Mode, specifying polarity and phase.
|
||||
Default: #GS_SPI_MODE_CPOL0_CPHA0.
|
||||
*/
|
||||
gs_spi_mode_t mode;
|
||||
/**
|
||||
Character size in bits, 8-16 bits.
|
||||
Default: 8 bits (prefered).
|
||||
*/
|
||||
uint8_t bits;
|
||||
} gs_spi_slave_config_t;
|
||||
|
||||
/**
|
||||
Start/enable SPI device reception.
|
||||
|
||||
Reception should not automatically be enabled by their init() functions, as this will complicate adding additional layers/hooks.
|
||||
|
||||
@param[in] device SPI device (handle)
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_spi_slave_start(uint8_t device);
|
||||
|
||||
/**
|
||||
Rx callback.
|
||||
|
||||
Function called as data is recevied on the device.
|
||||
|
||||
@param[in] device SPI device (handle).
|
||||
@param[in] rx_buffer Pointer to start of rx buffer.
|
||||
@param[in] rx number of bytes received so far.
|
||||
@param[in] new_request \a true on the first callback of new data, \a false on receiving additional data during same \a chip-select. Can be used to bring receiver back in sync with new request.
|
||||
@param_cswitch
|
||||
@return total number of bytes to receive before next call back. Return 0 to ignore rest of data - no additional call backs will be done for current SPI transaction.
|
||||
*/
|
||||
typedef uint8_t (* gs_spi_slave_receive_t)(uint8_t device, const uint8_t * rx_buffer, size_t rx, bool new_request, gs_context_switch_t * cswitch);
|
||||
|
||||
/**
|
||||
Set rx callback.
|
||||
|
||||
@param[in] device SPI device (handle).
|
||||
@param[in] rx Rx callback.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_spi_slave_set_rx(uint8_t device, gs_spi_slave_receive_t rx);
|
||||
|
||||
/**
|
||||
Set response data.
|
||||
|
||||
@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.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_spi_slave_set_response(uint8_t device, size_t offset, const uint8_t * tx, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
Reference in New Issue
Block a user