65 lines
1.6 KiB
C
65 lines
1.6 KiB
C
/**
|
|
* @file include/di_fw/spi.h
|
|
* @brief battery header file
|
|
* @date April 20, 2016
|
|
* @author A.A.W.M. Ruijs
|
|
* @copyright 2016 Dual Inventive Technology Centre B.V.
|
|
*/
|
|
#ifndef INCLUDE_DI_FW_SPI_H_
|
|
#define INCLUDE_DI_FW_SPI_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <di_fw/os.h>
|
|
|
|
/**
|
|
* SPI context
|
|
*/
|
|
struct di_fw_spi_ctx {
|
|
SPIDriver *drv;
|
|
/* blankline here for linter */
|
|
const SPIConfig cfg;
|
|
};
|
|
|
|
/**
|
|
* Initialize SPI
|
|
*/
|
|
void di_fw_spi_init(const struct di_fw_spi_ctx *ctx);
|
|
|
|
/**
|
|
* Spi exchange function
|
|
* @param ctx SPI context pointer
|
|
* @param tx pointer to write buffer
|
|
* @param rx pointer to read buffer
|
|
* @param bytes amount of bytes that need to be written and read
|
|
*/
|
|
int di_fw_spi_exchange(const struct di_fw_spi_ctx *ctx, uint8_t *tx, uint8_t *rx, size_t bytes);
|
|
|
|
/**
|
|
* SPI write/read function
|
|
* @param ctx SPI context pointer
|
|
* @param tx pointer to write buffer
|
|
* @param tx_size amount of bytes that need to be written
|
|
* @param rx pointer to read buffer
|
|
* @param rx_size amount of bytes that need to be read
|
|
*/
|
|
int di_fw_spi_writeread(const struct di_fw_spi_ctx *ctx, uint8_t *tx, size_t tx_size, uint8_t *rx, size_t rx_size);
|
|
|
|
/**
|
|
* Spi write function
|
|
* @param ctx SPI context pointer
|
|
* @param tx pointer to write buffer
|
|
* @param bytes amount of bytes that need to be written
|
|
*/
|
|
int di_fw_spi_write(const struct di_fw_spi_ctx *ctx, uint8_t *tx, size_t size);
|
|
|
|
/**
|
|
* Spi reads function
|
|
* @param ctx SPI context pointer
|
|
* @param rx pointer to read buffer
|
|
* @param bytes amount of bytes that need to be read
|
|
*/
|
|
int di_fw_spi_read(const struct di_fw_spi_ctx *ctx, uint8_t *rx, size_t size);
|
|
|
|
#endif /* INCLUDE_DI_FW_SPI_H_ */
|