2.5 Significance of Peripheral Libraries (PLIBs) in MPLAB Harmony v3
This is the lowest level interface to the peripherals of a device. This is
named as a library, but it consists of source (.c
) and header
(.h
) files. Typically, each peripheral instance has a source and
header file associated with it. The Application Program Interface (API) implementation
is kept simple, such that the most of it will be direct peripheral register access.
Most API names and structures are consistent across devices which helps in
driver portability. Typically, driver layers use PLIB API calls. Therefore, PLIBs are
closely associated with peripherals, and these vary from device-to-device. Most PLIBs
can be used either in polled mode or in interrupt mode. To realize polled mode, PLIBs
have blocking calls. Interrupt mode supports ISR functionality with call-back support.
There is no error checking, sanity checks, or state maintenance in a PLIB. The PLIB has
clean code and no conditional macros (#if, #elif.
) for readability.
Usage | UART/SERCOM_USART | SPI/SERCOM_SPI | TWIHS/SERCOM_I2C |
---|---|---|---|
Initialization | UARTx_Initialize() | SPIx_Initialize() | TWIHSx_Initialize() |
Transaction | UARTx_Write() | SPIx_Write() | TWIHSx_Write() |
UARTx_Read() | SPIx_Read() | TWIHSx_Read() | |
- | SPIx_WriteRead() | TWIHSx_WriteRead() | |
Status | UARTx_ReadIsBusy() | SPIx_IsBusy() | TWIHSx_IsBusy() |
UARTx_WriteIsBusy() |