Skip to content
Permalink
Browse files

new

  • Loading branch information...
naminic committed Jun 26, 2019
1 parent 72317b3 commit e949eb2794c2132ae4f6ad8a664a489cf9c872a6
Showing with 35,994 additions and 3,373 deletions.
  1. +116 −158 Middlewares samples/FAT32_SD_chan/Inc/ffconf.h
  2. +488 −0 Middlewares samples/FAT32_SD_chan/Inc/stm3210c_eval.h
  3. +280 −0 Middlewares samples/FAT32_SD_chan/Inc/stm3210c_eval_sd.h
  4. +0 −245 Middlewares samples/FAT32_SD_chan/Inc/stm3210c_sd.h
  5. +36 −0 Middlewares samples/FAT32_SD_chan/MDK-ARM/DebugConfig/fatf107_STM32F107VC_1.0.0.dbgconf
  6. +86 −109 Middlewares samples/FAT32_SD_chan/MDK-ARM/fatf107.uvoptx
  7. +19 −19 Middlewares samples/FAT32_SD_chan/MDK-ARM/fatf107.uvprojx
  8. +834 −895 Middlewares samples/FAT32_SD_chan/MDK-ARM/fatf107/fatf107.hex
  9. +158 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/00readme.txt
  10. +35 −73 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/diskio.c
  11. +9 −9 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/diskio.h
  12. +195 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c
  13. +41 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.h
  14. +416 −567 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/ff.c
  15. +18 −26 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/ff.h
  16. +20 −69 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/ff_gen_drv.c
  17. +17 −40 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/ff_gen_drv.h
  18. +244 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/ffconf_template.h
  19. +3,798 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/option/cc932.c
  20. +10,973 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/option/cc936.c
  21. +8,603 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/option/cc949.c
  22. +6,829 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/option/cc950.c
  23. +540 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/option/ccsbcs.c
  24. +5 −5 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/option/syscall.c
  25. +17 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/option/unicode.c
  26. +71 −0 Middlewares samples/FAT32_SD_chan/Middlewares/Third_Party/FatFs/src/st_readme.txt
  27. +0 −55 Middlewares samples/FAT32_SD_chan/Src/fatfs.c
  28. +101 −86 Middlewares samples/FAT32_SD_chan/Src/main.c
  29. +389 −0 Middlewares samples/FAT32_SD_chan/Src/stm3210c_eval.c
  30. +712 −0 Middlewares samples/FAT32_SD_chan/Src/stm3210c_eval_sd.c
  31. +0 −1,008 Middlewares samples/FAT32_SD_chan/Src/stm3210c_sd.c
  32. +932 −0 Middlewares samples/FAT32_SD_chan/Src/stm3210c_spi_sd.c
  33. +1 −0 Middlewares samples/FAT32_SD_chan/Src/stm32f1xx_hal_msp.c
  34. +11 −9 Middlewares samples/FAT32_SD_chan/Src/user_diskio.c

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -0,0 +1,280 @@
/**
******************************************************************************
* @file stm3210c_eval_sd.h
* @author MCD Application Team
* @version V6.0.0
* @date 16-December-2014
* @brief This file contains the common defines and functions prototypes for
* the stm3210c_eval_sd.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM3210C_EVAL_SD_H
#define __STM3210C_EVAL_SD_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm3210c_eval.h"

/** @addtogroup BSP
* @{
*/

/** @addtogroup STM3210C_EVAL
* @{
*/

/** @addtogroup STM3210C_EVAL_SD
* @{
*/


/** @defgroup STM3210C_EVAL_SD_Exported_Types Exported_Types
* @{
*/

/**
* @brief SD status structure definition
*/
#define MSD_OK 0x00
#define MSD_ERROR 0x01

typedef enum
{
/**
* @brief SD reponses and error flags
*/
SD_RESPONSE_NO_ERROR = (0x00),
SD_IN_IDLE_STATE = (0x01),
SD_ERASE_RESET = (0x02),
SD_ILLEGAL_COMMAND = (0x04),
SD_COM_CRC_ERROR = (0x08),
SD_ERASE_SEQUENCE_ERROR = (0x10),
SD_ADDRESS_ERROR = (0x20),
SD_PARAMETER_ERROR = (0x40),
SD_RESPONSE_FAILURE = (0xFF),

/**
* @brief Data response error
*/
SD_DATA_OK = (0x05),
SD_DATA_CRC_ERROR = (0x0B),
SD_DATA_WRITE_ERROR = (0x0D),
SD_DATA_OTHER_ERROR = (0xFF)
}SD_Info;

/**
* @brief Card Specific Data: CSD Register
*/
typedef struct
{
__IO uint8_t CSDStruct; /* CSD structure */
__IO uint8_t SysSpecVersion; /* System specification version */
__IO uint8_t Reserved1; /* Reserved */
__IO uint8_t TAAC; /* Data read access-time 1 */
__IO uint8_t NSAC; /* Data read access-time 2 in CLK cycles */
__IO uint8_t MaxBusClkFrec; /* Max. bus clock frequency */
__IO uint16_t CardComdClasses; /* Card command classes */
__IO uint8_t RdBlockLen; /* Max. read data block length */
__IO uint8_t PartBlockRead; /* Partial blocks for read allowed */
__IO uint8_t WrBlockMisalign; /* Write block misalignment */
__IO uint8_t RdBlockMisalign; /* Read block misalignment */
__IO uint8_t DSRImpl; /* DSR implemented */
__IO uint8_t Reserved2; /* Reserved */
__IO uint32_t DeviceSize; /* Device Size */
__IO uint8_t MaxRdCurrentVDDMin; /* Max. read current @ VDD min */
__IO uint8_t MaxRdCurrentVDDMax; /* Max. read current @ VDD max */
__IO uint8_t MaxWrCurrentVDDMin; /* Max. write current @ VDD min */
__IO uint8_t MaxWrCurrentVDDMax; /* Max. write current @ VDD max */
__IO uint8_t DeviceSizeMul; /* Device size multiplier */
__IO uint8_t EraseGrSize; /* Erase group size */
__IO uint8_t EraseGrMul; /* Erase group size multiplier */
__IO uint8_t WrProtectGrSize; /* Write protect group size */
__IO uint8_t WrProtectGrEnable; /* Write protect group enable */
__IO uint8_t ManDeflECC; /* Manufacturer default ECC */
__IO uint8_t WrSpeedFact; /* Write speed factor */
__IO uint8_t MaxWrBlockLen; /* Max. write data block length */
__IO uint8_t WriteBlockPaPartial; /* Partial blocks for write allowed */
__IO uint8_t Reserved3; /* Reserded */
__IO uint8_t ContentProtectAppli; /* Content protection application */
__IO uint8_t FileFormatGrouop; /* File format group */
__IO uint8_t CopyFlag; /* Copy flag (OTP) */
__IO uint8_t PermWrProtect; /* Permanent write protection */
__IO uint8_t TempWrProtect; /* Temporary write protection */
__IO uint8_t FileFormat; /* File Format */
__IO uint8_t ECC; /* ECC code */
__IO uint8_t CSD_CRC; /* CSD CRC */
__IO uint8_t Reserved4; /* always 1*/
} SD_CSD;

/**
* @brief Card Identification Data: CID Register
*/
typedef struct
{
__IO uint8_t ManufacturerID; /* ManufacturerID */
__IO uint16_t OEM_AppliID; /* OEM/Application ID */
__IO uint32_t ProdName1; /* Product Name part1 */
__IO uint8_t ProdName2; /* Product Name part2*/
__IO uint8_t ProdRev; /* Product Revision */
__IO uint32_t ProdSN; /* Product Serial Number */
__IO uint8_t Reserved1; /* Reserved1 */
__IO uint16_t ManufactDate; /* Manufacturing Date */
__IO uint8_t CID_CRC; /* CID CRC */
__IO uint8_t Reserved2; /* always 1 */
} SD_CID;

/**
* @brief SD Card information
*/
typedef struct
{
SD_CSD Csd;
SD_CID Cid;
uint32_t CardCapacity; /* Card Capacity */
uint32_t CardBlockSize; /* Card Block Size */
} SD_CardInfo;

/**
* @}
*/

/** @defgroup STM3210C_EVAL_SPI_SD_Exported_Constants Exported_Constants
* @{
*/

/**
* @brief Block Size
*/
#define SD_BLOCK_SIZE 0x200

/**
* @brief Start Data tokens:
* Tokens (necessary because at nop/idle (and CS active) only 0xff is
* on the data/command line)
*/
#define SD_START_DATA_SINGLE_BLOCK_READ 0xFE /* Data token start byte, Start Single Block Read */
#define SD_START_DATA_MULTIPLE_BLOCK_READ 0xFE /* Data token start byte, Start Multiple Block Read */
#define SD_START_DATA_SINGLE_BLOCK_WRITE 0xFE /* Data token start byte, Start Single Block Write */
#define SD_START_DATA_MULTIPLE_BLOCK_WRITE 0xFD /* Data token start byte, Start Multiple Block Write */
#define SD_STOP_DATA_MULTIPLE_BLOCK_WRITE 0xFD /* Data toke stop byte, Stop Multiple Block Write */

/**
* @brief SD detection on its memory slot
*/
#define SD_PRESENT ((uint8_t)0x01)
#define SD_NOT_PRESENT ((uint8_t)0x00)

/**
* @brief Commands: CMDxx = CMD-number | 0x40
*/
#define SD_CMD_GO_IDLE_STATE 0 /* CMD0 = 0x40 */
#define SD_CMD_SEND_OP_COND 1 /* CMD1 = 0x41 */
#define SD_CMD_SEND_CSD 9 /* CMD9 = 0x49 */
#define SD_CMD_SEND_CID 10 /* CMD10 = 0x4A */
#define SD_CMD_STOP_TRANSMISSION 12 /* CMD12 = 0x4C */
#define SD_CMD_SEND_STATUS 13 /* CMD13 = 0x4D */
#define SD_CMD_SET_BLOCKLEN 16 /* CMD16 = 0x50 */
#define SD_CMD_READ_SINGLE_BLOCK 17 /* CMD17 = 0x51 */
#define SD_CMD_READ_MULT_BLOCK 18 /* CMD18 = 0x52 */
#define SD_CMD_SET_BLOCK_COUNT 23 /* CMD23 = 0x57 */
#define SD_CMD_WRITE_SINGLE_BLOCK 24 /* CMD24 = 0x58 */
#define SD_CMD_WRITE_MULT_BLOCK 25 /* CMD25 = 0x59 */
#define SD_CMD_PROG_CSD 27 /* CMD27 = 0x5B */
#define SD_CMD_SET_WRITE_PROT 28 /* CMD28 = 0x5C */
#define SD_CMD_CLR_WRITE_PROT 29 /* CMD29 = 0x5D */
#define SD_CMD_SEND_WRITE_PROT 30 /* CMD30 = 0x5E */
#define SD_CMD_SD_ERASE_GRP_START 32 /* CMD32 = 0x60 */
#define SD_CMD_SD_ERASE_GRP_END 33 /* CMD33 = 0x61 */
#define SD_CMD_UNTAG_SECTOR 34 /* CMD34 = 0x62 */
#define SD_CMD_ERASE_GRP_START 35 /* CMD35 = 0x63 */
#define SD_CMD_ERASE_GRP_END 36 /* CMD36 = 0x64 */
#define SD_CMD_UNTAG_ERASE_GROUP 37 /* CMD37 = 0x65 */
#define SD_CMD_ERASE 38 /* CMD38 = 0x66 */


/**
* @}
*/

/** @defgroup STM3210C_EVAL_SD_Exported_Macro Exported_Macro
* @{
*/

/**
* @}
*/

/** @addtogroup STM3210C_EVAL_SD_Exported_Functions
* @{
*/
uint8_t BSP_SD_Init(void);
uint8_t BSP_SD_IsDetected(void);
uint8_t BSP_SD_ReadBlocks(uint32_t* p32Data, uint64_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks);
uint8_t BSP_SD_WriteBlocks(uint32_t* p32Data, uint64_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks);
uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr);
uint8_t BSP_SD_GetStatus(void);
uint8_t BSP_SD_GetCardInfo(SD_CardInfo *pCardInfo);

/* Link functions for SD Card peripheral*/
void SD_IO_Init(void);
void SD_IO_WriteByte(uint8_t Data);
uint8_t SD_IO_ReadByte(void);
HAL_StatusTypeDef SD_IO_WriteCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Response);
HAL_StatusTypeDef SD_IO_WaitResponse(uint8_t Response);
void SD_IO_WriteDummy(void);

/**
* @}
*/

/**
* @}
*/

/**
* @}
*/

/**
* @}
*/

#ifdef __cplusplus
}
#endif

#endif /* __STM3210C_EVAL_SD_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 comments on commit e949eb2

Please sign in to comment.
You can’t perform that action at this time.