RTEMS  5.1
Macros | Functions
qspi.c File Reference
#include "chip.h"
#include "stdlib.h"
#include "string.h"
#include <stdint.h>
#include <bsp/iocopy.h>

Macros

#define SCRAMBLE_KEY   0x0BADDEAD
 

Functions

__STATIC_INLINE void QSPI_ConfigureMode (Qspi *pQspi, uint8_t dMode)
 Configure QSPI/SPI mode. More...
 
__STATIC_INLINE void QSPI_Configure (Qspi *pQspi, uint32_t dwConfiguration)
 Configure mode register of QSPI. More...
 
__STATIC_INLINE void QSPI_SetInstAddr (Qspi *pQspi, uint32_t dwAddr)
 Configures a instruction address for QSPI in QSPI mode. More...
 
__STATIC_INLINE void QSPI_SetInst (Qspi *pQspi, uint8_t dwInst, uint8_t dwOpt)
 Configures instruction register with a given command for QSPI. More...
 
__STATIC_INLINE void QSPI_SetInstFrame (Qspi *pQspi, QspiInstFrame_t *pInstFrame)
 Configures instruction frame register of QSPI. More...
 
__STATIC_INLINE uint32_t QSPI_GetInstFrame (Qspi *pQspi)
 Reads the Instruction frame of QSPI. More...
 
__STATIC_INLINE uint16_t QSPI_ReadSPI (Qspi *pQspi)
 Read QSPI RDR register for SPI mode. More...
 
__STATIC_INLINE void QSPI_WriteSPI (Qspi *pQspi, uint16_t wData)
 Write to QSPI Tx register in SPI mode. More...
 
__STATIC_INLINE void QSPI_ScrambleData (Qspi *pQspi, uint32_t wKey, uint8_t EnableFlag, uint8_t Random)
 Configures QSPI scrambling with a given Key. More...
 
void QSPI_Enable (Qspi *pQspi)
 Enables a QSPI peripheral. More...
 
void QSPI_Disable (Qspi *pQspi)
 Disables a QSPI peripheral. More...
 
void QSPI_SwReset (Qspi *pQspi)
 Resets a QSPI peripheral. More...
 
QspidStatus_t QSPI_EnableIt (Qspi *pQspi, uint32_t dwSources)
 Enables one or more interrupt sources of a QSPI peripheral. More...
 
QspidStatus_t QSPI_DisableIt (Qspi *pQspi, uint32_t dwSources)
 Disables one or more interrupt sources of a QSPI peripheral. More...
 
uint32_t QSPI_GetItMask (Qspi *pQspi)
 Return the interrupt mask register. More...
 
uint32_t QSPI_GetEnabledItStatus (Qspi *pQspi)
 Returns enabled interrupt status. More...
 
uint32_t QSPI_GetStatus (Qspi *pQspi, const QspiStatus_t rStatus)
 Get the current status register of the given QSPI peripheral. More...
 
void QSPI_ConfigureClock (Qspi *pQspi, QspiClockMode_t ClockMode, uint32_t dwClockCfg)
 Configures peripheral clock of a QSPI/SPI peripheral. More...
 
QspidStatus_t QSPI_ConfigureInterface (Qspid_t *pQspid, QspiMode_t Mode, uint32_t dwConfiguration)
 Configures QSPI/SPI. More...
 
QspidStatus_t QSPI_EndTransfer (Qspi *pQspi)
 Ends ongoing transfer by releasing CS of QSPI peripheral. More...
 
QspidStatus_t QSPI_SingleReadSPI (Qspid_t *pQspid, uint16_t *const pData)
 Reads the data received by a SPI peripheral. This method must be called after a successful SPI_Write call. More...
 
QspidStatus_t QSPI_MultiReadSPI (Qspid_t *pQspid, uint16_t *const pData, uint32_t NumOfBytes)
 Reads multiple data received by a SPI peripheral. This method must be called after a successful SPI_Write call. More...
 
QspidStatus_t QSPI_SingleWriteSPI (Qspid_t *pQspid, uint16_t const *pData)
 Sends a single data through a SPI peripheral. More...
 
QspidStatus_t QSPI_MultiWriteSPI (Qspid_t *pQspid, uint16_t const *pData, uint32_t NumOfBytes)
 Sends multiple data through a SPI peripheral. More...
 
QspidStatus_t QSPI_SendCommand (Qspid_t *pQspid, uint8_t const KeepCfg)
 Send an instruction over QSPI (oly a flash command no data) More...
 
QspidStatus_t QSPI_SendCommandWithData (Qspid_t *pQspid, uint8_t const KeepCfg)
 Send instruction over QSPI with data. More...
 
QspidStatus_t QSPI_ReadCommand (Qspid_t *pQspid, uint8_t const KeepCfg)
 Send instruction over QSPI to read data. More...
 
QspidStatus_t QSPI_EnableMemAccess (Qspid_t *pQspid, uint8_t const KeepCfg, uint8_t ScrambleFlag)
 Sends an instruction over QSPI and configures other related address like Addr , Frame and synchronise bus access before data read or write. More...
 
QspidStatus_t QSPI_ReadWriteMem (Qspid_t *pQspid, Access_t const ReadWrite)
 Writes or reads the QSPI memory (0x80000000) to transmit or receive data from Flash memory. More...
 

Detailed Description

Implementation of Serial Peripheral Interface (QSPI) controller.

Function Documentation

◆ QSPI_Configure()

__STATIC_INLINE void QSPI_Configure ( Qspi pQspi,
uint32_t  dwConfiguration 
)

Configure mode register of QSPI.

Parameters
pQspiPointer to a Qspi instance.

◆ QSPI_ConfigureClock()

void QSPI_ConfigureClock ( Qspi pQspi,
QspiClockMode_t  ClockMode,
uint32_t  dwClockCfg 
)

Configures peripheral clock of a QSPI/SPI peripheral.

Parameters
pQspiPointer to an Qspi instance.
dwConfigurationDesired clock configuration.

◆ QSPI_ConfigureInterface()

QspidStatus_t QSPI_ConfigureInterface ( Qspid_t pQspid,
QspiMode_t  Mode,
uint32_t  dwConfiguration 
)

Configures QSPI/SPI.

Parameters
pQspiPointer to an Qspi instance.
ModeMode for QSPI or SPI
dwConfigurationConfig of SPI or QSPI mode

◆ QSPI_ConfigureMode()

__STATIC_INLINE void QSPI_ConfigureMode ( Qspi pQspi,
uint8_t  dMode 
)

Configure QSPI/SPI mode.

Parameters
pQspiPointer to a Qspi instance.

◆ QSPI_Disable()

void QSPI_Disable ( Qspi pQspi)

Disables a QSPI peripheral.

Parameters
pQspiPointer to a Qspi instance.

◆ QSPI_DisableIt()

QspidStatus_t QSPI_DisableIt ( Qspi pQspi,
uint32_t  dwSources 
)

Disables one or more interrupt sources of a QSPI peripheral.

Parameters
pQspiPointer to a Qspi instance.
sourcesBitwise OR of selected interrupt sources.

◆ QSPI_Enable()

void QSPI_Enable ( Qspi pQspi)

Enables a QSPI peripheral.

Parameters
pQspiPointer to a Qspi instance.

◆ QSPI_EnableIt()

QspidStatus_t QSPI_EnableIt ( Qspi pQspi,
uint32_t  dwSources 
)

Enables one or more interrupt sources of a QSPI peripheral.

Parameters
pQspiPointer to a Qspi instance.
sourcesBitwise OR of selected interrupt sources.

◆ QSPI_EnableMemAccess()

QspidStatus_t QSPI_EnableMemAccess ( Qspid_t pQspid,
uint8_t const  KeepCfg,
uint8_t  ScrambleFlag 
)

Sends an instruction over QSPI and configures other related address like Addr , Frame and synchronise bus access before data read or write.

Parameters
pQspiPointer to an Qspi instance.
KeepCfgTo keep Instruction from value or resets to zero
ScrambleFlagEnable or disable scramble on QSPI
Returns
Returns 1 if At least one instruction end has been detected since the last read of QSPI_SR.; otherwise returns 0.

◆ QSPI_EndTransfer()

QspidStatus_t QSPI_EndTransfer ( Qspi pQspi)

Ends ongoing transfer by releasing CS of QSPI peripheral.

Parameters
pQspiPointer to an Qspi instance.

◆ QSPI_GetEnabledItStatus()

uint32_t QSPI_GetEnabledItStatus ( Qspi pQspi)

Returns enabled interrupt status.

Returns
Qspi interrupt mask register.

◆ QSPI_GetInstFrame()

__STATIC_INLINE uint32_t QSPI_GetInstFrame ( Qspi pQspi)

Reads the Instruction frame of QSPI.

Parameters
pQspiPointer to an Qspi instance.

◆ QSPI_GetItMask()

uint32_t QSPI_GetItMask ( Qspi pQspi)

Return the interrupt mask register.

Returns
Qspi interrupt mask register.

◆ QSPI_GetStatus()

uint32_t QSPI_GetStatus ( Qspi pQspi,
const QspiStatus_t  rStatus 
)

Get the current status register of the given QSPI peripheral.

Note
This resets the internal value of the status register, so further read may yield different values.
Parameters
pQspiPointer to a Qspi instance.
rStatusCompare status with given status bit
Returns
QSPI status register.

◆ QSPI_MultiReadSPI()

QspidStatus_t QSPI_MultiReadSPI ( Qspid_t pQspid,
uint16_t *const  pData,
uint32_t  NumOfBytes 
)

Reads multiple data received by a SPI peripheral. This method must be called after a successful SPI_Write call.

Parameters
pQspidPointer to a Qspi instance.
pDataPointer to read buffer
NumOfBytesNum of bytes to read
Returns
Qspi status

◆ QSPI_MultiWriteSPI()

QspidStatus_t QSPI_MultiWriteSPI ( Qspid_t pQspid,
uint16_t const *  pData,
uint32_t  NumOfBytes 
)

Sends multiple data through a SPI peripheral.

Parameters
pQspidPointer to a Qspi instance.
pDataPointer to a Tx buffer
NumOfBytesNum of data to send.

◆ QSPI_ReadCommand()

QspidStatus_t QSPI_ReadCommand ( Qspid_t pQspid,
uint8_t const  KeepCfg 
)

Send instruction over QSPI to read data.

Parameters
pQspiPointer to an Qspi instance.
KeepCfgTo keep Instruction from value or resets to zero
Returns
Returns 1 if At least one instruction end has been detected since the last read of QSPI_SR.; otherwise returns 0.

◆ QSPI_ReadSPI()

__STATIC_INLINE uint16_t QSPI_ReadSPI ( Qspi pQspi)

Read QSPI RDR register for SPI mode.

Parameters
pQspiPointer to an Qspi instance.

◆ QSPI_ReadWriteMem()

QspidStatus_t QSPI_ReadWriteMem ( Qspid_t pQspid,
Access_t const  ReadWrite 
)

Writes or reads the QSPI memory (0x80000000) to transmit or receive data from Flash memory.

Parameters
pQspiPointer to an Qspi instance.
ReadWriteFlag to indicate read/write QSPI memory access
Returns
Returns 1 if At least one instruction end has been detected since the last read of QSPI_SR.; otherwise returns 0.

◆ QSPI_ScrambleData()

__STATIC_INLINE void QSPI_ScrambleData ( Qspi pQspi,
uint32_t  wKey,
uint8_t  EnableFlag,
uint8_t  Random 
)

Configures QSPI scrambling with a given Key.

Parameters
pQspiPointer to an Qspi instance.
wKeyKey for scramble/unscramble
EnableFlagEnable/disable scramble
RandomAdd random value with given key

◆ QSPI_SendCommand()

QspidStatus_t QSPI_SendCommand ( Qspid_t pQspid,
uint8_t const  KeepCfg 
)

Send an instruction over QSPI (oly a flash command no data)

Parameters
pQspiPointer to an Qspi instance.
KeepCfgTo keep Instruction fram value or restes to zero
Returns
Returns 1 if At least one instruction end has been detected since the last read of QSPI_SR.; otherwise returns 0.

◆ QSPI_SendCommandWithData()

QspidStatus_t QSPI_SendCommandWithData ( Qspid_t pQspid,
uint8_t const  KeepCfg 
)

Send instruction over QSPI with data.

Parameters
pQspiPointer to an Qspi instance.
KeepCfgTo keep Instruction fram value or restes to zero
Returns
Returns 1 if At least one instruction end has been detected since the last read of QSPI_SR.; otherwise returns 0.

◆ QSPI_SetInst()

__STATIC_INLINE void QSPI_SetInst ( Qspi pQspi,
uint8_t  dwInst,
uint8_t  dwOpt 
)

Configures instruction register with a given command for QSPI.

Parameters
pQspiPointer to a Qspi instance.
dwInstInstruction Code
dwOptInstruction Code option

◆ QSPI_SetInstAddr()

__STATIC_INLINE void QSPI_SetInstAddr ( Qspi pQspi,
uint32_t  dwAddr 
)

Configures a instruction address for QSPI in QSPI mode.

Parameters
pQspiPointer to a Qspi instance.
dwAddrInstruction Address

◆ QSPI_SetInstFrame()

__STATIC_INLINE void QSPI_SetInstFrame ( Qspi pQspi,
QspiInstFrame_t pInstFrame 
)

Configures instruction frame register of QSPI.

Parameters
pQspiPointer to a Qspi instance.
pInstFrameInstruction Frame configuration

◆ QSPI_SingleReadSPI()

QspidStatus_t QSPI_SingleReadSPI ( Qspid_t pQspid,
uint16_t *const  pData 
)

Reads the data received by a SPI peripheral. This method must be called after a successful SPI_Write call.

Parameters
pQspidPointer to a Qspi instance.
pDataBuffer to put read value
Returns
Qspi status

◆ QSPI_SingleWriteSPI()

QspidStatus_t QSPI_SingleWriteSPI ( Qspid_t pQspid,
uint16_t const *  pData 
)

Sends a single data through a SPI peripheral.

Parameters
pQspidPointer to a Qspi instance.
pDataPointer to Tx data
Returns
Qspi status

◆ QSPI_SwReset()

void QSPI_SwReset ( Qspi pQspi)

Resets a QSPI peripheral.

Parameters
pQspiPointer to a Qspi instance.

◆ QSPI_WriteSPI()

__STATIC_INLINE void QSPI_WriteSPI ( Qspi pQspi,
uint16_t  wData 
)

Write to QSPI Tx register in SPI mode.

Parameters
pQspiPointer to an Qspi instance.
wDataData to transmit