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_I2C_DMA_Functions

Library Functions. More...

Macros

#define TM_I2C_DMA_Send(I2Cx, TX_Buffer, count)    (TM_I2C_DMA_Transmit(I2Cx, TX_Buffer, NULL, count))
 Sends data over I2C without receiving data back using DMA. More...
 
#define TM_I2C_DMA_Receive(I2Cx, RX_Buffer, count)    (TM_I2C_DMA_Transmit(I2Cx, NULL, RX_Buffer, count))
 Sends dummy byte (0x00) over I2C to receive data back from slave over DMA. More...
 

Functions

void TM_I2C_DMA_Init (I2C_TypeDef *I2Cx)
 Initializes I2C peripheral DMA. More...
 
void TM_I2C_DMA_InitWithStreamAndChannel (I2C_TypeDef *I2Cx, DMA_Stream_TypeDef *TX_Stream, uint32_t TX_Channel, DMA_Stream_TypeDef *RX_Stream, uint32_t RX_Channel)
 Initializes I2C DMA functionality with custom DMA stream and channel options. More...
 
void TM_I2C_DMA_Deinit (I2C_TypeDef *I2Cx)
 Deinitializes I2C DMA functionality. More...
 
uint8_t TM_I2C_DMA_Transmit (I2C_TypeDef *I2Cx, uint8_t *TX_Buffer, uint8_t *RX_Buffer, uint16_t count)
 Transmits (exchanges) data over I2C with DMA. More...
 
uint8_t TM_I2C_DMA_SendByte (I2C_TypeDef *I2Cx, uint8_t value, uint16_t count)
 Sends one byte value multiple times over I2C with DMA. More...
 
uint8_t TM_I2C_DMA_SendHalfWord (I2C_TypeDef *I2Cx, uint16_t value, uint16_t count)
 Sends one half word value multiple times over I2C with DMA. More...
 
uint8_t TM_I2C_DMA_Transmitting (I2C_TypeDef *I2Cx)
 Checks if I2C DMA is still sending/receiving data. More...
 
DMA_Stream_TypeDef * TM_I2C_DMA_GetStreamTX (I2C_TypeDef *I2Cx)
 Gets TX DMA stream for specific I2C. More...
 
DMA_Stream_TypeDef * TM_I2C_DMA_GetStreamRX (I2C_TypeDef *I2Cx)
 Gets RX DMA stream for specific I2C. More...
 
void TM_I2C_DMA_EnableInterrupts (I2C_TypeDef *I2Cx)
 Enables DMA stream interrupts for specific I2C. More...
 
void TM_I2C_DMA_DisableInterrupts (I2C_TypeDef *I2Cx)
 Disables DMA stream interrupts for specific I2C. More...
 

Detailed Description

Library Functions.

Macro Definition Documentation

#define TM_I2C_DMA_Receive (   I2Cx,
  RX_Buffer,
  count 
)    (TM_I2C_DMA_Transmit(I2Cx, NULL, RX_Buffer, count))

Sends dummy byte (0x00) over I2C 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
I2CxPointer to I2Cx where DMA transmission will happen
RX_BufferPointer to RX_Buffer where DMA will save data from I2C
countNumber of bytes to be received over I2C 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_I2C_DMA_Send (   I2Cx,
  TX_Buffer,
  count 
)    (TM_I2C_DMA_Transmit(I2Cx, TX_Buffer, NULL, count))

Sends data over I2C without receiving data back using DMA.

Note
Try not to use local variables pointers for DMA memory as TX and RX Buffers
Parameters
*I2CxPointer to I2Cx where DMA transmission will happen
*TX_BufferPointer to TX_Buffer where DMA will take data to sent over I2C
countNumber of bytes to be send/received over I2C 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_I2C_DMA_Deinit ( I2C_TypeDef *  I2Cx)

Deinitializes I2C DMA functionality.

Parameters
*I2CxPointer to I2Cx where you want to disable DMA mode
Return values
None
void TM_I2C_DMA_DisableInterrupts ( I2C_TypeDef *  I2Cx)

Disables DMA stream interrupts for specific I2C.

Parameters
*I2CxPointer to I2Cx peripheral where you want to disable DMA stream interrupts
Return values
None
void TM_I2C_DMA_EnableInterrupts ( I2C_TypeDef *  I2Cx)

Enables DMA stream interrupts for specific I2C.

Parameters
*I2CxPointer to I2Cx peripheral where you want to enable DMA stream interrupts
Return values
None
DMA_Stream_TypeDef* TM_I2C_DMA_GetStreamRX ( I2C_TypeDef *  I2Cx)

Gets RX DMA stream for specific I2C.

Parameters
*I2CxPointer to I2Cx peripheral where you want to get RX stream
Return values
Pointerto I2C DMA RX stream
DMA_Stream_TypeDef* TM_I2C_DMA_GetStreamTX ( I2C_TypeDef *  I2Cx)

Gets TX DMA stream for specific I2C.

Parameters
*I2CxPointer to I2Cx peripheral where you want to get TX stream
Return values
Pointerto I2C DMA TX stream
void TM_I2C_DMA_Init ( I2C_TypeDef *  I2Cx)

Initializes I2C peripheral DMA.

Note
This function initializes TX and RX DMA streams for I2C
I2C HAVE TO be previously initialized using TM_I2C library
Parameters
*I2CxPointer to I2C peripheral where you want to enable DMA None
void TM_I2C_DMA_InitWithStreamAndChannel ( I2C_TypeDef *  I2Cx,
DMA_Stream_TypeDef *  TX_Stream,
uint32_t  TX_Channel,
DMA_Stream_TypeDef *  RX_Stream,
uint32_t  RX_Channel 
)

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

Note
I2C 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
*I2CxPointer to I2Cx 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 I2C 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 I2C in specific DMA Stream
Return values
None
uint8_t TM_I2C_DMA_SendByte ( I2C_TypeDef *  I2Cx,
uint8_t  value,
uint16_t  count 
)

Sends one byte value multiple times over I2C with DMA.

Parameters
I2CxPointer to I2Cx 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_I2C_DMA_SendHalfWord ( I2C_TypeDef *  I2Cx,
uint16_t  value,
uint16_t  count 
)

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

Parameters
I2CxPointer to I2Cx 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_I2C_DMA_Transmit ( I2C_TypeDef *  I2Cx,
uint8_t *  TX_Buffer,
uint8_t *  RX_Buffer,
uint16_t  count 
)

Transmits (exchanges) data over I2C with DMA.

Note
Try not to use local variables pointers for DMA memory as TX and RX Buffers
Parameters
*I2CxPointer to I2Cx where DMA transmission will happen
*TX_BufferPointer to TX_Buffer where DMA will take data to sent over I2C. 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 I2C. 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 I2C with DMA
Return values
Transmissionstarted status:
  • 0: DMA has not started with sending data
  • > 0: DMA has started with sending data
uint8_t TM_I2C_DMA_Transmitting ( I2C_TypeDef *  I2Cx)

Checks if I2C DMA is still sending/receiving data.

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