2.6 Advantages of MPLAB Harmony Drivers

The MPLAB Harmony drivers provide an abstracted interface to access the hardware. This enabless portability of the applications and middleware across platforms. This is the preferred method to access peripherals when the software needs to be ported across hardware platforms.

When two different clients in an application access the same instance of a peripheral, the driver must be capable of accessing the correct sensor to give data to the correct client. The MPLAB Harmony v3 driver is capable of handling this multi-client scenario.

The following are key features of the MPLAB Harmony drivers:

Multi-Client Operations

Figure 2-4. Multi-Client Operations

Multi-Instance Operation

In a Multi-Instance scenario, the same driver (code) is capable of handling many instances of a peripheral. Application clients can call the same driver function to perform the job with the respective peripheral instance.

Figure 2-5. Multi-Instance Operation
  • Same API for all the instances of a peripheral:
    • Application remains same when the peripheral instance is changed
    I2C Driver APITWISH/SERCOM I2C PLIB API
    DRV_I2C_WriteTransferAdd(...)SERCOMx_I2C1_Write(…)
    SERCOMx_I2C2_Write(…)
    DRV_I2C_ReadTransferAdd(...)SERCOMx_I2C1_Read(…)
    SERCOMx_I2C2_Read(…)
  • Support for DMA Transfer mode - Driver Interface or API remains same with or without DMA Transfer mode
  • Buffer/Queue Support
  • Error checking
  • Sanity checks
  • RTOS ready
  • Thread safe

Drivers will not use blocking APIs. Both sync and async driver types are available in MPLAB Harmony v3.

MPLAB Harmony v3 Drivers:

There are two MPLAB Harmony v3 drivers, Asynchronous (async) and Synchronous (sync). The driver details are as follows:

  • Asynchronous (async)
    • Non-blocking APIs
    • Works seamlessly in bare-metal and RTOS environment
    • Interrupt and Thread safe
  • Synchronous (sync)
    • Blocking APIs
    • Suitable for use in RTOS environment
    • Interrupt and Thread safe
Note: The term sync and async in MPLAB Harmony v3 have a different meaning than in Atmel START. In Atmel START, available driver types are sync, async and RTOS. sync means polled driver, async means interrupt based, and RTOS driver is an RTOS compliant driver.