Kinetis SDK v.1.3 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
This section describes the programming interface of the QSPI peripheral driver.
The following is a basic step-by-step overview of how to initialize QSPI and use QSPI for transfers. For API specific examples, see the examples below. The following example uses the interrupt-driven APIs and a blocking transfer to illustrate a high-level step-by-step usage.
The QSPI driver uses a run-time state structure to track the ongoing data transfers. The state structure for the driver is called qspi_state_t. This structure holds data that the QSPI peripheral driver uses to communicate between the transfer function and the interrupt handler and other driver functions. The interrupt handler in the driver also uses this information to keep track of its progress. The user is only required to pass the memory for the run-time state structure. The QSPI driver populates the members.
The QSPI driver uses instances of the qspi_config_t structure to represent the QSPI bus and buffer configuration required to communicate to an external flash that is connected to QSPI.
The configuration structure consists of the following settings: SCLK (baud rate in Hz), clock source, watermark settings, and AHB buffer settings for read data via AHB bus.
The QSPI driver uses instances of the qspi_flash_config_t structure to represent the flash features connected to the QSPI module.
The configuration structure consists of the following settings: flash size (supports maximum 2 flash), lookup table for flash commands, flash timing settings, flash endianess, and specific flash feature settings.
To initialize the QSPI driver, call the QSPI_DRV_Init() function and pass the instance number of the QSPI peripheral. For example, to use the QSPI0 module, pass a value 0 to the initialization function. In addition, the user also passes in the pointer to the run-time state structure used by the driver to keep track of data transfers.
The driver supports three different methods to transfer data: polling, interrupt, and DMA. The polling transfer is a blocking function and others are both non-blocking.
When using DMA to transfer data, ensure that the data is consistent when there is cache for memory. This means, when reading/ writing the data from/to memory, the application should ensure that data from or to the memory device is not cached.
Example for non-blocking function APIs and associated functions (interrupt and DMA-driven):
To deinitialize and shut down the QSPI module, call the function QSPI_DRV_Deinit().