STM32303E_EVAL BSP User Manual: stm32303e_eval_sd.c File Reference

STM32303E EVAL BSP Drivers

stm32303e_eval_sd.c File Reference

This file provides a set of functions needed to manage the SPI SD Card memory mounted on STM32303E-EVAL board. It implements a high level communication layer for read and write from/to this memory. The needed STM32F30x hardware resources (SPI and GPIO) are defined in stm32303e_eval.h file, and the initialization is performed in SD_LowLevel_Init() function declared in stm32303e_eval.c file. You can easily tailor this driver to any other development board, by just adapting the defines for hardware resources and SD_LowLevel_Init() function. More...

Go to the source code of this file.

Defines

#define SD_DUMMY_BYTE   0xFF
#define SD_NO_RESPONSE_EXPECTED   0x80

Functions

static uint8_t SD_GetCIDRegister (SD_CID *Cid)
 Read the CID card register.
static uint8_t SD_GetCSDRegister (SD_CSD *Csd)
 Read the CSD card register.
static SD_Info SD_GetDataResponse (void)
 Get SD card data response.
static uint8_t SD_GoIdleState (void)
 Put SD in Idle state.
static uint8_t SD_SendCmd (uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Response)
 Send 5 bytes command to the SD card and get response.
uint8_t BSP_SD_Init (void)
 Initializes the SD/SD communication.
uint8_t BSP_SD_IsDetected (void)
 Detects if SD card is correctly plugged in the memory slot or not.
uint8_t BSP_SD_GetCardInfo (SD_CardInfo *pCardInfo)
 Returns information about specific card.
uint8_t BSP_SD_ReadBlocks (uint32_t *p32Data, uint64_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
 Reads block(s) from a specified address in an SD card, in polling mode.
uint8_t BSP_SD_WriteBlocks (uint32_t *p32Data, uint64_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
 Writes block(s) to a specified address in an SD card, in polling mode.
uint8_t BSP_SD_GetStatus (void)
 Returns the SD status.
uint8_t BSP_SD_Erase (uint32_t StartAddr, uint32_t EndAddr)
 Erases the specified memory area of the given SD card.

Variables

__IO uint8_t SdStatus = SD_PRESENT

Detailed Description

This file provides a set of functions needed to manage the SPI SD Card memory mounted on STM32303E-EVAL board. It implements a high level communication layer for read and write from/to this memory. The needed STM32F30x hardware resources (SPI and GPIO) are defined in stm32303e_eval.h file, and the initialization is performed in SD_LowLevel_Init() function declared in stm32303e_eval.c file. You can easily tailor this driver to any other development board, by just adapting the defines for hardware resources and SD_LowLevel_Init() function.

Author:
MCD Application Team +-------------------------------------------------------+ | Pin assignment | +-------------------------+---------------+-------------+ | STM32F30x SPI Pins | SD | Pin | +-------------------------+---------------+-------------+ | SD_SPI_CS_PIN | ChipSelect | 1 | | SD_SPI_MOSI_PIN / MOSI | DataIn | 2 | | | GND | 3 (0 V) | | | VDD | 4 (3.3 V)| | SD_SPI_SCK_PIN / SCLK | Clock | 5 | | | GND | 6 (0 V) | | SD_SPI_MISO_PIN / MISO | DataOut | 7 | +-------------------------+---------------+-------------+
Attention:

© COPYRIGHT(c) 2016 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.

Definition in file stm32303e_eval_sd.c.

Generated on Wed May 31 2017 11:17:17 for STM32303E_EVAL BSP User Manual by   doxygen 1.7.6.1