mbed library with additional peripherals for ST F401 board

Fork of mbed-src by mbed official

This mbed LIB has additional peripherals for ST F401 board

  • UART2 : PA_3 rx, PA_2 tx
  • UART3 : PC_7 rx, PC_6 tx
  • I2C2 : PB_3 SDA, PB_10 SCL
  • I2C3 : PB_4 SDA, PA_8 SCL
Committer:
mbed_official
Date:
Mon Jan 27 14:30:07 2014 +0000
Revision:
76:aeb1df146756
Child:
80:66393a7b209d
Synchronized with git revision a31ec9c5f7bcb5c8a1b2eced103f6a1dfa921abd

Full URL: https://github.com/mbedmicro/mbed/commit/a31ec9c5f7bcb5c8a1b2eced103f6a1dfa921abd/

Add NUCLEO_L152RE

Who changed what in which revision?

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