fsfw-hal/stm32h7/spi/spiDefinitions.h

51 lines
1.2 KiB
C
Raw Normal View History

2021-06-03 14:00:50 +02:00
#ifndef FSFW_HAL_STM32H7_SPI_SPIDEFINITIONS_H_
#define FSFW_HAL_STM32H7_SPI_SPIDEFINITIONS_H_
#include "../../common/spi/spiCommon.h"
2021-06-05 00:04:38 +02:00
#include "fsfw/returnvalues/FwClassIds.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
2021-06-03 14:00:50 +02:00
#include "stm32h7xx_hal.h"
#include "stm32h7xx_hal_spi.h"
namespace spi {
2021-06-05 00:04:38 +02:00
static constexpr uint8_t HAL_SPI_ID = CLASS_ID::HAL_SPI;
static constexpr ReturnValue_t HAL_TIMEOUT_RETVAL = HasReturnvaluesIF::makeReturnCode(HAL_SPI_ID, 0);
2021-06-05 14:31:49 +02:00
static constexpr ReturnValue_t HAL_BUSY_RETVAL = HasReturnvaluesIF::makeReturnCode(HAL_SPI_ID, 1);
static constexpr ReturnValue_t HAL_ERROR_RETVAL = HasReturnvaluesIF::makeReturnCode(HAL_SPI_ID, 2);
2021-06-05 00:04:38 +02:00
2021-06-11 10:37:48 +02:00
enum class TransferStates {
IDLE,
WAIT,
SUCCESS,
FAILURE
};
2021-06-04 16:34:38 +02:00
enum SpiBus {
SPI_1,
SPI_2
};
2021-06-03 21:53:52 +02:00
enum TransferModes {
POLLING,
INTERRUPT,
DMA
};
2021-06-10 12:05:49 +02:00
void assignSpiMode(SpiModes spiMode, SPI_HandleTypeDef& spiHandle);
2021-06-03 14:00:50 +02:00
2021-06-03 14:03:38 +02:00
/**
* @brief Set SPI frequency to calculate correspondent baud-rate prescaler.
* @param clock_src_freq Frequency of clock source
* @param baudrate_mbps Baudrate to set to set
* @retval Baudrate prescaler
*/
uint32_t getPrescaler(uint32_t clock_src_freq, uint32_t baudrate_mbps);
2021-06-03 14:00:50 +02:00
}
#endif /* FSFW_HAL_STM32H7_SPI_SPIDEFINITIONS_H_ */