AM273x MCU+ SDK
09.02.00
Features Supported
Support for Single, Dual or Quad read operation.
Support for Interrupt mode.
Support for DMA read.
Programmable Signal Polarities
Programmable Active Clock Edge
Programmable Delay between chip select activation and output data from 0 to 3 QSPI clock cycles
SysConfig Features
Note It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
QSPI instance name
Input clock frequency to be used for QSPI module
Input clock divider which decides the baud-rate at which the flash will be read
Chip Select
Enabling DMA mode
In advanced config, you can choose various parameters like frame format, decoder chip select polarity, read dummy cycles, SDK Infra and QSPI Interrupt
Features NOT Supported
Dual and Quad writes are not supported.
Usage Overview
API Sequence
To use the QSPI driver to send data over the SPI bus, the application calls the following APIs:
Example Usage
Include the below file to access the APIs
#include <stdio.h>
#include <string.h>
#include <kernel/dpl/MutexArmP.h>
#include <kernel/nortos/dpl/r5/HwiP_armv7r_vim.h>
Instance Open Example
gQspiHandle =
QSPI_open (CONFIG_QSPI0, &qspiParams);
Instance Close Example
Blocking Write and Read Example
void transfer_blocking(void )
{
uint32_t itr = 0U;
transaction.
buf = (
void *)gQspiTxBuf;
transaction.
count = APP_QSPI_DATA_SIZE;
transaction.
buf = (
void *)gQspiRxBuf;
for (itr = 0U; itr < APP_QSPI_DATA_SIZE; itr++)
{
if (gQspiTxBuf[itr] != gQspiRxBuf[itr])
{
break ;
}
}
{
}
}
Non-Blocking Write and Read Example
void transfer_nonblocking(void )
{
uint32_t itr = 0U;
wrParams.
cmd = QSPI_NOR_PAGE_PROG;
wrParams.
cmdAddr = APP_QSPI_FLASH_OFFSET;
rdParams.
cmd = QSPI_NOR_CMD_SINGLE_READ;
rdParams.
cmdAddr = APP_QSPI_FLASH_OFFSET;
for (itr = 0U; itr < APP_QSPI_DATA_SIZE; itr++)
{
if (gQspiTxBuf[itr] != gQspiRxBuf[itr])
{
break ;
}
}
{
}
}
API
APIs for QSPI
void QSPI_writeCmdParams_init(QSPI_WriteCmdParams *wrParams)
Function to initialize the QSPI_Transaction structure.
uint8_t numAddrBytes
Definition: qspi/v0/qspi.h:137
void QSPI_Params_init(QSPI_Params *qspiParams)
Initialize data structure with defaults.
int32_t QSPI_writeConfigModeIntr(QSPI_Handle handle, QSPI_WriteCmdParams *wrParams)
Function to perform write to the flash in interrupt mode mode.
uint32_t addrOffset
Definition: qspi/v0/qspi.h:122
QSPI_Handle QSPI_open(uint32_t index, const QSPI_Params *openParams)
This function opens a given QSPI peripheral.
uint32_t count
Definition: qspi/v0/qspi.h:118
uint32_t cmdAddr
Definition: qspi/v0/qspi.h:149
QSPI Parameters.
Definition: qspi/v0/qspi.h:171
#define DebugP_log(format,...)
Function to log a string to the enabled console.
Definition: DebugP.h:225
uint32_t rxDataLen
Definition: qspi/v0/qspi.h:141
void * txDataBuf
Definition: qspi/v0/qspi.h:154
Definition: qspi/v0/qspi.h:131
uint8_t cmd
Definition: qspi/v0/qspi.h:132
#define DebugP_logError(format,...)
Function to log a string to the enabled console, for error zone.
Definition: DebugP.h:234
int32_t QSPI_readConfigModeIntr(QSPI_Handle handle, QSPI_ReadCmdParams *rdParams)
Function to perform read from the flash in interrupt mode.
#define SystemP_SUCCESS
Return status when the API execution was successful.
Definition: SystemP.h:56
void * rxDataBuf
Definition: qspi/v0/qspi.h:139
#define SystemP_FAILURE
Return status when the API execution was not successful due to a failure.
Definition: SystemP.h:61
uint32_t cmdAddr
Definition: qspi/v0/qspi.h:134
void QSPI_transaction_init(QSPI_Transaction *trans)
Function to initialize the QSPI_Transaction structure.
uint8_t cmd
Definition: qspi/v0/qspi.h:147
int32_t QSPI_writeConfigMode(QSPI_Handle handle, const QSPI_Transaction *trans)
Function to perform writes to the flash in configuration mode.
void QSPI_readCmdParams_init(QSPI_ReadCmdParams *rdParams)
Function to initialize the QSPI_Transaction structure.
uint32_t transferTimeout
Definition: qspi/v0/qspi.h:126
void * buf
Definition: qspi/v0/qspi.h:120
int32_t QSPI_readMemMapMode(QSPI_Handle handle, QSPI_Transaction *trans)
Function to perform reads from the flash in memory mapped mode.
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:177
void QSPI_close(QSPI_Handle handle)
Function to close a QSPI peripheral specified by the QSPI handle.
Data structure used with QSPI_Transfers - QSPI_writeConfigMode, QSPI_readMemMapMode.
Definition: qspi/v0/qspi.h:117
uint32_t txDataLen
Definition: qspi/v0/qspi.h:156
uint8_t numAddrBytes
Definition: qspi/v0/qspi.h:152
Definition: qspi/v0/qspi.h:146