The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
bogdanm
Date:
Mon Dec 09 18:43:03 2013 +0200
Revision:
73:1efda918f0ba
Child:
76:824293ae5e43
Release 73 of the mbed library

Main changes:

- added support for KL46Z and NUCLEO_F103RB
- STM32 USB device support
- various bug fixes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 73:1efda918f0ba 1 /**
bogdanm 73:1efda918f0ba 2 ******************************************************************************
bogdanm 73:1efda918f0ba 3 * @file stm32f10x_sdio.h
bogdanm 73:1efda918f0ba 4 * @author MCD Application Team
bogdanm 73:1efda918f0ba 5 * @version V3.5.0
bogdanm 73:1efda918f0ba 6 * @date 11-March-2011
bogdanm 73:1efda918f0ba 7 * @brief This file contains all the functions prototypes for the SDIO firmware
bogdanm 73:1efda918f0ba 8 * library.
bogdanm 73:1efda918f0ba 9 ******************************************************************************
bogdanm 73:1efda918f0ba 10 * @attention
bogdanm 73:1efda918f0ba 11 *
bogdanm 73:1efda918f0ba 12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
bogdanm 73:1efda918f0ba 13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
bogdanm 73:1efda918f0ba 14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
bogdanm 73:1efda918f0ba 15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
bogdanm 73:1efda918f0ba 16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
bogdanm 73:1efda918f0ba 17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
bogdanm 73:1efda918f0ba 18 *
bogdanm 73:1efda918f0ba 19 * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
bogdanm 73:1efda918f0ba 20 ******************************************************************************
bogdanm 73:1efda918f0ba 21 */
bogdanm 73:1efda918f0ba 22
bogdanm 73:1efda918f0ba 23 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 73:1efda918f0ba 24 #ifndef __STM32F10x_SDIO_H
bogdanm 73:1efda918f0ba 25 #define __STM32F10x_SDIO_H
bogdanm 73:1efda918f0ba 26
bogdanm 73:1efda918f0ba 27 #ifdef __cplusplus
bogdanm 73:1efda918f0ba 28 extern "C" {
bogdanm 73:1efda918f0ba 29 #endif
bogdanm 73:1efda918f0ba 30
bogdanm 73:1efda918f0ba 31 /* Includes ------------------------------------------------------------------*/
bogdanm 73:1efda918f0ba 32 #include "stm32f10x.h"
bogdanm 73:1efda918f0ba 33
bogdanm 73:1efda918f0ba 34 /** @addtogroup STM32F10x_StdPeriph_Driver
bogdanm 73:1efda918f0ba 35 * @{
bogdanm 73:1efda918f0ba 36 */
bogdanm 73:1efda918f0ba 37
bogdanm 73:1efda918f0ba 38 /** @addtogroup SDIO
bogdanm 73:1efda918f0ba 39 * @{
bogdanm 73:1efda918f0ba 40 */
bogdanm 73:1efda918f0ba 41
bogdanm 73:1efda918f0ba 42 /** @defgroup SDIO_Exported_Types
bogdanm 73:1efda918f0ba 43 * @{
bogdanm 73:1efda918f0ba 44 */
bogdanm 73:1efda918f0ba 45
bogdanm 73:1efda918f0ba 46 typedef struct
bogdanm 73:1efda918f0ba 47 {
bogdanm 73:1efda918f0ba 48 uint32_t SDIO_ClockEdge; /*!< Specifies the clock transition on which the bit capture is made.
bogdanm 73:1efda918f0ba 49 This parameter can be a value of @ref SDIO_Clock_Edge */
bogdanm 73:1efda918f0ba 50
bogdanm 73:1efda918f0ba 51 uint32_t SDIO_ClockBypass; /*!< Specifies whether the SDIO Clock divider bypass is
bogdanm 73:1efda918f0ba 52 enabled or disabled.
bogdanm 73:1efda918f0ba 53 This parameter can be a value of @ref SDIO_Clock_Bypass */
bogdanm 73:1efda918f0ba 54
bogdanm 73:1efda918f0ba 55 uint32_t SDIO_ClockPowerSave; /*!< Specifies whether SDIO Clock output is enabled or
bogdanm 73:1efda918f0ba 56 disabled when the bus is idle.
bogdanm 73:1efda918f0ba 57 This parameter can be a value of @ref SDIO_Clock_Power_Save */
bogdanm 73:1efda918f0ba 58
bogdanm 73:1efda918f0ba 59 uint32_t SDIO_BusWide; /*!< Specifies the SDIO bus width.
bogdanm 73:1efda918f0ba 60 This parameter can be a value of @ref SDIO_Bus_Wide */
bogdanm 73:1efda918f0ba 61
bogdanm 73:1efda918f0ba 62 uint32_t SDIO_HardwareFlowControl; /*!< Specifies whether the SDIO hardware flow control is enabled or disabled.
bogdanm 73:1efda918f0ba 63 This parameter can be a value of @ref SDIO_Hardware_Flow_Control */
bogdanm 73:1efda918f0ba 64
bogdanm 73:1efda918f0ba 65 uint8_t SDIO_ClockDiv; /*!< Specifies the clock frequency of the SDIO controller.
bogdanm 73:1efda918f0ba 66 This parameter can be a value between 0x00 and 0xFF. */
bogdanm 73:1efda918f0ba 67
bogdanm 73:1efda918f0ba 68 } SDIO_InitTypeDef;
bogdanm 73:1efda918f0ba 69
bogdanm 73:1efda918f0ba 70 typedef struct
bogdanm 73:1efda918f0ba 71 {
bogdanm 73:1efda918f0ba 72 uint32_t SDIO_Argument; /*!< Specifies the SDIO command argument which is sent
bogdanm 73:1efda918f0ba 73 to a card as part of a command message. If a command
bogdanm 73:1efda918f0ba 74 contains an argument, it must be loaded into this register
bogdanm 73:1efda918f0ba 75 before writing the command to the command register */
bogdanm 73:1efda918f0ba 76
bogdanm 73:1efda918f0ba 77 uint32_t SDIO_CmdIndex; /*!< Specifies the SDIO command index. It must be lower than 0x40. */
bogdanm 73:1efda918f0ba 78
bogdanm 73:1efda918f0ba 79 uint32_t SDIO_Response; /*!< Specifies the SDIO response type.
bogdanm 73:1efda918f0ba 80 This parameter can be a value of @ref SDIO_Response_Type */
bogdanm 73:1efda918f0ba 81
bogdanm 73:1efda918f0ba 82 uint32_t SDIO_Wait; /*!< Specifies whether SDIO wait-for-interrupt request is enabled or disabled.
bogdanm 73:1efda918f0ba 83 This parameter can be a value of @ref SDIO_Wait_Interrupt_State */
bogdanm 73:1efda918f0ba 84
bogdanm 73:1efda918f0ba 85 uint32_t SDIO_CPSM; /*!< Specifies whether SDIO Command path state machine (CPSM)
bogdanm 73:1efda918f0ba 86 is enabled or disabled.
bogdanm 73:1efda918f0ba 87 This parameter can be a value of @ref SDIO_CPSM_State */
bogdanm 73:1efda918f0ba 88 } SDIO_CmdInitTypeDef;
bogdanm 73:1efda918f0ba 89
bogdanm 73:1efda918f0ba 90 typedef struct
bogdanm 73:1efda918f0ba 91 {
bogdanm 73:1efda918f0ba 92 uint32_t SDIO_DataTimeOut; /*!< Specifies the data timeout period in card bus clock periods. */
bogdanm 73:1efda918f0ba 93
bogdanm 73:1efda918f0ba 94 uint32_t SDIO_DataLength; /*!< Specifies the number of data bytes to be transferred. */
bogdanm 73:1efda918f0ba 95
bogdanm 73:1efda918f0ba 96 uint32_t SDIO_DataBlockSize; /*!< Specifies the data block size for block transfer.
bogdanm 73:1efda918f0ba 97 This parameter can be a value of @ref SDIO_Data_Block_Size */
bogdanm 73:1efda918f0ba 98
bogdanm 73:1efda918f0ba 99 uint32_t SDIO_TransferDir; /*!< Specifies the data transfer direction, whether the transfer
bogdanm 73:1efda918f0ba 100 is a read or write.
bogdanm 73:1efda918f0ba 101 This parameter can be a value of @ref SDIO_Transfer_Direction */
bogdanm 73:1efda918f0ba 102
bogdanm 73:1efda918f0ba 103 uint32_t SDIO_TransferMode; /*!< Specifies whether data transfer is in stream or block mode.
bogdanm 73:1efda918f0ba 104 This parameter can be a value of @ref SDIO_Transfer_Type */
bogdanm 73:1efda918f0ba 105
bogdanm 73:1efda918f0ba 106 uint32_t SDIO_DPSM; /*!< Specifies whether SDIO Data path state machine (DPSM)
bogdanm 73:1efda918f0ba 107 is enabled or disabled.
bogdanm 73:1efda918f0ba 108 This parameter can be a value of @ref SDIO_DPSM_State */
bogdanm 73:1efda918f0ba 109 } SDIO_DataInitTypeDef;
bogdanm 73:1efda918f0ba 110
bogdanm 73:1efda918f0ba 111 /**
bogdanm 73:1efda918f0ba 112 * @}
bogdanm 73:1efda918f0ba 113 */
bogdanm 73:1efda918f0ba 114
bogdanm 73:1efda918f0ba 115 /** @defgroup SDIO_Exported_Constants
bogdanm 73:1efda918f0ba 116 * @{
bogdanm 73:1efda918f0ba 117 */
bogdanm 73:1efda918f0ba 118
bogdanm 73:1efda918f0ba 119 /** @defgroup SDIO_Clock_Edge
bogdanm 73:1efda918f0ba 120 * @{
bogdanm 73:1efda918f0ba 121 */
bogdanm 73:1efda918f0ba 122
bogdanm 73:1efda918f0ba 123 #define SDIO_ClockEdge_Rising ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 124 #define SDIO_ClockEdge_Falling ((uint32_t)0x00002000)
bogdanm 73:1efda918f0ba 125 #define IS_SDIO_CLOCK_EDGE(EDGE) (((EDGE) == SDIO_ClockEdge_Rising) || \
bogdanm 73:1efda918f0ba 126 ((EDGE) == SDIO_ClockEdge_Falling))
bogdanm 73:1efda918f0ba 127 /**
bogdanm 73:1efda918f0ba 128 * @}
bogdanm 73:1efda918f0ba 129 */
bogdanm 73:1efda918f0ba 130
bogdanm 73:1efda918f0ba 131 /** @defgroup SDIO_Clock_Bypass
bogdanm 73:1efda918f0ba 132 * @{
bogdanm 73:1efda918f0ba 133 */
bogdanm 73:1efda918f0ba 134
bogdanm 73:1efda918f0ba 135 #define SDIO_ClockBypass_Disable ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 136 #define SDIO_ClockBypass_Enable ((uint32_t)0x00000400)
bogdanm 73:1efda918f0ba 137 #define IS_SDIO_CLOCK_BYPASS(BYPASS) (((BYPASS) == SDIO_ClockBypass_Disable) || \
bogdanm 73:1efda918f0ba 138 ((BYPASS) == SDIO_ClockBypass_Enable))
bogdanm 73:1efda918f0ba 139 /**
bogdanm 73:1efda918f0ba 140 * @}
bogdanm 73:1efda918f0ba 141 */
bogdanm 73:1efda918f0ba 142
bogdanm 73:1efda918f0ba 143 /** @defgroup SDIO_Clock_Power_Save
bogdanm 73:1efda918f0ba 144 * @{
bogdanm 73:1efda918f0ba 145 */
bogdanm 73:1efda918f0ba 146
bogdanm 73:1efda918f0ba 147 #define SDIO_ClockPowerSave_Disable ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 148 #define SDIO_ClockPowerSave_Enable ((uint32_t)0x00000200)
bogdanm 73:1efda918f0ba 149 #define IS_SDIO_CLOCK_POWER_SAVE(SAVE) (((SAVE) == SDIO_ClockPowerSave_Disable) || \
bogdanm 73:1efda918f0ba 150 ((SAVE) == SDIO_ClockPowerSave_Enable))
bogdanm 73:1efda918f0ba 151 /**
bogdanm 73:1efda918f0ba 152 * @}
bogdanm 73:1efda918f0ba 153 */
bogdanm 73:1efda918f0ba 154
bogdanm 73:1efda918f0ba 155 /** @defgroup SDIO_Bus_Wide
bogdanm 73:1efda918f0ba 156 * @{
bogdanm 73:1efda918f0ba 157 */
bogdanm 73:1efda918f0ba 158
bogdanm 73:1efda918f0ba 159 #define SDIO_BusWide_1b ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 160 #define SDIO_BusWide_4b ((uint32_t)0x00000800)
bogdanm 73:1efda918f0ba 161 #define SDIO_BusWide_8b ((uint32_t)0x00001000)
bogdanm 73:1efda918f0ba 162 #define IS_SDIO_BUS_WIDE(WIDE) (((WIDE) == SDIO_BusWide_1b) || ((WIDE) == SDIO_BusWide_4b) || \
bogdanm 73:1efda918f0ba 163 ((WIDE) == SDIO_BusWide_8b))
bogdanm 73:1efda918f0ba 164
bogdanm 73:1efda918f0ba 165 /**
bogdanm 73:1efda918f0ba 166 * @}
bogdanm 73:1efda918f0ba 167 */
bogdanm 73:1efda918f0ba 168
bogdanm 73:1efda918f0ba 169 /** @defgroup SDIO_Hardware_Flow_Control
bogdanm 73:1efda918f0ba 170 * @{
bogdanm 73:1efda918f0ba 171 */
bogdanm 73:1efda918f0ba 172
bogdanm 73:1efda918f0ba 173 #define SDIO_HardwareFlowControl_Disable ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 174 #define SDIO_HardwareFlowControl_Enable ((uint32_t)0x00004000)
bogdanm 73:1efda918f0ba 175 #define IS_SDIO_HARDWARE_FLOW_CONTROL(CONTROL) (((CONTROL) == SDIO_HardwareFlowControl_Disable) || \
bogdanm 73:1efda918f0ba 176 ((CONTROL) == SDIO_HardwareFlowControl_Enable))
bogdanm 73:1efda918f0ba 177 /**
bogdanm 73:1efda918f0ba 178 * @}
bogdanm 73:1efda918f0ba 179 */
bogdanm 73:1efda918f0ba 180
bogdanm 73:1efda918f0ba 181 /** @defgroup SDIO_Power_State
bogdanm 73:1efda918f0ba 182 * @{
bogdanm 73:1efda918f0ba 183 */
bogdanm 73:1efda918f0ba 184
bogdanm 73:1efda918f0ba 185 #define SDIO_PowerState_OFF ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 186 #define SDIO_PowerState_ON ((uint32_t)0x00000003)
bogdanm 73:1efda918f0ba 187 #define IS_SDIO_POWER_STATE(STATE) (((STATE) == SDIO_PowerState_OFF) || ((STATE) == SDIO_PowerState_ON))
bogdanm 73:1efda918f0ba 188 /**
bogdanm 73:1efda918f0ba 189 * @}
bogdanm 73:1efda918f0ba 190 */
bogdanm 73:1efda918f0ba 191
bogdanm 73:1efda918f0ba 192
bogdanm 73:1efda918f0ba 193 /** @defgroup SDIO_Interrupt_sources
bogdanm 73:1efda918f0ba 194 * @{
bogdanm 73:1efda918f0ba 195 */
bogdanm 73:1efda918f0ba 196
bogdanm 73:1efda918f0ba 197 #define SDIO_IT_CCRCFAIL ((uint32_t)0x00000001)
bogdanm 73:1efda918f0ba 198 #define SDIO_IT_DCRCFAIL ((uint32_t)0x00000002)
bogdanm 73:1efda918f0ba 199 #define SDIO_IT_CTIMEOUT ((uint32_t)0x00000004)
bogdanm 73:1efda918f0ba 200 #define SDIO_IT_DTIMEOUT ((uint32_t)0x00000008)
bogdanm 73:1efda918f0ba 201 #define SDIO_IT_TXUNDERR ((uint32_t)0x00000010)
bogdanm 73:1efda918f0ba 202 #define SDIO_IT_RXOVERR ((uint32_t)0x00000020)
bogdanm 73:1efda918f0ba 203 #define SDIO_IT_CMDREND ((uint32_t)0x00000040)
bogdanm 73:1efda918f0ba 204 #define SDIO_IT_CMDSENT ((uint32_t)0x00000080)
bogdanm 73:1efda918f0ba 205 #define SDIO_IT_DATAEND ((uint32_t)0x00000100)
bogdanm 73:1efda918f0ba 206 #define SDIO_IT_STBITERR ((uint32_t)0x00000200)
bogdanm 73:1efda918f0ba 207 #define SDIO_IT_DBCKEND ((uint32_t)0x00000400)
bogdanm 73:1efda918f0ba 208 #define SDIO_IT_CMDACT ((uint32_t)0x00000800)
bogdanm 73:1efda918f0ba 209 #define SDIO_IT_TXACT ((uint32_t)0x00001000)
bogdanm 73:1efda918f0ba 210 #define SDIO_IT_RXACT ((uint32_t)0x00002000)
bogdanm 73:1efda918f0ba 211 #define SDIO_IT_TXFIFOHE ((uint32_t)0x00004000)
bogdanm 73:1efda918f0ba 212 #define SDIO_IT_RXFIFOHF ((uint32_t)0x00008000)
bogdanm 73:1efda918f0ba 213 #define SDIO_IT_TXFIFOF ((uint32_t)0x00010000)
bogdanm 73:1efda918f0ba 214 #define SDIO_IT_RXFIFOF ((uint32_t)0x00020000)
bogdanm 73:1efda918f0ba 215 #define SDIO_IT_TXFIFOE ((uint32_t)0x00040000)
bogdanm 73:1efda918f0ba 216 #define SDIO_IT_RXFIFOE ((uint32_t)0x00080000)
bogdanm 73:1efda918f0ba 217 #define SDIO_IT_TXDAVL ((uint32_t)0x00100000)
bogdanm 73:1efda918f0ba 218 #define SDIO_IT_RXDAVL ((uint32_t)0x00200000)
bogdanm 73:1efda918f0ba 219 #define SDIO_IT_SDIOIT ((uint32_t)0x00400000)
bogdanm 73:1efda918f0ba 220 #define SDIO_IT_CEATAEND ((uint32_t)0x00800000)
bogdanm 73:1efda918f0ba 221 #define IS_SDIO_IT(IT) ((((IT) & (uint32_t)0xFF000000) == 0x00) && ((IT) != (uint32_t)0x00))
bogdanm 73:1efda918f0ba 222 /**
bogdanm 73:1efda918f0ba 223 * @}
bogdanm 73:1efda918f0ba 224 */
bogdanm 73:1efda918f0ba 225
bogdanm 73:1efda918f0ba 226 /** @defgroup SDIO_Command_Index
bogdanm 73:1efda918f0ba 227 * @{
bogdanm 73:1efda918f0ba 228 */
bogdanm 73:1efda918f0ba 229
bogdanm 73:1efda918f0ba 230 #define IS_SDIO_CMD_INDEX(INDEX) ((INDEX) < 0x40)
bogdanm 73:1efda918f0ba 231 /**
bogdanm 73:1efda918f0ba 232 * @}
bogdanm 73:1efda918f0ba 233 */
bogdanm 73:1efda918f0ba 234
bogdanm 73:1efda918f0ba 235 /** @defgroup SDIO_Response_Type
bogdanm 73:1efda918f0ba 236 * @{
bogdanm 73:1efda918f0ba 237 */
bogdanm 73:1efda918f0ba 238
bogdanm 73:1efda918f0ba 239 #define SDIO_Response_No ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 240 #define SDIO_Response_Short ((uint32_t)0x00000040)
bogdanm 73:1efda918f0ba 241 #define SDIO_Response_Long ((uint32_t)0x000000C0)
bogdanm 73:1efda918f0ba 242 #define IS_SDIO_RESPONSE(RESPONSE) (((RESPONSE) == SDIO_Response_No) || \
bogdanm 73:1efda918f0ba 243 ((RESPONSE) == SDIO_Response_Short) || \
bogdanm 73:1efda918f0ba 244 ((RESPONSE) == SDIO_Response_Long))
bogdanm 73:1efda918f0ba 245 /**
bogdanm 73:1efda918f0ba 246 * @}
bogdanm 73:1efda918f0ba 247 */
bogdanm 73:1efda918f0ba 248
bogdanm 73:1efda918f0ba 249 /** @defgroup SDIO_Wait_Interrupt_State
bogdanm 73:1efda918f0ba 250 * @{
bogdanm 73:1efda918f0ba 251 */
bogdanm 73:1efda918f0ba 252
bogdanm 73:1efda918f0ba 253 #define SDIO_Wait_No ((uint32_t)0x00000000) /*!< SDIO No Wait, TimeOut is enabled */
bogdanm 73:1efda918f0ba 254 #define SDIO_Wait_IT ((uint32_t)0x00000100) /*!< SDIO Wait Interrupt Request */
bogdanm 73:1efda918f0ba 255 #define SDIO_Wait_Pend ((uint32_t)0x00000200) /*!< SDIO Wait End of transfer */
bogdanm 73:1efda918f0ba 256 #define IS_SDIO_WAIT(WAIT) (((WAIT) == SDIO_Wait_No) || ((WAIT) == SDIO_Wait_IT) || \
bogdanm 73:1efda918f0ba 257 ((WAIT) == SDIO_Wait_Pend))
bogdanm 73:1efda918f0ba 258 /**
bogdanm 73:1efda918f0ba 259 * @}
bogdanm 73:1efda918f0ba 260 */
bogdanm 73:1efda918f0ba 261
bogdanm 73:1efda918f0ba 262 /** @defgroup SDIO_CPSM_State
bogdanm 73:1efda918f0ba 263 * @{
bogdanm 73:1efda918f0ba 264 */
bogdanm 73:1efda918f0ba 265
bogdanm 73:1efda918f0ba 266 #define SDIO_CPSM_Disable ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 267 #define SDIO_CPSM_Enable ((uint32_t)0x00000400)
bogdanm 73:1efda918f0ba 268 #define IS_SDIO_CPSM(CPSM) (((CPSM) == SDIO_CPSM_Enable) || ((CPSM) == SDIO_CPSM_Disable))
bogdanm 73:1efda918f0ba 269 /**
bogdanm 73:1efda918f0ba 270 * @}
bogdanm 73:1efda918f0ba 271 */
bogdanm 73:1efda918f0ba 272
bogdanm 73:1efda918f0ba 273 /** @defgroup SDIO_Response_Registers
bogdanm 73:1efda918f0ba 274 * @{
bogdanm 73:1efda918f0ba 275 */
bogdanm 73:1efda918f0ba 276
bogdanm 73:1efda918f0ba 277 #define SDIO_RESP1 ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 278 #define SDIO_RESP2 ((uint32_t)0x00000004)
bogdanm 73:1efda918f0ba 279 #define SDIO_RESP3 ((uint32_t)0x00000008)
bogdanm 73:1efda918f0ba 280 #define SDIO_RESP4 ((uint32_t)0x0000000C)
bogdanm 73:1efda918f0ba 281 #define IS_SDIO_RESP(RESP) (((RESP) == SDIO_RESP1) || ((RESP) == SDIO_RESP2) || \
bogdanm 73:1efda918f0ba 282 ((RESP) == SDIO_RESP3) || ((RESP) == SDIO_RESP4))
bogdanm 73:1efda918f0ba 283 /**
bogdanm 73:1efda918f0ba 284 * @}
bogdanm 73:1efda918f0ba 285 */
bogdanm 73:1efda918f0ba 286
bogdanm 73:1efda918f0ba 287 /** @defgroup SDIO_Data_Length
bogdanm 73:1efda918f0ba 288 * @{
bogdanm 73:1efda918f0ba 289 */
bogdanm 73:1efda918f0ba 290
bogdanm 73:1efda918f0ba 291 #define IS_SDIO_DATA_LENGTH(LENGTH) ((LENGTH) <= 0x01FFFFFF)
bogdanm 73:1efda918f0ba 292 /**
bogdanm 73:1efda918f0ba 293 * @}
bogdanm 73:1efda918f0ba 294 */
bogdanm 73:1efda918f0ba 295
bogdanm 73:1efda918f0ba 296 /** @defgroup SDIO_Data_Block_Size
bogdanm 73:1efda918f0ba 297 * @{
bogdanm 73:1efda918f0ba 298 */
bogdanm 73:1efda918f0ba 299
bogdanm 73:1efda918f0ba 300 #define SDIO_DataBlockSize_1b ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 301 #define SDIO_DataBlockSize_2b ((uint32_t)0x00000010)
bogdanm 73:1efda918f0ba 302 #define SDIO_DataBlockSize_4b ((uint32_t)0x00000020)
bogdanm 73:1efda918f0ba 303 #define SDIO_DataBlockSize_8b ((uint32_t)0x00000030)
bogdanm 73:1efda918f0ba 304 #define SDIO_DataBlockSize_16b ((uint32_t)0x00000040)
bogdanm 73:1efda918f0ba 305 #define SDIO_DataBlockSize_32b ((uint32_t)0x00000050)
bogdanm 73:1efda918f0ba 306 #define SDIO_DataBlockSize_64b ((uint32_t)0x00000060)
bogdanm 73:1efda918f0ba 307 #define SDIO_DataBlockSize_128b ((uint32_t)0x00000070)
bogdanm 73:1efda918f0ba 308 #define SDIO_DataBlockSize_256b ((uint32_t)0x00000080)
bogdanm 73:1efda918f0ba 309 #define SDIO_DataBlockSize_512b ((uint32_t)0x00000090)
bogdanm 73:1efda918f0ba 310 #define SDIO_DataBlockSize_1024b ((uint32_t)0x000000A0)
bogdanm 73:1efda918f0ba 311 #define SDIO_DataBlockSize_2048b ((uint32_t)0x000000B0)
bogdanm 73:1efda918f0ba 312 #define SDIO_DataBlockSize_4096b ((uint32_t)0x000000C0)
bogdanm 73:1efda918f0ba 313 #define SDIO_DataBlockSize_8192b ((uint32_t)0x000000D0)
bogdanm 73:1efda918f0ba 314 #define SDIO_DataBlockSize_16384b ((uint32_t)0x000000E0)
bogdanm 73:1efda918f0ba 315 #define IS_SDIO_BLOCK_SIZE(SIZE) (((SIZE) == SDIO_DataBlockSize_1b) || \
bogdanm 73:1efda918f0ba 316 ((SIZE) == SDIO_DataBlockSize_2b) || \
bogdanm 73:1efda918f0ba 317 ((SIZE) == SDIO_DataBlockSize_4b) || \
bogdanm 73:1efda918f0ba 318 ((SIZE) == SDIO_DataBlockSize_8b) || \
bogdanm 73:1efda918f0ba 319 ((SIZE) == SDIO_DataBlockSize_16b) || \
bogdanm 73:1efda918f0ba 320 ((SIZE) == SDIO_DataBlockSize_32b) || \
bogdanm 73:1efda918f0ba 321 ((SIZE) == SDIO_DataBlockSize_64b) || \
bogdanm 73:1efda918f0ba 322 ((SIZE) == SDIO_DataBlockSize_128b) || \
bogdanm 73:1efda918f0ba 323 ((SIZE) == SDIO_DataBlockSize_256b) || \
bogdanm 73:1efda918f0ba 324 ((SIZE) == SDIO_DataBlockSize_512b) || \
bogdanm 73:1efda918f0ba 325 ((SIZE) == SDIO_DataBlockSize_1024b) || \
bogdanm 73:1efda918f0ba 326 ((SIZE) == SDIO_DataBlockSize_2048b) || \
bogdanm 73:1efda918f0ba 327 ((SIZE) == SDIO_DataBlockSize_4096b) || \
bogdanm 73:1efda918f0ba 328 ((SIZE) == SDIO_DataBlockSize_8192b) || \
bogdanm 73:1efda918f0ba 329 ((SIZE) == SDIO_DataBlockSize_16384b))
bogdanm 73:1efda918f0ba 330 /**
bogdanm 73:1efda918f0ba 331 * @}
bogdanm 73:1efda918f0ba 332 */
bogdanm 73:1efda918f0ba 333
bogdanm 73:1efda918f0ba 334 /** @defgroup SDIO_Transfer_Direction
bogdanm 73:1efda918f0ba 335 * @{
bogdanm 73:1efda918f0ba 336 */
bogdanm 73:1efda918f0ba 337
bogdanm 73:1efda918f0ba 338 #define SDIO_TransferDir_ToCard ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 339 #define SDIO_TransferDir_ToSDIO ((uint32_t)0x00000002)
bogdanm 73:1efda918f0ba 340 #define IS_SDIO_TRANSFER_DIR(DIR) (((DIR) == SDIO_TransferDir_ToCard) || \
bogdanm 73:1efda918f0ba 341 ((DIR) == SDIO_TransferDir_ToSDIO))
bogdanm 73:1efda918f0ba 342 /**
bogdanm 73:1efda918f0ba 343 * @}
bogdanm 73:1efda918f0ba 344 */
bogdanm 73:1efda918f0ba 345
bogdanm 73:1efda918f0ba 346 /** @defgroup SDIO_Transfer_Type
bogdanm 73:1efda918f0ba 347 * @{
bogdanm 73:1efda918f0ba 348 */
bogdanm 73:1efda918f0ba 349
bogdanm 73:1efda918f0ba 350 #define SDIO_TransferMode_Block ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 351 #define SDIO_TransferMode_Stream ((uint32_t)0x00000004)
bogdanm 73:1efda918f0ba 352 #define IS_SDIO_TRANSFER_MODE(MODE) (((MODE) == SDIO_TransferMode_Stream) || \
bogdanm 73:1efda918f0ba 353 ((MODE) == SDIO_TransferMode_Block))
bogdanm 73:1efda918f0ba 354 /**
bogdanm 73:1efda918f0ba 355 * @}
bogdanm 73:1efda918f0ba 356 */
bogdanm 73:1efda918f0ba 357
bogdanm 73:1efda918f0ba 358 /** @defgroup SDIO_DPSM_State
bogdanm 73:1efda918f0ba 359 * @{
bogdanm 73:1efda918f0ba 360 */
bogdanm 73:1efda918f0ba 361
bogdanm 73:1efda918f0ba 362 #define SDIO_DPSM_Disable ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 363 #define SDIO_DPSM_Enable ((uint32_t)0x00000001)
bogdanm 73:1efda918f0ba 364 #define IS_SDIO_DPSM(DPSM) (((DPSM) == SDIO_DPSM_Enable) || ((DPSM) == SDIO_DPSM_Disable))
bogdanm 73:1efda918f0ba 365 /**
bogdanm 73:1efda918f0ba 366 * @}
bogdanm 73:1efda918f0ba 367 */
bogdanm 73:1efda918f0ba 368
bogdanm 73:1efda918f0ba 369 /** @defgroup SDIO_Flags
bogdanm 73:1efda918f0ba 370 * @{
bogdanm 73:1efda918f0ba 371 */
bogdanm 73:1efda918f0ba 372
bogdanm 73:1efda918f0ba 373 #define SDIO_FLAG_CCRCFAIL ((uint32_t)0x00000001)
bogdanm 73:1efda918f0ba 374 #define SDIO_FLAG_DCRCFAIL ((uint32_t)0x00000002)
bogdanm 73:1efda918f0ba 375 #define SDIO_FLAG_CTIMEOUT ((uint32_t)0x00000004)
bogdanm 73:1efda918f0ba 376 #define SDIO_FLAG_DTIMEOUT ((uint32_t)0x00000008)
bogdanm 73:1efda918f0ba 377 #define SDIO_FLAG_TXUNDERR ((uint32_t)0x00000010)
bogdanm 73:1efda918f0ba 378 #define SDIO_FLAG_RXOVERR ((uint32_t)0x00000020)
bogdanm 73:1efda918f0ba 379 #define SDIO_FLAG_CMDREND ((uint32_t)0x00000040)
bogdanm 73:1efda918f0ba 380 #define SDIO_FLAG_CMDSENT ((uint32_t)0x00000080)
bogdanm 73:1efda918f0ba 381 #define SDIO_FLAG_DATAEND ((uint32_t)0x00000100)
bogdanm 73:1efda918f0ba 382 #define SDIO_FLAG_STBITERR ((uint32_t)0x00000200)
bogdanm 73:1efda918f0ba 383 #define SDIO_FLAG_DBCKEND ((uint32_t)0x00000400)
bogdanm 73:1efda918f0ba 384 #define SDIO_FLAG_CMDACT ((uint32_t)0x00000800)
bogdanm 73:1efda918f0ba 385 #define SDIO_FLAG_TXACT ((uint32_t)0x00001000)
bogdanm 73:1efda918f0ba 386 #define SDIO_FLAG_RXACT ((uint32_t)0x00002000)
bogdanm 73:1efda918f0ba 387 #define SDIO_FLAG_TXFIFOHE ((uint32_t)0x00004000)
bogdanm 73:1efda918f0ba 388 #define SDIO_FLAG_RXFIFOHF ((uint32_t)0x00008000)
bogdanm 73:1efda918f0ba 389 #define SDIO_FLAG_TXFIFOF ((uint32_t)0x00010000)
bogdanm 73:1efda918f0ba 390 #define SDIO_FLAG_RXFIFOF ((uint32_t)0x00020000)
bogdanm 73:1efda918f0ba 391 #define SDIO_FLAG_TXFIFOE ((uint32_t)0x00040000)
bogdanm 73:1efda918f0ba 392 #define SDIO_FLAG_RXFIFOE ((uint32_t)0x00080000)
bogdanm 73:1efda918f0ba 393 #define SDIO_FLAG_TXDAVL ((uint32_t)0x00100000)
bogdanm 73:1efda918f0ba 394 #define SDIO_FLAG_RXDAVL ((uint32_t)0x00200000)
bogdanm 73:1efda918f0ba 395 #define SDIO_FLAG_SDIOIT ((uint32_t)0x00400000)
bogdanm 73:1efda918f0ba 396 #define SDIO_FLAG_CEATAEND ((uint32_t)0x00800000)
bogdanm 73:1efda918f0ba 397 #define IS_SDIO_FLAG(FLAG) (((FLAG) == SDIO_FLAG_CCRCFAIL) || \
bogdanm 73:1efda918f0ba 398 ((FLAG) == SDIO_FLAG_DCRCFAIL) || \
bogdanm 73:1efda918f0ba 399 ((FLAG) == SDIO_FLAG_CTIMEOUT) || \
bogdanm 73:1efda918f0ba 400 ((FLAG) == SDIO_FLAG_DTIMEOUT) || \
bogdanm 73:1efda918f0ba 401 ((FLAG) == SDIO_FLAG_TXUNDERR) || \
bogdanm 73:1efda918f0ba 402 ((FLAG) == SDIO_FLAG_RXOVERR) || \
bogdanm 73:1efda918f0ba 403 ((FLAG) == SDIO_FLAG_CMDREND) || \
bogdanm 73:1efda918f0ba 404 ((FLAG) == SDIO_FLAG_CMDSENT) || \
bogdanm 73:1efda918f0ba 405 ((FLAG) == SDIO_FLAG_DATAEND) || \
bogdanm 73:1efda918f0ba 406 ((FLAG) == SDIO_FLAG_STBITERR) || \
bogdanm 73:1efda918f0ba 407 ((FLAG) == SDIO_FLAG_DBCKEND) || \
bogdanm 73:1efda918f0ba 408 ((FLAG) == SDIO_FLAG_CMDACT) || \
bogdanm 73:1efda918f0ba 409 ((FLAG) == SDIO_FLAG_TXACT) || \
bogdanm 73:1efda918f0ba 410 ((FLAG) == SDIO_FLAG_RXACT) || \
bogdanm 73:1efda918f0ba 411 ((FLAG) == SDIO_FLAG_TXFIFOHE) || \
bogdanm 73:1efda918f0ba 412 ((FLAG) == SDIO_FLAG_RXFIFOHF) || \
bogdanm 73:1efda918f0ba 413 ((FLAG) == SDIO_FLAG_TXFIFOF) || \
bogdanm 73:1efda918f0ba 414 ((FLAG) == SDIO_FLAG_RXFIFOF) || \
bogdanm 73:1efda918f0ba 415 ((FLAG) == SDIO_FLAG_TXFIFOE) || \
bogdanm 73:1efda918f0ba 416 ((FLAG) == SDIO_FLAG_RXFIFOE) || \
bogdanm 73:1efda918f0ba 417 ((FLAG) == SDIO_FLAG_TXDAVL) || \
bogdanm 73:1efda918f0ba 418 ((FLAG) == SDIO_FLAG_RXDAVL) || \
bogdanm 73:1efda918f0ba 419 ((FLAG) == SDIO_FLAG_SDIOIT) || \
bogdanm 73:1efda918f0ba 420 ((FLAG) == SDIO_FLAG_CEATAEND))
bogdanm 73:1efda918f0ba 421
bogdanm 73:1efda918f0ba 422 #define IS_SDIO_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFF3FF800) == 0x00) && ((FLAG) != (uint32_t)0x00))
bogdanm 73:1efda918f0ba 423
bogdanm 73:1efda918f0ba 424 #define IS_SDIO_GET_IT(IT) (((IT) == SDIO_IT_CCRCFAIL) || \
bogdanm 73:1efda918f0ba 425 ((IT) == SDIO_IT_DCRCFAIL) || \
bogdanm 73:1efda918f0ba 426 ((IT) == SDIO_IT_CTIMEOUT) || \
bogdanm 73:1efda918f0ba 427 ((IT) == SDIO_IT_DTIMEOUT) || \
bogdanm 73:1efda918f0ba 428 ((IT) == SDIO_IT_TXUNDERR) || \
bogdanm 73:1efda918f0ba 429 ((IT) == SDIO_IT_RXOVERR) || \
bogdanm 73:1efda918f0ba 430 ((IT) == SDIO_IT_CMDREND) || \
bogdanm 73:1efda918f0ba 431 ((IT) == SDIO_IT_CMDSENT) || \
bogdanm 73:1efda918f0ba 432 ((IT) == SDIO_IT_DATAEND) || \
bogdanm 73:1efda918f0ba 433 ((IT) == SDIO_IT_STBITERR) || \
bogdanm 73:1efda918f0ba 434 ((IT) == SDIO_IT_DBCKEND) || \
bogdanm 73:1efda918f0ba 435 ((IT) == SDIO_IT_CMDACT) || \
bogdanm 73:1efda918f0ba 436 ((IT) == SDIO_IT_TXACT) || \
bogdanm 73:1efda918f0ba 437 ((IT) == SDIO_IT_RXACT) || \
bogdanm 73:1efda918f0ba 438 ((IT) == SDIO_IT_TXFIFOHE) || \
bogdanm 73:1efda918f0ba 439 ((IT) == SDIO_IT_RXFIFOHF) || \
bogdanm 73:1efda918f0ba 440 ((IT) == SDIO_IT_TXFIFOF) || \
bogdanm 73:1efda918f0ba 441 ((IT) == SDIO_IT_RXFIFOF) || \
bogdanm 73:1efda918f0ba 442 ((IT) == SDIO_IT_TXFIFOE) || \
bogdanm 73:1efda918f0ba 443 ((IT) == SDIO_IT_RXFIFOE) || \
bogdanm 73:1efda918f0ba 444 ((IT) == SDIO_IT_TXDAVL) || \
bogdanm 73:1efda918f0ba 445 ((IT) == SDIO_IT_RXDAVL) || \
bogdanm 73:1efda918f0ba 446 ((IT) == SDIO_IT_SDIOIT) || \
bogdanm 73:1efda918f0ba 447 ((IT) == SDIO_IT_CEATAEND))
bogdanm 73:1efda918f0ba 448
bogdanm 73:1efda918f0ba 449 #define IS_SDIO_CLEAR_IT(IT) ((((IT) & (uint32_t)0xFF3FF800) == 0x00) && ((IT) != (uint32_t)0x00))
bogdanm 73:1efda918f0ba 450
bogdanm 73:1efda918f0ba 451 /**
bogdanm 73:1efda918f0ba 452 * @}
bogdanm 73:1efda918f0ba 453 */
bogdanm 73:1efda918f0ba 454
bogdanm 73:1efda918f0ba 455 /** @defgroup SDIO_Read_Wait_Mode
bogdanm 73:1efda918f0ba 456 * @{
bogdanm 73:1efda918f0ba 457 */
bogdanm 73:1efda918f0ba 458
bogdanm 73:1efda918f0ba 459 #define SDIO_ReadWaitMode_CLK ((uint32_t)0x00000001)
bogdanm 73:1efda918f0ba 460 #define SDIO_ReadWaitMode_DATA2 ((uint32_t)0x00000000)
bogdanm 73:1efda918f0ba 461 #define IS_SDIO_READWAIT_MODE(MODE) (((MODE) == SDIO_ReadWaitMode_CLK) || \
bogdanm 73:1efda918f0ba 462 ((MODE) == SDIO_ReadWaitMode_DATA2))
bogdanm 73:1efda918f0ba 463 /**
bogdanm 73:1efda918f0ba 464 * @}
bogdanm 73:1efda918f0ba 465 */
bogdanm 73:1efda918f0ba 466
bogdanm 73:1efda918f0ba 467 /**
bogdanm 73:1efda918f0ba 468 * @}
bogdanm 73:1efda918f0ba 469 */
bogdanm 73:1efda918f0ba 470
bogdanm 73:1efda918f0ba 471 /** @defgroup SDIO_Exported_Macros
bogdanm 73:1efda918f0ba 472 * @{
bogdanm 73:1efda918f0ba 473 */
bogdanm 73:1efda918f0ba 474
bogdanm 73:1efda918f0ba 475 /**
bogdanm 73:1efda918f0ba 476 * @}
bogdanm 73:1efda918f0ba 477 */
bogdanm 73:1efda918f0ba 478
bogdanm 73:1efda918f0ba 479 /** @defgroup SDIO_Exported_Functions
bogdanm 73:1efda918f0ba 480 * @{
bogdanm 73:1efda918f0ba 481 */
bogdanm 73:1efda918f0ba 482
bogdanm 73:1efda918f0ba 483 void SDIO_DeInit(void);
bogdanm 73:1efda918f0ba 484 void SDIO_Init(SDIO_InitTypeDef* SDIO_InitStruct);
bogdanm 73:1efda918f0ba 485 void SDIO_StructInit(SDIO_InitTypeDef* SDIO_InitStruct);
bogdanm 73:1efda918f0ba 486 void SDIO_ClockCmd(FunctionalState NewState);
bogdanm 73:1efda918f0ba 487 void SDIO_SetPowerState(uint32_t SDIO_PowerState);
bogdanm 73:1efda918f0ba 488 uint32_t SDIO_GetPowerState(void);
bogdanm 73:1efda918f0ba 489 void SDIO_ITConfig(uint32_t SDIO_IT, FunctionalState NewState);
bogdanm 73:1efda918f0ba 490 void SDIO_DMACmd(FunctionalState NewState);
bogdanm 73:1efda918f0ba 491 void SDIO_SendCommand(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct);
bogdanm 73:1efda918f0ba 492 void SDIO_CmdStructInit(SDIO_CmdInitTypeDef* SDIO_CmdInitStruct);
bogdanm 73:1efda918f0ba 493 uint8_t SDIO_GetCommandResponse(void);
bogdanm 73:1efda918f0ba 494 uint32_t SDIO_GetResponse(uint32_t SDIO_RESP);
bogdanm 73:1efda918f0ba 495 void SDIO_DataConfig(SDIO_DataInitTypeDef* SDIO_DataInitStruct);
bogdanm 73:1efda918f0ba 496 void SDIO_DataStructInit(SDIO_DataInitTypeDef* SDIO_DataInitStruct);
bogdanm 73:1efda918f0ba 497 uint32_t SDIO_GetDataCounter(void);
bogdanm 73:1efda918f0ba 498 uint32_t SDIO_ReadData(void);
bogdanm 73:1efda918f0ba 499 void SDIO_WriteData(uint32_t Data);
bogdanm 73:1efda918f0ba 500 uint32_t SDIO_GetFIFOCount(void);
bogdanm 73:1efda918f0ba 501 void SDIO_StartSDIOReadWait(FunctionalState NewState);
bogdanm 73:1efda918f0ba 502 void SDIO_StopSDIOReadWait(FunctionalState NewState);
bogdanm 73:1efda918f0ba 503 void SDIO_SetSDIOReadWaitMode(uint32_t SDIO_ReadWaitMode);
bogdanm 73:1efda918f0ba 504 void SDIO_SetSDIOOperation(FunctionalState NewState);
bogdanm 73:1efda918f0ba 505 void SDIO_SendSDIOSuspendCmd(FunctionalState NewState);
bogdanm 73:1efda918f0ba 506 void SDIO_CommandCompletionCmd(FunctionalState NewState);
bogdanm 73:1efda918f0ba 507 void SDIO_CEATAITCmd(FunctionalState NewState);
bogdanm 73:1efda918f0ba 508 void SDIO_SendCEATACmd(FunctionalState NewState);
bogdanm 73:1efda918f0ba 509 FlagStatus SDIO_GetFlagStatus(uint32_t SDIO_FLAG);
bogdanm 73:1efda918f0ba 510 void SDIO_ClearFlag(uint32_t SDIO_FLAG);
bogdanm 73:1efda918f0ba 511 ITStatus SDIO_GetITStatus(uint32_t SDIO_IT);
bogdanm 73:1efda918f0ba 512 void SDIO_ClearITPendingBit(uint32_t SDIO_IT);
bogdanm 73:1efda918f0ba 513
bogdanm 73:1efda918f0ba 514 #ifdef __cplusplus
bogdanm 73:1efda918f0ba 515 }
bogdanm 73:1efda918f0ba 516 #endif
bogdanm 73:1efda918f0ba 517
bogdanm 73:1efda918f0ba 518 #endif /* __STM32F10x_SDIO_H */
bogdanm 73:1efda918f0ba 519 /**
bogdanm 73:1efda918f0ba 520 * @}
bogdanm 73:1efda918f0ba 521 */
bogdanm 73:1efda918f0ba 522
bogdanm 73:1efda918f0ba 523 /**
bogdanm 73:1efda918f0ba 524 * @}
bogdanm 73:1efda918f0ba 525 */
bogdanm 73:1efda918f0ba 526
bogdanm 73:1efda918f0ba 527 /**
bogdanm 73:1efda918f0ba 528 * @}
bogdanm 73:1efda918f0ba 529 */
bogdanm 73:1efda918f0ba 530
bogdanm 73:1efda918f0ba 531 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/