📄 vspi.h
字号:
VSPI_CTRL_NB_19, VSPI_CTRL_NB_20, VSPI_CTRL_NB_21, VSPI_CTRL_NB_22,
VSPI_CTRL_NB_23, VSPI_CTRL_NB_24, VSPI_CTRL_NB_25, VSPI_CTRL_NB_26,
VSPI_CTRL_NB_27, VSPI_CTRL_NB_28, VSPI_CTRL_NB_29, VSPI_CTRL_NB_30,
VSPI_CTRL_NB_31, VSPI_CTRL_NB_32 // 32 bits transmit
} VSPI_TrxLength_t;
//To select the driven device
//Index of the addressed device 5 devices maximum => [0..4]
typedef enum
{
VSPI_DEVICE_0 = 0x00, // Index of the addressed device 0
VSPI_DEVICE_1, // Index of the addressed device 1
VSPI_DEVICE_2, // Index of the addressed device 2
VSPI_DEVICE_3, // Index of the addressed device 3
VSPI_DEVICE_4 // Index of the addressed device 4
} VSPI_DeviceIndex_t;
//Indicate if the read or write process is still on going
typedef enum
{
VSPI_FREE, //Spi is ready to start a new process
VSPI_BUSY //Spi is still working on a previous request
} VSPI_Status_t;
//Indicate if DMA mode is enable.
typedef enum
{
DMA_EN = 0x1, //dma is enable
DMA_DIS = 0x0 //dma is disable
} VSPI_dma_en_t;
/*
-----------------------------------------------------------------------------
NAME : VSPI_TestRegisters. -
DESCRIPTION : Test the reset default values of the whole spi registers. -
Test the access of the register to the VSPI module. -
PARAMETERS : None. -
RETURN VALUE: Return the result of the test OK or BAD. -
LIMITATIONS : To invoke on Reset only. -
-----------------------------------------------------------------------------
*/
UWORD16 VSPI_TestRegisters(void);
/*
-----------------------------------------------------------------------------
NAME : VSPI_InitSet1. -
DESCRIPTION : Setup the configuration of the serial port (REG_SET1) -
clock enabling, clock prescale, interrupts masking. -
PARAMETERS : -
clock_en => Spi Clock module enable/disable. -
Pscale => Pre-scale clock divisor PTV = 1, 2 ,4 ,8 and 16. -
IntWr => Interrupt valid for write cycle MSK0. -
IntRdWr => Interrupt valid for Read/write cycle MSK1. -
RETURN VALUE: None. -
LIMITATIONS : This fct is not allowed to enable interrupts. -
By default, the two IT for read and write process are -
inactive. -
-----------------------------------------------------------------------------
*/
void VSPI_InitSet1 (VSPI_EnableClock_t enClk,
VSPI_Ptv_t Pscale,
VSPI_MaskIntWr_t IntWr,
VSPI_MaskIntRdWr_t IntRdWr);
/*
-----------------------------------------------------------------------------
NAME : VSPI_InitSet2. -
DESCRIPTION : Setup SET2_REG register, configuring the active edge of clock-
the active level of the nebale signal and format of the -
enable signal. -
PARAMETERS : -
AcedgDevi => Active edge of the clock. -
Ptspen => Format of enable signals nTSPEN. -
Ltspen => Format of enable signals nTSPEN (level or edge trigger). -
RETURN VALUE: None. -
LIMITATION : To be called only once at initialization. -
-----------------------------------------------------------------------------
*/
void VSPI_InitSet2 (VSPI_EdgeClock_t AcedgDevi,
VSPI_Ptspen_t Ptspen,
VSPI_Ltspen_t Ltspen);
/*
-----------------------------------------------------------------------------
NAME : VSPI_InitCtrl. -
DESCRIPTION : Setup CTRL_REG register. -
Configure the Read/Write process activation, write activation-
and transmission word size. -
PARAMETERS : -
Rdproc => Read and Write process activation. -
Wrproc => Write process activation. -
Nbsize => Word size transmission (from 0 to 31). -
DeviceNumber => index of device. -
Dma_en => Enable dma mode.
RETURN VALUE: None. -
LIMITATION : None. -
-----------------------------------------------------------------------------
*/
void VSPI_InitCtrl (VSPI_CtrlRd_t Rdproc,
VSPI_CtrlWr_t Wrproc,
VSPI_TrxLength_t Nbsize,
VSPI_DeviceIndex_t DeviceNumber,
VSPI_dma_en_t Dma_en);
/*
-----------------------------------------------------------------------------
NAME : VSPI_writeTxLsb. -
DESCRIPTION : Write in data to transmit REG_TX_LSB (LSB of data). -
PARAMETERS : Txlsb lsb side of data to transmit. -
RETURN VALUE: None. -
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
void VSPI_writeTxLsb (UWORD16 Txlsb);
/*
-----------------------------------------------------------------------------
NAME : VSPI_writeTxMsb. -
DESCRIPTION : Write data into transmit REG_TX_MSB (MSB of data). -
PARAMETERS : Txmsb msb side of data to transmit. -
RETURN VALUE: None. -
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
void VSPI_writeTxMsb (UWORD16 Txmsb);
/*
-----------------------------------------------------------------------------
NAME : VSPI_readRxLsb. -
DESCRIPTION : Read in data to transmit (LSB of data). -
PARAMETERS : None. -
RETURN VALUE: Rxlsb lsb side of receive data. -
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
UWORD16 VSPI_readRxLsb(void);
/*
-----------------------------------------------------------------------------
NAME : VSPI_readRxMsb. -
DESCRIPTION : Read in data to transmit register (LSB of data). -
PARAMETERS : None. -
RETURN VALUE: Rxmsb msb side of receive data. -
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
UWORD16 VSPI_readRxMsb (void);
/*
-----------------------------------------------------------------------------
NAME : VSPI_ReadStatus. -
DESCRIPTION : Read STATUS_REG register checking for a previous ongoing -
transmission. -
PARAMETERS : None. -
RETURN VALUE: SPI_FREE when ready to start a new process. -
SPI_BUSY when either a write or read process is still ongoing-
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
VSPI_Status_t VSPI_ReadStatus(void);
/*
-----------------------------------------------------------------------------
NAME : VSPI_IsReadEnd. -
DESCRIPTION : Read STATUS_REG register to detect end of read. -
PARAMETERS : None. -
RETURN VALUE: True on end of transmission otherwise False. -
LIMITATIONS : To be used for polling the status after starting -
serialization. -
-----------------------------------------------------------------------------
*/
boolean_t VSPI_IsReadEnd(void);
/*
-----------------------------------------------------------------------------
NAME : VSPI_IsWriteEnd. -
DESCRIPTION : Read STATUS_REG register to detect end of write. -
PARAMETERS : None. -
RETURN VALUE: True on end of transmission otherwise False. -
LIMITATIONS : To be used for polling the status after starting -
serialization. -
-----------------------------------------------------------------------------
*/
boolean_t VSPI_IsWriteEnd(void);
/*
-----------------------------------------------------------------------------
NAME : VSPI_StartClock. -
DESCRIPTION : Start the VSPI clock. -
PARAMETERS : None. -
RETURN VALUE: None. -
LIMITATIONS : This fct is required before writting/reading the status -
register. -
-----------------------------------------------------------------------------
*/
void VSPI_StartClock(void);
/*
-----------------------------------------------------------------------------
NAME : VSPI_StopClock. -
DESCRIPTION : Stop the VSPI clock to avoid power consumption during period -
of VSPI inactivity. -
PARAMETERS : None. -
RETURN VALUE: None. -
LIMITATIONS : Stopping the spi clock while a serialization is on going -
lead to a loose of data. -
Stop the clock after a status check is strongly recommended -
if ( VSPI_ReadStatus() == VSPI_FREE ) -
VSPI_ClockStop(); -
-----------------------------------------------------------------------------
*/
void VSPI_StopClock(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -