TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle
TM_SPI_DMA_Functions

Library Functions. More...

Macros

#define TM_SPI_DMA_Send(SPIx, TX_Buffer, count)    (TM_SPI_DMA_Transmit(SPIx, TX_Buffer, NULL, count))
 Sends data over SPI without receiving data back using DMA. More...
 
#define TM_SPI_DMA_Receive(SPIx, RX_Buffer, count)    (TM_SPI_DMA_Transmit(SPIx, NULL, RX_Buffer, count))
 Sends dummy byte (0x00) over SPI to receive data back from slave over DMA. More...
 

Functions

void TM_SPI_DMA_Init (SPI_TypeDef *SPIx)
 Initializes SPI peripheral DMA. More...
 
void TM_SPI_DMA_InitWithStreamAndChannel (SPI_TypeDef *SPIx, DMA_Stream_TypeDef *TX_Stream, uint32_t TX_Channel, DMA_Stream_TypeDef *RX_Stream, uint32_t RX_Channel)
 Initializes SPI DMA functionality with custom DMA stream and channel options. More...
 
void TM_SPI_DMA_Deinit (SPI_TypeDef *SPIx)
 Deinitializes SPI DMA functionality. More...
 
uint8_t TM_SPI_DMA_Transmit (SPI_TypeDef *SPIx, uint8_t *TX_Buffer, uint8_t *RX_Buffer, uint16_t count)
 Transmits (exchanges) data over SPI with DMA. More...
 
uint8_t TM_SPI_DMA_SendByte (SPI_TypeDef *SPIx, uint8_t value, uint16_t count)
 Sends one byte value multiple times over SPI with DMA. More...
 
uint8_t TM_SPI_DMA_SendHalfWord (SPI_TypeDef *SPIx, uint16_t value, uint16_t count)
 Sends one half word value multiple times over SPI with DMA. More...
 
uint8_t TM_SPI_DMA_Transmitting (SPI_TypeDef *SPIx)
 Checks if SPI DMA is still sending/receiving data. More...
 
DMA_Stream_TypeDef * TM_SPI_DMA_GetStreamTX (SPI_TypeDef *SPIx)
 Gets TX DMA stream for specific SPI. More...
 
DMA_Stream_TypeDef * TM_SPI_DMA_GetStreamRX (SPI_TypeDef *SPIx)
 Gets RX DMA stream for specific SPI. More...
 
void TM_SPI_DMA_EnableInterrupts (SPI_TypeDef *SPIx)
 Enables DMA stream interrupts for specific SPI. More...
 
void TM_SPI_DMA_DisableInterrupts (SPI_TypeDef *SPIx)
 Disables DMA stream interrupts for specific SPI. More...
 

Detailed Description

Library Functions.

Macro Definition Documentation

#define TM_SPI_DMA_Receive (   SPIx,
  RX_Buffer,
  count 
)    (TM_SPI_DMA_Transmit(SPIx, NULL, RX_Buffer, count))

Sends dummy byte (0x00) over SPI to receive data back from slave over DMA.

Note
Try not to use local variables pointers for DMA memory as TX and RX Buffers
Parameters
SPIxPointer to SPIx where DMA transmission will happen
RX_BufferPointer to RX_Buffer where DMA will save data from SPI
countNumber of bytes to be received over SPI with DMA
Return values
Receivingstarted status:
  • 0: DMA has not started with sending data
  • > 0: DMA has started with sending data
Note
Defined as macro for faster execution
#define TM_SPI_DMA_Send (   SPIx,
  TX_Buffer,
  count 
)    (TM_SPI_DMA_Transmit(SPIx, TX_Buffer, NULL, count))

Sends data over SPI without receiving data back using DMA.

Note
Try not to use local variables pointers for DMA memory as TX and RX Buffers
Parameters
*SPIxPointer to SPIx where DMA transmission will happen
*TX_BufferPointer to TX_Buffer where DMA will take data to sent over SPI
countNumber of bytes to be send/received over SPI with DMA
Return values
Sendingstarted status:
  • 0: DMA has not started with sending data
  • > 0: DMA has started with sending data
Note
Defined as macro for faster execution

Function Documentation

void TM_SPI_DMA_Deinit ( SPI_TypeDef *  SPIx)

Deinitializes SPI DMA functionality.

Parameters
*SPIxPointer to SPIx where you want to disable DMA mode
Return values
None
void TM_SPI_DMA_DisableInterrupts ( SPI_TypeDef *  SPIx)

Disables DMA stream interrupts for specific SPI.

Parameters
*SPIxPointer to SPIx peripheral where you want to disable DMA stream interrupts
Return values
None
void TM_SPI_DMA_EnableInterrupts ( SPI_TypeDef *  SPIx)

Enables DMA stream interrupts for specific SPI.

Parameters
*SPIxPointer to SPIx peripheral where you want to enable DMA stream interrupts
Return values
None
DMA_Stream_TypeDef* TM_SPI_DMA_GetStreamRX ( SPI_TypeDef *  SPIx)

Gets RX DMA stream for specific SPI.

Parameters
*SPIxPointer to SPIx peripheral where you want to get RX stream
Return values
Pointerto SPI DMA RX stream
DMA_Stream_TypeDef* TM_SPI_DMA_GetStreamTX ( SPI_TypeDef *  SPIx)

Gets TX DMA stream for specific SPI.

Parameters
*SPIxPointer to SPIx peripheral where you want to get TX stream
Return values
Pointerto SPI DMA TX stream
void TM_SPI_DMA_Init ( SPI_TypeDef *  SPIx)

Initializes SPI peripheral DMA.

Note
This function initializes TX and RX DMA streams for SPI
SPI HAVE TO be previously initialized using TM_SPI library
Parameters
*SPIxPointer to SPI peripheral where you want to enable DMA None
void TM_SPI_DMA_InitWithStreamAndChannel ( SPI_TypeDef *  SPIx,
DMA_Stream_TypeDef *  TX_Stream,
uint32_t  TX_Channel,
DMA_Stream_TypeDef *  RX_Stream,
uint32_t  RX_Channel 
)

Initializes SPI DMA functionality with custom DMA stream and channel options.

Note
SPI HAVE TO be previously initialized using TM_USART library
Use this function only in case default Stream and Channel settings are not good for you
Parameters
*SPIxPointer to SPIx where you want to set custom DMA streams and channels
*TX_StreamPointer to DMAy_Streamx, where y is DMA (1 or 2) and x is Stream (0 to 7)
TX_ChannelSelect DMA TX channel for your SPI in specific DMA Stream
*RX_StreamPointer to DMAy_Streamx, where y is DMA (1 or 2) and x is Stream (0 to 7)
RX_ChannelSelect DMA RX channel for your SPI in specific DMA Stream
Return values
None
uint8_t TM_SPI_DMA_SendByte ( SPI_TypeDef *  SPIx,
uint8_t  value,
uint16_t  count 
)

Sends one byte value multiple times over SPI with DMA.

Parameters
SPIxPointer to SPIx where DMA transmission will happen
valueByte value to be sent
countNumber of bytes with value of
  • value will be sent
Return values
Transmissionstarted status:
  • 0: DMA has not started with sending data
  • > 0: DMA has started with sending data
uint8_t TM_SPI_DMA_SendHalfWord ( SPI_TypeDef *  SPIx,
uint16_t  value,
uint16_t  count 
)

Sends one half word value multiple times over SPI with DMA.

Parameters
SPIxPointer to SPIx where DMA transmission will happen
valueByte value to be sent
countNumber of half words with value of
  • value will be sent
Return values
Transmissionstarted status:
  • 0: DMA has not started with sending data
  • > 0: DMA has started with sending data
uint8_t TM_SPI_DMA_Transmit ( SPI_TypeDef *  SPIx,
uint8_t *  TX_Buffer,
uint8_t *  RX_Buffer,
uint16_t  count 
)

Transmits (exchanges) data over SPI with DMA.

Note
Try not to use local variables pointers for DMA memory as TX and RX Buffers
Parameters
*SPIxPointer to SPIx where DMA transmission will happen
*TX_BufferPointer to TX_Buffer where DMA will take data to sent over SPI. Set this parameter to NULL, if you want to sent "0x00" and only receive data into *RX_Buffer pointer
*RX_BufferPointer to RX_Buffer where DMA will save data from SPI. Set this parameter to NULL, if you don't want to receive any data, only sent from TX_Buffer
countNumber of bytes to be send/received over SPI with DMA
Return values
Transmissionstarted status:
  • 0: DMA has not started with sending data
  • > 0: DMA has started with sending data
uint8_t TM_SPI_DMA_Transmitting ( SPI_TypeDef *  SPIx)

Checks if SPI DMA is still sending/receiving data.

Parameters
*SPIxPointer to SPIx where you want to enable DMA TX mode
Return values
Sendingstatus:
  • 0: SPI DMA does not sending any more
  • > 0: SPI DMA is still sending data