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

Library Functions. More...

Macros

#define TM_BUFFER_SetStringDelimiter(Buffer, StrDel)   ((Buffer)->StringDelimiter = (StrDel))
 Sets string delimiter character when reading from buffer as string. More...
 

Functions

uint8_t TM_BUFFER_Init (TM_BUFFER_t *Buffer, uint32_t Size, uint8_t *BufferPtr)
 Initializes buffer structure for work. More...
 
void TM_BUFFER_Free (TM_BUFFER_t *Buffer)
 Free memory for buffer allocated using malloc. More...
 
uint32_t TM_BUFFER_Write (TM_BUFFER_t *Buffer, uint8_t *Data, uint32_t count)
 Writes data to buffer. More...
 
uint32_t TM_BUFFER_WriteToTop (TM_BUFFER_t *Buffer, uint8_t *Data, uint32_t count)
 Writes data to buffer to top of buffer in reversed order. More...
 
uint32_t TM_BUFFER_Read (TM_BUFFER_t *Buffer, uint8_t *Data, uint32_t count)
 Reads data from buffer. More...
 
uint32_t TM_BUFFER_GetFree (TM_BUFFER_t *Buffer)
 Gets number of free elements in buffer. More...
 
uint32_t TM_BUFFER_GetFull (TM_BUFFER_t *Buffer)
 Gets number of elements in buffer. More...
 
void TM_BUFFER_Reset (TM_BUFFER_t *Buffer)
 Resets (clears) buffer pointers. More...
 
int32_t TM_BUFFER_FindElement (TM_BUFFER_t *Buffer, uint8_t Element)
 Checks if specific element value is stored in buffer. More...
 
int32_t TM_BUFFER_Find (TM_BUFFER_t *Buffer, uint8_t *Data, uint32_t Size)
 Checks if specific data sequence are stored in buffer. More...
 
uint32_t TM_BUFFER_WriteString (TM_BUFFER_t *Buffer, char *buff)
 Writes string formatted data to buffer. More...
 
uint32_t TM_BUFFER_ReadString (TM_BUFFER_t *Buffer, char *buff, uint32_t buffsize)
 Reads from buffer as string. More...
 
int8_t TM_BUFFER_CheckElement (TM_BUFFER_t *Buffer, uint32_t pos, uint8_t *element)
 Checks if character exists in location in buffer. More...
 

Detailed Description

Library Functions.

Macro Definition Documentation

#define TM_BUFFER_SetStringDelimiter (   Buffer,
  StrDel 
)    ((Buffer)->StringDelimiter = (StrDel))

Sets string delimiter character when reading from buffer as string.

Parameters
BufferPointer to TM_BUFFER_t structure
StringDelimIterCharacter as string delimiter
Return values
None

Function Documentation

int8_t TM_BUFFER_CheckElement ( TM_BUFFER_t Buffer,
uint32_t  pos,
uint8_t *  element 
)

Checks if character exists in location in buffer.

Parameters
*BufferPointer to TM_BUFFER_t structure
posPosition in buffer, starting from 0
*elementPointer to save value at desired position to be stored into
Return values
Checkstatus:
  • 0: Buffer is not so long as position desired
  • > 0: Position to check was inside buffer data size
int32_t TM_BUFFER_Find ( TM_BUFFER_t Buffer,
uint8_t *  Data,
uint32_t  Size 
)

Checks if specific data sequence are stored in buffer.

Parameters
*BufferPointer to TM_BUFFER_t structure
uint8_t*Data: Array with data sequence
SizeData size in units of bytes
Return values
Statusof sequence:
  • < 0: Sequence was not found
  • >= 0: Sequence found, start sequence location in buffer is returned
int32_t TM_BUFFER_FindElement ( TM_BUFFER_t Buffer,
uint8_t  Element 
)

Checks if specific element value is stored in buffer.

Parameters
*BufferPointer to TM_BUFFER_t structure
uint8_tElement: Element to check
Return values
Statusof element:
  • < 0: Element was not found
  • >= 0: Element found, location in buffer is returned Ex: If value 1 is returned, it means 1 read from buffer and your element will be returned
void TM_BUFFER_Free ( TM_BUFFER_t Buffer)

Free memory for buffer allocated using malloc.

Note
This function has sense only if malloc was used for dynamic allocation
Parameters
*BufferPointer to TM_BUFFER_t structure
Return values
None
uint32_t TM_BUFFER_GetFree ( TM_BUFFER_t Buffer)

Gets number of free elements in buffer.

Parameters
*BufferPointer to TM_BUFFER_t structure
Return values
Numberof free elements in buffer
uint32_t TM_BUFFER_GetFull ( TM_BUFFER_t Buffer)

Gets number of elements in buffer.

Parameters
*BufferPointer to TM_BUFFER_t structure
Return values
Numberof elements in buffer
uint8_t TM_BUFFER_Init ( TM_BUFFER_t Buffer,
uint32_t  Size,
uint8_t *  BufferPtr 
)

Initializes buffer structure for work.

Parameters
*BufferPointer to TM_BUFFER_t structure to initialize
SizeSize of buffer in units of bytes
*BufferPtrPointer to array for buffer storage. Its length should be equal to
Sizeparameter. If NULL is passed as parameter, malloc will be used to allocate memory on heap.
Return values
Bufferinitialization status:
  • 0: Buffer initialized OK
  • > 0: Buffer initialization error. Malloc has failed with allocation
uint32_t TM_BUFFER_Read ( TM_BUFFER_t Buffer,
uint8_t *  Data,
uint32_t  count 
)

Reads data from buffer.

Parameters
*BufferPointer to TM_BUFFER_t structure
*DataPointer to data where read values will be stored
countNumber of elements of type unsigned char to read
Return values
Numberof elements read from buffer
uint32_t TM_BUFFER_ReadString ( TM_BUFFER_t Buffer,
char *  buff,
uint32_t  buffsize 
)

Reads from buffer as string.

Parameters
*BufferPointer to TM_BUFFER_t structure
*buffPointer to buffer where string will be stored
buffsizeBuffer size in units of bytes
Return values
Numberof characters in string
void TM_BUFFER_Reset ( TM_BUFFER_t Buffer)

Resets (clears) buffer pointers.

Parameters
*BufferPointer to TM_BUFFER_t structure
Return values
None
uint32_t TM_BUFFER_Write ( TM_BUFFER_t Buffer,
uint8_t *  Data,
uint32_t  count 
)

Writes data to buffer.

Parameters
*BufferPointer to TM_BUFFER_t structure
*DataPointer to data to be written
countNumber of elements of type unsigned char to write
Return values
Numberof elements written in buffer
uint32_t TM_BUFFER_WriteString ( TM_BUFFER_t Buffer,
char *  buff 
)

Writes string formatted data to buffer.

Parameters
*BufferPointer to TM_BUFFER_t structure
*buffPointer to string to write
Return values
Numberof characters written
uint32_t TM_BUFFER_WriteToTop ( TM_BUFFER_t Buffer,
uint8_t *  Data,
uint32_t  count 
)

Writes data to buffer to top of buffer in reversed order.

Note
This function is not thread safe so make sure you don't have read operations when you try to use this function.
Parameters
*BufferPointer to TM_BUFFER_t structure
*DataPointer to data to be written
countNumber of elements of type unsigned char to write
Return values
Numberof elements written in buffer on top in reverse order