spi100khz.h
来自「OMAP1030 处理器的ARM 侧硬件测试代码 OMAP1030 是TI」· C头文件 代码 · 共 518 行 · 第 1/2 页
H
518 行
SPI_100KHZ_CTRL_NB_15, SPI_100KHZ_CTRL_NB_16, SPI_100KHZ_CTRL_NB_17,
SPI_100KHZ_CTRL_NB_18, SPI_100KHZ_CTRL_NB_19, SPI_100KHZ_CTRL_NB_20,
SPI_100KHZ_CTRL_NB_21, SPI_100KHZ_CTRL_NB_22, SPI_100KHZ_CTRL_NB_23,
SPI_100KHZ_CTRL_NB_24, SPI_100KHZ_CTRL_NB_25, SPI_100KHZ_CTRL_NB_26,
SPI_100KHZ_CTRL_NB_27, SPI_100KHZ_CTRL_NB_28, SPI_100KHZ_CTRL_NB_29,
SPI_100KHZ_CTRL_NB_30, SPI_100KHZ_CTRL_NB_31,
SPI_100KHZ_CTRL_NB_32 // 32 bits transmit
} SPI_100KHZ_TrxLength_t;
//To select the driven device
//Index of the addressed device 5 devices maximum => [0..4]
typedef enum
{
SPI_100KHZ_DEVICE_0 = 0x00, // Index of the addressed device 0
SPI_100KHZ_DEVICE_1, // Index of the addressed device 1
SPI_100KHZ_DEVICE_2, // Index of the addressed device 2
SPI_100KHZ_DEVICE_3, // Index of the addressed device 3
SPI_100KHZ_DEVICE_4 // Index of the addressed device 4
} SPI_100KHZ_DeviceIndex_t;
//Indicate if the read or write process is still on going
typedef enum
{
SPI_100KHZ_FREE, //Spi is ready to start a new process
SPI_100KHZ_BUSY //Spi is still working on a previous request
} SPI_100KHZ_Status_t;
/*
-----------------------------------------------------------------------------
NAME : SPI_100khz_TestRegisters. -
DESCRIPTION : Test the reset default values of the whole spi registers. -
Test the access of the register to the SPI_100KHZ module. -
PARAMETERS : None. -
RETURN VALUE: Return the result of the test OK or BAD. -
LIMITATIONS : To invoke on Reset only. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_TestRegisters( )\
SPI_100hzTestRegisters( SPI_MODULE_1)
UWORD16 SPI_100khzTestRegisters (SPI_module_t module);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzInitSet1. -
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. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_InitSet1( enClk, Pscale, IntWr, IntRdWr)\
SPI_100khzInitSet1( SPI_MODULE_1,\
(enClk), (Pscale), (IntWr), (IntRdWr))
void SPI_100khzInitSet1 (SPI_module_t module,
SPI_100KHZ_EnableClock_t enClk,
SPI_100KHZ_Ptv_t Pscale,
SPI_100KHZ_MaskIntWr_t IntWr,
SPI_100KHZ_MaskIntRdWr_t IntRdWr);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzInitSet2. -
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. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_InitSet2( AcedgDevi, Ptspen, Ltspen)\
SPI_100khzInitSet2( SPI_MODULE_1, (AcedgDevi), (Ptspen), (Ltspen))
void SPI_100KhzInitSet2 (SPI_module_t module,
SPI_100KHZ_EdgeClock_t AcedgDevi,
SPI_100KHZ_Ptspen_t Ptspen,
SPI_100KHZ_Ltspen_t Ltspen);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzInitCTRL. -
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. -
RETURN VALUE: None. -
LIMITATION : None. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_InitCTRL( enClk, Pscale, IntWr, IntRdWr)\
SPI_100khzInitCTRL( SPI_MODULE_1,\
(enClk), (Pscale), (IntWr), (IntRdWr))
void SPI_100KhzInitCTRL (SPI_module_t module,
SPI_100KHZ_CtrlRd_t Rdproc,
SPI_100KHZ_CtrlWr_t Wrproc,
SPI_100KHZ_TrxLength_t Nbsize,
SPI_100KHZ_DeviceIndex_t DeviceNumber);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzWriteTxLsb. -
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. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_writeTX_LSB( Txlsb)\
SPI_100KhzWriteTxLsb( SPI_MODULE_1, (Txlsb))
void SPI_100KhzWriteTxLsb (SPI_module_t module, UWORD16 Txlsb);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzWriteTxMsb. -
DESCRIPTION : Write data into transmit REG_TX_MSB (MSB of data). -
PARAMETERS : Txmsb msb side of data to transmit. -
RETURN VALUE: None. -
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_writeTX_MSB( Txmsb)\
SPI_100khzWriteTxMsb( SPI_MODULE_1, (Txmsb))
void SPI_100khzWriteTxMsb (SPI_module_t module, UWORD16 Txmsb);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzReadRxLsb. -
DESCRIPTION : Read in data to transmit (LSB of data). -
PARAMETERS : None. -
RETURN VALUE: Rxlsb lsb side of receive data. -
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_readRX_LSB( )\
SPI_100KhzReadRxLsb( SPI_MODULE_1)
UWORD16 SPI_100KhzReadRxLsb (SPI_module_t module);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzReadRxMsb. -
DESCRIPTION : Read in data to transmit register (LSB of data). -
PARAMETERS : None. -
RETURN VALUE: Rxmsb msb side of receive data. -
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_readRX_MSB( )\
SPI_100KhzReadRxMsb( SPI_MODULE_1)
UWORD16 SPI_100KhzReadRxMsb (SPI_module_t module);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzReadStatus. -
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. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_ReadStatus( )\
SPI_100KhzReadStatus( SPI_MODULE_1)
SPI_100KHZ_Status_t SPI_100KhzReadStatus (SPI_module_t module);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzIsReadEnd. -
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. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_IsReadEnd( )\
SPI_100KhzIsReadEnd( SPI_MODULE_1)
boolean_t SPI_100KhzIsReadEnd (SPI_module_t module);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzIsWriteEnd. -
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. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_IsWriteEnd( )\
SPI_100khzIsWriteEnd( SPI_MODULE_1)
boolean_t SPI_100khzIsWriteEnd (SPI_module_t module);
/*
-----------------------------------------------------------------------------
NAME : SPI_100KhzStartClock. -
DESCRIPTION : Start the SPI clock. -
PARAMETERS : None. -
RETURN VALUE: None. -
LIMITATIONS : This fct is required before writting/reading the status -
register. -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_StartClock( )\
SPI_100khzStartClock( SPI_MODULE_1)
void SPI_100khzStartClock(SPI_module_t module);
/*
-----------------------------------------------------------------------------
NAME : SPI_100khzStopClock. -
DESCRIPTION : Stop the SPI clock to avoid power consumption during period -
of SPI 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 ( SPI_100KhzReadStatus() == SPI_100KHZ_FREE ) -
SPI_100KHZ_ClockStop(); -
-----------------------------------------------------------------------------
*/
#define SPI_100KHZ_StopClock( )\
SPI_100khzStopClock( SPI_MODULE_1)
void SPI_100khzStopClock(SPI_module_t module);
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?