SAMV71 Xplained Ultra Software Package 1.3

qspi.c File Reference

#include "chip.h"
#include "stdlib.h"
#include "string.h"
#include <stdint.h>

Go to the source code of this file.

Defines

#define SCRAMBLE_KEY   0x0BADDEAD

Functions

__STATIC_INLINE void QSPI_ConfigureMode (Qspi *pQspi, uint8_t dMode)
 Configure QSPI/SPI mode.
__STATIC_INLINE void QSPI_Configure (Qspi *pQspi, uint32_t dwConfiguration)
 Configure mode register of QSPI.
__STATIC_INLINE void QSPI_SetInstAddr (Qspi *pQspi, uint32_t dwAddr)
 Configures a instruction address for QSPI in QSPI mode.
__STATIC_INLINE void QSPI_SetInst (Qspi *pQspi, uint8_t dwInst, uint8_t dwOpt)
 Configures instruction register with a given command for QSPI.
__STATIC_INLINE void QSPI_SetInstFrame (Qspi *pQspi, QspiInstFrame_t *pInstFrame)
 Configures instruction frame register of QSPI.
__STATIC_INLINE uint32_t QSPI_GetInstFrame (Qspi *pQspi)
 Reads the Instruction frame of QSPI.
__STATIC_INLINE uint16_t QSPI_ReadSPI (Qspi *pQspi)
 Read QSPI RDR register for SPI mode.
__STATIC_INLINE void QSPI_WriteSPI (Qspi *pQspi, uint16_t wData)
 Write to QSPI Tx register in SPI mode.
__STATIC_INLINE void QSPI_ScrambleData (Qspi *pQspi, uint32_t wKey, uint8_t EnableFlag, uint8_t Random)
 Configures QSPI scrambling with a given Key.
void QSPI_Enable (Qspi *pQspi)
 Enables a QSPI peripheral.
void QSPI_Disable (Qspi *pQspi)
 Disables a QSPI peripheral.
void QSPI_SwReset (Qspi *pQspi)
 Resets a QSPI peripheral.
QspidStatus_t QSPI_EnableIt (Qspi *pQspi, uint32_t dwSources)
 Enables one or more interrupt sources of a QSPI peripheral.
QspidStatus_t QSPI_DisableIt (Qspi *pQspi, uint32_t dwSources)
 Disables one or more interrupt sources of a QSPI peripheral.
uint32_t QSPI_GetItMask (Qspi *pQspi)
 Return the interrupt mask register.
uint32_t QSPI_GetEnabledItStatus (Qspi *pQspi)
 Returns enabled interrupt status.
uint32_t QSPI_GetStatus (Qspi *pQspi, const QspiStatus_t rStatus)
 Get the current status register of the given QSPI peripheral.
void QSPI_ConfigureClock (Qspi *pQspi, QspiClockMode_t ClockMode, uint32_t dwClockCfg)
 Configures peripheral clock of a QSPI/SPI peripheral.
QspidStatus_t QSPI_ConfigureInterface (Qspid_t *pQspid, QspiMode_t Mode, uint32_t dwConfiguration)
 Configures QSPI/SPI.
QspidStatus_t QSPI_EndTransfer (Qspi *pQspi)
 Ends ongoing transfer by releasing CS of QSPI peripheral.
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.
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.
QspidStatus_t QSPI_SingleWriteSPI (Qspid_t *pQspid, uint16_t const *pData)
 Sends a single data through a SPI peripheral.
QspidStatus_t QSPI_MultiWriteSPI (Qspid_t *pQspid, uint16_t const *pData, uint32_t NumOfBytes)
 Sends multiple data through a SPI peripheral.
QspidStatus_t QSPI_SendCommand (Qspid_t *pQspid, uint8_t const KeepCfg)
 Send an instruction over QSPI (oly a flash command no data).
QspidStatus_t QSPI_SendCommandWithData (Qspid_t *pQspid, uint8_t const KeepCfg)
 Send instruction over QSPI with data.
QspidStatus_t QSPI_ReadCommand (Qspid_t *pQspid, uint8_t const KeepCfg)
 Send instruction over QSPI to read data.
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.
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.

Detailed Description

Implementation of Serial Peripheral Interface (QSPI) controller.

Definition in file qspi.c.


Function Documentation

__STATIC_INLINE void QSPI_Configure ( Qspi pQspi,
uint32_t  dwConfiguration 
)

Configure mode register of QSPI.

Parameters:
pQspi Pointer to a Qspi instance.

Definition at line 103 of file qspi.c.

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

Configures peripheral clock of a QSPI/SPI peripheral.

Parameters:
pQspi Pointer to an Qspi instance.
dwConfiguration Desired clock configuration.

Definition at line 315 of file qspi.c.

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

Configures QSPI/SPI.

Parameters:
pQspi Pointer to an Qspi instance.
Mode Mode for QSPI or SPI
dwConfiguration Config of SPI or QSPI mode

Definition at line 329 of file qspi.c.

Here is the call graph for this function:

__STATIC_INLINE void QSPI_ConfigureMode ( Qspi pQspi,
uint8_t  dMode 
)

Configure QSPI/SPI mode.

Parameters:
pQspi Pointer to a Qspi instance.

Definition at line 92 of file qspi.c.

void QSPI_Disable ( Qspi pQspi  ) 

Disables a QSPI peripheral.

Parameters:
pQspi Pointer to a Qspi instance.

Definition at line 229 of file qspi.c.

QspidStatus_t QSPI_DisableIt ( Qspi pQspi,
uint32_t  dwSources 
)

Disables one or more interrupt sources of a QSPI peripheral.

Parameters:
pQspi Pointer to a Qspi instance.
sources Bitwise OR of selected interrupt sources.

Definition at line 266 of file qspi.c.

void QSPI_Enable ( Qspi pQspi  ) 

Enables a QSPI peripheral.

Parameters:
pQspi Pointer to a Qspi instance.

Definition at line 217 of file qspi.c.

QspidStatus_t QSPI_EnableIt ( Qspi pQspi,
uint32_t  dwSources 
)

Enables one or more interrupt sources of a QSPI peripheral.

Parameters:
pQspi Pointer to a Qspi instance.
sources Bitwise OR of selected interrupt sources.

Definition at line 253 of file qspi.c.

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:
pQspi Pointer to an Qspi instance.
KeepCfg To keep Instruction from value or resets to zero
ScrambleFlag Enable 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.

Definition at line 653 of file qspi.c.

Here is the call graph for this function:

QspidStatus_t QSPI_EndTransfer ( Qspi pQspi  ) 

Ends ongoing transfer by releasing CS of QSPI peripheral.

Parameters:
pQspi Pointer to an Qspi instance.

Definition at line 350 of file qspi.c.

Here is the call graph for this function:

uint32_t QSPI_GetEnabledItStatus ( Qspi pQspi  ) 

Returns enabled interrupt status.

Returns:
Qspi interrupt mask register.

Definition at line 289 of file qspi.c.

Here is the call graph for this function:

__STATIC_INLINE uint32_t QSPI_GetInstFrame ( Qspi pQspi  ) 

Reads the Instruction frame of QSPI.

Parameters:
pQspi Pointer to an Qspi instance.

Definition at line 153 of file qspi.c.

uint32_t QSPI_GetItMask ( Qspi pQspi  ) 

Return the interrupt mask register.

Returns:
Qspi interrupt mask register.

Definition at line 278 of file qspi.c.

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:
pQspi Pointer to a Qspi instance.
rStatus Compare status with given status bit
Returns:
QSPI status register.

Definition at line 303 of file qspi.c.

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:
pQspid Pointer to a Qspi instance.
pData Pointer to read buffer
NumOfBytes Num of bytes to read
Returns:
Qspi status

Definition at line 409 of file qspi.c.

Here is the call graph for this function:

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

Sends multiple data through a SPI peripheral.

Parameters:
pQspid Pointer to a Qspi instance.
pData Pointer to a Tx buffer
NumOfBytes Num of data to send.

Definition at line 490 of file qspi.c.

Here is the call graph for this function:

QspidStatus_t QSPI_ReadCommand ( Qspid_t pQspid,
uint8_t const   KeepCfg 
)

Send instruction over QSPI to read data.

Parameters:
pQspi Pointer to an Qspi instance.
KeepCfg To 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.

Definition at line 613 of file qspi.c.

Here is the call graph for this function:

__STATIC_INLINE uint16_t QSPI_ReadSPI ( Qspi pQspi  ) 

Read QSPI RDR register for SPI mode.

Parameters:
pQspi Pointer to an Qspi instance.

Definition at line 164 of file qspi.c.

Here is the call graph for this function:

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:
pQspi Pointer to an Qspi instance.
ReadWrite Flag 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.

Definition at line 688 of file qspi.c.

Here is the call graph for this function:

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

Configures QSPI scrambling with a given Key.

Parameters:
pQspi Pointer to an Qspi instance.
wKey Key for scramble/unscramble
EnableFlag Enable/disable scramble
Random Add random value with given key

Definition at line 195 of file qspi.c.

QspidStatus_t QSPI_SendCommand ( Qspid_t pQspid,
uint8_t const   KeepCfg 
)

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

Parameters:
pQspi Pointer to an Qspi instance.
KeepCfg To 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.

Definition at line 540 of file qspi.c.

Here is the call graph for this function:

QspidStatus_t QSPI_SendCommandWithData ( Qspid_t pQspid,
uint8_t const   KeepCfg 
)

Send instruction over QSPI with data.

Parameters:
pQspi Pointer to an Qspi instance.
KeepCfg To 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.

Definition at line 574 of file qspi.c.

Here is the call graph for this function:

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

Configures instruction register with a given command for QSPI.

Parameters:
pQspi Pointer to a Qspi instance.
dwInst Instruction Code
dwOpt Instruction Code option

Definition at line 130 of file qspi.c.

__STATIC_INLINE void QSPI_SetInstAddr ( Qspi pQspi,
uint32_t  dwAddr 
)

Configures a instruction address for QSPI in QSPI mode.

Parameters:
pQspi Pointer to a Qspi instance.
dwAddr Instruction Address

Definition at line 116 of file qspi.c.

__STATIC_INLINE void QSPI_SetInstFrame ( Qspi pQspi,
QspiInstFrame_t pInstFrame 
)

Configures instruction frame register of QSPI.

Parameters:
pQspi Pointer to a Qspi instance.
pInstFrame Instruction Frame configuration

Definition at line 142 of file qspi.c.

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:
pQspid Pointer to a Qspi instance.
pData Buffer to put read value
Returns:
Qspi status

Definition at line 371 of file qspi.c.

Here is the call graph for this function:

QspidStatus_t QSPI_SingleWriteSPI ( Qspid_t pQspid,
uint16_t const *  pData 
)

Sends a single data through a SPI peripheral.

Parameters:
pQspid Pointer to a Qspi instance.
pData Pointer to Tx data
Returns:
Qspi status

Definition at line 457 of file qspi.c.

Here is the call graph for this function:

void QSPI_SwReset ( Qspi pQspi  ) 

Resets a QSPI peripheral.

Parameters:
pQspi Pointer to a Qspi instance.

Definition at line 241 of file qspi.c.

__STATIC_INLINE void QSPI_WriteSPI ( Qspi pQspi,
uint16_t  wData 
)

Write to QSPI Tx register in SPI mode.

Parameters:
pQspi Pointer to an Qspi instance.
wData Data to transmit

Definition at line 178 of file qspi.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines