fsfw-hal/stm32h7/spi/spiCore.h

61 lines
1.6 KiB
C
Raw Normal View History

2021-06-03 14:38:34 +02:00
#ifndef FSFW_HAL_STM32H7_SPI_SPICORE_H_
#define FSFW_HAL_STM32H7_SPI_SPICORE_H_
#include "stm32h7xx_hal.h"
#include "stm32h7xx_hal_dma.h"
#ifdef __cplusplus
extern "C" {
#endif
2021-06-04 16:34:38 +02:00
using msp_func_t = void (*) (void* args);
2021-06-05 13:29:43 +02:00
using spi_transfer_cb_t = void (*) (SPI_HandleTypeDef *hspi, void* userArgs);
namespace spi {
2021-06-03 21:42:52 +02:00
/**
* Assign MSP init functions. Important for SPI configuration
* @param init_func
* @param init_args
* @param deinit_func
* @param deinit_args
*/
2021-06-05 13:29:43 +02:00
void setSpiMspFunctions(msp_func_t init_func, void* init_args, msp_func_t deinit_func,
2021-06-03 21:42:52 +02:00
void* deinit_args);
2021-06-03 14:38:34 +02:00
/**
* Assign DMA handles. Required to use DMA for SPI transfers.
* @param txHandle
* @param rxHandle
*/
2021-06-05 13:29:43 +02:00
void setDmaHandles(DMA_HandleTypeDef* txHandle, DMA_HandleTypeDef* rxHandle);
void getDmaHandles(DMA_HandleTypeDef** txHandle, DMA_HandleTypeDef** rxHandle);
2021-06-03 14:38:34 +02:00
2021-06-05 13:29:43 +02:00
void getMspInitFunction(msp_func_t* init_func, void **args);
void getMspDeinitFunction(msp_func_t* deinit_func, void **args);
2021-06-03 14:38:34 +02:00
/**
* Assign SPI handle. Needs to be done before using the SPI
* @param spiHandle
*/
2021-06-05 13:29:43 +02:00
void setSpiHandle(SPI_HandleTypeDef *spiHandle);
void assignTransferRxTxCompleteCallback(spi_transfer_cb_t callback, void* userArgs);
void assignTransferRxCompleteCallback(spi_transfer_cb_t callback, void* userArgs);
void assignTransferTxCompleteCallback(spi_transfer_cb_t callback, void* userArgs);
void assignTransferErrorCallback(spi_transfer_cb_t callback, void* userArgs);
2021-06-03 14:38:34 +02:00
/**
* Get the assigned SPI handle.
* @return
*/
2021-06-05 13:29:43 +02:00
SPI_HandleTypeDef* getSpiHandle();
}
2021-06-03 14:38:34 +02:00
#ifdef __cplusplus
}
#endif
#endif /* FSFW_HAL_STM32H7_SPI_SPICORE_H_ */