📄 stm32f10x_sdio.c
字号:
/*******************************************************************************
* 函数名 : SDIO_SetSDIOOperation
* 功能描述 : Enables or disables the SD I/O Mode Operation.
* 输入 : NewState: new state of SDIO specific operation.
* This parameter can be: ENABLE or DISABLE.
* 输出 : None
* 返回 : None
*******************************************************************************/
void SDIO_SetSDIOOperation(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(vu32 *) DCTRL_SDIOEN_BB = (u32)NewState;
}
/*******************************************************************************
* 函数名 : SDIO_SendSDIOSuspendCmd
* 功能描述 : Enables or disables the SD I/O Mode suspend command sending.
* 输入 : NewState: new state of the SD I/O Mode suspend command.
* This parameter can be: ENABLE or DISABLE.
* 输出 : None
* 返回 : None
*******************************************************************************/
void SDIO_SendSDIOSuspendCmd(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(vu32 *) CMD_SDIOSUSPEND_BB = (u32)NewState;
}
/*******************************************************************************
* 函数名 : SDIO_CommandCompletionCmd
* 功能描述 : Enables or disables the command completion signal.
* 输入 : NewState: new state of command completion signal.
* This parameter can be: ENABLE or DISABLE.
* 输出 : None
* 返回 : None
*******************************************************************************/
void SDIO_CommandCompletionCmd(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(vu32 *) CMD_ENCMDCOMPL_BB = (u32)NewState;
}
/*******************************************************************************
* 函数名 : SDIO_CEATAITCmd
* 功能描述 : Enables or disables the CE-ATA interrupt.
* 输入 : NewState: new state of CE-ATA interrupt.
* This parameter can be: ENABLE or DISABLE.
* 输出 : None
* 返回 : None
*******************************************************************************/
void SDIO_CEATAITCmd(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(vu32 *) CMD_NIEN_BB = (u32)((~((u32)NewState)) & ((u32)0x1));
}
/*******************************************************************************
* 函数名 : SDIO_SendCEATACmd
* 功能描述 : Sends CE-ATA command (CMD61).
* 输入 : NewState: new state of CE-ATA command.
* This parameter can be: ENABLE or DISABLE.
* 输出 : None
* 返回 : None
*******************************************************************************/
void SDIO_SendCEATACmd(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(vu32 *) CMD_ATACMD_BB = (u32)NewState;
}
/*******************************************************************************
* 函数名 : SDIO_GetFlagStatus
* 功能描述 : Checks whether the specified SDIO flag is set or not.
* 输入 : SDIO_FLAG: specifies the flag to check.
* This parameter can be one of the following values:
* - SDIO_FLAG_CCRCFAIL: Command response received (CRC check
* failed)
* - SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check
* failed)
* - SDIO_FLAG_CTIMEOUT: Command response timeout
* - SDIO_FLAG_DTIMEOUT: Data timeou
* - SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
* - SDIO_FLAG_RXOVERR: Received FIFO overrun error
* - SDIO_FLAG_CMDREND: Command response received (CRC check
* passed)
* - SDIO_FLAG_CMDSENT: Command sent (no response required)
* - SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is
* zero)
* - SDIO_FLAG_STBITERR: Start bit not detected on all data
* signals in wide bus mode
* - SDIO_FLAG_DBCKEND: Data block sent/received (CRC check
* passed)
* - SDIO_FLAG_CMDACT: Command transfer in progress
* - SDIO_FLAG_TXACT: Data transmit in progress
* - SDIO_FLAG_RXACT: Data receive in progress
* - SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty
* - SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full
* - SDIO_FLAG_TXFIFOF: Transmit FIFO full
* - SDIO_FLAG_RXFIFOF: Receive FIFO full
* - SDIO_FLAG_TXFIFOE: Transmit FIFO empty
* - SDIO_FLAG_RXFIFOE: Receive FIFO empty
* - SDIO_FLAG_TXDAVL: Data available in transmit FIFO
* - SDIO_FLAG_RXDAVL: Data available in receive FIFO
* - SDIO_FLAG_SDIOIT: SD I/O interrupt received
* - SDIO_FLAG_CEATAEND: CE-ATA command completion signal
* received for CMD61
* 输出 : None
* 返回 : The new state of SDIO_FLAG (SET or RESET).
*******************************************************************************/
FlagStatus SDIO_GetFlagStatus(u32 SDIO_FLAG)
{
FlagStatus bitstatus = RESET;
/* Check the parameters */
assert_param(IS_SDIO_FLAG(SDIO_FLAG));
if ((SDIO->STA & SDIO_FLAG) != (u32)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
/*******************************************************************************
* 函数名 : SDIO_ClearFlag
* 功能描述 : Clears the SDIO's pending flags.
* 输入 : SDIO_FLAG: specifies the flag to clear.
* This parameter can be one or a combination of the following
* values:
* - SDIO_FLAG_CCRCFAIL: Command response received (CRC check
* failed)
* - SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check
* failed)
* - SDIO_FLAG_CTIMEOUT: Command response timeout
* - SDIO_FLAG_DTIMEOUT: Data timeou
* - SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
* - SDIO_FLAG_RXOVERR: Received FIFO overrun error
* - SDIO_FLAG_CMDREND: Command response received (CRC check
* passed)
* - SDIO_FLAG_CMDSENT: Command sent (no response required)
* - SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is
* zero)
* - SDIO_FLAG_STBITERR: Start bit not detected on all data
* signals in wide bus mode
* - SDIO_FLAG_DBCKEND: Data block sent/received (CRC check
* passed)
* - SDIO_FLAG_SDIOIT: SD I/O interrupt received
* - SDIO_FLAG_CEATAEND: CE-ATA command completion signal
* received for CMD61
* 输出 : None
* 返回 : None
*******************************************************************************/
void SDIO_ClearFlag(u32 SDIO_FLAG)
{
/* Check the parameters */
assert_param(IS_SDIO_CLEAR_FLAG(SDIO_FLAG));
SDIO->ICR = SDIO_FLAG;
}
/*******************************************************************************
* 函数名 : SDIO_GetITStatus
* 功能描述 : Checks whether the specified SDIO interrupt has occurred or not.
* 输入 : SDIO_IT: specifies the SDIO interrupt source to check.
* This parameter can be one of the following values:
* - SDIO_IT_CCRCFAIL: Command response received (CRC check
* failed) interrupt
* - SDIO_IT_DCRCFAIL: Data block sent/received (CRC check
* failed) interrupt
* - SDIO_IT_CTIMEOUT: Command response timeout interrupt
* - SDIO_IT_DTIMEOUT: Data timeout interrupt
* - SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
* - SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
* - SDIO_IT_CMDREND: Command response received (CRC check
* passed) interrupt
* - SDIO_IT_CMDSENT: Command sent (no response required)
* interrupt
* - SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is
* zero) interrupt
* - SDIO_IT_STBITERR: Start bit not detected on all data
* signals in wide bus mode interrupt
* - SDIO_IT_DBCKEND: Data block sent/received (CRC check
* passed) interrupt
* - SDIO_IT_CMDACT: Command transfer in progress interrupt
* - SDIO_IT_TXACT: Data transmit in progress interrupt
* - SDIO_IT_RXACT: Data receive in progress interrupt
* - SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
* - SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
* - SDIO_IT_TXFIFOF: Transmit FIFO full interrupt
* - SDIO_IT_RXFIFOF: Receive FIFO full interrupt
* - SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt
* - SDIO_IT_RXFIFOE: Receive FIFO empty interrupt
* - SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt
* - SDIO_IT_RXDAVL: Data available in receive FIFO interrupt
* - SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
* - SDIO_IT_CEATAEND: CE-ATA command completion signal
* received for CMD61 interrupt
* 输出 : None
* 返回 : The new state of SDIO_IT (SET or RESET).
*******************************************************************************/
ITStatus SDIO_GetITStatus(u32 SDIO_IT)
{
ITStatus bitstatus = RESET;
/* Check the parameters */
assert_param(IS_SDIO_GET_IT(SDIO_IT));
if ((SDIO->STA & SDIO_IT) != (u32)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
/*******************************************************************************
* 函数名 : SDIO_ClearITPendingBit
* 功能描述 : Clears the SDIO抯 interrupt pending bits.
* 输入 : SDIO_IT: specifies the interrupt pending bit to clear.
* This parameter can be one or a combination of the following
* values:
* - SDIO_IT_CCRCFAIL: Command response received (CRC check
* failed) interrupt
* - SDIO_IT_DCRCFAIL: Data block sent/received (CRC check
* failed) interrupt
* - SDIO_IT_CTIMEOUT: Command response timeout interrupt
* - SDIO_IT_DTIMEOUT: Data timeout interrupt
* - SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
* - SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
* - SDIO_IT_CMDREND: Command response received (CRC check
* passed) interrupt
* - SDIO_IT_CMDSENT: Command sent (no response required)
* interrupt
* - SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is
* zero) interrupt
* - SDIO_IT_STBITERR: Start bit not detected on all data
* signals in wide bus mode interrupt
* - SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
* - SDIO_IT_CEATAEND: CE-ATA command completion signal
* received for CMD61
* 输出 : None
* 返回 : None
*******************************************************************************/
void SDIO_ClearITPendingBit(u32 SDIO_IT)
{
/* Check the parameters */
assert_param(IS_SDIO_CLEAR_IT(SDIO_IT));
SDIO->ICR = SDIO_IT;
}
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -