drv_sd.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * File : drv_sd.h
  3. * SPI mode SD Card Driver
  4. * This file is part of RT-Thread RTOS
  5. * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
  6. *
  7. * The license and distribution terms for this file may be
  8. * found in the file LICENSE in this distribution or at
  9. * http://www.rt-thread.org/license/LICENSE
  10. *
  11. * Change Logs:
  12. * Date Author Notes
  13. * 2013-11-06 xiaonong first version.
  14. */
  15. #ifndef __DRV_SD_H
  16. #define __DRV_SD_H
  17. #include <stdint.h>
  18. #include <rtthread.h>
  19. #include <LPC54608.h>
  20. #include "fsl_card.h"
  21. #include "fsl_iocon.h"
  22. #define IOCON_PIO_DIGITAL_EN 0x0100u /*!< Enables digital function */
  23. #define IOCON_PIO_FUNC1 0x01u /*!< Selects pin function 1 */
  24. #define IOCON_PIO_FUNC2 0x02u /*!< Selects pin function 2 */
  25. #define IOCON_PIO_INPFILT_OFF 0x0200u /*!< Input filter disabled */
  26. #define IOCON_PIO_INV_DI 0x00u /*!< Input function is not inverted */
  27. #define IOCON_PIO_MODE_INACT 0x00u /*!< No addition pin function */
  28. #define IOCON_PIO_MODE_PULLUP 0x20u /*!< Selects pull-up function */
  29. #define IOCON_PIO_OPENDRAIN_DI 0x00u /*!< Open drain is disabled */
  30. #define IOCON_PIO_SLEW_FAST 0x0400u /*!< Fast mode, slew rate control is disabled */
  31. #define IOCON_PIO_SLEW_STANDARD 0x00u /*!< Standard mode, output slew rate control is enabled */
  32. #define PIN3_IDX 3u /*!< Pin number for pin 3 in a port 2 */
  33. #define PIN4_IDX 4u /*!< Pin number for pin 4 in a port 2 */
  34. #define PIN5_IDX 5u /*!< Pin number for pin 5 in a port 2 */
  35. #define PIN6_IDX 6u /*!< Pin number for pin 6 in a port 2 */
  36. #define PIN7_IDX 7u /*!< Pin number for pin 7 in a port 2 */
  37. #define PIN8_IDX 8u /*!< Pin number for pin 8 in a port 2 */
  38. #define PIN9_IDX 9u /*!< Pin number for pin 9 in a port 2 */
  39. #define PIN10_IDX 10u /*!< Pin number for pin 10 in a port 2 */
  40. #define PIN15_IDX 15u /*!< Pin number for pin 15 in a port 3 */
  41. #define PIN27_IDX 27u /*!< Pin number for pin 27 in a port 1 */
  42. #define PIN28_IDX 28u /*!< Pin number for pin 28 in a port 1 */
  43. #define PIN29_IDX 29u /*!< Pin number for pin 29 in a port 0 */
  44. #define PIN30_IDX 30u /*!< Pin number for pin 30 in a port 0 */
  45. #define PORT0_IDX 0u /*!< Port index */
  46. #define PORT1_IDX 1u /*!< Port index */
  47. #define PORT2_IDX 2u /*!< Port index */
  48. #define PORT3_IDX 3u /*!< Port index */
  49. struct mci_device
  50. {
  51. struct rt_device parent; /**< RT-Thread device struct */
  52. struct rt_device_blk_geometry geometry; /**< sector size, sector count */
  53. sd_card_t card; /**< Card descriptor */
  54. rt_event_t finish_event; /**< data send finish event*/
  55. rt_bool_t data_error; /**< data send error*/
  56. struct rt_mutex lock;
  57. };
  58. extern rt_err_t mci_hw_init(const char *device_name);
  59. #endif // __DRV_SD_H