2021-06-03 14:38:34 +02:00
|
|
|
#ifndef FSFW_HAL_STM32H7_SPI_SPICORE_H_
|
|
|
|
#define FSFW_HAL_STM32H7_SPI_SPICORE_H_
|
|
|
|
|
2021-06-10 19:09:33 +02:00
|
|
|
#include <fsfw_hal/stm32h7/dma.h>
|
2021-06-03 14:38:34 +02:00
|
|
|
#include "stm32h7xx_hal.h"
|
|
|
|
#include "stm32h7xx_hal_dma.h"
|
|
|
|
|
2021-06-10 19:09:33 +02:00
|
|
|
|
2021-06-03 14:38:34 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
2021-06-10 19:09:33 +02:00
|
|
|
void configureDmaHandle(DMA_HandleTypeDef* Handle, dma::DMAType dmaType, dma::DMAIndexes dmaIdx,
|
|
|
|
dma::DMAStreams dmaStream, IRQn_Type* dmaIrqNumber, uint32_t dmaMode = DMA_NORMAL,
|
|
|
|
uint32_t dmaPriority = DMA_PRIORITY_LOW);
|
2021-06-03 21:42:52 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* 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_ */
|