fatfs_portable.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _FATFS_PORTABLE_H_
  13. #define _FATFS_PORTABLE_H_
  14. #include "osi_compiler.h"
  15. #include "ff.h"
  16. #include "diskio.h"
  17. OSI_EXTERN_C_BEGIN
  18. /**
  19. * \brief forward declaration
  20. */
  21. struct blockDevice;
  22. /**
  23. * \brief register a block device to fatfs
  24. *
  25. * fatfs uses BYTE as device. And the mapping between BYTE and block
  26. * device instance are maintained outside.
  27. *
  28. * \param dev block device
  29. * \return
  30. * - fatfs device index
  31. * - 0xFF on error
  32. */
  33. BYTE fat_disk_register_device(struct blockDevice *dev);
  34. /**
  35. * \brief unregister block device at specified index
  36. *
  37. * \param idx fatfs device index
  38. * \return
  39. * - true on success
  40. * - false on error, invalid parameter
  41. */
  42. bool fat_disk_unregister_device(BYTE idx);
  43. /**
  44. * \brief get drive status
  45. *
  46. * \param idx fatfs device index
  47. * \return drive status
  48. */
  49. DSTATUS fat_disk_status(BYTE idx);
  50. /**
  51. * \brief initialize a drive
  52. *
  53. * \param idx fatfs device index
  54. * \return drive status
  55. */
  56. DSTATUS fat_disk_initialize(BYTE idx);
  57. /**
  58. * \brief read sector or sectors
  59. *
  60. * \param idx fatfs device index
  61. * \param buff data buffer to store read data
  62. * \param sector start sector in LBA
  63. * \param count number of sectors to read
  64. * \return result
  65. */
  66. DRESULT fat_disk_read(BYTE idx, BYTE *buff, DWORD sector, UINT count);
  67. /**
  68. * \brief write sector or sectors
  69. *
  70. * \param idx fatfs device index
  71. * \param buff data to be written
  72. * \param sector start sector in LBA
  73. * \param count number of sectors to read
  74. * \return result
  75. */
  76. DRESULT fat_disk_write(BYTE idx, const BYTE *buff, DWORD sector, UINT count);
  77. /**
  78. * \brief miscellaneous functions
  79. *
  80. * \param idx fatfs device index
  81. * \param cmd control code
  82. * \param buff buffer to send/receive control data
  83. * \return result
  84. */
  85. DRESULT fat_disk_ioctl(BYTE idx, BYTE cmd, void *buff);
  86. OSI_EXTERN_C_END
  87. #endif