modm API documentation

#include <modm/platform/spi/spi_hal_1.hpp>

Inheritance diagram for modm::platform::SpiHal1:
modm::platform::SpiBase

Public Types

enum  DataMode : uint32_t {
  DataMode::Mode0 = 0b00, DataMode::Mode1 = SPI_CR1_CPHA, DataMode::Mode2 = SPI_CR1_CPOL, Mode3 = SPI_CR1_CPOL | SPI_CR1_CPHA,
  All = Mode3
}
 
enum  DataOrder : uint32_t { MsbFirst = 0b0, LsbFirst = SPI_CR1_LSBFIRST, All = LsbFirst }
 
enum  DataSize : uint32_t { Bit8 = 0, Bit16 = SPI_CR1_DFF, All = Bit16 }
 
enum  Interrupt : uint32_t {
  RxBufferNotEmpty = SPI_CR2_RXNEIE, TxBufferEmpty = SPI_CR2_TXEIE, Error = SPI_CR2_ERRIE, RxDmaEnable = SPI_CR2_RXDMAEN,
  TxDmaEnable = SPI_CR2_TXDMAEN
}
 
enum  InterruptFlag : uint32_t {
  TxBufferEmpty = SPI_SR_TXE, RxBufferNotEmpty = SPI_SR_RXNE, CrcError = SPI_SR_CRCERR, ModeFaultError = SPI_SR_MODF,
  OverrunError = SPI_SR_OVR, Busy = SPI_SR_BSY, FrameFormatError = SPI_SR_FRE
}
 
enum  MasterSelection : uint32_t { Slave = 0, Master = SPI_CR1_MSTR, All = Master }
 
enum  Prescaler : uint32_t {
  Div2 = 0, Div4 = SPI_CR1_BR_0, Div8 = SPI_CR1_BR_1, Div16 = SPI_CR1_BR_1 | SPI_CR1_BR_0,
  Div32 = SPI_CR1_BR_2, Div64 = SPI_CR1_BR_2 | SPI_CR1_BR_0, Div128 = SPI_CR1_BR_2 | SPI_CR1_BR_1, Div256 = SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0
}
 

Public Member Functions

 MODM_FLAGS32 (Interrupt)
 
 MODM_FLAGS32 (InterruptFlag)
 

Static Public Member Functions

static void enable ()
 Enables the clock, resets the hardware and sets the SPE bit.
 
static void disable ()
 Disables the hw module (by disabling its clock line)
 
static void initialize (Prescaler prescaler, MasterSelection masterSelection=MasterSelection::Master, DataMode dataMode=DataMode::Mode0, DataOrder dataOrder=DataOrder::MsbFirst, DataSize dataSize=DataSize::Bit8)
 
static void setDataMode (DataMode dataMode)
 
static void setDataOrder (DataOrder dataOrder)
 
static void setDataSize (DataSize dataSize)
 
static void setMasterSelection (MasterSelection masterSelection)
 
static bool isReceiveRegisterNotEmpty ()
 Returns true if data has been received.
 
static bool isTransmitRegisterEmpty ()
 Returns true if data can be written.
 
static void write (uint16_t data)
 
static void write (uint8_t data)
 
static void read (uint8_t &data)
 
static void read (uint16_t &data)
 
static void enableInterruptVector (bool enable, uint32_t priority)
 
static void enableInterrupt (Interrupt_t interrupt)
 
static void disableInterrupt (Interrupt_t interrupt)
 
static InterruptFlag_t getInterruptFlags ()
 
static void acknowledgeInterruptFlag (InterruptFlag_t flags)
 
static void enableTransfer ()
 
static void disableTransfer ()
 

Detailed Description

Serial peripheral interface (SPI1)

Very basic implementation that exposes more hardware features than the regular Spi classes.

Author
Kevin Laeufer

Member Enumeration Documentation

enum modm::platform::SpiBase::DataMode : uint32_t
inheritedstrong
Enum ValuesDocumentation
Mode0 

clock normal, sample on rising edge

Mode1 

clock normal, sample on falling edge

Mode2 

clock inverted, sample on falling edge clock inverted, sample on rising edge

Member Function Documentation

static void modm::platform::SpiHal1::acknowledgeInterruptFlag ( InterruptFlag_t  flags)
static
Warning
Not all InterruptFlags can be cleared this way.
static void modm::platform::SpiHal1::initialize ( Prescaler  prescaler,
MasterSelection  masterSelection = MasterSelection::Master,
DataMode  dataMode = DataMode::Mode0,
DataOrder  dataOrder = DataOrder::MsbFirst,
DataSize  dataSize = DataSize::Bit8 
)
static

Initialize Spi Peripheral

Enables clocks, the UART peripheral Sets baudrate and parity.

static void modm::platform::SpiHal1::read ( uint16_t &  data)
static

Returns the value of the data register

Warning
This method does NOT do any sanity checks!! It is your responsibility to check if the register contains something useful!
static void modm::platform::SpiHal1::read ( uint8_t &  data)
static

Returns the value of the data register

Warning
This method does NOT do any sanity checks!! It is your responsibility to check if the register contains something useful!
static void modm::platform::SpiHal1::write ( uint16_t  data)
static

Write up to 16 Bit to the data register

Warning
This method does NOT do any sanity checks!! It is your responsibility to check if the register is empty!
static void modm::platform::SpiHal1::write ( uint8_t  data)
static

Write 8 Bit to the data register

Warning
This method does NOT do any sanity checks!! It is your responsibility to check if the register is empty!

The documentation for this class was generated from the following file: