Creating USART Dynamic Drivers
MHC does not create functions for Dynamic Drivers like it does for Static Drivers. It instead uses the Universal Synchronous/Asynchronous Receiver/Transmitter (USART) Driver configuration macros to create data structures (also known as objects) for each USART Driver instance. These objects are passed into the Dynamic Driver functions to specify how the drivers are configured. This means a USART Dynamic Driver function can control any USART instance, depending on which instance you pass into the function.
MHC also uses USART peripheral libraries to configure the specific peripherals you selected to use for each driver instance.
|USART Data Transfer Model||DMA?|
|Byte by Byte||No|
|File I/O Read/Write||No|
|File I/O Read/Write with Buffer Queue||No|
|Buffer Queue with DMA||Yes|
Unlike the USART Static drivers, the Dynamic drivers provide three different data transfer models:
- Byte by Byte
- Transfer data through USART driver one byte at a time.
- File I/O Read/Write
- Can process a block of data using read and write functions. Depending on the mode (blocking or non-blocking) in which the client opened the driver, the driver will either block until all of the data is transferred (only if using an RTOS) or will immediately return with the number of bytes transferred.
- Buffer Queue
- Allows clients to queue data transfers for processing. The driver returns a buffer handle for a queued request. Clients can track the completion of a buffer through events and API.
You configure the USART Dynamic Drivers using the selections provided by MHC. These drivers are created when you press the MHC "Generate" button. MHC's first step in this process is to create USART Driver configuration macros based on your selections.
Next, MHC uses these macros to create the USART Driver initialization structures.
The last job MHC performs for you is to initialize the USART Dynamic Driver object structures.
Using USART Dynamic Drivers
Once the driver is initialized, it must be "opened" by a client before it can be used.
You must do the following:
- Create a handle (pointer) for a client to use with a USART Driver instance.
- Open a client for a specific USART Driver instance and assign the handle to it.
Opening a Client for a USART Dynamic Driver
Two parameters are passed into this USART open function:
- Specific USART instance to open
- How you want to use the USART (I/O Intent)
The I/O Intent parameter is used for all Dynamic Drivers, and defines how the client interacts with the driver instance. It defines the intended usage or desired behavior of the device driver.
Once this handle has been assigned to a specific USART Driver instance, it must be passed into the library functions to control that instance.
Using the USART Dynamic Driver
You do not need to understand how MHC creates dynamic drivers to use them. If you want these details, click the following button. For a higher level understanding of how to use USART Dynamic Drivers, click on the "Harmony USART Tutorial" button below.
USART Dynamic Driver Details
Learn more >