Add SPI settings

This commit is contained in:
Henrik Stickann
2022-04-15 14:55:49 +02:00
parent ae460b69f6
commit 3c8fce14f6
2 changed files with 143 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
#ifndef STA_SPI_SETTINGS_HPP
#define STA_SPI_SETTINGS_HPP
#include <cstdint>
namespace sta
{
enum class SpiClkPolarity
{
LOW,
HIGH
};
enum class SpiClkPhase
{
EDGE_1,
EDGE_2
};
enum class SpiMode
{
MODE_0,
MODE_1,
MODE_2,
MODE_3
};
enum class SpiDataSize
{
BIT_8,
BIT_16
};
enum class SpiBitOrder
{
MSB,
LSB
};
enum class SpiBaudRatePrescaler
{
BRP_2,
BRP_4,
BRP_8,
BRP_16,
BRP_32,
BRP_64,
BRP_128,
BRP_256
};
struct SpiSettings
{
SpiMode mode;
SpiDataSize dataSize;
SpiBitOrder bitOrder;
uint32_t clkSpeed;
SpiBaudRatePrescaler baudRatePrescaler; /**< Subject to change */
};
SpiClkPolarity getSpiClkPolarity(SpiMode mode);
SpiClkPhase getSpiClkPhase(SpiMode mode);
SpiMode getSpiMode(SpiClkPolarity polarity, SpiClkPhase phase);
} // namespace sta
#endif // STA_SPI_SETTINGS_HPP