Macros | Functions
stm32f4xx_sdio.c File Reference

This file provides firmware functions to manage the following functionalities of the Secure digital input/output interface (SDIO) peripheral: More...

#include "stm32f4xx_sdio.h"
#include "stm32f4xx_rcc.h"
Include dependency graph for stm32f4xx_sdio.c:

Go to the source code of this file.

Macros

#define ATACMD_BitNumber   0x0E
 
#define CLKCR_CLEAR_MASK   ((uint32_t)0xFFFF8100)
 
#define CLKCR_CLKEN_BB   (PERIPH_BB_BASE + (CLKCR_OFFSET * 32) + (CLKEN_BitNumber * 4))
 
#define CLKCR_OFFSET   (SDIO_OFFSET + 0x04)
 
#define CLKEN_BitNumber   0x08
 
#define CMD_ATACMD_BB   (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ATACMD_BitNumber * 4))
 
#define CMD_CLEAR_MASK   ((uint32_t)0xFFFFF800)
 
#define CMD_ENCMDCOMPL_BB   (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ENCMDCOMPL_BitNumber * 4))
 
#define CMD_NIEN_BB   (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (NIEN_BitNumber * 4))
 
#define CMD_OFFSET   (SDIO_OFFSET + 0x0C)
 
#define CMD_SDIOSUSPEND_BB   (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (SDIOSUSPEND_BitNumber * 4))
 
#define DCTRL_CLEAR_MASK   ((uint32_t)0xFFFFFF08)
 
#define DCTRL_DMAEN_BB   (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (DMAEN_BitNumber * 4))
 
#define DCTRL_OFFSET   (SDIO_OFFSET + 0x2C)
 
#define DCTRL_RWMOD_BB   (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWMOD_BitNumber * 4))
 
#define DCTRL_RWSTART_BB   (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTART_BitNumber * 4))
 
#define DCTRL_RWSTOP_BB   (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTOP_BitNumber * 4))
 
#define DCTRL_SDIOEN_BB   (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (SDIOEN_BitNumber * 4))
 
#define DMAEN_BitNumber   0x03
 
#define ENCMDCOMPL_BitNumber   0x0C
 
#define NIEN_BitNumber   0x0D
 
#define PWR_PWRCTRL_MASK   ((uint32_t)0xFFFFFFFC)
 
#define RWMOD_BitNumber   0x0A
 
#define RWSTART_BitNumber   0x08
 
#define RWSTOP_BitNumber   0x09
 
#define SDIO_OFFSET   (SDIO_BASE - PERIPH_BASE)
 
#define SDIO_RESP_ADDR   ((uint32_t)(SDIO_BASE + 0x14))
 
#define SDIOEN_BitNumber   0x0B
 
#define SDIOSUSPEND_BitNumber   0x0B
 

Functions

void SDIO_CEATAITCmd (FunctionalState NewState)
 Enables or disables the CE-ATA interrupt. More...
 
void SDIO_ClearFlag (uint32_t SDIO_FLAG)
 Clears the SDIO's pending flags. More...
 
void SDIO_ClearITPendingBit (uint32_t SDIO_IT)
 Clears the SDIO's interrupt pending bits. More...
 
void SDIO_ClockCmd (FunctionalState NewState)
 Enables or disables the SDIO Clock. More...
 
void SDIO_CmdStructInit (SDIO_CmdInitTypeDef *SDIO_CmdInitStruct)
 Fills each SDIO_CmdInitStruct member with its default value. More...
 
void SDIO_CommandCompletionCmd (FunctionalState NewState)
 Enables or disables the command completion signal. More...
 
void SDIO_DataConfig (SDIO_DataInitTypeDef *SDIO_DataInitStruct)
 Initializes the SDIO data path according to the specified parameters in the SDIO_DataInitStruct. More...
 
void SDIO_DataStructInit (SDIO_DataInitTypeDef *SDIO_DataInitStruct)
 Fills each SDIO_DataInitStruct member with its default value. More...
 
void SDIO_DeInit (void)
 Deinitializes the SDIO peripheral registers to their default reset values. More...
 
void SDIO_DMACmd (FunctionalState NewState)
 Enables or disables the SDIO DMA request. More...
 
uint8_t SDIO_GetCommandResponse (void)
 Returns command index of last command for which response received. More...
 
uint32_t SDIO_GetDataCounter (void)
 Returns number of remaining data bytes to be transferred. More...
 
uint32_t SDIO_GetFIFOCount (void)
 Returns the number of words left to be written to or read from FIFO. More...
 
FlagStatus SDIO_GetFlagStatus (uint32_t SDIO_FLAG)
 Checks whether the specified SDIO flag is set or not. More...
 
ITStatus SDIO_GetITStatus (uint32_t SDIO_IT)
 Checks whether the specified SDIO interrupt has occurred or not. More...
 
uint32_t SDIO_GetPowerState (void)
 Gets the power status of the controller. More...
 
uint32_t SDIO_GetResponse (uint32_t SDIO_RESP)
 Returns response received from the card for the last command. More...
 
void SDIO_Init (SDIO_InitTypeDef *SDIO_InitStruct)
 Initializes the SDIO peripheral according to the specified parameters in the SDIO_InitStruct. More...
 
void SDIO_ITConfig (uint32_t SDIO_IT, FunctionalState NewState)
 Enables or disables the SDIO interrupts. More...
 
uint32_t SDIO_ReadData (void)
 Read one data word from Rx FIFO. More...
 
void SDIO_SendCEATACmd (FunctionalState NewState)
 Sends CE-ATA command (CMD61). More...
 
void SDIO_SendCommand (SDIO_CmdInitTypeDef *SDIO_CmdInitStruct)
 Initializes the SDIO Command according to the specified parameters in the SDIO_CmdInitStruct and send the command. More...
 
void SDIO_SendSDIOSuspendCmd (FunctionalState NewState)
 Enables or disables the SD I/O Mode suspend command sending. More...
 
void SDIO_SetPowerState (uint32_t SDIO_PowerState)
 Sets the power status of the controller. More...
 
void SDIO_SetSDIOOperation (FunctionalState NewState)
 Enables or disables the SD I/O Mode Operation. More...
 
void SDIO_SetSDIOReadWaitMode (uint32_t SDIO_ReadWaitMode)
 Sets one of the two options of inserting read wait interval. More...
 
void SDIO_StartSDIOReadWait (FunctionalState NewState)
 Starts the SD I/O Read Wait operation. More...
 
void SDIO_StopSDIOReadWait (FunctionalState NewState)
 Stops the SD I/O Read Wait operation. More...
 
void SDIO_StructInit (SDIO_InitTypeDef *SDIO_InitStruct)
 Fills each SDIO_InitStruct member with its default value. More...
 
void SDIO_WriteData (uint32_t Data)
 Write one data word to Tx FIFO. More...
 

Detailed Description

This file provides firmware functions to manage the following functionalities of the Secure digital input/output interface (SDIO) peripheral:

Author
MCD Application Team
Version
V1.1.0
Date
11-January-2013
  • Initialization and Configuration
  • Command path state machine (CPSM) management
  • Data path state machine (DPSM) management
  • SDIO IO Cards mode management
  • CE-ATA mode management
  • DMA transfers management
  • Interrupts and flags management
 ===================================================================
                 ##### How to use this driver #####
 ===================================================================
 [..]
   (#) The SDIO clock (SDIOCLK = 48 MHz) is coming from a specific output of PLL 
       (PLL48CLK). Before to start working with SDIO peripheral make sure that the
       PLL is well configured.
       The SDIO peripheral uses two clock signals:
       (++) SDIO adapter clock (SDIOCLK = 48 MHz)
       (++) APB2 bus clock (PCLK2)
       
       -@@- PCLK2 and SDIO_CK clock frequencies must respect the following condition:
           Frequency(PCLK2) >= (3 / 8 x Frequency(SDIO_CK))
  
   (#) Enable peripheral clock using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SDIO, ENABLE).
  
   (#) According to the SDIO mode, enable the GPIO clocks using 
       RCC_AHB1PeriphClockCmd() function. 
       The I/O can be one of the following configurations:
       (++) 1-bit data length: SDIO_CMD, SDIO_CK and D0.
       (++) 4-bit data length: SDIO_CMD, SDIO_CK and D[3:0].
       (++) 8-bit data length: SDIO_CMD, SDIO_CK and D[7:0].      
  
   (#) Peripheral alternate function: 
       (++) Connect the pin to the desired peripherals' Alternate Function (AF) 
           using GPIO_PinAFConfig() function
       (++) Configure the desired pin in alternate function by: 
           GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
       (++) Select the type, pull-up/pull-down and output speed via GPIO_PuPd, 
           GPIO_OType and GPIO_Speed members
       (++) Call GPIO_Init() function
  
   (#) Program the Clock Edge, Clock Bypass, Clock Power Save, Bus Wide, 
       hardware, flow control and the Clock Divider using the SDIO_Init()
       function.
  
   (#) Enable the Power ON State using the SDIO_SetPowerState(SDIO_PowerState_ON) 
       function.
                
   (#) Enable the clock using the SDIO_ClockCmd() function.
  
   (#) Enable the NVIC and the corresponding interrupt using the function 
       SDIO_ITConfig() if you need to use interrupt mode. 
  
   (#) When using the DMA mode 
       (++) Configure the DMA using DMA_Init() function
       (++) Active the needed channel Request using SDIO_DMACmd() function
  
   (#) Enable the DMA using the DMA_Cmd() function, when using DMA mode. 
  
   (#) To control the CPSM (Command Path State Machine) and send 
       commands to the card use the SDIO_SendCommand(), 
       SDIO_GetCommandResponse() and SDIO_GetResponse() functions. First, user has
       to fill the command structure (pointer to SDIO_CmdInitTypeDef) according 
       to the selected command to be sent.
       The parameters that should be filled are:
       (++) Command Argument
       (++) Command Index
       (++) Command Response type
       (++) Command Wait
       (++) CPSM Status (Enable or Disable).
  
       -@@- To check if the command is well received, read the SDIO_CMDRESP
           register using the SDIO_GetCommandResponse().
           The SDIO responses registers (SDIO_RESP1 to SDIO_RESP2), use the
           SDIO_GetResponse() function.
  
   (#) To control the DPSM (Data Path State Machine) and send/receive 
       data to/from the card use the SDIO_DataConfig(), SDIO_GetDataCounter(), 
       SDIO_ReadData(), SDIO_WriteData() and SDIO_GetFIFOCount() functions.
  
 *** Read Operations ***
 =======================
 [..]
   (#) First, user has to fill the data structure (pointer to
       SDIO_DataInitTypeDef) according to the selected data type to be received.
       The parameters that should be filled are:
       (++) Data TimeOut
       (++) Data Length
       (++) Data Block size
       (++) Data Transfer direction: should be from card (To SDIO)
       (++) Data Transfer mode
       (++) DPSM Status (Enable or Disable)
                                     
   (#) Configure the SDIO resources to receive the data from the card
       according to selected transfer mode (Refer to Step 8, 9 and 10).
  
   (#)  Send the selected Read command (refer to step 11).
                    
   (#) Use the SDIO flags/interrupts to check the transfer status.
  
 *** Write Operations ***
 ========================
 [..]
   (#) First, user has to fill the data structure (pointer to
       SDIO_DataInitTypeDef) according to the selected data type to be received.
       The parameters that should be filled are:
       (++) Data TimeOut
       (++) Data Length
       (++) Data Block size
       (++) Data Transfer direction:  should be to card (To CARD)
       (++) Data Transfer mode
       (++) DPSM Status (Enable or Disable)
  
   (#) Configure the SDIO resources to send the data to the card according to 
       selected transfer mode (Refer to Step 8, 9 and 10).
                     
   (#) Send the selected Write command (refer to step 11).
                    
   (#) Use the SDIO flags/interrupts to check the transfer status.
@attention

<h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>

Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at:

       http://www.st.com/software_license_agreement_liberty_v2

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Definition in file stm32f4xx_sdio.c.



rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Oct 24 2019 03:17:21