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

USART Functions. More...

Functions

void TM_USART_Init (USART_TypeDef *USARTx, TM_USART_PinsPack_t pinspack, uint32_t baudrate)
 Initializes USARTx peripheral and corresponding pins. More...
 
void TM_USART_InitWithFlowControl (USART_TypeDef *USARTx, TM_USART_PinsPack_t pinspack, uint32_t baudrate, TM_USART_HardwareFlowControl_t FlowControl)
 Initializes USARTx peripheral and corresponding pins with custom hardware flow control mode. More...
 
static __INLINE void TM_USART_Putc (USART_TypeDef *USARTx, volatile char c)
 Puts character to USART port. More...
 
void TM_USART_Puts (USART_TypeDef *USARTx, char *str)
 Puts string to USART port. More...
 
void TM_USART_Send (USART_TypeDef *USARTx, uint8_t *DataArray, uint16_t count)
 Sends data array to USART port. More...
 
uint8_t TM_USART_Getc (USART_TypeDef *USARTx)
 Gets character from internal USART buffer. More...
 
uint16_t TM_USART_Gets (USART_TypeDef *USARTx, char *buffer, uint16_t bufsize)
 Get string from USART. More...
 
int16_t TM_USART_FindCharacter (USART_TypeDef *USARTx, uint8_t c)
 Check if character c is available in internal buffer. More...
 
uint8_t TM_USART_BufferEmpty (USART_TypeDef *USARTx)
 Checks if internal USARTx buffer is empty. More...
 
uint8_t TM_USART_BufferFull (USART_TypeDef *USARTx)
 Checks if internal USARTx buffer is full. More...
 
uint16_t TM_USART_BufferCount (USART_TypeDef *USARTx)
 Gets number of bytes in USART buffer. More...
 
void TM_USART_ClearBuffer (USART_TypeDef *USARTx)
 Clears internal USART buffer. More...
 
void TM_USART_SetCustomStringEndCharacter (USART_TypeDef *USARTx, uint8_t Character)
 Sets custom character for TM_USART_Gets() function to detect when string ends. More...
 
int16_t TM_USART_FindString (USART_TypeDef *USARTx, char *str)
 Search for string in USART buffer if exists. More...
 
void TM_USART_InitCustomPinsCallback (USART_TypeDef *USARTx, uint16_t AlternateFunction)
 Callback for custom pins initialization for USARTx. More...
 
__weak void TM_USART1_ReceiveHandler (uint8_t c)
 Callback function for receive interrupt on USART1 in case you have enabled custom USART handler mode. More...
 
__weak void TM_USART2_ReceiveHandler (uint8_t c)
 Callback function for receive interrupt on USART2 in case you have enabled custom USART handler mode. More...
 
__weak void TM_USART3_ReceiveHandler (uint8_t c)
 Callback function for receive interrupt on USART3 in case you have enabled custom USART handler mode. More...
 
__weak void TM_UART4_ReceiveHandler (uint8_t c)
 Callback function for receive interrupt on UART4 in case you have enabled custom USART handler mode. More...
 
__weak void TM_UART5_ReceiveHandler (uint8_t c)
 Callback function for receive interrupt on UART5 in case you have enabled custom USART handler mode. More...
 
__weak void TM_USART6_ReceiveHandler (uint8_t c)
 Callback function for receive interrupt on USART6 in case you have enabled custom USART handler mode. More...
 
__weak void TM_UART7_ReceiveHandler (uint8_t c)
 Callback function for receive interrupt on UART7 in case you have enabled custom USART handler mode. More...
 
__weak void TM_UART8_ReceiveHandler (uint8_t c)
 Callback function for receive interrupt on UART8 in case you have enabled custom USART handler mode. More...
 

Detailed Description

USART Functions.

Function Documentation

__weak void TM_UART4_ReceiveHandler ( uint8_t  c)

Callback function for receive interrupt on UART4 in case you have enabled custom USART handler mode.

Note
With __weak parameter to prevent link errors if not defined by user
Parameters
ccharacter received via USART
Return values
None
__weak void TM_UART5_ReceiveHandler ( uint8_t  c)

Callback function for receive interrupt on UART5 in case you have enabled custom USART handler mode.

Note
With __weak parameter to prevent link errors if not defined by user
Parameters
ccharacter received via USART
Return values
None
__weak void TM_UART7_ReceiveHandler ( uint8_t  c)

Callback function for receive interrupt on UART7 in case you have enabled custom USART handler mode.

Note
With __weak parameter to prevent link errors if not defined by user
Parameters
ccharacter received via USART
Return values
None
__weak void TM_UART8_ReceiveHandler ( uint8_t  c)

Callback function for receive interrupt on UART8 in case you have enabled custom USART handler mode.

Note
With __weak parameter to prevent link errors if not defined by user
Parameters
ccharacter received via USART
Return values
None
__weak void TM_USART1_ReceiveHandler ( uint8_t  c)

Callback function for receive interrupt on USART1 in case you have enabled custom USART handler mode.

Note
With __weak parameter to prevent link errors if not defined by user
Parameters
ccharacter received via USART
Return values
None
__weak void TM_USART2_ReceiveHandler ( uint8_t  c)

Callback function for receive interrupt on USART2 in case you have enabled custom USART handler mode.

Note
With __weak parameter to prevent link errors if not defined by user
Parameters
ccharacter received via USART
Return values
None
__weak void TM_USART3_ReceiveHandler ( uint8_t  c)

Callback function for receive interrupt on USART3 in case you have enabled custom USART handler mode.

Note
With __weak parameter to prevent link errors if not defined by user
Parameters
ccharacter received via USART
Return values
None
__weak void TM_USART6_ReceiveHandler ( uint8_t  c)

Callback function for receive interrupt on USART6 in case you have enabled custom USART handler mode.

Note
With __weak parameter to prevent link errors if not defined by user
Parameters
ccharacter received via USART
Return values
None
uint16_t TM_USART_BufferCount ( USART_TypeDef *  USARTx)

Gets number of bytes in USART buffer.

Parameters
*USARTxPointer to USARTx peripheral you will use
Return values
Numberof elements in buffer
uint8_t TM_USART_BufferEmpty ( USART_TypeDef *  USARTx)

Checks if internal USARTx buffer is empty.

Parameters
*USARTxPointer to USARTx peripheral you will use
Return values
Bufferempty status:
  • 0: Buffer is not empty
  • > 0: Buffer is empty
uint8_t TM_USART_BufferFull ( USART_TypeDef *  USARTx)

Checks if internal USARTx buffer is full.

Parameters
*USARTxPointer to USARTx peripheral you will use
Return values
Bufferfull status:
  • 0: Buffer is not full
  • > 0: Buffer is full
void TM_USART_ClearBuffer ( USART_TypeDef *  USARTx)

Clears internal USART buffer.

Parameters
*USARTxPointer to USARTx peripheral you will use
Return values
None
int16_t TM_USART_FindCharacter ( USART_TypeDef *  USARTx,
uint8_t  c 
)

Check if character c is available in internal buffer.

Parameters
*USARTxPointer to USARTx peripheral you will use
ccharacter to check if it is in USARTx's buffer
Return values
Characterstatus:
  • < 0: Character was not found
  • >= 0: Character has been found in buffer
int16_t TM_USART_FindString ( USART_TypeDef *  USARTx,
char *  str 
)

Search for string in USART buffer if exists.

Parameters
*USARTxPointer to USARTx peripheral you will use
*strString to be searched
Return values
Searchstatus:
  • < 0: String is not in buffer
  • >= 0: String is in buffer
uint8_t TM_USART_Getc ( USART_TypeDef *  USARTx)

Gets character from internal USART buffer.

Parameters
*USARTxPointer to USARTx peripheral you will use
Return values
Characterfrom buffer, or 0 if nothing in buffer
uint16_t TM_USART_Gets ( USART_TypeDef *  USARTx,
char *  buffer,
uint16_t  bufsize 
)

Get string from USART.

This function can create a string from USART received data.

It generates string until "\n" is not recognized or buffer length is full.

Note
As of version 1.5, this function automatically adds 0x0A (Line feed) at the end of string.
Parameters
*USARTxPointer to USARTx peripheral you will use
*bufferPointer to buffer where data will be stored from buffer
bufsizemaximal number of characters we can add to your buffer, including leading zero
Return values
Numberof characters in buffer
void TM_USART_Init ( USART_TypeDef *  USARTx,
TM_USART_PinsPack_t  pinspack,
uint32_t  baudrate 
)

Initializes USARTx peripheral and corresponding pins.

Parameters
*USARTxPointer to USARTx peripheral you will use
pinspackThis parameter can be a value of TM_USART_PinsPack_t enumeration
baudrateBaudrate number for USART communication
Return values
None
void TM_USART_InitCustomPinsCallback ( USART_TypeDef *  USARTx,
uint16_t  AlternateFunction 
)

Callback for custom pins initialization for USARTx.

When you call TM_USART_Init() function, and if you pass

  • TM_USART_PinsPack_Custom to function, then this function will be called where you can initialize custom pins for USART peripheral.
    Note
    With __weak parameter to prevent link errors if not defined by user
    Parameters
    *USARTxPointer to USARTx peripheral you will use for initialization
    AlternateFunctionAlternate function number which should be used for GPIO pins
    Return values
    None
void TM_USART_InitWithFlowControl ( USART_TypeDef *  USARTx,
TM_USART_PinsPack_t  pinspack,
uint32_t  baudrate,
TM_USART_HardwareFlowControl_t  FlowControl 
)

Initializes USARTx peripheral and corresponding pins with custom hardware flow control mode.

Note
Hardware flow control pins are not initialized. Easy solution is to use
Parameters
*USARTxPointer to USARTx peripheral you will use
pinspackThis parameter can be a value of TM_USART_PinsPack_t enumeration
baudrateBaudrate number for USART communication
FlowControlFlow control mode you will use. This parameter can be a value of TM_USART_HardwareFlowControl_t enumeration
Return values
None
static __INLINE void TM_USART_Putc ( USART_TypeDef *  USARTx,
volatile char  c 
)
static

Puts character to USART port.

Parameters
*USARTxPointer to USARTx peripheral you will use
ccharacter to be send over USART
Return values
None
void TM_USART_Puts ( USART_TypeDef *  USARTx,
char *  str 
)

Puts string to USART port.

Parameters
*USARTxPointer to USARTx peripheral you will use
*strPointer to string to send over USART
Return values
None
void TM_USART_Send ( USART_TypeDef *  USARTx,
uint8_t *  DataArray,
uint16_t  count 
)

Sends data array to USART port.

Parameters
*USARTxPointer to USARTx peripheral you will use
*DataArrayPointer to data array to be sent over USART
countNumber of elements in data array to be send over USART
Return values
None
void TM_USART_SetCustomStringEndCharacter ( USART_TypeDef *  USARTx,
uint8_t  Character 
)

Sets custom character for TM_USART_Gets() function to detect when string ends.

Parameters
*USARTxPointer to USARTx peripheral you will use
CharacterCharacter value to be used as string end
Note
Character will also be added at the end for your buffer when calling TM_USART_Gets() function
Return values
None