STM32 USART Lecture 2 – USART driver APIs prototypes

 

USART driver APIs prototypes

 

 

In the realm of embedded systems and microcontroller programming, understanding USART (Universal Synchronous Asynchronous Receiver Transmitter) driver API prototypes is essential for robust driver development. These APIs form the bridge between software and hardware, enabling seamless communication.

In this article, let’s understand the API prototypes for the driver development task.

The implementation of these APIs, as depicted in Figure 1, is similar to the SPI and I2C. To kickstart your USART driver development journey, you can directly copy and paste the code for these APIs into a driver.c file.

USART driver APIs prototypes
Figure 1. APIs to be implemented.

 

Begin by extracting the API prototypes from the USART_API_prototype.h file, which can be found in the attached resource section. These prototypes should be incorporated into the driver.h file, laying the foundation for comprehensive USART functionality.

Copy the API prototypes from the file USART_API_prototype.h (Figure 2), which is attached in the resource section, and paste it in the driver.h file.

USART driver APIs prototypes
Figure 2. USART_API_prototype.h file.

 

USART driver APIs prototypes
Figure 3. API for peripheral clock setup.

 

Figure 3 shows that there are APIs for peripheral clock setup, Init and De-init, and data send and receive. There will be send data, send data with IT, receive data and receive data with IT APIs. You need to implement these APIs. So, add the prototypes of all these APIs to the driver.h file.

 

Exercise:

Implement USART_PeriClockControl(), USART_DeInit(), USART_IRQInterruptConfig(),  USART_IRQPriorityConfig(), and other peripheral control APIs.

  1. USART_PeriClockControl(): This API is responsible for configuring the peripheral clock, a fundamental step to enable USART communication.
  2. USART_DeInit(): De-initialization of the USART peripheral to reset its settings and prepare for a fresh configuration.
  3. USART_IRQInterruptConfig(): Configuration of USART interrupt settings, facilitating timely responses to communication events.
  4. USART_IRQPriorityConfig(): Prioritization of USART interrupts to manage concurrent tasks effectively.

 

 

In the following article, let’s see Configuration options and USART registers

 

FastBit Embedded Brain Academy Courses

Click here: https://fastbitlab.com/course1

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.