?? stm32l1xx_sdio.c
字號:
/* Check the parameters */
assert_param(IS_SDIO_READWAIT_MODE(SDIO_ReadWaitMode));
*(__IO uint32_t *) DCTRL_RWMOD_BB = SDIO_ReadWaitMode;
}
/**
* @brief Enables or disables the SD I/O Mode Operation.
* @param NewState: new state of SDIO specific operation.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void SDIO_SetSDIOOperation(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(__IO uint32_t *) DCTRL_SDIOEN_BB = (uint32_t)NewState;
}
/**
* @brief Enables or disables the SD I/O Mode suspend command sending.
* @param NewState: new state of the SD I/O Mode suspend command.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void SDIO_SendSDIOSuspendCmd(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(__IO uint32_t *) CMD_SDIOSUSPEND_BB = (uint32_t)NewState;
}
/**
* @}
*/
/** @defgroup SDIO_Group6 CE-ATA mode management functions
* @brief CE-ATA mode management functions
*
@verbatim
==============================================================================
##### CE-ATA mode management functions #####
==============================================================================
[..] This section provide functions allowing to program and read the CE-ATA
card.
@endverbatim
* @{
*/
/**
* @brief Enables or disables the command completion signal.
* @param NewState: new state of command completion signal.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void SDIO_CommandCompletionCmd(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(__IO uint32_t *) CMD_ENCMDCOMPL_BB = (uint32_t)NewState;
}
/**
* @brief Enables or disables the CE-ATA interrupt.
* @param NewState: new state of CE-ATA interrupt. This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void SDIO_CEATAITCmd(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(__IO uint32_t *) CMD_NIEN_BB = (uint32_t)((~((uint32_t)NewState)) & ((uint32_t)0x1));
}
/**
* @brief Sends CE-ATA command (CMD61).
* @param NewState: new state of CE-ATA command. This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void SDIO_SendCEATACmd(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(__IO uint32_t *) CMD_ATACMD_BB = (uint32_t)NewState;
}
/**
* @}
*/
/** @defgroup SDIO_Group7 Interrupts and flags management functions
* @brief Interrupts and flags management functions
@verbatim
==============================================================================
##### Interrupts and flags management functions #####
==============================================================================
@endverbatim
* @{
*/
/**
* @brief Enables or disables the SDIO interrupts.
* @param SDIO_IT: specifies the SDIO interrupt sources to be enabled or disabled.
* This parameter can be one or a combination of the following values:
* @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt.
* @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt.
* @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt.
* @arg SDIO_IT_DTIMEOUT: Data timeout interrupt.
* @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt.
* @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt.
* @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt.
* @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt.
* @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt.
* @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide
* bus mode interrupt.
* @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt.
* @arg SDIO_IT_CMDACT: Command transfer in progress interrupt.
* @arg SDIO_IT_TXACT: Data transmit in progress interrupt.
* @arg SDIO_IT_RXACT: Data receive in progress interrupt.
* @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt.
* @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt.
* @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt.
* @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt.
* @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt.
* @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt.
* @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt.
* @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt.
* @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt.
* @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt.
* @param NewState: new state of the specified SDIO interrupts.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void SDIO_ITConfig(uint32_t SDIO_IT, FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_SDIO_IT(SDIO_IT));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
/* Enable the SDIO interrupts */
SDIO->MASK |= SDIO_IT;
}
else
{
/* Disable the SDIO interrupts */
SDIO->MASK &= ~SDIO_IT;
}
}
/**
* @brief Checks whether the specified SDIO flag is set or not.
* @param SDIO_FLAG: specifies the flag to check.
* This parameter can be one of the following values:
* @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed).
* @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed).
* @arg SDIO_FLAG_CTIMEOUT: Command response timeout.
* @arg SDIO_FLAG_DTIMEOUT: Data timeout.
* @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error.
* @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error.
* @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed).
* @arg SDIO_FLAG_CMDSENT: Command sent (no response required).
* @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero).
* @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide
* bus mode.
* @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed).
* @arg SDIO_FLAG_CMDACT: Command transfer in progress.
* @arg SDIO_FLAG_TXACT: Data transmit in progress.
* @arg SDIO_FLAG_RXACT: Data receive in progress.
* @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty.
* @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full.
* @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full.
* @arg SDIO_FLAG_RXFIFOF: Receive FIFO full.
* @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty.
* @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty.
* @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO.
* @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO.
* @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received.
* @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61.
* @retval The new state of SDIO_FLAG (SET or RESET).
*/
FlagStatus SDIO_GetFlagStatus(uint32_t SDIO_FLAG)
{
FlagStatus bitstatus = RESET;
/* Check the parameters */
assert_param(IS_SDIO_FLAG(SDIO_FLAG));
if ((SDIO->STA & SDIO_FLAG) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
/**
* @brief Clears the SDIO's pending flags.
* @param SDIO_FLAG: specifies the flag to clear.
* This parameter can be one or a combination of the following values:
* @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed).
* @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed).
* @arg SDIO_FLAG_CTIMEOUT: Command response timeout.
* @arg SDIO_FLAG_DTIMEOUT: Data timeout.
* @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error.
* @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error.
* @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed).
* @arg SDIO_FLAG_CMDSENT: Command sent (no response required).
* @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero).
* @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide
* bus mode.
* @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed).
* @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received.
* @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61.
* @retval None
*/
void SDIO_ClearFlag(uint32_t SDIO_FLAG)
{
/* Check the parameters */
assert_param(IS_SDIO_CLEAR_FLAG(SDIO_FLAG));
SDIO->ICR = SDIO_FLAG;
}
/**
* @brief Checks whether the specified SDIO interrupt has occurred or not.
* @param SDIO_IT: specifies the SDIO interrupt source to check.
* This parameter can be one of the following values:
* @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt.
* @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt.
* @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt.
* @arg SDIO_IT_DTIMEOUT: Data timeout interrupt.
* @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt.
* @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt.
* @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt.
* @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt.
* @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt.
* @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide
* bus mode interrupt.
* @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt.
* @arg SDIO_IT_CMDACT: Command transfer in progress interrupt.
* @arg SDIO_IT_TXACT: Data transmit in progress interrupt.
* @arg SDIO_IT_RXACT: Data receive in progress interrupt.
* @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt.
* @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt.
* @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt.
* @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt.
* @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt.
* @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt.
* @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt.
* @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt.
* @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt.
* @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt.
* @retval The new state of SDIO_IT (SET or RESET).
*/
ITStatus SDIO_GetITStatus(uint32_t SDIO_IT)
{
ITStatus bitstatus = RESET;
/* Check the parameters */
assert_param(IS_SDIO_GET_IT(SDIO_IT));
if ((SDIO->STA & SDIO_IT) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
/**
* @brief Clears the SDIO's interrupt pending bits.
* @param SDIO_IT: specifies the interrupt pending bit to clear.
* This parameter can be one or a combination of the following values:
* @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt.
* @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt.
* @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt.
* @arg SDIO_IT_DTIMEOUT: Data timeout interrupt.
* @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt.
* @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt.
* @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt.
* @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt.
* @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt.
* @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide
* bus mode interrupt.
* @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt.
* @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61.
* @retval None
*/
void SDIO_ClearITPendingBit(uint32_t SDIO_IT)
{
/* Check the parameters */
assert_param(IS_SDIO_CLEAR_IT(SDIO_IT));
SDIO->ICR = SDIO_IT;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2012 STMicroelectronics *****END OF FILE****/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -