mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_sdio.c@106:ced8cbb51063, 2014-02-26 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Feb 26 09:45:12 2014 +0000
- Revision:
- 106:ced8cbb51063
- Parent:
- 80:66393a7b209d
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd
Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/
[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 76:aeb1df146756 | 1 | /** |
mbed_official | 76:aeb1df146756 | 2 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 3 | * @file stm32l1xx_sdio.c |
mbed_official | 76:aeb1df146756 | 4 | * @author MCD Application Team |
mbed_official | 80:66393a7b209d | 5 | * @version V1.3.0 |
mbed_official | 80:66393a7b209d | 6 | * @date 31-January-2014 |
mbed_official | 76:aeb1df146756 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 76:aeb1df146756 | 8 | * functionalities of the SDIO peripheral: |
mbed_official | 76:aeb1df146756 | 9 | * + Initialization |
mbed_official | 76:aeb1df146756 | 10 | * + Interrupts and flags management |
mbed_official | 76:aeb1df146756 | 11 | * |
mbed_official | 76:aeb1df146756 | 12 | * @verbatim |
mbed_official | 76:aeb1df146756 | 13 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 14 | ##### How to use this driver ##### |
mbed_official | 76:aeb1df146756 | 15 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 16 | [..] |
mbed_official | 76:aeb1df146756 | 17 | (#) The SDIO clock (SDIOCLK = 48 MHz) is coming from a specific output of PLL |
mbed_official | 76:aeb1df146756 | 18 | (PLLVCO) througth a fixed divider by 2. |
mbed_official | 76:aeb1df146756 | 19 | Before to start working with SDIO peripheral make sure that the PLLVCO is |
mbed_official | 76:aeb1df146756 | 20 | well configured to 96MHz. |
mbed_official | 76:aeb1df146756 | 21 | The SDIO peripheral uses two clock signals: |
mbed_official | 76:aeb1df146756 | 22 | (++) SDIO adapter clock (SDIOCLK = 48 MHz). |
mbed_official | 76:aeb1df146756 | 23 | (++) APB2 bus clock (PCLK2). |
mbed_official | 76:aeb1df146756 | 24 | PCLK2 and SDIO_CK clock frequencies must respect the following |
mbed_official | 76:aeb1df146756 | 25 | condition: Frequenc(PCLK2) >= (3 / 8 x Frequency(SDIO_CK)). |
mbed_official | 76:aeb1df146756 | 26 | (#) Enable peripheral clock using |
mbed_official | 76:aeb1df146756 | 27 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_SDIO, ENABLE). |
mbed_official | 76:aeb1df146756 | 28 | (#) According to the SDIO mode, enable the GPIO clocks using |
mbed_official | 76:aeb1df146756 | 29 | RCC_AHBPeriphClockCmd() function. |
mbed_official | 76:aeb1df146756 | 30 | The I/O can be one of the following configurations: |
mbed_official | 76:aeb1df146756 | 31 | (++) 1-bit data length: SDIO_CMD, SDIO_CK and D0. |
mbed_official | 76:aeb1df146756 | 32 | (++) 4-bit data length: SDIO_CMD, SDIO_CK and D[3:0]. |
mbed_official | 76:aeb1df146756 | 33 | (++) 8-bit data length: SDIO_CMD, SDIO_CK and D[7:0]. |
mbed_official | 76:aeb1df146756 | 34 | |
mbed_official | 76:aeb1df146756 | 35 | (#) Peripheral's alternate function: |
mbed_official | 76:aeb1df146756 | 36 | (++) Connect the pin to the desired peripherals' Alternate |
mbed_official | 76:aeb1df146756 | 37 | Function (AF) using GPIO_PinAFConfig() function. |
mbed_official | 76:aeb1df146756 | 38 | (++) Configure the desired pin in alternate function by: |
mbed_official | 76:aeb1df146756 | 39 | GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF. |
mbed_official | 76:aeb1df146756 | 40 | (++) Select the type, pull-up/pull-down and output speed via |
mbed_official | 76:aeb1df146756 | 41 | GPIO_PuPd, GPIO_OType and GPIO_Speed members. |
mbed_official | 76:aeb1df146756 | 42 | (++) Call GPIO_Init() function. |
mbed_official | 76:aeb1df146756 | 43 | |
mbed_official | 76:aeb1df146756 | 44 | (#) Program the Clock Edge, Clock Bypass, Clock Power Save, Bus Wide, |
mbed_official | 76:aeb1df146756 | 45 | hardware, flow control and the Clock Divider using the SDIO_Init() |
mbed_official | 76:aeb1df146756 | 46 | function. |
mbed_official | 76:aeb1df146756 | 47 | (#) Enable the Power ON State using the SDIO_SetPowerState(SDIO_PowerState_ON) |
mbed_official | 76:aeb1df146756 | 48 | function. |
mbed_official | 76:aeb1df146756 | 49 | (#) Enable the clock using the SDIO_ClockCmd() function. |
mbed_official | 76:aeb1df146756 | 50 | (#) Enable the NVIC and the corresponding interrupt using the function |
mbed_official | 76:aeb1df146756 | 51 | SDIO_ITConfig() if you need to use interrupt mode. |
mbed_official | 76:aeb1df146756 | 52 | (#) When using the DMA mode |
mbed_official | 76:aeb1df146756 | 53 | (++) Configure the DMA using DMA_Init() function. |
mbed_official | 76:aeb1df146756 | 54 | (++) Active the needed channel Request using SDIO_DMACmd() function. |
mbed_official | 76:aeb1df146756 | 55 | (#) Enable the DMA using the DMA_Cmd() function, when using DMA mode. |
mbed_official | 76:aeb1df146756 | 56 | (#) To control the CPSM (Command Path State Machine) and send commands to the |
mbed_official | 76:aeb1df146756 | 57 | card use the SDIO_SendCommand(), SDIO_GetCommandResponse() and |
mbed_official | 76:aeb1df146756 | 58 | SDIO_GetResponse() functions. First, user has to fill the command |
mbed_official | 76:aeb1df146756 | 59 | structure (pointer to SDIO_CmdInitTypeDef) according to the selected |
mbed_official | 76:aeb1df146756 | 60 | command to be sent. The parameters that should be filled are: |
mbed_official | 76:aeb1df146756 | 61 | (++) Command Argument. |
mbed_official | 76:aeb1df146756 | 62 | (++) Command Index. |
mbed_official | 76:aeb1df146756 | 63 | (++) Command Response type. |
mbed_official | 76:aeb1df146756 | 64 | (++) Command Wait. |
mbed_official | 76:aeb1df146756 | 65 | (++) CPSM Status (Enable or Disable). |
mbed_official | 76:aeb1df146756 | 66 | To check if the command is well received, read the SDIO_CMDRESP register |
mbed_official | 76:aeb1df146756 | 67 | using the SDIO_GetCommandResponse(). The SDIO responses registers |
mbed_official | 76:aeb1df146756 | 68 | (SDIO_RESP1 to SDIO_RESP2), use the SDIO_GetResponse() function. |
mbed_official | 76:aeb1df146756 | 69 | (#) To control the DPSM (Data Path State Machine) and send/receive |
mbed_official | 76:aeb1df146756 | 70 | data to/from the card use the SDIO_DataConfig(), SDIO_GetDataCounter(), |
mbed_official | 76:aeb1df146756 | 71 | SDIO_ReadData(), SDIO_WriteData() and SDIO_GetFIFOCount() functions. |
mbed_official | 76:aeb1df146756 | 72 | |
mbed_official | 76:aeb1df146756 | 73 | *** Read Operations *** |
mbed_official | 76:aeb1df146756 | 74 | ----------------------- |
mbed_official | 76:aeb1df146756 | 75 | [..] |
mbed_official | 76:aeb1df146756 | 76 | (#) First, user has to fill the data structure (pointer to |
mbed_official | 76:aeb1df146756 | 77 | SDIO_DataInitTypeDef) according to the selected data type to be received. |
mbed_official | 76:aeb1df146756 | 78 | The parameters that should be filled are: |
mbed_official | 76:aeb1df146756 | 79 | (++) Data TimeOut. |
mbed_official | 76:aeb1df146756 | 80 | (++) Data Length. |
mbed_official | 76:aeb1df146756 | 81 | (++) Data Block size. |
mbed_official | 76:aeb1df146756 | 82 | (++) Data Transfer direction: should be from card (To SDIO). |
mbed_official | 76:aeb1df146756 | 83 | (++) Data Transfer mode. |
mbed_official | 76:aeb1df146756 | 84 | (++) DPSM Status (Enable or Disable). |
mbed_official | 76:aeb1df146756 | 85 | (#) Configure the SDIO resources to receive the data from the card |
mbed_official | 76:aeb1df146756 | 86 | according to selected transfer mode (Refer to Step 8, 9 and 10). |
mbed_official | 76:aeb1df146756 | 87 | (#) Send the selected Read command (refer to step 11). |
mbed_official | 76:aeb1df146756 | 88 | (#) Use the SDIO flags/interrupts to check the transfer status. |
mbed_official | 76:aeb1df146756 | 89 | |
mbed_official | 76:aeb1df146756 | 90 | *** Write Operations *** |
mbed_official | 76:aeb1df146756 | 91 | ------------------------ |
mbed_official | 76:aeb1df146756 | 92 | [..] |
mbed_official | 76:aeb1df146756 | 93 | (#) First, user has to fill the data structure (pointer to |
mbed_official | 76:aeb1df146756 | 94 | SDIO_DataInitTypeDef) according to the selected data type to be received. |
mbed_official | 76:aeb1df146756 | 95 | The parameters that should be filled are: |
mbed_official | 76:aeb1df146756 | 96 | (++) Data TimeOut. |
mbed_official | 76:aeb1df146756 | 97 | (++) Data Length. |
mbed_official | 76:aeb1df146756 | 98 | (++) Data Block size. |
mbed_official | 76:aeb1df146756 | 99 | (++) Data Transfer direction: should be to card (To CARD). |
mbed_official | 76:aeb1df146756 | 100 | (++) Data Transfer mode. |
mbed_official | 76:aeb1df146756 | 101 | (++) DPSM Status (Enable or Disable). |
mbed_official | 76:aeb1df146756 | 102 | (#) Configure the SDIO resources to send the data to the card |
mbed_official | 76:aeb1df146756 | 103 | according to selected transfer mode (Refer to Step 8, 9 and 10). |
mbed_official | 76:aeb1df146756 | 104 | (#) Send the selected Write command (refer to step 11). |
mbed_official | 76:aeb1df146756 | 105 | (#) Use the SDIO flags/interrupts to check the transfer status. |
mbed_official | 76:aeb1df146756 | 106 | |
mbed_official | 76:aeb1df146756 | 107 | @endverbatim |
mbed_official | 76:aeb1df146756 | 108 | * |
mbed_official | 76:aeb1df146756 | 109 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 110 | * @attention |
mbed_official | 76:aeb1df146756 | 111 | * |
mbed_official | 106:ced8cbb51063 | 112 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 76:aeb1df146756 | 113 | * |
mbed_official | 106:ced8cbb51063 | 114 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 106:ced8cbb51063 | 115 | * are permitted provided that the following conditions are met: |
mbed_official | 106:ced8cbb51063 | 116 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 106:ced8cbb51063 | 117 | * this list of conditions and the following disclaimer. |
mbed_official | 106:ced8cbb51063 | 118 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 106:ced8cbb51063 | 119 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 106:ced8cbb51063 | 120 | * and/or other materials provided with the distribution. |
mbed_official | 106:ced8cbb51063 | 121 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 106:ced8cbb51063 | 122 | * may be used to endorse or promote products derived from this software |
mbed_official | 106:ced8cbb51063 | 123 | * without specific prior written permission. |
mbed_official | 76:aeb1df146756 | 124 | * |
mbed_official | 106:ced8cbb51063 | 125 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 106:ced8cbb51063 | 126 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 106:ced8cbb51063 | 127 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 106:ced8cbb51063 | 128 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 106:ced8cbb51063 | 129 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 106:ced8cbb51063 | 130 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 106:ced8cbb51063 | 131 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 106:ced8cbb51063 | 132 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 106:ced8cbb51063 | 133 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 106:ced8cbb51063 | 134 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 76:aeb1df146756 | 135 | * |
mbed_official | 76:aeb1df146756 | 136 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 137 | */ |
mbed_official | 76:aeb1df146756 | 138 | |
mbed_official | 76:aeb1df146756 | 139 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 140 | #include "stm32l1xx_sdio.h" |
mbed_official | 76:aeb1df146756 | 141 | #include "stm32l1xx_rcc.h" |
mbed_official | 76:aeb1df146756 | 142 | |
mbed_official | 76:aeb1df146756 | 143 | /** @addtogroup STM32L1xx_StdPeriph_Driver |
mbed_official | 76:aeb1df146756 | 144 | * @{ |
mbed_official | 76:aeb1df146756 | 145 | */ |
mbed_official | 76:aeb1df146756 | 146 | |
mbed_official | 76:aeb1df146756 | 147 | /** @defgroup SDIO |
mbed_official | 76:aeb1df146756 | 148 | * @brief SDIO driver modules |
mbed_official | 76:aeb1df146756 | 149 | * @{ |
mbed_official | 76:aeb1df146756 | 150 | */ |
mbed_official | 76:aeb1df146756 | 151 | |
mbed_official | 76:aeb1df146756 | 152 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 153 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 154 | |
mbed_official | 76:aeb1df146756 | 155 | /* ------------ SDIO registers bit address in the alias region ----------- */ |
mbed_official | 76:aeb1df146756 | 156 | #define SDIO_OFFSET (SDIO_BASE - PERIPH_BASE) |
mbed_official | 76:aeb1df146756 | 157 | |
mbed_official | 76:aeb1df146756 | 158 | /* --- CLKCR Register ---*/ |
mbed_official | 76:aeb1df146756 | 159 | |
mbed_official | 76:aeb1df146756 | 160 | /* Alias word address of CLKEN bit */ |
mbed_official | 76:aeb1df146756 | 161 | #define CLKCR_OFFSET (SDIO_OFFSET + 0x04) |
mbed_official | 76:aeb1df146756 | 162 | #define CLKEN_BitNumber 0x08 |
mbed_official | 76:aeb1df146756 | 163 | #define CLKCR_CLKEN_BB (PERIPH_BB_BASE + (CLKCR_OFFSET * 32) + (CLKEN_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 164 | |
mbed_official | 76:aeb1df146756 | 165 | /* --- CMD Register ---*/ |
mbed_official | 76:aeb1df146756 | 166 | |
mbed_official | 76:aeb1df146756 | 167 | /* Alias word address of SDIOSUSPEND bit */ |
mbed_official | 76:aeb1df146756 | 168 | #define CMD_OFFSET (SDIO_OFFSET + 0x0C) |
mbed_official | 76:aeb1df146756 | 169 | #define SDIOSUSPEND_BitNumber 0x0B |
mbed_official | 76:aeb1df146756 | 170 | #define CMD_SDIOSUSPEND_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (SDIOSUSPEND_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 171 | |
mbed_official | 76:aeb1df146756 | 172 | /* Alias word address of ENCMDCOMPL bit */ |
mbed_official | 76:aeb1df146756 | 173 | #define ENCMDCOMPL_BitNumber 0x0C |
mbed_official | 76:aeb1df146756 | 174 | #define CMD_ENCMDCOMPL_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ENCMDCOMPL_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 175 | |
mbed_official | 76:aeb1df146756 | 176 | /* Alias word address of NIEN bit */ |
mbed_official | 76:aeb1df146756 | 177 | #define NIEN_BitNumber 0x0D |
mbed_official | 76:aeb1df146756 | 178 | #define CMD_NIEN_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (NIEN_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 179 | |
mbed_official | 76:aeb1df146756 | 180 | /* Alias word address of ATACMD bit */ |
mbed_official | 76:aeb1df146756 | 181 | #define ATACMD_BitNumber 0x0E |
mbed_official | 76:aeb1df146756 | 182 | #define CMD_ATACMD_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ATACMD_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 183 | |
mbed_official | 76:aeb1df146756 | 184 | /* --- DCTRL Register ---*/ |
mbed_official | 76:aeb1df146756 | 185 | |
mbed_official | 76:aeb1df146756 | 186 | /* Alias word address of DMAEN bit */ |
mbed_official | 76:aeb1df146756 | 187 | #define DCTRL_OFFSET (SDIO_OFFSET + 0x2C) |
mbed_official | 76:aeb1df146756 | 188 | #define DMAEN_BitNumber 0x03 |
mbed_official | 76:aeb1df146756 | 189 | #define DCTRL_DMAEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (DMAEN_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 190 | |
mbed_official | 76:aeb1df146756 | 191 | /* Alias word address of RWSTART bit */ |
mbed_official | 76:aeb1df146756 | 192 | #define RWSTART_BitNumber 0x08 |
mbed_official | 76:aeb1df146756 | 193 | #define DCTRL_RWSTART_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTART_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 194 | |
mbed_official | 76:aeb1df146756 | 195 | /* Alias word address of RWSTOP bit */ |
mbed_official | 76:aeb1df146756 | 196 | #define RWSTOP_BitNumber 0x09 |
mbed_official | 76:aeb1df146756 | 197 | #define DCTRL_RWSTOP_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTOP_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 198 | |
mbed_official | 76:aeb1df146756 | 199 | /* Alias word address of RWMOD bit */ |
mbed_official | 76:aeb1df146756 | 200 | #define RWMOD_BitNumber 0x0A |
mbed_official | 76:aeb1df146756 | 201 | #define DCTRL_RWMOD_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWMOD_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 202 | |
mbed_official | 76:aeb1df146756 | 203 | /* Alias word address of SDIOEN bit */ |
mbed_official | 76:aeb1df146756 | 204 | #define SDIOEN_BitNumber 0x0B |
mbed_official | 76:aeb1df146756 | 205 | #define DCTRL_SDIOEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (SDIOEN_BitNumber * 4)) |
mbed_official | 76:aeb1df146756 | 206 | |
mbed_official | 76:aeb1df146756 | 207 | /* ---------------------- SDIO registers bit mask ------------------------ */ |
mbed_official | 76:aeb1df146756 | 208 | |
mbed_official | 76:aeb1df146756 | 209 | /* --- CLKCR Register ---*/ |
mbed_official | 76:aeb1df146756 | 210 | |
mbed_official | 76:aeb1df146756 | 211 | /* CLKCR register clear mask */ |
mbed_official | 76:aeb1df146756 | 212 | #define CLKCR_CLEAR_MASK ((uint32_t)0xFFFF8100) |
mbed_official | 76:aeb1df146756 | 213 | |
mbed_official | 76:aeb1df146756 | 214 | /* --- PWRCTRL Register ---*/ |
mbed_official | 76:aeb1df146756 | 215 | |
mbed_official | 76:aeb1df146756 | 216 | /* SDIO PWRCTRL Mask */ |
mbed_official | 76:aeb1df146756 | 217 | #define PWR_PWRCTRL_MASK ((uint32_t)0xFFFFFFFC) |
mbed_official | 76:aeb1df146756 | 218 | |
mbed_official | 76:aeb1df146756 | 219 | /* --- DCTRL Register ---*/ |
mbed_official | 76:aeb1df146756 | 220 | |
mbed_official | 76:aeb1df146756 | 221 | /* SDIO DCTRL Clear Mask */ |
mbed_official | 76:aeb1df146756 | 222 | #define DCTRL_CLEAR_MASK ((uint32_t)0xFFFFFF08) |
mbed_official | 76:aeb1df146756 | 223 | |
mbed_official | 76:aeb1df146756 | 224 | /* --- CMD Register ---*/ |
mbed_official | 76:aeb1df146756 | 225 | |
mbed_official | 76:aeb1df146756 | 226 | /* CMD Register clear mask */ |
mbed_official | 76:aeb1df146756 | 227 | #define CMD_CLEAR_MASK ((uint32_t)0xFFFFF800) |
mbed_official | 76:aeb1df146756 | 228 | |
mbed_official | 76:aeb1df146756 | 229 | /* SDIO RESP Registers Address */ |
mbed_official | 76:aeb1df146756 | 230 | #define SDIO_RESP_ADDR ((uint32_t)(SDIO_BASE + 0x14)) |
mbed_official | 76:aeb1df146756 | 231 | |
mbed_official | 76:aeb1df146756 | 232 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 233 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 234 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 235 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 236 | |
mbed_official | 76:aeb1df146756 | 237 | /** @defgroup SDIO_Private_Functions |
mbed_official | 76:aeb1df146756 | 238 | * @{ |
mbed_official | 76:aeb1df146756 | 239 | */ |
mbed_official | 76:aeb1df146756 | 240 | |
mbed_official | 76:aeb1df146756 | 241 | /** @defgroup SDIO_Group1 Initialization and Configuration functions |
mbed_official | 76:aeb1df146756 | 242 | * @brief Initialization and Configuration functions |
mbed_official | 76:aeb1df146756 | 243 | * |
mbed_official | 76:aeb1df146756 | 244 | @verbatim |
mbed_official | 76:aeb1df146756 | 245 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 246 | ##### Initialization and Configuration functions ##### |
mbed_official | 76:aeb1df146756 | 247 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 248 | |
mbed_official | 76:aeb1df146756 | 249 | @endverbatim |
mbed_official | 76:aeb1df146756 | 250 | * @{ |
mbed_official | 76:aeb1df146756 | 251 | */ |
mbed_official | 76:aeb1df146756 | 252 | |
mbed_official | 76:aeb1df146756 | 253 | /** |
mbed_official | 76:aeb1df146756 | 254 | * @brief Deinitializes the SDIO peripheral registers to their default reset values. |
mbed_official | 76:aeb1df146756 | 255 | * @param None |
mbed_official | 76:aeb1df146756 | 256 | * @retval None |
mbed_official | 76:aeb1df146756 | 257 | */ |
mbed_official | 76:aeb1df146756 | 258 | void SDIO_DeInit(void) |
mbed_official | 76:aeb1df146756 | 259 | { |
mbed_official | 76:aeb1df146756 | 260 | RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDIO, ENABLE); |
mbed_official | 76:aeb1df146756 | 261 | RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDIO, DISABLE); |
mbed_official | 76:aeb1df146756 | 262 | } |
mbed_official | 76:aeb1df146756 | 263 | |
mbed_official | 76:aeb1df146756 | 264 | /** |
mbed_official | 76:aeb1df146756 | 265 | * @brief Initializes the SDIO peripheral according to the specified |
mbed_official | 76:aeb1df146756 | 266 | * parameters in the SDIO_InitStruct. |
mbed_official | 76:aeb1df146756 | 267 | * @param SDIO_InitStruct : pointer to a SDIO_InitTypeDef structure |
mbed_official | 76:aeb1df146756 | 268 | * that contains the configuration information for the SDIO peripheral. |
mbed_official | 76:aeb1df146756 | 269 | * @retval None |
mbed_official | 76:aeb1df146756 | 270 | */ |
mbed_official | 76:aeb1df146756 | 271 | void SDIO_Init(SDIO_InitTypeDef* SDIO_InitStruct) |
mbed_official | 76:aeb1df146756 | 272 | { |
mbed_official | 76:aeb1df146756 | 273 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 274 | |
mbed_official | 76:aeb1df146756 | 275 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 276 | assert_param(IS_SDIO_CLOCK_EDGE(SDIO_InitStruct->SDIO_ClockEdge)); |
mbed_official | 76:aeb1df146756 | 277 | assert_param(IS_SDIO_CLOCK_BYPASS(SDIO_InitStruct->SDIO_ClockBypass)); |
mbed_official | 76:aeb1df146756 | 278 | assert_param(IS_SDIO_CLOCK_POWER_SAVE(SDIO_InitStruct->SDIO_ClockPowerSave)); |
mbed_official | 76:aeb1df146756 | 279 | assert_param(IS_SDIO_BUS_WIDE(SDIO_InitStruct->SDIO_BusWide)); |
mbed_official | 76:aeb1df146756 | 280 | assert_param(IS_SDIO_HARDWARE_FLOW_CONTROL(SDIO_InitStruct->SDIO_HardwareFlowControl)); |
mbed_official | 76:aeb1df146756 | 281 | |
mbed_official | 76:aeb1df146756 | 282 | /*---------------------------- SDIO CLKCR Configuration ------------------------*/ |
mbed_official | 76:aeb1df146756 | 283 | /* Get the SDIO CLKCR value */ |
mbed_official | 76:aeb1df146756 | 284 | tmpreg = SDIO->CLKCR; |
mbed_official | 76:aeb1df146756 | 285 | |
mbed_official | 76:aeb1df146756 | 286 | /* Clear CLKDIV, PWRSAV, BYPASS, WIDBUS, NEGEDGE, HWFC_EN bits */ |
mbed_official | 76:aeb1df146756 | 287 | tmpreg &= CLKCR_CLEAR_MASK; |
mbed_official | 76:aeb1df146756 | 288 | |
mbed_official | 76:aeb1df146756 | 289 | /* Set CLKDIV bits according to SDIO_ClockDiv value */ |
mbed_official | 76:aeb1df146756 | 290 | /* Set PWRSAV bit according to SDIO_ClockPowerSave value */ |
mbed_official | 76:aeb1df146756 | 291 | /* Set BYPASS bit according to SDIO_ClockBypass value */ |
mbed_official | 76:aeb1df146756 | 292 | /* Set WIDBUS bits according to SDIO_BusWide value */ |
mbed_official | 76:aeb1df146756 | 293 | /* Set NEGEDGE bits according to SDIO_ClockEdge value */ |
mbed_official | 76:aeb1df146756 | 294 | /* Set HWFC_EN bits according to SDIO_HardwareFlowControl value */ |
mbed_official | 76:aeb1df146756 | 295 | tmpreg |= (SDIO_InitStruct->SDIO_ClockDiv | SDIO_InitStruct->SDIO_ClockPowerSave | |
mbed_official | 76:aeb1df146756 | 296 | SDIO_InitStruct->SDIO_ClockBypass | SDIO_InitStruct->SDIO_BusWide | |
mbed_official | 76:aeb1df146756 | 297 | SDIO_InitStruct->SDIO_ClockEdge | SDIO_InitStruct->SDIO_HardwareFlowControl); |
mbed_official | 76:aeb1df146756 | 298 | |
mbed_official | 76:aeb1df146756 | 299 | /* Write to SDIO CLKCR */ |
mbed_official | 76:aeb1df146756 | 300 | SDIO->CLKCR = tmpreg; |
mbed_official | 76:aeb1df146756 | 301 | } |
mbed_official | 76:aeb1df146756 | 302 | |
mbed_official | 76:aeb1df146756 | 303 | /** |
mbed_official | 76:aeb1df146756 | 304 | * @brief Fills each SDIO_InitStruct member with its default value. |
mbed_official | 76:aeb1df146756 | 305 | * @param SDIO_InitStruct: pointer to an SDIO_InitTypeDef structure which |
mbed_official | 76:aeb1df146756 | 306 | * will be initialized. |
mbed_official | 76:aeb1df146756 | 307 | * @retval None |
mbed_official | 76:aeb1df146756 | 308 | */ |
mbed_official | 76:aeb1df146756 | 309 | void SDIO_StructInit(SDIO_InitTypeDef* SDIO_InitStruct) |
mbed_official | 76:aeb1df146756 | 310 | { |
mbed_official | 76:aeb1df146756 | 311 | /* SDIO_InitStruct members default value */ |
mbed_official | 76:aeb1df146756 | 312 | SDIO_InitStruct->SDIO_ClockDiv = 0x00; |
mbed_official | 76:aeb1df146756 | 313 | SDIO_InitStruct->SDIO_ClockEdge = SDIO_ClockEdge_Rising; |
mbed_official | 76:aeb1df146756 | 314 | SDIO_InitStruct->SDIO_ClockBypass = SDIO_ClockBypass_Disable; |
mbed_official | 76:aeb1df146756 | 315 | SDIO_InitStruct->SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable; |
mbed_official | 76:aeb1df146756 | 316 | SDIO_InitStruct->SDIO_BusWide = SDIO_BusWide_1b; |
mbed_official | 76:aeb1df146756 | 317 | SDIO_InitStruct->SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable; |
mbed_official | 76:aeb1df146756 | 318 | } |
mbed_official | 76:aeb1df146756 | 319 | |
mbed_official | 76:aeb1df146756 | 320 | /** |
mbed_official | 76:aeb1df146756 | 321 | * @brief Enables or disables the SDIO Clock. |
mbed_official | 76:aeb1df146756 | 322 | * @param NewState: new state of the SDIO Clock. This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 323 | * @retval None |
mbed_official | 76:aeb1df146756 | 324 | */ |
mbed_official | 76:aeb1df146756 | 325 | void SDIO_ClockCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 326 | { |
mbed_official | 76:aeb1df146756 | 327 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 328 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 329 | |
mbed_official | 76:aeb1df146756 | 330 | *(__IO uint32_t *) CLKCR_CLKEN_BB = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 331 | } |
mbed_official | 76:aeb1df146756 | 332 | |
mbed_official | 76:aeb1df146756 | 333 | /** |
mbed_official | 76:aeb1df146756 | 334 | * @brief Sets the power status of the controller. |
mbed_official | 76:aeb1df146756 | 335 | * @param SDIO_PowerState: new state of the Power state. |
mbed_official | 76:aeb1df146756 | 336 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 337 | * @arg SDIO_PowerState_OFF: SDIO Power OFF. |
mbed_official | 76:aeb1df146756 | 338 | * @arg SDIO_PowerState_ON: SDIO Power ON. |
mbed_official | 76:aeb1df146756 | 339 | * @retval None |
mbed_official | 76:aeb1df146756 | 340 | */ |
mbed_official | 76:aeb1df146756 | 341 | void SDIO_SetPowerState(uint32_t SDIO_PowerState) |
mbed_official | 76:aeb1df146756 | 342 | { |
mbed_official | 76:aeb1df146756 | 343 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 344 | assert_param(IS_SDIO_POWER_STATE(SDIO_PowerState)); |
mbed_official | 76:aeb1df146756 | 345 | |
mbed_official | 76:aeb1df146756 | 346 | SDIO->POWER = SDIO_PowerState; |
mbed_official | 76:aeb1df146756 | 347 | } |
mbed_official | 76:aeb1df146756 | 348 | |
mbed_official | 76:aeb1df146756 | 349 | /** |
mbed_official | 76:aeb1df146756 | 350 | * @brief Gets the power status of the controller. |
mbed_official | 76:aeb1df146756 | 351 | * @param None |
mbed_official | 76:aeb1df146756 | 352 | * @retval Power status of the controller. The returned value can |
mbed_official | 76:aeb1df146756 | 353 | * be one of the following: |
mbed_official | 76:aeb1df146756 | 354 | * - 0x00: Power OFF |
mbed_official | 76:aeb1df146756 | 355 | * - 0x02: Power UP |
mbed_official | 76:aeb1df146756 | 356 | * - 0x03: Power ON |
mbed_official | 76:aeb1df146756 | 357 | */ |
mbed_official | 76:aeb1df146756 | 358 | uint32_t SDIO_GetPowerState(void) |
mbed_official | 76:aeb1df146756 | 359 | { |
mbed_official | 76:aeb1df146756 | 360 | return (SDIO->POWER & (~PWR_PWRCTRL_MASK)); |
mbed_official | 76:aeb1df146756 | 361 | } |
mbed_official | 76:aeb1df146756 | 362 | |
mbed_official | 76:aeb1df146756 | 363 | /** |
mbed_official | 76:aeb1df146756 | 364 | * @} |
mbed_official | 76:aeb1df146756 | 365 | */ |
mbed_official | 76:aeb1df146756 | 366 | |
mbed_official | 76:aeb1df146756 | 367 | /** @defgroup SDIO_Group2 DMA transfers management functions |
mbed_official | 76:aeb1df146756 | 368 | * @brief DMA transfers management functions |
mbed_official | 76:aeb1df146756 | 369 | * |
mbed_official | 76:aeb1df146756 | 370 | @verbatim |
mbed_official | 76:aeb1df146756 | 371 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 372 | ##### DMA transfers management functions ##### |
mbed_official | 76:aeb1df146756 | 373 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 374 | [..] This section provide functions allowing to program SDIO DMA transfer. |
mbed_official | 76:aeb1df146756 | 375 | |
mbed_official | 76:aeb1df146756 | 376 | @endverbatim |
mbed_official | 76:aeb1df146756 | 377 | * @{ |
mbed_official | 76:aeb1df146756 | 378 | */ |
mbed_official | 76:aeb1df146756 | 379 | |
mbed_official | 76:aeb1df146756 | 380 | /** |
mbed_official | 76:aeb1df146756 | 381 | * @brief Enables or disables the SDIO DMA request. |
mbed_official | 76:aeb1df146756 | 382 | * @param NewState: new state of the selected SDIO DMA request. |
mbed_official | 76:aeb1df146756 | 383 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 384 | * @retval None |
mbed_official | 76:aeb1df146756 | 385 | */ |
mbed_official | 76:aeb1df146756 | 386 | void SDIO_DMACmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 387 | { |
mbed_official | 76:aeb1df146756 | 388 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 389 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 390 | |
mbed_official | 76:aeb1df146756 | 391 | *(__IO uint32_t *) DCTRL_DMAEN_BB = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 392 | } |
mbed_official | 76:aeb1df146756 | 393 | |
mbed_official | 76:aeb1df146756 | 394 | /** |
mbed_official | 76:aeb1df146756 | 395 | * @} |
mbed_official | 76:aeb1df146756 | 396 | */ |
mbed_official | 76:aeb1df146756 | 397 | |
mbed_official | 76:aeb1df146756 | 398 | /** @defgroup SDIO_Group3 Command path state machine (CPSM) management functions |
mbed_official | 76:aeb1df146756 | 399 | * @brief Command path state machine (CPSM) management functions |
mbed_official | 76:aeb1df146756 | 400 | * |
mbed_official | 76:aeb1df146756 | 401 | @verbatim |
mbed_official | 76:aeb1df146756 | 402 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 403 | ##### Command path state machine (CPSM) management functions ##### |
mbed_official | 76:aeb1df146756 | 404 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 405 | [..] This section provide functions allowing to program and read the Command |
mbed_official | 76:aeb1df146756 | 406 | path state machine (CPSM). |
mbed_official | 76:aeb1df146756 | 407 | |
mbed_official | 76:aeb1df146756 | 408 | @endverbatim |
mbed_official | 76:aeb1df146756 | 409 | * @{ |
mbed_official | 76:aeb1df146756 | 410 | */ |
mbed_official | 76:aeb1df146756 | 411 | |
mbed_official | 76:aeb1df146756 | 412 | /** |
mbed_official | 76:aeb1df146756 | 413 | * @brief Initializes the SDIO Command according to the specified |
mbed_official | 76:aeb1df146756 | 414 | * parameters in the SDIO_CmdInitStruct and send the command. |
mbed_official | 76:aeb1df146756 | 415 | * @param SDIO_CmdInitStruct : pointer to a SDIO_CmdInitTypeDef |
mbed_official | 76:aeb1df146756 | 416 | * structure that contains the configuration information for the SDIO command. |
mbed_official | 76:aeb1df146756 | 417 | * @retval None |
mbed_official | 76:aeb1df146756 | 418 | */ |
mbed_official | 76:aeb1df146756 | 419 | void SDIO_SendCommand(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct) |
mbed_official | 76:aeb1df146756 | 420 | { |
mbed_official | 76:aeb1df146756 | 421 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 422 | |
mbed_official | 76:aeb1df146756 | 423 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 424 | assert_param(IS_SDIO_CMD_INDEX(SDIO_CmdInitStruct->SDIO_CmdIndex)); |
mbed_official | 76:aeb1df146756 | 425 | assert_param(IS_SDIO_RESPONSE(SDIO_CmdInitStruct->SDIO_Response)); |
mbed_official | 76:aeb1df146756 | 426 | assert_param(IS_SDIO_WAIT(SDIO_CmdInitStruct->SDIO_Wait)); |
mbed_official | 76:aeb1df146756 | 427 | assert_param(IS_SDIO_CPSM(SDIO_CmdInitStruct->SDIO_CPSM)); |
mbed_official | 76:aeb1df146756 | 428 | |
mbed_official | 76:aeb1df146756 | 429 | /*---------------------------- SDIO ARG Configuration ------------------------*/ |
mbed_official | 76:aeb1df146756 | 430 | /* Set the SDIO Argument value */ |
mbed_official | 76:aeb1df146756 | 431 | SDIO->ARG = SDIO_CmdInitStruct->SDIO_Argument; |
mbed_official | 76:aeb1df146756 | 432 | |
mbed_official | 76:aeb1df146756 | 433 | /*---------------------------- SDIO CMD Configuration ------------------------*/ |
mbed_official | 76:aeb1df146756 | 434 | /* Get the SDIO CMD value */ |
mbed_official | 76:aeb1df146756 | 435 | tmpreg = SDIO->CMD; |
mbed_official | 76:aeb1df146756 | 436 | /* Clear CMDINDEX, WAITRESP, WAITINT, WAITPEND, CPSMEN bits */ |
mbed_official | 76:aeb1df146756 | 437 | tmpreg &= CMD_CLEAR_MASK; |
mbed_official | 76:aeb1df146756 | 438 | /* Set CMDINDEX bits according to SDIO_CmdIndex value */ |
mbed_official | 76:aeb1df146756 | 439 | /* Set WAITRESP bits according to SDIO_Response value */ |
mbed_official | 76:aeb1df146756 | 440 | /* Set WAITINT and WAITPEND bits according to SDIO_Wait value */ |
mbed_official | 76:aeb1df146756 | 441 | /* Set CPSMEN bits according to SDIO_CPSM value */ |
mbed_official | 76:aeb1df146756 | 442 | tmpreg |= (uint32_t)SDIO_CmdInitStruct->SDIO_CmdIndex | SDIO_CmdInitStruct->SDIO_Response |
mbed_official | 76:aeb1df146756 | 443 | | SDIO_CmdInitStruct->SDIO_Wait | SDIO_CmdInitStruct->SDIO_CPSM; |
mbed_official | 76:aeb1df146756 | 444 | |
mbed_official | 76:aeb1df146756 | 445 | /* Write to SDIO CMD */ |
mbed_official | 76:aeb1df146756 | 446 | SDIO->CMD = tmpreg; |
mbed_official | 76:aeb1df146756 | 447 | } |
mbed_official | 76:aeb1df146756 | 448 | |
mbed_official | 76:aeb1df146756 | 449 | /** |
mbed_official | 76:aeb1df146756 | 450 | * @brief Fills each SDIO_CmdInitStruct member with its default value. |
mbed_official | 76:aeb1df146756 | 451 | * @param SDIO_CmdInitStruct: pointer to an SDIO_CmdInitTypeDef |
mbed_official | 76:aeb1df146756 | 452 | * structure which will be initialized. |
mbed_official | 76:aeb1df146756 | 453 | * @retval None |
mbed_official | 76:aeb1df146756 | 454 | */ |
mbed_official | 76:aeb1df146756 | 455 | void SDIO_CmdStructInit(SDIO_CmdInitTypeDef* SDIO_CmdInitStruct) |
mbed_official | 76:aeb1df146756 | 456 | { |
mbed_official | 76:aeb1df146756 | 457 | /* SDIO_CmdInitStruct members default value */ |
mbed_official | 76:aeb1df146756 | 458 | SDIO_CmdInitStruct->SDIO_Argument = 0x00; |
mbed_official | 76:aeb1df146756 | 459 | SDIO_CmdInitStruct->SDIO_CmdIndex = 0x00; |
mbed_official | 76:aeb1df146756 | 460 | SDIO_CmdInitStruct->SDIO_Response = SDIO_Response_No; |
mbed_official | 76:aeb1df146756 | 461 | SDIO_CmdInitStruct->SDIO_Wait = SDIO_Wait_No; |
mbed_official | 76:aeb1df146756 | 462 | SDIO_CmdInitStruct->SDIO_CPSM = SDIO_CPSM_Disable; |
mbed_official | 76:aeb1df146756 | 463 | } |
mbed_official | 76:aeb1df146756 | 464 | |
mbed_official | 76:aeb1df146756 | 465 | /** |
mbed_official | 76:aeb1df146756 | 466 | * @brief Returns command index of last command for which response received. |
mbed_official | 76:aeb1df146756 | 467 | * @param None |
mbed_official | 76:aeb1df146756 | 468 | * @retval Returns the command index of the last command response received. |
mbed_official | 76:aeb1df146756 | 469 | */ |
mbed_official | 76:aeb1df146756 | 470 | uint8_t SDIO_GetCommandResponse(void) |
mbed_official | 76:aeb1df146756 | 471 | { |
mbed_official | 76:aeb1df146756 | 472 | return (uint8_t)(SDIO->RESPCMD); |
mbed_official | 76:aeb1df146756 | 473 | } |
mbed_official | 76:aeb1df146756 | 474 | |
mbed_official | 76:aeb1df146756 | 475 | /** |
mbed_official | 76:aeb1df146756 | 476 | * @brief Returns response received from the card for the last command. |
mbed_official | 76:aeb1df146756 | 477 | * @param SDIO_RESP: Specifies the SDIO response register. |
mbed_official | 76:aeb1df146756 | 478 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 479 | * @arg SDIO_RESP1: Response Register 1. |
mbed_official | 76:aeb1df146756 | 480 | * @arg SDIO_RESP2: Response Register 2. |
mbed_official | 76:aeb1df146756 | 481 | * @arg SDIO_RESP3: Response Register 3. |
mbed_official | 76:aeb1df146756 | 482 | * @arg SDIO_RESP4: Response Register 4. |
mbed_official | 76:aeb1df146756 | 483 | * @retval The Corresponding response register value. |
mbed_official | 76:aeb1df146756 | 484 | */ |
mbed_official | 76:aeb1df146756 | 485 | uint32_t SDIO_GetResponse(uint32_t SDIO_RESP) |
mbed_official | 76:aeb1df146756 | 486 | { |
mbed_official | 76:aeb1df146756 | 487 | __IO uint32_t tmp = 0; |
mbed_official | 76:aeb1df146756 | 488 | |
mbed_official | 76:aeb1df146756 | 489 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 490 | assert_param(IS_SDIO_RESP(SDIO_RESP)); |
mbed_official | 76:aeb1df146756 | 491 | |
mbed_official | 76:aeb1df146756 | 492 | tmp = SDIO_RESP_ADDR + SDIO_RESP; |
mbed_official | 76:aeb1df146756 | 493 | |
mbed_official | 76:aeb1df146756 | 494 | return (*(__IO uint32_t *) tmp); |
mbed_official | 76:aeb1df146756 | 495 | } |
mbed_official | 76:aeb1df146756 | 496 | |
mbed_official | 76:aeb1df146756 | 497 | /** |
mbed_official | 76:aeb1df146756 | 498 | * @} |
mbed_official | 76:aeb1df146756 | 499 | */ |
mbed_official | 76:aeb1df146756 | 500 | |
mbed_official | 76:aeb1df146756 | 501 | /** @defgroup SDIO_Group4 Data path state machine (DPSM) management functions |
mbed_official | 76:aeb1df146756 | 502 | * @brief Data path state machine (DPSM) management functions |
mbed_official | 76:aeb1df146756 | 503 | * |
mbed_official | 76:aeb1df146756 | 504 | @verbatim |
mbed_official | 76:aeb1df146756 | 505 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 506 | ##### Data path state machine (DPSM) management functions ##### |
mbed_official | 76:aeb1df146756 | 507 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 508 | [..] This section provide functions allowing to program and read the Data path |
mbed_official | 76:aeb1df146756 | 509 | state machine (DPSM). |
mbed_official | 76:aeb1df146756 | 510 | |
mbed_official | 76:aeb1df146756 | 511 | @endverbatim |
mbed_official | 76:aeb1df146756 | 512 | * @{ |
mbed_official | 76:aeb1df146756 | 513 | */ |
mbed_official | 76:aeb1df146756 | 514 | |
mbed_official | 76:aeb1df146756 | 515 | /** |
mbed_official | 76:aeb1df146756 | 516 | * @brief Initializes the SDIO data path according to the specified |
mbed_official | 76:aeb1df146756 | 517 | * parameters in the SDIO_DataInitStruct. |
mbed_official | 76:aeb1df146756 | 518 | * @param SDIO_DataInitStruct : pointer to a SDIO_DataInitTypeDef structure that |
mbed_official | 76:aeb1df146756 | 519 | * contains the configuration information for the SDIO command. |
mbed_official | 76:aeb1df146756 | 520 | * @retval None |
mbed_official | 76:aeb1df146756 | 521 | */ |
mbed_official | 76:aeb1df146756 | 522 | void SDIO_DataConfig(SDIO_DataInitTypeDef* SDIO_DataInitStruct) |
mbed_official | 76:aeb1df146756 | 523 | { |
mbed_official | 76:aeb1df146756 | 524 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 525 | |
mbed_official | 76:aeb1df146756 | 526 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 527 | assert_param(IS_SDIO_DATA_LENGTH(SDIO_DataInitStruct->SDIO_DataLength)); |
mbed_official | 76:aeb1df146756 | 528 | assert_param(IS_SDIO_BLOCK_SIZE(SDIO_DataInitStruct->SDIO_DataBlockSize)); |
mbed_official | 76:aeb1df146756 | 529 | assert_param(IS_SDIO_TRANSFER_DIR(SDIO_DataInitStruct->SDIO_TransferDir)); |
mbed_official | 76:aeb1df146756 | 530 | assert_param(IS_SDIO_TRANSFER_MODE(SDIO_DataInitStruct->SDIO_TransferMode)); |
mbed_official | 76:aeb1df146756 | 531 | assert_param(IS_SDIO_DPSM(SDIO_DataInitStruct->SDIO_DPSM)); |
mbed_official | 76:aeb1df146756 | 532 | |
mbed_official | 76:aeb1df146756 | 533 | /*---------------------------- SDIO DTIMER Configuration ---------------------*/ |
mbed_official | 76:aeb1df146756 | 534 | /* Set the SDIO Data TimeOut value */ |
mbed_official | 76:aeb1df146756 | 535 | SDIO->DTIMER = SDIO_DataInitStruct->SDIO_DataTimeOut; |
mbed_official | 76:aeb1df146756 | 536 | |
mbed_official | 76:aeb1df146756 | 537 | /*---------------------------- SDIO DLEN Configuration -----------------------*/ |
mbed_official | 76:aeb1df146756 | 538 | /* Set the SDIO DataLength value */ |
mbed_official | 76:aeb1df146756 | 539 | SDIO->DLEN = SDIO_DataInitStruct->SDIO_DataLength; |
mbed_official | 76:aeb1df146756 | 540 | |
mbed_official | 76:aeb1df146756 | 541 | /*---------------------------- SDIO DCTRL Configuration ----------------------*/ |
mbed_official | 76:aeb1df146756 | 542 | /* Get the SDIO DCTRL value */ |
mbed_official | 76:aeb1df146756 | 543 | tmpreg = SDIO->DCTRL; |
mbed_official | 76:aeb1df146756 | 544 | /* Clear DEN, DTMODE, DTDIR and DBCKSIZE bits */ |
mbed_official | 76:aeb1df146756 | 545 | tmpreg &= DCTRL_CLEAR_MASK; |
mbed_official | 76:aeb1df146756 | 546 | /* Set DEN bit according to SDIO_DPSM value */ |
mbed_official | 76:aeb1df146756 | 547 | /* Set DTMODE bit according to SDIO_TransferMode value */ |
mbed_official | 76:aeb1df146756 | 548 | /* Set DTDIR bit according to SDIO_TransferDir value */ |
mbed_official | 76:aeb1df146756 | 549 | /* Set DBCKSIZE bits according to SDIO_DataBlockSize value */ |
mbed_official | 76:aeb1df146756 | 550 | tmpreg |= (uint32_t)SDIO_DataInitStruct->SDIO_DataBlockSize | SDIO_DataInitStruct->SDIO_TransferDir |
mbed_official | 76:aeb1df146756 | 551 | | SDIO_DataInitStruct->SDIO_TransferMode | SDIO_DataInitStruct->SDIO_DPSM; |
mbed_official | 76:aeb1df146756 | 552 | |
mbed_official | 76:aeb1df146756 | 553 | /* Write to SDIO DCTRL */ |
mbed_official | 76:aeb1df146756 | 554 | SDIO->DCTRL = tmpreg; |
mbed_official | 76:aeb1df146756 | 555 | } |
mbed_official | 76:aeb1df146756 | 556 | |
mbed_official | 76:aeb1df146756 | 557 | /** |
mbed_official | 76:aeb1df146756 | 558 | * @brief Fills each SDIO_DataInitStruct member with its default value. |
mbed_official | 76:aeb1df146756 | 559 | * @param SDIO_DataInitStruct: pointer to an SDIO_DataInitTypeDef structure which |
mbed_official | 76:aeb1df146756 | 560 | * will be initialized. |
mbed_official | 76:aeb1df146756 | 561 | * @retval None |
mbed_official | 76:aeb1df146756 | 562 | */ |
mbed_official | 76:aeb1df146756 | 563 | void SDIO_DataStructInit(SDIO_DataInitTypeDef* SDIO_DataInitStruct) |
mbed_official | 76:aeb1df146756 | 564 | { |
mbed_official | 76:aeb1df146756 | 565 | /* SDIO_DataInitStruct members default value */ |
mbed_official | 76:aeb1df146756 | 566 | SDIO_DataInitStruct->SDIO_DataTimeOut = 0xFFFFFFFF; |
mbed_official | 76:aeb1df146756 | 567 | SDIO_DataInitStruct->SDIO_DataLength = 0x00; |
mbed_official | 76:aeb1df146756 | 568 | SDIO_DataInitStruct->SDIO_DataBlockSize = SDIO_DataBlockSize_1b; |
mbed_official | 76:aeb1df146756 | 569 | SDIO_DataInitStruct->SDIO_TransferDir = SDIO_TransferDir_ToCard; |
mbed_official | 76:aeb1df146756 | 570 | SDIO_DataInitStruct->SDIO_TransferMode = SDIO_TransferMode_Block; |
mbed_official | 76:aeb1df146756 | 571 | SDIO_DataInitStruct->SDIO_DPSM = SDIO_DPSM_Disable; |
mbed_official | 76:aeb1df146756 | 572 | } |
mbed_official | 76:aeb1df146756 | 573 | |
mbed_official | 76:aeb1df146756 | 574 | /** |
mbed_official | 76:aeb1df146756 | 575 | * @brief Returns number of remaining data bytes to be transferred. |
mbed_official | 76:aeb1df146756 | 576 | * @param None |
mbed_official | 76:aeb1df146756 | 577 | * @retval Number of remaining data bytes to be transferred |
mbed_official | 76:aeb1df146756 | 578 | */ |
mbed_official | 76:aeb1df146756 | 579 | uint32_t SDIO_GetDataCounter(void) |
mbed_official | 76:aeb1df146756 | 580 | { |
mbed_official | 76:aeb1df146756 | 581 | return SDIO->DCOUNT; |
mbed_official | 76:aeb1df146756 | 582 | } |
mbed_official | 76:aeb1df146756 | 583 | |
mbed_official | 76:aeb1df146756 | 584 | /** |
mbed_official | 76:aeb1df146756 | 585 | * @brief Read one data word from Rx FIFO. |
mbed_official | 76:aeb1df146756 | 586 | * @param None |
mbed_official | 76:aeb1df146756 | 587 | * @retval Data received |
mbed_official | 76:aeb1df146756 | 588 | */ |
mbed_official | 76:aeb1df146756 | 589 | uint32_t SDIO_ReadData(void) |
mbed_official | 76:aeb1df146756 | 590 | { |
mbed_official | 76:aeb1df146756 | 591 | return SDIO->FIFO; |
mbed_official | 76:aeb1df146756 | 592 | } |
mbed_official | 76:aeb1df146756 | 593 | |
mbed_official | 76:aeb1df146756 | 594 | /** |
mbed_official | 76:aeb1df146756 | 595 | * @brief Write one data word to Tx FIFO. |
mbed_official | 76:aeb1df146756 | 596 | * @param Data: 32-bit data word to write. |
mbed_official | 76:aeb1df146756 | 597 | * @retval None |
mbed_official | 76:aeb1df146756 | 598 | */ |
mbed_official | 76:aeb1df146756 | 599 | void SDIO_WriteData(uint32_t Data) |
mbed_official | 76:aeb1df146756 | 600 | { |
mbed_official | 76:aeb1df146756 | 601 | SDIO->FIFO = Data; |
mbed_official | 76:aeb1df146756 | 602 | } |
mbed_official | 76:aeb1df146756 | 603 | |
mbed_official | 76:aeb1df146756 | 604 | /** |
mbed_official | 76:aeb1df146756 | 605 | * @brief Returns the number of words left to be written to or read from FIFO. |
mbed_official | 76:aeb1df146756 | 606 | * @param None |
mbed_official | 76:aeb1df146756 | 607 | * @retval Remaining number of words. |
mbed_official | 76:aeb1df146756 | 608 | */ |
mbed_official | 76:aeb1df146756 | 609 | uint32_t SDIO_GetFIFOCount(void) |
mbed_official | 76:aeb1df146756 | 610 | { |
mbed_official | 76:aeb1df146756 | 611 | return SDIO->FIFOCNT; |
mbed_official | 76:aeb1df146756 | 612 | } |
mbed_official | 76:aeb1df146756 | 613 | |
mbed_official | 76:aeb1df146756 | 614 | /** |
mbed_official | 76:aeb1df146756 | 615 | * @} |
mbed_official | 76:aeb1df146756 | 616 | */ |
mbed_official | 76:aeb1df146756 | 617 | |
mbed_official | 76:aeb1df146756 | 618 | /** @defgroup SDIO_Group5 SDIO IO Cards mode management functions |
mbed_official | 76:aeb1df146756 | 619 | * @brief SDIO IO Cards mode management functions |
mbed_official | 76:aeb1df146756 | 620 | * |
mbed_official | 76:aeb1df146756 | 621 | @verbatim |
mbed_official | 76:aeb1df146756 | 622 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 623 | ##### SDIO IO Cards mode management functions ##### |
mbed_official | 76:aeb1df146756 | 624 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 625 | [..] This section provide functions allowing to program and read the SDIO IO |
mbed_official | 76:aeb1df146756 | 626 | Cards. |
mbed_official | 76:aeb1df146756 | 627 | |
mbed_official | 76:aeb1df146756 | 628 | @endverbatim |
mbed_official | 76:aeb1df146756 | 629 | * @{ |
mbed_official | 76:aeb1df146756 | 630 | */ |
mbed_official | 76:aeb1df146756 | 631 | |
mbed_official | 76:aeb1df146756 | 632 | /** |
mbed_official | 76:aeb1df146756 | 633 | * @brief Starts the SD I/O Read Wait operation. |
mbed_official | 76:aeb1df146756 | 634 | * @param NewState: new state of the Start SDIO Read Wait operation. |
mbed_official | 76:aeb1df146756 | 635 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 636 | * @retval None |
mbed_official | 76:aeb1df146756 | 637 | */ |
mbed_official | 76:aeb1df146756 | 638 | void SDIO_StartSDIOReadWait(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 639 | { |
mbed_official | 76:aeb1df146756 | 640 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 641 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 642 | |
mbed_official | 76:aeb1df146756 | 643 | *(__IO uint32_t *) DCTRL_RWSTART_BB = (uint32_t) NewState; |
mbed_official | 76:aeb1df146756 | 644 | } |
mbed_official | 76:aeb1df146756 | 645 | |
mbed_official | 76:aeb1df146756 | 646 | /** |
mbed_official | 76:aeb1df146756 | 647 | * @brief Stops the SD I/O Read Wait operation. |
mbed_official | 76:aeb1df146756 | 648 | * @param NewState: new state of the Stop SDIO Read Wait operation. |
mbed_official | 76:aeb1df146756 | 649 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 650 | * @retval None |
mbed_official | 76:aeb1df146756 | 651 | */ |
mbed_official | 76:aeb1df146756 | 652 | void SDIO_StopSDIOReadWait(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 653 | { |
mbed_official | 76:aeb1df146756 | 654 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 655 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 656 | |
mbed_official | 76:aeb1df146756 | 657 | *(__IO uint32_t *) DCTRL_RWSTOP_BB = (uint32_t) NewState; |
mbed_official | 76:aeb1df146756 | 658 | } |
mbed_official | 76:aeb1df146756 | 659 | |
mbed_official | 76:aeb1df146756 | 660 | /** |
mbed_official | 76:aeb1df146756 | 661 | * @brief Sets one of the two options of inserting read wait interval. |
mbed_official | 76:aeb1df146756 | 662 | * @param SDIO_ReadWaitMode: SD I/O Read Wait operation mode. |
mbed_official | 76:aeb1df146756 | 663 | * This parametre can be: |
mbed_official | 76:aeb1df146756 | 664 | * @arg SDIO_ReadWaitMode_CLK: Read Wait control by stopping SDIOCLK. |
mbed_official | 76:aeb1df146756 | 665 | * @arg SDIO_ReadWaitMode_DATA2: Read Wait control using SDIO_DATA2. |
mbed_official | 76:aeb1df146756 | 666 | * @retval None |
mbed_official | 76:aeb1df146756 | 667 | */ |
mbed_official | 76:aeb1df146756 | 668 | void SDIO_SetSDIOReadWaitMode(uint32_t SDIO_ReadWaitMode) |
mbed_official | 76:aeb1df146756 | 669 | { |
mbed_official | 76:aeb1df146756 | 670 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 671 | assert_param(IS_SDIO_READWAIT_MODE(SDIO_ReadWaitMode)); |
mbed_official | 76:aeb1df146756 | 672 | |
mbed_official | 76:aeb1df146756 | 673 | *(__IO uint32_t *) DCTRL_RWMOD_BB = SDIO_ReadWaitMode; |
mbed_official | 76:aeb1df146756 | 674 | } |
mbed_official | 76:aeb1df146756 | 675 | |
mbed_official | 76:aeb1df146756 | 676 | /** |
mbed_official | 76:aeb1df146756 | 677 | * @brief Enables or disables the SD I/O Mode Operation. |
mbed_official | 76:aeb1df146756 | 678 | * @param NewState: new state of SDIO specific operation. |
mbed_official | 76:aeb1df146756 | 679 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 680 | * @retval None |
mbed_official | 76:aeb1df146756 | 681 | */ |
mbed_official | 76:aeb1df146756 | 682 | void SDIO_SetSDIOOperation(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 683 | { |
mbed_official | 76:aeb1df146756 | 684 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 685 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 686 | |
mbed_official | 76:aeb1df146756 | 687 | *(__IO uint32_t *) DCTRL_SDIOEN_BB = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 688 | } |
mbed_official | 76:aeb1df146756 | 689 | |
mbed_official | 76:aeb1df146756 | 690 | /** |
mbed_official | 76:aeb1df146756 | 691 | * @brief Enables or disables the SD I/O Mode suspend command sending. |
mbed_official | 76:aeb1df146756 | 692 | * @param NewState: new state of the SD I/O Mode suspend command. |
mbed_official | 76:aeb1df146756 | 693 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 694 | * @retval None |
mbed_official | 76:aeb1df146756 | 695 | */ |
mbed_official | 76:aeb1df146756 | 696 | void SDIO_SendSDIOSuspendCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 697 | { |
mbed_official | 76:aeb1df146756 | 698 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 699 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 700 | |
mbed_official | 76:aeb1df146756 | 701 | *(__IO uint32_t *) CMD_SDIOSUSPEND_BB = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 702 | } |
mbed_official | 76:aeb1df146756 | 703 | |
mbed_official | 76:aeb1df146756 | 704 | /** |
mbed_official | 76:aeb1df146756 | 705 | * @} |
mbed_official | 76:aeb1df146756 | 706 | */ |
mbed_official | 76:aeb1df146756 | 707 | |
mbed_official | 76:aeb1df146756 | 708 | /** @defgroup SDIO_Group6 CE-ATA mode management functions |
mbed_official | 76:aeb1df146756 | 709 | * @brief CE-ATA mode management functions |
mbed_official | 76:aeb1df146756 | 710 | * |
mbed_official | 76:aeb1df146756 | 711 | @verbatim |
mbed_official | 76:aeb1df146756 | 712 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 713 | ##### CE-ATA mode management functions ##### |
mbed_official | 76:aeb1df146756 | 714 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 715 | [..] This section provide functions allowing to program and read the CE-ATA |
mbed_official | 76:aeb1df146756 | 716 | card. |
mbed_official | 76:aeb1df146756 | 717 | |
mbed_official | 76:aeb1df146756 | 718 | @endverbatim |
mbed_official | 76:aeb1df146756 | 719 | * @{ |
mbed_official | 76:aeb1df146756 | 720 | */ |
mbed_official | 76:aeb1df146756 | 721 | |
mbed_official | 76:aeb1df146756 | 722 | /** |
mbed_official | 76:aeb1df146756 | 723 | * @brief Enables or disables the command completion signal. |
mbed_official | 76:aeb1df146756 | 724 | * @param NewState: new state of command completion signal. |
mbed_official | 76:aeb1df146756 | 725 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 726 | * @retval None |
mbed_official | 76:aeb1df146756 | 727 | */ |
mbed_official | 76:aeb1df146756 | 728 | void SDIO_CommandCompletionCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 729 | { |
mbed_official | 76:aeb1df146756 | 730 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 731 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 732 | |
mbed_official | 76:aeb1df146756 | 733 | *(__IO uint32_t *) CMD_ENCMDCOMPL_BB = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 734 | } |
mbed_official | 76:aeb1df146756 | 735 | |
mbed_official | 76:aeb1df146756 | 736 | /** |
mbed_official | 76:aeb1df146756 | 737 | * @brief Enables or disables the CE-ATA interrupt. |
mbed_official | 76:aeb1df146756 | 738 | * @param NewState: new state of CE-ATA interrupt. This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 739 | * @retval None |
mbed_official | 76:aeb1df146756 | 740 | */ |
mbed_official | 76:aeb1df146756 | 741 | void SDIO_CEATAITCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 742 | { |
mbed_official | 76:aeb1df146756 | 743 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 744 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 745 | |
mbed_official | 76:aeb1df146756 | 746 | *(__IO uint32_t *) CMD_NIEN_BB = (uint32_t)((~((uint32_t)NewState)) & ((uint32_t)0x1)); |
mbed_official | 76:aeb1df146756 | 747 | } |
mbed_official | 76:aeb1df146756 | 748 | |
mbed_official | 76:aeb1df146756 | 749 | /** |
mbed_official | 76:aeb1df146756 | 750 | * @brief Sends CE-ATA command (CMD61). |
mbed_official | 76:aeb1df146756 | 751 | * @param NewState: new state of CE-ATA command. This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 752 | * @retval None |
mbed_official | 76:aeb1df146756 | 753 | */ |
mbed_official | 76:aeb1df146756 | 754 | void SDIO_SendCEATACmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 755 | { |
mbed_official | 76:aeb1df146756 | 756 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 757 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 758 | |
mbed_official | 76:aeb1df146756 | 759 | *(__IO uint32_t *) CMD_ATACMD_BB = (uint32_t)NewState; |
mbed_official | 76:aeb1df146756 | 760 | } |
mbed_official | 76:aeb1df146756 | 761 | |
mbed_official | 76:aeb1df146756 | 762 | /** |
mbed_official | 76:aeb1df146756 | 763 | * @} |
mbed_official | 76:aeb1df146756 | 764 | */ |
mbed_official | 76:aeb1df146756 | 765 | |
mbed_official | 76:aeb1df146756 | 766 | /** @defgroup SDIO_Group7 Interrupts and flags management functions |
mbed_official | 76:aeb1df146756 | 767 | * @brief Interrupts and flags management functions |
mbed_official | 76:aeb1df146756 | 768 | |
mbed_official | 76:aeb1df146756 | 769 | |
mbed_official | 76:aeb1df146756 | 770 | @verbatim |
mbed_official | 76:aeb1df146756 | 771 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 772 | ##### Interrupts and flags management functions ##### |
mbed_official | 76:aeb1df146756 | 773 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 774 | |
mbed_official | 76:aeb1df146756 | 775 | @endverbatim |
mbed_official | 76:aeb1df146756 | 776 | * @{ |
mbed_official | 76:aeb1df146756 | 777 | */ |
mbed_official | 76:aeb1df146756 | 778 | |
mbed_official | 76:aeb1df146756 | 779 | /** |
mbed_official | 76:aeb1df146756 | 780 | * @brief Enables or disables the SDIO interrupts. |
mbed_official | 76:aeb1df146756 | 781 | * @param SDIO_IT: specifies the SDIO interrupt sources to be enabled or disabled. |
mbed_official | 76:aeb1df146756 | 782 | * This parameter can be one or a combination of the following values: |
mbed_official | 76:aeb1df146756 | 783 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt. |
mbed_official | 76:aeb1df146756 | 784 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt. |
mbed_official | 76:aeb1df146756 | 785 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt. |
mbed_official | 76:aeb1df146756 | 786 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt. |
mbed_official | 76:aeb1df146756 | 787 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt. |
mbed_official | 76:aeb1df146756 | 788 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt. |
mbed_official | 76:aeb1df146756 | 789 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt. |
mbed_official | 76:aeb1df146756 | 790 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt. |
mbed_official | 76:aeb1df146756 | 791 | * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt. |
mbed_official | 76:aeb1df146756 | 792 | * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide |
mbed_official | 76:aeb1df146756 | 793 | * bus mode interrupt. |
mbed_official | 76:aeb1df146756 | 794 | * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt. |
mbed_official | 76:aeb1df146756 | 795 | * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt. |
mbed_official | 76:aeb1df146756 | 796 | * @arg SDIO_IT_TXACT: Data transmit in progress interrupt. |
mbed_official | 76:aeb1df146756 | 797 | * @arg SDIO_IT_RXACT: Data receive in progress interrupt. |
mbed_official | 76:aeb1df146756 | 798 | * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt. |
mbed_official | 76:aeb1df146756 | 799 | * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt. |
mbed_official | 76:aeb1df146756 | 800 | * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt. |
mbed_official | 76:aeb1df146756 | 801 | * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt. |
mbed_official | 76:aeb1df146756 | 802 | * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt. |
mbed_official | 76:aeb1df146756 | 803 | * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt. |
mbed_official | 76:aeb1df146756 | 804 | * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt. |
mbed_official | 76:aeb1df146756 | 805 | * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt. |
mbed_official | 76:aeb1df146756 | 806 | * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt. |
mbed_official | 76:aeb1df146756 | 807 | * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt. |
mbed_official | 76:aeb1df146756 | 808 | * @param NewState: new state of the specified SDIO interrupts. |
mbed_official | 76:aeb1df146756 | 809 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 810 | * @retval None |
mbed_official | 76:aeb1df146756 | 811 | */ |
mbed_official | 76:aeb1df146756 | 812 | void SDIO_ITConfig(uint32_t SDIO_IT, FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 813 | { |
mbed_official | 76:aeb1df146756 | 814 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 815 | assert_param(IS_SDIO_IT(SDIO_IT)); |
mbed_official | 76:aeb1df146756 | 816 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 817 | |
mbed_official | 76:aeb1df146756 | 818 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 819 | { |
mbed_official | 76:aeb1df146756 | 820 | /* Enable the SDIO interrupts */ |
mbed_official | 76:aeb1df146756 | 821 | SDIO->MASK |= SDIO_IT; |
mbed_official | 76:aeb1df146756 | 822 | } |
mbed_official | 76:aeb1df146756 | 823 | else |
mbed_official | 76:aeb1df146756 | 824 | { |
mbed_official | 76:aeb1df146756 | 825 | /* Disable the SDIO interrupts */ |
mbed_official | 76:aeb1df146756 | 826 | SDIO->MASK &= ~SDIO_IT; |
mbed_official | 76:aeb1df146756 | 827 | } |
mbed_official | 76:aeb1df146756 | 828 | } |
mbed_official | 76:aeb1df146756 | 829 | |
mbed_official | 76:aeb1df146756 | 830 | /** |
mbed_official | 76:aeb1df146756 | 831 | * @brief Checks whether the specified SDIO flag is set or not. |
mbed_official | 76:aeb1df146756 | 832 | * @param SDIO_FLAG: specifies the flag to check. |
mbed_official | 76:aeb1df146756 | 833 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 834 | * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed). |
mbed_official | 76:aeb1df146756 | 835 | * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed). |
mbed_official | 76:aeb1df146756 | 836 | * @arg SDIO_FLAG_CTIMEOUT: Command response timeout. |
mbed_official | 76:aeb1df146756 | 837 | * @arg SDIO_FLAG_DTIMEOUT: Data timeout. |
mbed_official | 76:aeb1df146756 | 838 | * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error. |
mbed_official | 76:aeb1df146756 | 839 | * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error. |
mbed_official | 76:aeb1df146756 | 840 | * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed). |
mbed_official | 76:aeb1df146756 | 841 | * @arg SDIO_FLAG_CMDSENT: Command sent (no response required). |
mbed_official | 76:aeb1df146756 | 842 | * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero). |
mbed_official | 76:aeb1df146756 | 843 | * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide |
mbed_official | 76:aeb1df146756 | 844 | * bus mode. |
mbed_official | 76:aeb1df146756 | 845 | * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed). |
mbed_official | 76:aeb1df146756 | 846 | * @arg SDIO_FLAG_CMDACT: Command transfer in progress. |
mbed_official | 76:aeb1df146756 | 847 | * @arg SDIO_FLAG_TXACT: Data transmit in progress. |
mbed_official | 76:aeb1df146756 | 848 | * @arg SDIO_FLAG_RXACT: Data receive in progress. |
mbed_official | 76:aeb1df146756 | 849 | * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty. |
mbed_official | 76:aeb1df146756 | 850 | * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full. |
mbed_official | 76:aeb1df146756 | 851 | * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full. |
mbed_official | 76:aeb1df146756 | 852 | * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full. |
mbed_official | 76:aeb1df146756 | 853 | * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty. |
mbed_official | 76:aeb1df146756 | 854 | * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty. |
mbed_official | 76:aeb1df146756 | 855 | * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO. |
mbed_official | 76:aeb1df146756 | 856 | * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO. |
mbed_official | 76:aeb1df146756 | 857 | * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received. |
mbed_official | 76:aeb1df146756 | 858 | * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61. |
mbed_official | 76:aeb1df146756 | 859 | * @retval The new state of SDIO_FLAG (SET or RESET). |
mbed_official | 76:aeb1df146756 | 860 | */ |
mbed_official | 76:aeb1df146756 | 861 | FlagStatus SDIO_GetFlagStatus(uint32_t SDIO_FLAG) |
mbed_official | 76:aeb1df146756 | 862 | { |
mbed_official | 76:aeb1df146756 | 863 | FlagStatus bitstatus = RESET; |
mbed_official | 76:aeb1df146756 | 864 | |
mbed_official | 76:aeb1df146756 | 865 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 866 | assert_param(IS_SDIO_FLAG(SDIO_FLAG)); |
mbed_official | 76:aeb1df146756 | 867 | |
mbed_official | 76:aeb1df146756 | 868 | if ((SDIO->STA & SDIO_FLAG) != (uint32_t)RESET) |
mbed_official | 76:aeb1df146756 | 869 | { |
mbed_official | 76:aeb1df146756 | 870 | bitstatus = SET; |
mbed_official | 76:aeb1df146756 | 871 | } |
mbed_official | 76:aeb1df146756 | 872 | else |
mbed_official | 76:aeb1df146756 | 873 | { |
mbed_official | 76:aeb1df146756 | 874 | bitstatus = RESET; |
mbed_official | 76:aeb1df146756 | 875 | } |
mbed_official | 76:aeb1df146756 | 876 | return bitstatus; |
mbed_official | 76:aeb1df146756 | 877 | } |
mbed_official | 76:aeb1df146756 | 878 | |
mbed_official | 76:aeb1df146756 | 879 | /** |
mbed_official | 76:aeb1df146756 | 880 | * @brief Clears the SDIO's pending flags. |
mbed_official | 76:aeb1df146756 | 881 | * @param SDIO_FLAG: specifies the flag to clear. |
mbed_official | 76:aeb1df146756 | 882 | * This parameter can be one or a combination of the following values: |
mbed_official | 76:aeb1df146756 | 883 | * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed). |
mbed_official | 76:aeb1df146756 | 884 | * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed). |
mbed_official | 76:aeb1df146756 | 885 | * @arg SDIO_FLAG_CTIMEOUT: Command response timeout. |
mbed_official | 76:aeb1df146756 | 886 | * @arg SDIO_FLAG_DTIMEOUT: Data timeout. |
mbed_official | 76:aeb1df146756 | 887 | * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error. |
mbed_official | 76:aeb1df146756 | 888 | * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error. |
mbed_official | 76:aeb1df146756 | 889 | * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed). |
mbed_official | 76:aeb1df146756 | 890 | * @arg SDIO_FLAG_CMDSENT: Command sent (no response required). |
mbed_official | 76:aeb1df146756 | 891 | * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero). |
mbed_official | 76:aeb1df146756 | 892 | * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide |
mbed_official | 76:aeb1df146756 | 893 | * bus mode. |
mbed_official | 76:aeb1df146756 | 894 | * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed). |
mbed_official | 76:aeb1df146756 | 895 | * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received. |
mbed_official | 76:aeb1df146756 | 896 | * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61. |
mbed_official | 76:aeb1df146756 | 897 | * @retval None |
mbed_official | 76:aeb1df146756 | 898 | */ |
mbed_official | 76:aeb1df146756 | 899 | void SDIO_ClearFlag(uint32_t SDIO_FLAG) |
mbed_official | 76:aeb1df146756 | 900 | { |
mbed_official | 76:aeb1df146756 | 901 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 902 | assert_param(IS_SDIO_CLEAR_FLAG(SDIO_FLAG)); |
mbed_official | 76:aeb1df146756 | 903 | |
mbed_official | 76:aeb1df146756 | 904 | SDIO->ICR = SDIO_FLAG; |
mbed_official | 76:aeb1df146756 | 905 | } |
mbed_official | 76:aeb1df146756 | 906 | |
mbed_official | 76:aeb1df146756 | 907 | /** |
mbed_official | 76:aeb1df146756 | 908 | * @brief Checks whether the specified SDIO interrupt has occurred or not. |
mbed_official | 76:aeb1df146756 | 909 | * @param SDIO_IT: specifies the SDIO interrupt source to check. |
mbed_official | 76:aeb1df146756 | 910 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 911 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt. |
mbed_official | 76:aeb1df146756 | 912 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt. |
mbed_official | 76:aeb1df146756 | 913 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt. |
mbed_official | 76:aeb1df146756 | 914 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt. |
mbed_official | 76:aeb1df146756 | 915 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt. |
mbed_official | 76:aeb1df146756 | 916 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt. |
mbed_official | 76:aeb1df146756 | 917 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt. |
mbed_official | 76:aeb1df146756 | 918 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt. |
mbed_official | 76:aeb1df146756 | 919 | * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt. |
mbed_official | 76:aeb1df146756 | 920 | * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide |
mbed_official | 76:aeb1df146756 | 921 | * bus mode interrupt. |
mbed_official | 76:aeb1df146756 | 922 | * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt. |
mbed_official | 76:aeb1df146756 | 923 | * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt. |
mbed_official | 76:aeb1df146756 | 924 | * @arg SDIO_IT_TXACT: Data transmit in progress interrupt. |
mbed_official | 76:aeb1df146756 | 925 | * @arg SDIO_IT_RXACT: Data receive in progress interrupt. |
mbed_official | 76:aeb1df146756 | 926 | * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt. |
mbed_official | 76:aeb1df146756 | 927 | * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt. |
mbed_official | 76:aeb1df146756 | 928 | * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt. |
mbed_official | 76:aeb1df146756 | 929 | * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt. |
mbed_official | 76:aeb1df146756 | 930 | * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt. |
mbed_official | 76:aeb1df146756 | 931 | * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt. |
mbed_official | 76:aeb1df146756 | 932 | * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt. |
mbed_official | 76:aeb1df146756 | 933 | * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt. |
mbed_official | 76:aeb1df146756 | 934 | * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt. |
mbed_official | 76:aeb1df146756 | 935 | * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt. |
mbed_official | 76:aeb1df146756 | 936 | * @retval The new state of SDIO_IT (SET or RESET). |
mbed_official | 76:aeb1df146756 | 937 | */ |
mbed_official | 76:aeb1df146756 | 938 | ITStatus SDIO_GetITStatus(uint32_t SDIO_IT) |
mbed_official | 76:aeb1df146756 | 939 | { |
mbed_official | 76:aeb1df146756 | 940 | ITStatus bitstatus = RESET; |
mbed_official | 76:aeb1df146756 | 941 | |
mbed_official | 76:aeb1df146756 | 942 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 943 | assert_param(IS_SDIO_GET_IT(SDIO_IT)); |
mbed_official | 76:aeb1df146756 | 944 | if ((SDIO->STA & SDIO_IT) != (uint32_t)RESET) |
mbed_official | 76:aeb1df146756 | 945 | { |
mbed_official | 76:aeb1df146756 | 946 | bitstatus = SET; |
mbed_official | 76:aeb1df146756 | 947 | } |
mbed_official | 76:aeb1df146756 | 948 | else |
mbed_official | 76:aeb1df146756 | 949 | { |
mbed_official | 76:aeb1df146756 | 950 | bitstatus = RESET; |
mbed_official | 76:aeb1df146756 | 951 | } |
mbed_official | 76:aeb1df146756 | 952 | return bitstatus; |
mbed_official | 76:aeb1df146756 | 953 | } |
mbed_official | 76:aeb1df146756 | 954 | |
mbed_official | 76:aeb1df146756 | 955 | /** |
mbed_official | 76:aeb1df146756 | 956 | * @brief Clears the SDIO's interrupt pending bits. |
mbed_official | 76:aeb1df146756 | 957 | * @param SDIO_IT: specifies the interrupt pending bit to clear. |
mbed_official | 76:aeb1df146756 | 958 | * This parameter can be one or a combination of the following values: |
mbed_official | 76:aeb1df146756 | 959 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt. |
mbed_official | 76:aeb1df146756 | 960 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt. |
mbed_official | 76:aeb1df146756 | 961 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt. |
mbed_official | 76:aeb1df146756 | 962 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt. |
mbed_official | 76:aeb1df146756 | 963 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt. |
mbed_official | 76:aeb1df146756 | 964 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt. |
mbed_official | 76:aeb1df146756 | 965 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt. |
mbed_official | 76:aeb1df146756 | 966 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt. |
mbed_official | 76:aeb1df146756 | 967 | * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt. |
mbed_official | 76:aeb1df146756 | 968 | * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide |
mbed_official | 76:aeb1df146756 | 969 | * bus mode interrupt. |
mbed_official | 76:aeb1df146756 | 970 | * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt. |
mbed_official | 76:aeb1df146756 | 971 | * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61. |
mbed_official | 76:aeb1df146756 | 972 | * @retval None |
mbed_official | 76:aeb1df146756 | 973 | */ |
mbed_official | 76:aeb1df146756 | 974 | void SDIO_ClearITPendingBit(uint32_t SDIO_IT) |
mbed_official | 76:aeb1df146756 | 975 | { |
mbed_official | 76:aeb1df146756 | 976 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 977 | assert_param(IS_SDIO_CLEAR_IT(SDIO_IT)); |
mbed_official | 76:aeb1df146756 | 978 | |
mbed_official | 76:aeb1df146756 | 979 | SDIO->ICR = SDIO_IT; |
mbed_official | 76:aeb1df146756 | 980 | } |
mbed_official | 76:aeb1df146756 | 981 | |
mbed_official | 76:aeb1df146756 | 982 | /** |
mbed_official | 76:aeb1df146756 | 983 | * @} |
mbed_official | 76:aeb1df146756 | 984 | */ |
mbed_official | 76:aeb1df146756 | 985 | |
mbed_official | 76:aeb1df146756 | 986 | /** |
mbed_official | 76:aeb1df146756 | 987 | * @} |
mbed_official | 76:aeb1df146756 | 988 | */ |
mbed_official | 76:aeb1df146756 | 989 | |
mbed_official | 76:aeb1df146756 | 990 | /** |
mbed_official | 76:aeb1df146756 | 991 | * @} |
mbed_official | 76:aeb1df146756 | 992 | */ |
mbed_official | 76:aeb1df146756 | 993 | |
mbed_official | 76:aeb1df146756 | 994 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |