This example code shows how to use the STM32F407′s USART. It initializes the USART1 in receive and transmit mode an receives a data string via an interrupt.
The USART allows us to send data to a PC or other device via the serial interface (RS232). We can also receive data from a PC or another device. However please note that the STM32F407 works at 3.3V and most other devices operate at 5V or even the standard +-12V for RS232.
In order to connect to these devices (particularly the RS232 devices) you need to use a level shifter like the MAX232 or a serial to USB converter like the FT232.
If you wonder where to find all the values and properties for the InitStruct’s have a look at the include files located in the STM32F4 library by ST under Libraries/STM32F4xx_StdPeriph_Driver/ in the inc and src folders
Everything is explained in the comments. Enjoy the code!