Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

89 lines
3.1KB

  1. /**
  2. * Copyright (c) 2011-2019 Bill Greiman
  3. * This file is part of the SdFat library for SD memory cards.
  4. *
  5. * MIT License
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included
  15. * in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. /**
  26. * \file
  27. * \brief BlockDeviceInterface include file.
  28. */
  29. #ifndef BlockDeviceInterface_h
  30. #define BlockDeviceInterface_h
  31. #include <stdint.h>
  32. #include <stddef.h>
  33. #include "../SdFatConfig.h"
  34. /**
  35. * \class BlockDeviceInterface
  36. * \brief BlockDeviceInterface class.
  37. */
  38. class BlockDeviceInterface {
  39. public:
  40. virtual ~BlockDeviceInterface() {}
  41. /**
  42. * Read a 512 byte sector.
  43. *
  44. * \param[in] sector Logical sector to be read.
  45. * \param[out] dst Pointer to the location that will receive the data.
  46. * \return true for success or false for failure.
  47. */
  48. virtual bool readSector(uint32_t sector, uint8_t* dst) = 0;
  49. #if USE_MULTI_SECTOR_IO
  50. /**
  51. * Read multiple 512 byte sectors.
  52. *
  53. * \param[in] sector Logical sector to be read.
  54. * \param[in] ns Number of sectors to be read.
  55. * \param[out] dst Pointer to the location that will receive the data.
  56. * \return true for success or false for failure.
  57. */
  58. virtual bool readSectors(uint32_t sector, uint8_t* dst, size_t ns) = 0;
  59. #endif // USE_MULTI_SECTOR_IO
  60. /** \return device size in sectors. */
  61. virtual uint32_t sectorCount() = 0;
  62. /** End multi-sector transfer and go to idle state.
  63. * \return true for success or false for failure.
  64. */
  65. virtual bool syncDevice() = 0;
  66. /**
  67. * Writes a 512 byte sector.
  68. *
  69. * \param[in] sector Logical sector to be written.
  70. * \param[in] src Pointer to the location of the data to be written.
  71. * \return true for success or false for failure.
  72. */
  73. virtual bool writeSector(uint32_t sector, const uint8_t* src) = 0;
  74. #if USE_MULTI_SECTOR_IO
  75. /**
  76. * Write multiple 512 byte sectors.
  77. *
  78. * \param[in] sector Logical sector to be written.
  79. * \param[in] ns Number of sectors to be written.
  80. * \param[in] src Pointer to the location of the data to be written.
  81. * \return true for success or false for failure.
  82. */
  83. virtual bool writeSectors(uint32_t sector, const uint8_t* src, size_t ns) = 0;
  84. #endif // USE_MULTI_SECTOR_IO
  85. };
  86. #endif // BlockDeviceInterface_h