Analyze the UART IIC SPI driver writing steps

1. First, set the function of the pin and set the pin to the corresponding mode

 

2. Then set some parameters corresponding to the serial port controller (that is, some parameters of the register) to complete the basic settings of the serial port, such as the baud rate of the UART. The parameters to be configured are generally listed in the initialization structure of the corresponding peripheral. So this step becomes very simple, just assign values ​​to the initialization structure of the corresponding peripheral. And I found that the setting of the pin is actually the assignment of the parameter inside the structure of the pin! ! ! ! ! It's all made into a structure, very convenient! ! ! ! ! ! ! ! ! ! So the whole process becomes just fill in the two structures, no wonder you don't need to use STM32cube to select a few times! ! ! ! ! ! This is indeed the essence! ! ! ! ! ! !

 

3. Then write send or receive.

 

I think the main body can be divided into the above three parts.

 

The screenshot below is from Wildfire's STM32 book

Guess you like

Origin blog.csdn.net/sinat_16643223/article/details/109285568