Creating USART Static Drivers
The Static driver library is used to control individual Universal Synchronous/Asynchronous Receiver/Transmitter (USART) peripherals (USART1 or USART2 or …). MHC is used to configure which USART peripheral is controlled by a specific USART driver instance. These custom drivers are created by MHC when you generate the files (click the "Generate" button). Here are some examples of Static drivers:
rx_byte = DRV_USART0_ReadByte (); // Read a byte from USART driver instance 0 DRV_USART0_WriteByte ('a'); // Write character 'a' to USART driver instance 0 DRV_USART1_WriteByte ('b'); // Write character 'b' to USART driver instance 1
If the Static drivers shown above were configured by MHC as shown in the picture below, then the character 'a' will be transmitted on USART4 and 'b' will be transmitted on USART2.
Harmony Static Drivers are simpler to use than Dynamic Drivers because they don't rely on an object-oriented (data structure-oriented) programming model. Data structures (objects) defining the drivers are not needed for the Static Drivers because the static driver functions are generated (customized) by MHC, based on the selections you've made in MHC.
|USART Static Driver Functions|
Initialize USART driver instance 0 (not the non-existant USART0 peripheral)
Returns true if USART instance 0 receiver buffer is empty
Receive a byte from USART instance 0
Transmit the character 'c' to USART instance 0
The Static Driver functions shown above are for USART Driver instance 0. The "0" in USART0" indicates which driver instance is being controlled. In other words, if you need two Static Drivers, MHC will generate a group of "USART0" functions and a group of "USART1" functions (to control driver instance 0 and instance 1 respectively).
The Static Driver API is much smaller than the Dynamic Driver API, and only implements a byte-by-byte transfer model. These are all the functions implemented for a single USART Static driver instance:
Using USART Static Drivers
Once you have used MHC to generate the USART Static Drivers, you can use them as shown in the example below.
Using the USART Static Driver
You do not need to understand how MHC creates static drivers to use them. If you want these details, click the following button. For a higher level understanding of how to use USART Static Drivers, click on the "Harmony USART Tutorial" button below.
USART Static Driver Details
Learn more >