📄 73x_bspi.c
字号:
}
/*******************************************************************************
* Function Name : BSPI_ITConfig
* Description : Enables or disables the specified BSPI interrupts.
* Input : - BSPIx: where x can be 0, 1 or 2 to select the BSPI peripheral.
* - BSPI_IT: specifies the BSPI interrupts sources to be enabled
* or disabled. This parameter can be any combination of the
* following values:
* - BSPI_IT_REI: Receive error interrupt mask
* - BSPI_IT_BEI: Bus error interrupt mask
* - NewState: new state of the specified BSPI interrupts.
* This parameter can be: ENABLE or DISABLE.
* Output : None
* Return : None
*******************************************************************************/
void BSPI_ITConfig(BSPI_TypeDef* BSPIx, u16 BSPI_IT, FunctionalState NewState)
{
if(NewState == ENABLE)
{
BSPIx->CSR1 |= BSPI_IT;
}
else
{
BSPIx->CSR1 &= ~BSPI_IT;
}
}
/*******************************************************************************
* Function Name : BSPI_TxITConfig
* Description : Configures the transmit interrupt source.
* Input : - BSPIx: where x can be 0, 1 or 2 to select the BSPI peripheral.
* - BSPI_TxIT: specifies the BSPI transmit interrupt source to
* be enabled. This parameter can be one of the following values:
* - BSPI_TxIT_NONE: No interrupt
* - BSPI_TxIT_TFE: Transmit FIFO empty interrupt mask
* - BSPI_TxIT_TUFL: Transmit underflow interrupt mask
* - BSPI_TxIT_TFF: Transmit FIFO full interrupt mask
* Output : None
* Return : None
*******************************************************************************/
void BSPI_TxITConfig(BSPI_TypeDef* BSPIx, u16 BSPI_TxIT)
{
/* clear the TIE[1:0] bits in CSR2 register */
BSPIx->CSR2 &= BSPI_TxIT_Mask;
/* set the TIE[1:0] bits according to BSPI_TxIT value */
BSPIx->CSR2 |= BSPI_TxIT;
}
/*******************************************************************************
* Function Name : BSPI_RxITConfig
* Description : Configures the receive interrupt source.
* Input : - BSPIx: where x can be 0, 1 or 2 to select the BSPI peripheral.
* - BSPI_RxIT: specifies the BSPI receive interrupt source to
* be enabled. This parameter can be one of the following values:
* - BSPI_RxIT_NONE: No interrupt
* - BSPI_RxIT_RFNE: Receive FIFO not empty interrupt mask
* - BSPI_RxIT_RFF: Receive FIFO full interrupt mask
* Output : None
* Return : None
*******************************************************************************/
void BSPI_RxITConfig(BSPI_TypeDef* BSPIx, u16 BSPI_RxIT)
{
/* clear the RIE[1:0] bits in CSR1 register */
BSPIx->CSR1 &= BSPI_RxIT_Mask;
/* set the RIE[1:0] bits according to BSPI_RxIT value */
BSPIx->CSR1 |= BSPI_RxIT;
}
/*******************************************************************************
* Function Name : BSPI_DMAConfig
* Description : Enables or disables the transmit and/or receive DMA request.
* Input : - BSPIx: where x can be 0, 1 or 2 to select the BSPI peripheral.
* - BSPI_DMAReq : specifies the DMA request to be enabled or
* disabled. This parameter can be any combination of the
* following values:
* - BSPI_DMAReq_Tx: DMA transmit request mask
* - BSPI_DMAReq_Rx: DMA receive request mask
* - NewState: new state of the specified DMA request.
* This parameter can be: ENABLE or DISABLE.
* Output : None
* Return : None
*******************************************************************************/
void BSPI_DMAConfig(BSPI_TypeDef* BSPIx, u8 BSPI_DMAReq, FunctionalState NewState)
{
if(NewState == ENABLE)
{
BSPIx->CSR3 |= BSPI_DMAReq;
}
else
{
BSPIx->CSR3 &= ~BSPI_DMAReq;
}
}
/*******************************************************************************
* Function Name : BSPI_DMATxBurstConfig
* Description : Configures the transmit burst length of the BSPIx抯 DMA interface.
* Input : - BSPIx: where x can be 0, 1 or 2 to select the BSPI peripheral.
* - BSPI_DMA_TxBurst: specifies the transmit burst length.
* This parameter can be one of the following values:
* - BSPI_DMA_TxBurst_1Word: 1 word transferred
* - BSPI_DMA_TxBurst_4Word: 4 words transferred
* - BSPI_DMA_TxBurst_8Word: 8 words transferred
* - BSPI_DMA_TxBurst_16Word: 16 words transferred
* Output : None
* Return : None
*******************************************************************************/
void BSPI_DMATxBurstConfig(BSPI_TypeDef* BSPIx, u8 BSPI_DMA_TxBurst)
{
/* clear the TBURST_LEN[1:0] bits in CSR3 register */
BSPIx->CSR3 &= BSPI_DMA_TxBurst_Mask;
/* set the TBURST_LEN[1:0] bits according to BSPI_DMA_TxBurst value */
BSPIx->CSR3 |= BSPI_DMA_TxBurst;
}
/*******************************************************************************
* Function Name : BSPI_DMARxBurstConfig
* Description : Configures the receive burst length of the BSPIx抯 DMA interface.
* Input : - BSPIx: where x can be 0, 1 or 2 to select the BSPI peripheral.
* - BSPI_DMA_RxBurst: specifies the receive burst length.
* This parameter can be one of the following values:
* - BSPI_DMA_RxBurst_1Word: 1 word transferred
* - BSPI_DMA_RxBurst_4Word: 4 words transferred
* - BSPI_DMA_RxBurst_8Word: 8 words transferred
* - BSPI_DMA_RxBurst_16Word: 16 words transferred
* Output : None
* Return : None
*******************************************************************************/
void BSPI_DMARxBurstConfig(BSPI_TypeDef* BSPIx, u8 BSPI_DMA_RxBurst)
{
/* clear the RBURST_LEN[1:0] bits in CSR3 register */
BSPIx->CSR3 &= BSPI_DMA_RxBurst_Mask;
/* set the RBURST_LEN[1:0] bits according to BSPI_DMA_RxBurst value */
BSPIx->CSR3 |= BSPI_DMA_RxBurst;
}
/*******************************************************************************
* Function Name : BSPI_DMACmd
* Description : Enables or disables the BSPIx DMA interface.
* Input : - BSPIx: where x can be 0, 1 or 2 to select the BSPI peripheral.
* - NewState: new state of the DMA interface. This parameter
* can be: ENABLE or DISABLE.
* Output : None
* Return : None
*******************************************************************************/
void BSPI_DMACmd(BSPI_TypeDef* BSPIx, FunctionalState NewState)
{
if(NewState == ENABLE)
{
BSPIx->CSR3 |= BSPI_DMA_Enable;
}
else
{
BSPIx->CSR3 &= BSPI_DMA_Disable;
}
}
/*******************************************************************************
* Function Name : BSPI_WordSend.
* Description : Transmits a single word through the BSPI peripheral.
* Input : - BSPIx: where x can be 0, 1 or 2 to select the BSPI peripheral.
* - Data : word to be transmitted.
* Output : None
* Return : None
*******************************************************************************/
void BSPI_WordSend(BSPI_TypeDef* BSPIx, u16 Data)
{
if ((BSPIx->CSR1 & BSPI_WordLength_16b) == FALSE)
{
Data <<= 8;
}
BSPIx->TXR = Data;
}
/*******************************************************************************
* Function Name : BSPI_BufferSend.
* Description : Transmits data from a user defined buffer. This function will
* fail if an error occurs.
* Input : - BSPIx: where x can be 0, 1 or 2 to select the BSPI peripheral.
* - PtrToBuffer : 憉8
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -