157 #include "stm32f4xx_rcc.h" 172 #define SDIO_OFFSET (SDIO_BASE - PERIPH_BASE) 176 #define CLKCR_OFFSET (SDIO_OFFSET + 0x04) 177 #define CLKEN_BitNumber 0x08 178 #define CLKCR_CLKEN_BB (PERIPH_BB_BASE + (CLKCR_OFFSET * 32) + (CLKEN_BitNumber * 4)) 182 #define CMD_OFFSET (SDIO_OFFSET + 0x0C) 183 #define SDIOSUSPEND_BitNumber 0x0B 184 #define CMD_SDIOSUSPEND_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (SDIOSUSPEND_BitNumber * 4)) 187 #define ENCMDCOMPL_BitNumber 0x0C 188 #define CMD_ENCMDCOMPL_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ENCMDCOMPL_BitNumber * 4)) 191 #define NIEN_BitNumber 0x0D 192 #define CMD_NIEN_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (NIEN_BitNumber * 4)) 195 #define ATACMD_BitNumber 0x0E 196 #define CMD_ATACMD_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ATACMD_BitNumber * 4)) 200 #define DCTRL_OFFSET (SDIO_OFFSET + 0x2C) 201 #define DMAEN_BitNumber 0x03 202 #define DCTRL_DMAEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (DMAEN_BitNumber * 4)) 205 #define RWSTART_BitNumber 0x08 206 #define DCTRL_RWSTART_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTART_BitNumber * 4)) 209 #define RWSTOP_BitNumber 0x09 210 #define DCTRL_RWSTOP_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTOP_BitNumber * 4)) 213 #define RWMOD_BitNumber 0x0A 214 #define DCTRL_RWMOD_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWMOD_BitNumber * 4)) 217 #define SDIOEN_BitNumber 0x0B 218 #define DCTRL_SDIOEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (SDIOEN_BitNumber * 4)) 223 #define CLKCR_CLEAR_MASK ((uint32_t)0xFFFF8100) 227 #define PWR_PWRCTRL_MASK ((uint32_t)0xFFFFFFFC) 231 #define DCTRL_CLEAR_MASK ((uint32_t)0xFFFFFF08) 235 #define CMD_CLEAR_MASK ((uint32_t)0xFFFFF800) 238 #define SDIO_RESP_ADDR ((uint32_t)(SDIO_BASE + 0x14)) 292 tmpreg =
SDIO->CLKCR;
308 SDIO->CLKCR = tmpreg;
355 SDIO->POWER = SDIO_PowerState;
452 return (uint8_t)(
SDIO->RESPCMD);
467 __IO uint32_t tmp = 0;
474 return (*(
__IO uint32_t *) tmp);
524 tmpreg =
SDIO->DCTRL;
535 SDIO->DCTRL = tmpreg;
592 return SDIO->FIFOCNT;
728 *(
__IO uint32_t *)
CMD_NIEN_BB = (uint32_t)((~((uint32_t)NewState)) & ((uint32_t)0x1));
836 SDIO->MASK |= SDIO_IT;
841 SDIO->MASK &= ~SDIO_IT;
882 if ((
SDIO->STA & SDIO_FLAG) != (uint32_t)
RESET)
917 SDIO->ICR = SDIO_FLAG;
957 if ((
SDIO->STA & SDIO_IT) != (uint32_t)
RESET)
#define IS_SDIO_TRANSFER_MODE(MODE)
FlagStatus SDIO_GetFlagStatus(uint32_t SDIO_FLAG)
Checks whether the specified SDIO flag is set or not.
uint32_t SDIO_TransferMode
void SDIO_WriteData(uint32_t Data)
Write one data word to Tx FIFO.
void SDIO_StopSDIOReadWait(FunctionalState NewState)
Stops the SD I/O Read Wait operation.
void SDIO_CommandCompletionCmd(FunctionalState NewState)
Enables or disables the command completion signal.
#define IS_SDIO_CLEAR_FLAG(FLAG)
#define IS_SDIO_GET_IT(IT)
#define IS_SDIO_CLOCK_EDGE(EDGE)
uint32_t SDIO_GetPowerState(void)
Gets the power status of the controller.
uint32_t SDIO_DataBlockSize
uint32_t SDIO_ClockPowerSave
#define SDIO_DPSM_Disable
#define IS_SDIO_DATA_LENGTH(LENGTH)
#define RCC_APB2Periph_SDIO
#define IS_SDIO_RESP(RESP)
void assert_param(int val)
#define IS_SDIO_HARDWARE_FLOW_CONTROL(CONTROL)
void SDIO_StructInit(SDIO_InitTypeDef *SDIO_InitStruct)
Fills each SDIO_InitStruct member with its default value.
#define SDIO_DataBlockSize_1b
void SDIO_ClearFlag(uint32_t SDIO_FLAG)
Clears the SDIO's pending flags.
#define IS_SDIO_READWAIT_MODE(MODE)
#define SDIO_TransferDir_ToCard
#define IS_FUNCTIONAL_STATE(STATE)
#define IS_SDIO_TRANSFER_DIR(DIR)
#define IS_SDIO_CLEAR_IT(IT)
uint32_t SDIO_DataTimeOut
void SDIO_ClearITPendingBit(uint32_t SDIO_IT)
Clears the SDIO's interrupt pending bits.
uint8_t SDIO_GetCommandResponse(void)
Returns command index of last command for which response received.
#define IS_SDIO_CMD_INDEX(INDEX)
void SDIO_ITConfig(uint32_t SDIO_IT, FunctionalState NewState)
Enables or disables the SDIO interrupts.
void SDIO_StartSDIOReadWait(FunctionalState NewState)
Starts the SD I/O Read Wait operation.
void SDIO_SetSDIOReadWaitMode(uint32_t SDIO_ReadWaitMode)
Sets one of the two options of inserting read wait interval.
void SDIO_CEATAITCmd(FunctionalState NewState)
Enables or disables the CE-ATA interrupt.
#define IS_SDIO_CPSM(CPSM)
#define CMD_SDIOSUSPEND_BB
#define IS_SDIO_BLOCK_SIZE(SIZE)
void SDIO_SetSDIOOperation(FunctionalState NewState)
Enables or disables the SD I/O Mode Operation.
uint32_t SDIO_GetFIFOCount(void)
Returns the number of words left to be written to or read from FIFO.
#define IS_SDIO_CLOCK_POWER_SAVE(SAVE)
void SDIO_DataStructInit(SDIO_DataInitTypeDef *SDIO_DataInitStruct)
Fills each SDIO_DataInitStruct member with its default value.
#define SDIO_ClockEdge_Rising
void SDIO_SetPowerState(uint32_t SDIO_PowerState)
Sets the power status of the controller.
uint32_t SDIO_GetResponse(uint32_t SDIO_RESP)
Returns response received from the card for the last command.
uint32_t SDIO_ReadData(void)
Read one data word from Rx FIFO.
void SDIO_DataConfig(SDIO_DataInitTypeDef *SDIO_DataInitStruct)
Initializes the SDIO data path according to the specified parameters in the SDIO_DataInitStruct.
void SDIO_ClockCmd(FunctionalState NewState)
Enables or disables the SDIO Clock.
#define IS_SDIO_FLAG(FLAG)
#define IS_SDIO_BUS_WIDE(WIDE)
This file contains all the functions prototypes for the SDIO firmware library.
#define SDIO_ClockPowerSave_Disable
uint32_t SDIO_ClockBypass
void SDIO_Init(SDIO_InitTypeDef *SDIO_InitStruct)
Initializes the SDIO peripheral according to the specified parameters in the SDIO_InitStruct.
void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
Forces or releases High Speed APB (APB2) peripheral reset.
#define IS_SDIO_POWER_STATE(STATE)
void SDIO_DeInit(void)
Deinitializes the SDIO peripheral registers to their default reset values.
#define SDIO_CPSM_Disable
uint32_t SDIO_HardwareFlowControl
void SDIO_SendCEATACmd(FunctionalState NewState)
Sends CE-ATA command (CMD61).
#define SDIO_ClockBypass_Disable
#define IS_SDIO_RESPONSE(RESPONSE)
uint32_t SDIO_TransferDir
ITStatus SDIO_GetITStatus(uint32_t SDIO_IT)
Checks whether the specified SDIO interrupt has occurred or not.
#define SDIO_TransferMode_Block
#define IS_SDIO_CLOCK_BYPASS(BYPASS)
#define IS_SDIO_DPSM(DPSM)
void SDIO_SendSDIOSuspendCmd(FunctionalState NewState)
Enables or disables the SD I/O Mode suspend command sending.
uint32_t SDIO_GetDataCounter(void)
Returns number of remaining data bytes to be transferred.
#define SDIO_HardwareFlowControl_Disable
void SDIO_SendCommand(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct)
Initializes the SDIO Command according to the specified parameters in the SDIO_CmdInitStruct and send...
#define CMD_ENCMDCOMPL_BB
#define IS_SDIO_WAIT(WAIT)
void SDIO_DMACmd(FunctionalState NewState)
Enables or disables the SDIO DMA request.
void SDIO_CmdStructInit(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct)
Fills each SDIO_CmdInitStruct member with its default value.