USART Driver API: USART Init
Now let’s implement USART_Init API.
Steps:
1. Download the file attached in the resource section, and the file name is USART_Init.c (Figure 1).
2. Copy the function in Figure 1 into the driver.c file and resolve all the TODOs. You can see TODO is mentioned at many places (Figure 2), and it is an indication for you to replace that with the actual code.
For example, in Figure 2, you have to replace the first TODO with the code to enable the clock for a given USART peripheral. If you don’t remove it, then the compiler will issue an error. Therefore, you have to remove that TODO, and instead of that, you have to write the actual code. Try to resolve all the TODOs, and that will complete the USART_Init() function.
There are several comments in the attached file. Read the comment, understand it and then try to code according to that.
3. At the end, you have to configure the baud rate (Figure 3). This part will be coded after discussing the baud rate generation.
In the following article, let’s see USART Driver API: Tx and Rx assignment.
FastBit Embedded Brain Academy Courses
Click here: https://fastbitlab.com/course1