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

76 lines
2.7KB

  1. /* FatLib Library
  2. * Copyright (C) 2016 by William Greiman
  3. *
  4. * This file is part of the FatLib Library
  5. *
  6. * This Library is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This Library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with the FatLib Library. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef BaseBlockDriver_h
  21. #define BaseBlockDriver_h
  22. #include "FatLibConfig.h"
  23. /**
  24. * \class BaseBlockDriver
  25. * \brief Base block driver.
  26. */
  27. class BaseBlockDriver {
  28. public:
  29. /**
  30. * Read a 512 byte block from an SD card.
  31. *
  32. * \param[in] block Logical block to be read.
  33. * \param[out] dst Pointer to the location that will receive the data.
  34. * \return The value true is returned for success and
  35. * the value false is returned for failure.
  36. */
  37. virtual bool readBlock(uint32_t block, uint8_t* dst) = 0;
  38. /** End multi-block transfer and go to idle state.
  39. * \return The value true is returned for success and
  40. * the value false is returned for failure.
  41. */
  42. virtual bool syncBlocks() = 0;
  43. /**
  44. * Writes a 512 byte block to an SD card.
  45. *
  46. * \param[in] block Logical block to be written.
  47. * \param[in] src Pointer to the location of the data to be written.
  48. * \return The value true is returned for success and
  49. * the value false is returned for failure.
  50. */
  51. virtual bool writeBlock(uint32_t block, const uint8_t* src) = 0;
  52. #if USE_MULTI_BLOCK_IO
  53. /**
  54. * Read multiple 512 byte blocks from an SD card.
  55. *
  56. * \param[in] block Logical block to be read.
  57. * \param[in] nb Number of blocks to be read.
  58. * \param[out] dst Pointer to the location that will receive the data.
  59. * \return The value true is returned for success and
  60. * the value false is returned for failure.
  61. */
  62. virtual bool readBlocks(uint32_t block, uint8_t* dst, size_t nb) = 0;
  63. /**
  64. * Write multiple 512 byte blocks to an SD card.
  65. *
  66. * \param[in] block Logical block to be written.
  67. * \param[in] nb Number of blocks to be written.
  68. * \param[in] src Pointer to the location of the data to be written.
  69. * \return The value true is returned for success and
  70. * the value false is returned for failure.
  71. */
  72. virtual bool writeBlocks(uint32_t block, const uint8_t* src, size_t nb) = 0;
  73. #endif // USE_MULTI_BLOCK_IO
  74. };
  75. #endif // BaseBlockDriver_h