| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 | 
							- /**
 
-   ******************************************************************************
 
-   * File Name          : SDIO.c
 
-   * Description        : This file provides code for the configuration
 
-   *                      of the SDIO instances.
 
-   ******************************************************************************
 
-   *
 
-   * COPYRIGHT(c) 2019 STMicroelectronics
 
-   *
 
-   * Redistribution and use in source and binary forms, with or without modification,
 
-   * are permitted provided that the following conditions are met:
 
-   *   1. Redistributions of source code must retain the above copyright notice,
 
-   *      this list of conditions and the following disclaimer.
 
-   *   2. Redistributions in binary form must reproduce the above copyright notice,
 
-   *      this list of conditions and the following disclaimer in the documentation
 
-   *      and/or other materials provided with the distribution.
 
-   *   3. Neither the name of STMicroelectronics nor the names of its contributors
 
-   *      may be used to endorse or promote products derived from this software
 
-   *      without specific prior written permission.
 
-   *
 
-   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
-   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
-   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
-   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 
-   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
-   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
-   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
-   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 
-   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
-   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-   *
 
-   ******************************************************************************
 
-   */
 
- /* Includes ------------------------------------------------------------------*/
 
- #include "sdio.h"
 
- #include "gpio.h"
 
- #include "dma.h"
 
- /* USER CODE BEGIN 0 */
 
- /* USER CODE END 0 */
 
- SD_HandleTypeDef hsd;
 
- HAL_SD_CardInfoTypedef SDCardInfo;
 
- DMA_HandleTypeDef hdma_sdio_tx;
 
- DMA_HandleTypeDef hdma_sdio_rx;
 
- /* SDIO init function */
 
- void MX_SDIO_SD_Init(void)
 
- {
 
-   hsd.Instance = SDIO;
 
-   hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
 
-   hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
 
-   hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
 
-   hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
 
-   hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
 
-   hsd.Init.ClockDiv = 0;
 
-   HAL_SD_Init(&hsd, &SDCardInfo);
 
-   HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B);
 
- }
 
- void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
 
- {
 
-   GPIO_InitTypeDef GPIO_InitStruct;
 
-   if(hsd->Instance==SDIO)
 
-   {
 
-   /* USER CODE BEGIN SDIO_MspInit 0 */
 
-   /* USER CODE END SDIO_MspInit 0 */
 
-     /* Peripheral clock enable */
 
-     __SDIO_CLK_ENABLE();
 
-   
 
-     /**SDIO GPIO Configuration    
 
-     PC8     ------> SDIO_D0
 
-     PC9     ------> SDIO_D1
 
-     PC10     ------> SDIO_D2
 
-     PC11     ------> SDIO_D3
 
-     PC12     ------> SDIO_CK
 
-     PD2     ------> SDIO_CMD 
 
-     */
 
-     GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11;
 
-     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 
-     GPIO_InitStruct.Pull = GPIO_PULLUP;
 
-     GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
 
-     GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
 
-     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
-     GPIO_InitStruct.Pin = GPIO_PIN_12;
 
-     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 
-     GPIO_InitStruct.Pull = GPIO_NOPULL;
 
-     GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
 
-     GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
 
-     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
-     GPIO_InitStruct.Pin = GPIO_PIN_2;
 
-     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 
-     GPIO_InitStruct.Pull = GPIO_PULLUP;
 
-     GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
 
-     GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
 
-     HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
 
-     /* Peripheral DMA init*/
 
-   
 
-     hdma_sdio_tx.Instance = DMA2_Stream3;
 
-     hdma_sdio_tx.Init.Channel = DMA_CHANNEL_4;
 
-     hdma_sdio_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
 
-     hdma_sdio_tx.Init.PeriphInc = DMA_PINC_DISABLE;
 
-     hdma_sdio_tx.Init.MemInc = DMA_MINC_ENABLE;
 
-     hdma_sdio_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
 
-     hdma_sdio_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
 
-     hdma_sdio_tx.Init.Mode = DMA_PFCTRL;
 
-     hdma_sdio_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
 
-     hdma_sdio_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
 
-     hdma_sdio_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
 
-     hdma_sdio_tx.Init.MemBurst = DMA_MBURST_INC4;
 
-     hdma_sdio_tx.Init.PeriphBurst = DMA_PBURST_INC4;
 
-     HAL_DMA_Init(&hdma_sdio_tx);
 
-     __HAL_LINKDMA(hsd,hdmatx,hdma_sdio_tx);
 
-     hdma_sdio_rx.Instance = DMA2_Stream6;
 
-     hdma_sdio_rx.Init.Channel = DMA_CHANNEL_4;
 
-     hdma_sdio_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
 
-     hdma_sdio_rx.Init.PeriphInc = DMA_PINC_DISABLE;
 
-     hdma_sdio_rx.Init.MemInc = DMA_MINC_ENABLE;
 
-     hdma_sdio_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
 
-     hdma_sdio_rx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
 
-     hdma_sdio_rx.Init.Mode = DMA_PFCTRL;
 
-     hdma_sdio_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
 
-     hdma_sdio_rx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
 
-     hdma_sdio_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
 
-     hdma_sdio_rx.Init.MemBurst = DMA_MBURST_INC4;
 
-     hdma_sdio_rx.Init.PeriphBurst = DMA_PBURST_INC4;
 
-     HAL_DMA_Init(&hdma_sdio_rx);
 
-     __HAL_LINKDMA(hsd,hdmarx,hdma_sdio_rx);
 
-     /* Peripheral interrupt init*/
 
-     HAL_NVIC_SetPriority(SDIO_IRQn, 0, 0);
 
-     HAL_NVIC_EnableIRQ(SDIO_IRQn);
 
-   /* USER CODE BEGIN SDIO_MspInit 1 */
 
-   /* USER CODE END SDIO_MspInit 1 */
 
-   }
 
- }
 
- void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
 
- {
 
-   if(hsd->Instance==SDIO)
 
-   {
 
-   /* USER CODE BEGIN SDIO_MspDeInit 0 */
 
-   /* USER CODE END SDIO_MspDeInit 0 */
 
-     /* Peripheral clock disable */
 
-     __SDIO_CLK_DISABLE();
 
-   
 
-     /**SDIO GPIO Configuration    
 
-     PC8     ------> SDIO_D0
 
-     PC9     ------> SDIO_D1
 
-     PC10     ------> SDIO_D2
 
-     PC11     ------> SDIO_D3
 
-     PC12     ------> SDIO_CK
 
-     PD2     ------> SDIO_CMD 
 
-     */
 
-     HAL_GPIO_DeInit(GPIOC, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 
 
-                           |GPIO_PIN_12);
 
-     HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
 
-     /* Peripheral DMA DeInit*/
 
-     HAL_DMA_DeInit(hsd->hdmatx);
 
-     HAL_DMA_DeInit(hsd->hdmarx);
 
-     /* Peripheral interrupt Deinit*/
 
-     HAL_NVIC_DisableIRQ(SDIO_IRQn);
 
-   }
 
-   /* USER CODE BEGIN SDIO_MspDeInit 1 */
 
-   /* USER CODE END SDIO_MspDeInit 1 */
 
- } 
 
- /* USER CODE BEGIN 1 */
 
- /* USER CODE END 1 */
 
- /**
 
-   * @}
 
-   */
 
- /**
 
-   * @}
 
-   */
 
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 
 
  |