M480 BSP V3.05.005
The Board Support Package for M480 Series
Macros | Functions

Macros

#define SPIM_ENABLE_CIPHER()
 
#define SPIM_DISABLE_CIPHER()
 
#define SPIM_ENABLE_BALEN()
 
#define SPIM_DISABLE_BALEN()
 
#define SPIM_SET_4BYTE_ADDR_EN(x)
 
#define SPIM_ENABLE_INT()
 
#define SPIM_DISABLE_INT()
 
#define SPIM_IS_IF_ON()
 
#define SPIM_CLR_INT()
 
#define SPIM_SET_DATA_WIDTH(x)
 
#define SPIM_GET_DATA_WIDTH()
 
#define SPIM_SET_DATA_NUM(x)
 
#define SPIM_GET_DATA_NUM()
 
#define SPIM_ENABLE_SING_INPUT_MODE()
 
#define SPIM_ENABLE_SING_OUTPUT_MODE()
 
#define SPIM_ENABLE_DUAL_INPUT_MODE()
 
#define SPIM_ENABLE_DUAL_OUTPUT_MODE()
 
#define SPIM_ENABLE_QUAD_INPUT_MODE()
 
#define SPIM_ENABLE_QUAD_OUTPUT_MODE()
 
#define SPIM_SET_SUSP_INTVL(x)
 
#define SPIM_GET_SUSP_INTVL()
 
#define SPIM_SET_OPMODE(x)
 
#define SPIM_GET_OP_MODE()
 
#define SPIM_SET_SPIM_MODE(x)
 
#define SPIM_GET_SPIM_MODE()
 
#define SPIM_SET_GO()
 
#define SPIM_IS_BUSY()
 
#define SPIM_WAIT_FREE()
 
#define SPIM_ENABLE_CACHE()
 
#define SPIM_DISABLE_CACHE()
 
#define SPIM_IS_CACHE_EN()
 
#define SPIM_ENABLE_CCM()
 
#define SPIM_DISABLE_CCM()
 
#define SPIM_IS_CCM_EN()
 
#define SPIM_INVALID_CACHE()
 
#define SPIM_SET_SS_EN(x)
 
#define SPIM_GET_SS_EN()
 
#define SPIM_SET_SS_ACTLVL(x)
 
#define SPIM_SET_IDL_INTVL(x)
 
#define SPIM_GET_IDL_INTVL()
 
#define SPIM_SET_CLOCK_DIVIDER(x)
 
#define SPIM_GET_CLOCK_DIVIDER()
 
#define SPIM_SET_RXCLKDLY_DWDELSEL(x)
 
#define SPIM_GET_RXCLKDLY_DWDELSEL()
 
#define SPIM_SET_RXCLKDLY_RDDLYSEL(x)
 
#define SPIM_GET_RXCLKDLY_RDDLYSEL()
 
#define SPIM_SET_RXCLKDLY_RDEDGE()
 
#define SPIM_CLR_RXCLKDLY_RDEDGE()
 
#define SPIM_SET_DMMCTL_CRMDAT(x)
 
#define SPIM_GET_DMMCTL_CRMDAT()
 
#define SPIM_DMM_SET_DESELTIM(x)
 
#define SPIM_DMM_GET_DESELTIM()
 
#define SPIM_DMM_ENABLE_BWEN()
 
#define SPIM_DMM_DISABLE_BWEN()
 
#define SPIM_DMM_ENABLE_CREN()
 
#define SPIM_DMM_DISABLE_CREN()
 
#define SPIM_DMM_SET_ACTSCLKT(x)
 
#define SPIM_DMM_SET_DEFAULT_ACTSCLK()
 
#define SPIM_SET_DCNUM(x)
 
#define SPIM_SET_DEFAULT_DCNUM(x)
 

Functions

int SPIM_InitFlash (int clrWP)
 Initialize SPIM flash. More...
 
uint32_t SPIM_GetSClkFreq (void)
 Get SPIM serial clock. More...
 
void SPIM_ReadJedecId (uint8_t idBuf[], uint32_t u32NRx, uint32_t u32NBit)
 Issue JEDEC ID command. More...
 
int SPIM_Enable_4Bytes_Mode (int isEn, uint32_t u32NBit)
 Enter/Exit 4-byte address mode. More...
 
int SPIM_Is4ByteModeEnable (uint32_t u32NBit)
 
void SPIM_ChipErase (uint32_t u32NBit, int isSync)
 Erase whole chip. More...
 
void SPIM_EraseBlock (uint32_t u32Addr, int is4ByteAddr, uint8_t u8ErsCmd, uint32_t u32NBit, int isSync)
 Erase one block. More...
 
void SPIM_IO_Write (uint32_t u32Addr, int is4ByteAddr, uint32_t u32NTx, uint8_t pu8TxBuf[], uint8_t wrCmd, uint32_t u32NBitCmd, uint32_t u32NBitAddr, uint32_t u32NBitDat)
 Write data to SPI Flash by sending commands manually (I/O mode). More...
 
void SPIM_IO_Read (uint32_t u32Addr, int is4ByteAddr, uint32_t u32NRx, uint8_t pu8RxBuf[], uint8_t rdCmd, uint32_t u32NBitCmd, uint32_t u32NBitAddr, uint32_t u32NBitDat, int u32NDummy)
 Read data from SPI Flash by sending commands manually (I/O mode). More...
 
void SPIM_DMA_Write (uint32_t u32Addr, int is4ByteAddr, uint32_t u32NTx, uint8_t pu8TxBuf[], uint32_t wrCmd)
 Write data to SPI Flash by Page Write mode. More...
 
void SPIM_DMA_Read (uint32_t u32Addr, int is4ByteAddr, uint32_t u32NRx, uint8_t pu8RxBuf[], uint32_t u32RdCmd, int isSync)
 Read data from SPI Flash by Page Read mode. More...
 
void SPIM_EnterDirectMapMode (int is4ByteAddr, uint32_t u32RdCmd, uint32_t u32IdleIntvl)
 Enter Direct Map mode. More...
 
void SPIM_ExitDirectMapMode (void)
 Exit Direct Map mode. More...
 
void SPIM_SetQuadEnable (int isEn, uint32_t u32NBit)
 Set Quad Enable/disable. More...
 
void SPIM_WinbondUnlock (uint32_t u32NBit)
 
static void spim_eon_set_qpi_mode (int isEn)
 Enter/exit QPI mode. More...
 
static void SPIM_SPANSION_4Bytes_Enable (int isEn, uint32_t u32NBit)
 

Detailed Description

HIDDEN_SYMBOLS

Macro Definition Documentation

◆ SPIM_CLR_INT

#define SPIM_CLR_INT ( )

Clear interrupt flag.

Definition at line 204 of file spim.h.

◆ SPIM_CLR_RXCLKDLY_RDEDGE

#define SPIM_CLR_RXCLKDLY_RDEDGE ( )

Get sampling clock edge selection for received data

Definition at line 504 of file spim.h.

◆ SPIM_DISABLE_BALEN

#define SPIM_DISABLE_BALEN ( )

Disable cipher balance

Definition at line 171 of file spim.h.

◆ SPIM_DISABLE_CACHE

#define SPIM_DISABLE_CACHE ( )

Disable cache.

Definition at line 372 of file spim.h.

◆ SPIM_DISABLE_CCM

#define SPIM_DISABLE_CCM ( )

Disable CCM.

Definition at line 390 of file spim.h.

◆ SPIM_DISABLE_CIPHER

#define SPIM_DISABLE_CIPHER ( )

Disable cipher.

Definition at line 159 of file spim.h.

◆ SPIM_DISABLE_INT

#define SPIM_DISABLE_INT ( )

Disable SPIM interrupt

Definition at line 192 of file spim.h.

◆ SPIM_DMM_DISABLE_BWEN

#define SPIM_DMM_DISABLE_BWEN ( )

Disable DMM mode burst wrap mode

Definition at line 549 of file spim.h.

◆ SPIM_DMM_DISABLE_CREN

#define SPIM_DMM_DISABLE_CREN ( )

Disable DMM mode continuous read mode

Definition at line 561 of file spim.h.

◆ SPIM_DMM_ENABLE_BWEN

#define SPIM_DMM_ENABLE_BWEN ( )

Enable DMM mode burst wrap mode

Definition at line 543 of file spim.h.

◆ SPIM_DMM_ENABLE_CREN

#define SPIM_DMM_ENABLE_CREN ( )

Enable DMM mode continuous read mode

Definition at line 555 of file spim.h.

◆ SPIM_DMM_GET_DESELTIM

#define SPIM_DMM_GET_DESELTIM ( )

Get current DMM mode SPI flash deselect time setting

Definition at line 536 of file spim.h.

◆ SPIM_DMM_SET_ACTSCLKT

#define SPIM_DMM_SET_ACTSCLKT (   x)

Set DMM mode SPI flash active SCLK time

Definition at line 567 of file spim.h.

◆ SPIM_DMM_SET_DEFAULT_ACTSCLK

#define SPIM_DMM_SET_DEFAULT_ACTSCLK ( )

Set SPI flash active SCLK time as SPIM default

Definition at line 576 of file spim.h.

◆ SPIM_DMM_SET_DESELTIM

#define SPIM_DMM_SET_DESELTIM (   x)

Set DMM mode SPI flash deselect time

Definition at line 527 of file spim.h.

◆ SPIM_ENABLE_BALEN

#define SPIM_ENABLE_BALEN ( )

Enable cipher balance

Definition at line 165 of file spim.h.

◆ SPIM_ENABLE_CACHE

#define SPIM_ENABLE_CACHE ( )

Enable cache.

Definition at line 366 of file spim.h.

◆ SPIM_ENABLE_CCM

#define SPIM_ENABLE_CCM ( )

Enable CCM

Definition at line 384 of file spim.h.

◆ SPIM_ENABLE_CIPHER

#define SPIM_ENABLE_CIPHER ( )

Enable cipher.

Definition at line 153 of file spim.h.

◆ SPIM_ENABLE_DUAL_INPUT_MODE

#define SPIM_ENABLE_DUAL_INPUT_MODE ( )

Enable Dual Input mode.

Definition at line 263 of file spim.h.

◆ SPIM_ENABLE_DUAL_OUTPUT_MODE

#define SPIM_ENABLE_DUAL_OUTPUT_MODE ( )

Enable Dual Output mode.

Definition at line 272 of file spim.h.

◆ SPIM_ENABLE_INT

#define SPIM_ENABLE_INT ( )

Enable SPIM interrupt

Definition at line 186 of file spim.h.

◆ SPIM_ENABLE_QUAD_INPUT_MODE

#define SPIM_ENABLE_QUAD_INPUT_MODE ( )

Enable Quad Input mode.

Definition at line 281 of file spim.h.

◆ SPIM_ENABLE_QUAD_OUTPUT_MODE

#define SPIM_ENABLE_QUAD_OUTPUT_MODE ( )

Enable Quad Output mode.

Definition at line 290 of file spim.h.

◆ SPIM_ENABLE_SING_INPUT_MODE

#define SPIM_ENABLE_SING_INPUT_MODE ( )

Enable Single Input mode.

Definition at line 245 of file spim.h.

◆ SPIM_ENABLE_SING_OUTPUT_MODE

#define SPIM_ENABLE_SING_OUTPUT_MODE ( )

Enable Single Output mode.

Definition at line 254 of file spim.h.

◆ SPIM_GET_CLOCK_DIVIDER

#define SPIM_GET_CLOCK_DIVIDER ( )

Get SPIM current clock divider setting

Definition at line 458 of file spim.h.

◆ SPIM_GET_DATA_NUM

#define SPIM_GET_DATA_NUM ( )

Get data transmit/receive burst number

Definition at line 238 of file spim.h.

◆ SPIM_GET_DATA_WIDTH

#define SPIM_GET_DATA_WIDTH ( )

Get data transmit/receive bit length setting

Definition at line 222 of file spim.h.

◆ SPIM_GET_DMMCTL_CRMDAT

#define SPIM_GET_DMMCTL_CRMDAT ( )

Get mode bits data for continuous read mode

Definition at line 520 of file spim.h.

◆ SPIM_GET_IDL_INTVL

#define SPIM_GET_IDL_INTVL ( )

Get idle time interval setting

Definition at line 442 of file spim.h.

◆ SPIM_GET_OP_MODE

#define SPIM_GET_OP_MODE ( )

Get operation mode.

Definition at line 324 of file spim.h.

◆ SPIM_GET_RXCLKDLY_DWDELSEL

#define SPIM_GET_RXCLKDLY_DWDELSEL ( )

Get SPI flash deselect time interval of DMA write mode

Definition at line 474 of file spim.h.

◆ SPIM_GET_RXCLKDLY_RDDLYSEL

#define SPIM_GET_RXCLKDLY_RDDLYSEL ( )

Get sampling clock delay selection for received data

Definition at line 490 of file spim.h.

◆ SPIM_GET_SPIM_MODE

#define SPIM_GET_SPIM_MODE ( )

Get SPIM mode.

Definition at line 339 of file spim.h.

◆ SPIM_GET_SS_EN

#define SPIM_GET_SS_EN ( )

Is SS(Select Active) in active level.

Definition at line 417 of file spim.h.

◆ SPIM_GET_SUSP_INTVL

#define SPIM_GET_SUSP_INTVL ( )

Get suspend interval setting

Definition at line 308 of file spim.h.

◆ SPIM_INVALID_CACHE

#define SPIM_INVALID_CACHE ( )

Invalidate cache.

Definition at line 402 of file spim.h.

◆ SPIM_IS_BUSY

#define SPIM_IS_BUSY ( )

Is engine busy.

Definition at line 351 of file spim.h.

◆ SPIM_IS_CACHE_EN

#define SPIM_IS_CACHE_EN ( )

Is cache enabled.

Definition at line 378 of file spim.h.

◆ SPIM_IS_CCM_EN

#define SPIM_IS_CCM_EN ( )

Is CCM enabled.

Definition at line 396 of file spim.h.

◆ SPIM_IS_IF_ON

#define SPIM_IS_IF_ON ( )

Is interrupt flag on.

Definition at line 198 of file spim.h.

◆ SPIM_SET_4BYTE_ADDR_EN

#define SPIM_SET_4BYTE_ADDR_EN (   x)

Set 4-byte address to be enabled/disabled.

Definition at line 177 of file spim.h.

◆ SPIM_SET_CLOCK_DIVIDER

#define SPIM_SET_CLOCK_DIVIDER (   x)

Set SPIM clock divider

Definition at line 449 of file spim.h.

◆ SPIM_SET_DATA_NUM

#define SPIM_SET_DATA_NUM (   x)

Set data transmit/receive burst number

Definition at line 229 of file spim.h.

◆ SPIM_SET_DATA_WIDTH

#define SPIM_SET_DATA_WIDTH (   x)

Set transmit/receive bit length

Definition at line 213 of file spim.h.

◆ SPIM_SET_DCNUM

#define SPIM_SET_DCNUM (   x)

Set dummy cycle number (Only for DMM mode and DMA mode)

Definition at line 582 of file spim.h.

◆ SPIM_SET_DEFAULT_DCNUM

#define SPIM_SET_DEFAULT_DCNUM (   x)

Set dummy cycle number (Only for DMM mode and DMA mode) as SPIM default

Definition at line 591 of file spim.h.

◆ SPIM_SET_DMMCTL_CRMDAT

#define SPIM_SET_DMMCTL_CRMDAT (   x)

Set mode bits data for continuous read mode

Definition at line 511 of file spim.h.

◆ SPIM_SET_GO

#define SPIM_SET_GO ( )

Start operation.

Definition at line 345 of file spim.h.

◆ SPIM_SET_IDL_INTVL

#define SPIM_SET_IDL_INTVL (   x)

Set idle time interval

Definition at line 433 of file spim.h.

◆ SPIM_SET_OPMODE

#define SPIM_SET_OPMODE (   x)

Set operation mode.

Definition at line 315 of file spim.h.

◆ SPIM_SET_RXCLKDLY_DWDELSEL

#define SPIM_SET_RXCLKDLY_DWDELSEL (   x)

Set SPI flash deselect time interval of DMA write mode

Definition at line 465 of file spim.h.

◆ SPIM_SET_RXCLKDLY_RDDLYSEL

#define SPIM_SET_RXCLKDLY_RDDLYSEL (   x)

Set sampling clock delay selection for received data

Definition at line 481 of file spim.h.

◆ SPIM_SET_RXCLKDLY_RDEDGE

#define SPIM_SET_RXCLKDLY_RDEDGE ( )

Set sampling clock edge selection for received data

Definition at line 497 of file spim.h.

◆ SPIM_SET_SPIM_MODE

#define SPIM_SET_SPIM_MODE (   x)

Set SPIM mode.

Definition at line 330 of file spim.h.

◆ SPIM_SET_SS_ACTLVL

#define SPIM_SET_SS_ACTLVL (   x)

Set active level of slave select to be high/low.

Definition at line 424 of file spim.h.

◆ SPIM_SET_SS_EN

#define SPIM_SET_SS_EN (   x)

Set SS(Select Active) to active level.

Definition at line 408 of file spim.h.

◆ SPIM_SET_SUSP_INTVL

#define SPIM_SET_SUSP_INTVL (   x)

Set suspend interval which ranges between 0 and 15.

Definition at line 299 of file spim.h.

◆ SPIM_WAIT_FREE

#define SPIM_WAIT_FREE ( )

Wait for free.

Definition at line 357 of file spim.h.

Function Documentation

◆ SPIM_ChipErase()

void SPIM_ChipErase ( uint32_t  u32NBit,
int  isSync 
)

Erase whole chip.

Parameters
u32NBitN-bit transmit/receive.
isSyncBlock or not.
Returns
None.

Definition at line 935 of file spim.c.

◆ SPIM_DMA_Read()

void SPIM_DMA_Read ( uint32_t  u32Addr,
int  is4ByteAddr,
uint32_t  u32NRx,
uint8_t  pu8RxBuf[],
uint32_t  u32RdCmd,
int  isSync 
)

Read data from SPI Flash by Page Read mode.

Parameters
u32AddrStart address to read.
is4ByteAddr4-byte u32Address or not.
u32NRxNumber of bytes to read.
pu8RxBufReceive buffer.
u32RdCmdRead command.
isSyncBlock or not.
Returns
None.

Definition at line 1268 of file spim.c.

◆ SPIM_DMA_Write()

void SPIM_DMA_Write ( uint32_t  u32Addr,
int  is4ByteAddr,
uint32_t  u32NTx,
uint8_t  pu8TxBuf[],
uint32_t  wrCmd 
)

Write data to SPI Flash by Page Write mode.

Parameters
u32AddrStart address to write.
is4ByteAddr4-byte address or not.
u32NTxNumber of bytes to write.
pu8TxBufTransmit buffer.
wrCmdWrite command.
Returns
None.

Definition at line 1219 of file spim.c.

◆ SPIM_Enable_4Bytes_Mode()

int SPIM_Enable_4Bytes_Mode ( int  isEn,
uint32_t  u32NBit 
)

Enter/Exit 4-byte address mode.

HIDDEN_SYMBOLS

Parameters
isEnEnable/disable.
u32NBitN-bit transmit/receive.
Returns
0 success -1 failed

Definition at line 832 of file spim.c.

◆ SPIM_EnterDirectMapMode()

void SPIM_EnterDirectMapMode ( int  is4ByteAddr,
uint32_t  u32RdCmd,
uint32_t  u32IdleIntvl 
)

Enter Direct Map mode.

Parameters
is4ByteAddr4-byte u32Address or not.
u32RdCmdRead command.
u32IdleIntvlIdle interval.
Returns
None.

Definition at line 1293 of file spim.c.

◆ spim_eon_set_qpi_mode()

static void spim_eon_set_qpi_mode ( int  isEn)
static

Enter/exit QPI mode.

Parameters
isEnEnable/disable.
Returns
None.

Definition at line 706 of file spim.c.

◆ SPIM_EraseBlock()

void SPIM_EraseBlock ( uint32_t  u32Addr,
int  is4ByteAddr,
uint8_t  u8ErsCmd,
uint32_t  u32NBit,
int  isSync 
)

Erase one block.

Parameters
u32AddrBlock to erase which contains the u32Addr.
is4ByteAddr4-byte u32Address or not.
u8ErsCmdErase command.
u32NBitN-bit transmit/receive.
isSyncBlock or not.
Returns
None.

Definition at line 962 of file spim.c.

◆ SPIM_ExitDirectMapMode()

void SPIM_ExitDirectMapMode ( void  )

Exit Direct Map mode.

Returns
None.

Definition at line 1305 of file spim.c.

◆ SPIM_GetSClkFreq()

uint32_t SPIM_GetSClkFreq ( void  )

Get SPIM serial clock.

HIDDEN_SYMBOLS

Returns
SPI serial clock.

This function calculates the serial clock of SPI in Hz.

Definition at line 479 of file spim.c.

◆ SPIM_InitFlash()

int SPIM_InitFlash ( int  clrWP)

Initialize SPIM flash.

Parameters
clrWPClear Write Protect or not.
Returns
0 Success.
-1 Unrecognized manufacture ID or failed on reading manufacture ID.

Definition at line 492 of file spim.c.

◆ SPIM_IO_Read()

void SPIM_IO_Read ( uint32_t  u32Addr,
int  is4ByteAddr,
uint32_t  u32NRx,
uint8_t  pu8RxBuf[],
uint8_t  rdCmd,
uint32_t  u32NBitCmd,
uint32_t  u32NBitAddr,
uint32_t  u32NBitDat,
int  u32NDummy 
)

Read data from SPI Flash by sending commands manually (I/O mode).

Parameters
u32AddrStart u32Address to read.
is4ByteAddr4-byte u32Address or not.
u32NRxNumber of bytes to read.
pu8RxBufReceive buffer.
rdCmdRead command.
u32NBitCmdN-bit transmit command.
u32NBitAddrN-bit transmit u32Address.
u32NBitDatN-bit transmit/receive data.
u32NDummyNumber of dummy bytes following address.
Returns
None.

Definition at line 1166 of file spim.c.

◆ SPIM_IO_Write()

void SPIM_IO_Write ( uint32_t  u32Addr,
int  is4ByteAddr,
uint32_t  u32NTx,
uint8_t  pu8TxBuf[],
uint8_t  wrCmd,
uint32_t  u32NBitCmd,
uint32_t  u32NBitAddr,
uint32_t  u32NBitDat 
)

Write data to SPI Flash by sending commands manually (I/O mode).

HIDDEN_SYMBOLS

Parameters
u32AddrStart u32Address to write.
is4ByteAddr4-byte u32Address or not.
u32NTxNumber of bytes to write.
pu8TxBufTransmit buffer.
wrCmdWrite command.
u32NBitCmdN-bit transmit command.
u32NBitAddrN-bit transmit u32Address.
u32NBitDatN-bit transmit/receive data.
Returns
None.

Definition at line 1113 of file spim.c.

◆ SPIM_Is4ByteModeEnable()

int SPIM_Is4ByteModeEnable ( uint32_t  u32NBit)

◆ SPIM_ReadJedecId()

void SPIM_ReadJedecId ( uint8_t  idBuf[],
uint32_t  u32NRx,
uint32_t  u32NBit 
)

Issue JEDEC ID command.

Parameters
idBufID buffer.
u32NRxSize of ID buffer.
u32NBitN-bit transmit/receive.
Returns
None.

Definition at line 566 of file spim.c.

◆ SPIM_SetQuadEnable()

void SPIM_SetQuadEnable ( int  isEn,
uint32_t  u32NBit 
)

Set Quad Enable/disable.

HIDDEN_SYMBOLS

Parameters
isEnEnable/disable.
u32NBitN-bit transmit/receive.
Returns
None.

Definition at line 650 of file spim.c.

◆ SPIM_SPANSION_4Bytes_Enable()

static void SPIM_SPANSION_4Bytes_Enable ( int  isEn,
uint32_t  u32NBit 
)
static

Definition at line 738 of file spim.c.

◆ SPIM_WinbondUnlock()

void SPIM_WinbondUnlock ( uint32_t  u32NBit)

Definition at line 902 of file spim.c.