diskio_sdio.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*-----------------------------------------------------------------------*/
  2. /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2016 */
  3. /*-----------------------------------------------------------------------*/
  4. /* If a working storage control module is available, it should be */
  5. /* attached to the FatFs via a glue function rather than modifying it. */
  6. /* This is an example of glue functions to attach various exsisting */
  7. /* storage control modules to the FatFs module with a defined API. */
  8. /*-----------------------------------------------------------------------*/
  9. #include "luat_base.h"
  10. #include "luat_sdio.h"
  11. #include "ff.h" /* Obtains integer types */
  12. #include "diskio.h" /* Declarations of disk functions */
  13. #define LUAT_LOG_TAG "fatfs"
  14. #include "luat_log.h"
  15. DSTATUS sdio_initialize (
  16. void* userdata
  17. )
  18. {
  19. return 0;
  20. }
  21. /*-----------------------------------------------------------------------*/
  22. /* Get Disk Status */
  23. /*-----------------------------------------------------------------------*/
  24. DSTATUS sdio_status (
  25. void* userdata
  26. )
  27. {
  28. //if (drv) return STA_NOINIT;
  29. return 0;
  30. }
  31. /*-----------------------------------------------------------------------*/
  32. /* Read Sector(s) */
  33. /*-----------------------------------------------------------------------*/
  34. DRESULT sdio_read (
  35. void* userdata,
  36. BYTE *buff, /* Pointer to the data buffer to store read data */
  37. DWORD sector, /* Start sector number (LBA) */
  38. UINT count /* Sector count (1..128) */
  39. )
  40. {
  41. return 0;
  42. }
  43. /*-----------------------------------------------------------------------*/
  44. /* Write Sector(s) */
  45. /*-----------------------------------------------------------------------*/
  46. DRESULT sdio_write (
  47. void* userdata,
  48. const BYTE *buff, /* Pointer to the data to be written */
  49. DWORD sector, /* Start sector number (LBA) */
  50. UINT count /* Sector count (1..128) */
  51. )
  52. {
  53. return 0;
  54. }
  55. /*-----------------------------------------------------------------------*/
  56. /* Miscellaneous Functions */
  57. /*-----------------------------------------------------------------------*/
  58. DRESULT sdio_ioctl (
  59. void* userdata,
  60. BYTE ctrl, /* Control code */
  61. void *buff /* Buffer to send/receive control data */
  62. )
  63. {
  64. return 0;
  65. }
  66. const block_disk_opts_t sdio_disk_opts = {
  67. .initialize = sdio_initialize,
  68. .status = sdio_status,
  69. .read = sdio_read,
  70. .write = sdio_write,
  71. .ioctl = sdio_ioctl,
  72. };
  73. #ifndef LUAT_COMPILER_NOWEAK
  74. LUAT_WEAK void luat_sdio_set_sdhc_ctrl(block_disk_t *disk)
  75. {
  76. }
  77. #else
  78. void luat_sdio_set_sdhc_ctrl(block_disk_t *disk);
  79. #endif
  80. static block_disk_t disk = {0};
  81. DRESULT diskio_open_sdio(BYTE pdrv, luat_fatfs_sdio_t* userdata) {
  82. // 暂时只支持单个fatfs实例
  83. disk.opts = &sdio_disk_opts;
  84. disk.userdata = userdata;
  85. luat_sdio_set_sdhc_ctrl(&disk);
  86. return diskio_open(pdrv, &disk);
  87. }
  88. //static DWORD get_fattime() {
  89. // how to get?
  90. //}
  91. //--------------------------------------------------------------------------------------