USART Dynamic Driver Library for Harmony v2

Creating USART Dynamic Drivers

MPLAB® Harmony Configurator (MHC) does not create functions for dynamic drivers as 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 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 a Real-Time Operating System (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 the Application Programming Interface (API.)

You configure the USART dynamic drivers using the selections provided by MHC. These drivers are created when you press MHC "Generate" button. MHC's first step in this process is to create USART driver configuration macros based on your selections.

USART_dynamic_config.png

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.

mhc_driver_3.png

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:

  1. Create a handle (pointer) for a client to use with a USART driver instance.
  2. Open a client for a specific USART Driver instance and assign the handle to it.

Opening a Client for a USART dynamic driver

usart_open.png

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

using_dynamic.png

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 >

 Learn More

 
Harmony USART Tutorial
Learn more >
 
Example Code and Projects
Learn more >
 
Entire USART Driver Interface
Learn more >
 
USART Hardware Description
Learn more >
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.