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 = &gQspiObject[CONFIG_QSPI0];
Instance Close Example
Blocking Read Example
void writeRead_blocking(void)
{
msg.
cmd = QSPI_NOR_PAGE_PROG;
msg.
cmdAddr = APP_QSPI_FLASH_OFFSET;
{
}
else
{
}
}
Non-Blocking Example ISR Register
static __attribute__((__section__(
".text.hwi"), noinline, naked, target(
"arm"), aligned(4))) void App_QSPI_ISR(
void)
{
gQspiHandle, \
intrNum, \
gQSPIVimStsAddr, \
gQSPIVimStsClrMask,
intcBaseAddr);
}
Non-Blocking Transfer Example
void transfer_nonblocking(void)
{
uint32_t itr = 0U;
gQspiHandle->interruptCallback = isrCallback;
intrNum = gQspiHandle->hQspiInit->intrNum;
intcBaseAddr = gHwiConfig.intcBaseAddr;
gQSPIVimStsAddr = intcBaseAddr + (0x404u + (((intrNum)>> 5) & 0xFu) * 0x20u);
gQSPIVimStsClrMask = 0x1u << ((intrNum) & 0x1Fu);
HwiP_setPri(intrNum, 4U);
HwiP_setVecAddr(intrNum, (uintptr_t)&App_QSPI_ISR);
msg.
cmdAddr = APP_QSPI_FLASH_OFFSET;
msg.
cmd = QSPI_NOR_PAGE_PROG;
{
while(try_lock_mutex(&transferMutex) == MUTEX_ARM_LOCKED);
}
else
{
}
transferMutex = MUTEX_ARM_LOCKED;
msg.
cmd = QSPI_NOR_CMD_SINGLE_READ;
{
while(try_lock_mutex(&transferMutex) == MUTEX_ARM_LOCKED);
}
else
{
}
for(itr = 0U; itr < APP_QSPI_DATA_SIZE; itr++)
{
if(gQspiTxBuf[itr] != gQspiRxBuf[itr])
{
break;
}
}
{
}
HwiP_setVecAddr(intrNum, 0);
}
Non-Blocking Example ISR callback
void isrCallback(
void *
args)
{
unlock_mutex(&transferMutex);
}
API
APIs for QSPI LLD