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 USART Library for STM32Fxxx - More...


 USART Typedefs.
 USART default values for defines.
 USART Functions.

Detailed Description

TM USART Library for STM32Fxxx -

Library works for all 8 U(S)ARTs which are supported on STM32Fxxx devices.

Supported devices

Library supported STM32F4xx and STM32F7xx devices as well as STM32F0xx.

All parameters in this library uses the same names as USART name in STM32 series.
USART receive interrupt handlers

Every USART channel has it's own receive interrupt which stores incoming data into cyclic buffer. If you want to use your own receive handler, then you have to open defines.h files and set a define.

//Use custom IRQ Receive handler
//Change X with possible U(S)ARTs: USART1, USART2, USART3, UART4, UART5, USART6, UART7, UART8

After you set define, you have to create a function, which will handle custom request

//Change X with possible U(S)ARTs: USART1, USART2, USART3, UART4, UART5, USART6, UART7, UART8
//Parameter c is a received character
void TM_X_ReceiveHandler(uint8_t c) {
//Do your stuff here when byte is received
If you use custom receive interrupt handler, then incoming data is not stored in internal buffer
USART Internal cyclic buffer

In your project you can set internal cyclic buffer length, default is 32Bytes, with:

//Set buffer sie for all buffers
#define TM_USART_BUFFER_SIZE number_of_bytes

in your project's defines.h file. This will set default length for each buffer. So if you are working with F429 (it has 8 U(S)ARTs) then you will use 8kB RAM if you set define above to 1024.

If you don't change anything, then all USART's have buffer length of value, stored in TM_USART_BUFFER_SIZE define. If you want let's say just for USART1 to be 1kB, but others default value, you can add define below in defines.h file:

//Buffer length for USART1 is 1kB, for others is still TM_USART_BUFFER_SIZE
#define TM_USART1_BUFFER_SIZE 1024

Other possible settings are (for other U(S)ARTs):

Custom string delimiter for TM_USART_Gets() function

By default, LF (Line Feed) character was used, but now you can select custom character using TM_USART_SetCustomStringEndCharacter() function.

             |PINSPACK 1     |PINSPACK 2     |PINSPACK 3    
U(S)ARTX     |TX     RX      |TX     RX      |TX     RX

//STM32F4xx and STM32F7xx
USART1       |PA9    PA10    |PB6    PB7     |-      -
USART2       |PA2    PA3     |PD5    PD6     |-      -
USART3       |PB10   PB11    |PC10   PC11    |PD8    PD9
UART4        |PA0    PA1     |PC10   PC11    |-      -
UART5        |PC12   PD2     |-      -       |-      -
USART6       |PC6    PC7     |PG14   PG9     |-      -
UART7        |PE8    PE7     |PF7    PF6     |-      -
UART8        |PE1    PE0     |-      -       |-      -

//Additions for STM32F0xx
USART4       |PA0    PA1     |PC10   PC11    |PE8    PE9
USART5       |PB3    PB4     |PC12   PD2     |PE10   PE11
USART7       |PC0    PC1     |PC6    PC7     |PF2    PF3
USART8       |PC2    PC3     |PC8    PC9     |PD13   PD14

In case these pins are not good for you, you can use TM_USART_PinsPack_Custom in function and callback function will be called, where you can initialize your custom pinout for your USART peripheral

Change USART default operation modes

In this section, you can change USART functionality. Do this only in case you know what are you doing!

Open defines.h file, copy define you want to change and fill settings

//Change X with possible U(S)ARTs: USART1, USART2, USART3, UART4, UART5, USART6, UART7, UART8, for STM32F0xx additions: USART4, USART5, USART7, USART8
//Set flow control
#define TM_X_HARDWARE_FLOW_CONTROL TM_USART_HardwareFlowControl_None
//Set mode
//Set parity
//Set stopbits
//Set USART datasize
 Version 1.0
   - First release
 Version 1.1
  - September 03, 2015
  - Added support for buffers which now requires separate library for USART
 Version 1.2
  - December 26, 2015
  - On reinitialization USART with other baudrate, USART didn't work properly and needs some time to start.
  - With forcing register reset this has been fixed


 - STM32Fxxx HAL
 - attributes.h
 - defines.h