1 /* 2 * Copyright (c) 2006-2022, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2011-05-13 onelife Initial creation for using EFM32 USART module 9 * 2011-07-07 onelife Modify initialization function to return error code 10 */ 11 12 #ifndef __DEV_SDCARD_H__ 13 #define __DEV_SDCARD_H__ 14 15 /* Includes ------------------------------------------------------------------*/ 16 /* Exported types ------------------------------------------------------------*/ 17 /* Exported constants --------------------------------------------------------*/ 18 /* Exported macro ------------------------------------------------------------*/ 19 #define EFM32_SDCLK_LOW (100000) 20 #if defined(EFM32_GXXX_DK) 21 #define EFM32_SDCLK_HIGH (16000000) 22 #elif defined(EFM32GG_DK3750) 23 #define EFM32_SDCLK_HIGH (19000000) 24 #endif 25 26 #if (EFM32_SDCLK_HIGH > (EFM32_HFXO_FREQUENCY/2)) 27 #error "EFM32 SPI clock should not be more than (EFM32_HFXO_FREQUENCY/2)" 28 #endif 29 30 #define SD_SPEED_LOW (0) 31 #define SD_SPEED_HIGH (1) 32 #define SD_WAIT_PERIOD (RT_TICK_PER_SECOND) 33 34 #define SD_SECTOR_SIZE_SHIFT (9) 35 #define SD_SECTOR_SIZE (1 << SD_SECTOR_SIZE_SHIFT) 36 #define SD_BLOCK_SIZE_CSD (16) 37 #define SD_BLOCK_SIZE_CID (16) 38 #define SD_BLOCK_SIZE_OCR (4) 39 #define SD_BLOCK_SIZE_SDSTAT (64) 40 41 /* Card type definitions (CardType) */ 42 #define CT_MMC (0x01) 43 #define CT_SD1 (0x02) 44 #define CT_SD2 (0x04) 45 #define CT_SDC (CT_SD1|CT_SD2) 46 #define CT_BLOCK (0x08) 47 48 /* Definitions for MMC/SDC command */ 49 #define CMD0 (0) /* GO_IDLE_STATE */ 50 #define CMD1 (1) /* SEND_OP_COND */ 51 #define ACMD41 (41|0x80) /* SEND_OP_COND (SDC) */ 52 #define CMD8 (8) /* SEND_IF_COND */ 53 #define CMD9 (9) /* SEND_CSD */ 54 #define CMD10 (10) /* SEND_CID */ 55 #define CMD12 (12) /* STOP_TRANSMISSION */ 56 #define ACMD13 (13|0x80) /* SD_STATUS (SDC) */ 57 #define CMD16 (16) /* SET_BLOCKLEN */ 58 #define CMD17 (17) /* READ_SINGLE_BLOCK */ 59 #define CMD18 (18) /* READ_MULTIPLE_BLOCK */ 60 #define CMD23 (23) /* SET_BLOCK_COUNT */ 61 #define ACMD23 (23|0x80) /* SET_WR_BLK_ERASE_COUNT (SDC) */ 62 #define CMD24 (24) /* WRITE_BLOCK */ 63 #define CMD25 (25) /* WRITE_MULTIPLE_BLOCK */ 64 #define CMD41 (41) /* SEND_OP_COND (ACMD) */ 65 #define CMD55 (55) /* APP_CMD */ 66 #define CMD58 (58) /* READ_OCR */ 67 68 /* Exported functions ------------------------------------------------------- */ 69 rt_err_t efm_spiSd_init(void); 70 void efm_spiSd_deinit(void); 71 72 #endif /* __DEV_SDCARD_H__ */ 73