drv_sdcard.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /******************************************************************//**
  2. * @file drv_sdcard.h
  3. * @brief Memory card driver (SPI mode) of RT-Thread RTOS for using EFM32 USART module
  4. * COPYRIGHT (C) 2011, RT-Thread Development Team
  5. * @author onelife
  6. * @version 0.4 beta
  7. **********************************************************************
  8. * @section License
  9. * The license and distribution terms for this file may be found in the file LICENSE in this
  10. * distribution or at http://www.rt-thread.org/license/LICENSE
  11. **********************************************************************
  12. * @section Change Logs
  13. * Date Author Notes
  14. * 2011-05-13 onelife Initial creation for using EFM32 USART module
  15. *********************************************************************/
  16. #ifndef __DEV_SDCARD_H__
  17. #define __DEV_SDCARD_H__
  18. /* Includes -------------------------------------------------------------------*/
  19. /* Exported types -------------------------------------------------------------*/
  20. /* Exported constants ---------------------------------------------------------*/
  21. /* Exported macro -------------------------------------------------------------*/
  22. #define EFM32_SDCLK_LOW (100000)
  23. #define EFM32_SDCLK_HIGH (EFM32_HFXO_FREQUENCY/2)
  24. #define SD_SPEED_LOW (0)
  25. #define SD_SPEED_HIGH (1)
  26. #define SD_WAIT_PERIOD (RT_TICK_PER_SECOND)
  27. #define SD_SECTOR_SIZE_SHIFT (9)
  28. #define SD_SECTOR_SIZE (1 << SD_SECTOR_SIZE_SHIFT)
  29. #define SD_BLOCK_SIZE_CSD (16)
  30. #define SD_BLOCK_SIZE_CID (16)
  31. #define SD_BLOCK_SIZE_OCR (4)
  32. #define SD_BLOCK_SIZE_SDSTAT (64)
  33. /* Card type definitions (CardType) */
  34. #define CT_MMC (0x01)
  35. #define CT_SD1 (0x02)
  36. #define CT_SD2 (0x04)
  37. #define CT_SDC (CT_SD1|CT_SD2)
  38. #define CT_BLOCK (0x08)
  39. /* Definitions for MMC/SDC command */
  40. #define CMD0 (0) /* GO_IDLE_STATE */
  41. #define CMD1 (1) /* SEND_OP_COND */
  42. #define ACMD41 (41|0x80) /* SEND_OP_COND (SDC) */
  43. #define CMD8 (8) /* SEND_IF_COND */
  44. #define CMD9 (9) /* SEND_CSD */
  45. #define CMD10 (10) /* SEND_CID */
  46. #define CMD12 (12) /* STOP_TRANSMISSION */
  47. #define ACMD13 (13|0x80) /* SD_STATUS (SDC) */
  48. #define CMD16 (16) /* SET_BLOCKLEN */
  49. #define CMD17 (17) /* READ_SINGLE_BLOCK */
  50. #define CMD18 (18) /* READ_MULTIPLE_BLOCK */
  51. #define CMD23 (23) /* SET_BLOCK_COUNT */
  52. #define ACMD23 (23|0x80) /* SET_WR_BLK_ERASE_COUNT (SDC) */
  53. #define CMD24 (24) /* WRITE_BLOCK */
  54. #define CMD25 (25) /* WRITE_MULTIPLE_BLOCK */
  55. #define CMD41 (41) /* SEND_OP_COND (ACMD) */
  56. #define CMD55 (55) /* APP_CMD */
  57. #define CMD58 (58) /* READ_OCR */
  58. /* Exported functions --------------------------------------------------------- */
  59. void efm_spiSd_init(void);
  60. void efm_spiSd_deinit(void);
  61. #endif /* __DEV_SDCARD_H__ */