You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.3KB

  1. /* Arduino SdFat Library
  2. * Copyright (C) 2012 by William Greiman
  3. *
  4. * This file is part of the Arduino SdFat 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 Arduino SdFat Library. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef SdVolume_h
  21. #include "SdSpiCard.h"
  22. #include "utility/FatLib.h"
  23. #define SdVolume_h
  24. #ifndef USE_SD_VOLUME
  25. #error SdVolume is deperacated. Remove this line to continue using this class.
  26. #endif // USE_SD_VOLUME
  27. //==============================================================================
  28. /**
  29. * \class SdVolume
  30. * \brief SdVolume Soon to be removed.
  31. */
  32. class SdVolume : public FatVolume {
  33. public:
  34. /** Initialize a FAT volume. Try partition one first then try super
  35. * floppy format.
  36. *
  37. * \param[in] dev The Sd2Card where the volume is located.
  38. *
  39. * \return true for success else false.
  40. */
  41. bool init(Sd2Card* dev) {
  42. return init(dev, 1) ? true : init(dev, 0);
  43. }
  44. /** Initialize a FAT volume.
  45. *
  46. * \param[in] dev The Sd2Card where the volume is located.
  47. * \param[in] part the partition to use. Zero for super floppy or 1-4.
  48. * \return true for success else false.
  49. */
  50. bool init(Sd2Card* dev, uint8_t part) {
  51. m_sdCard = dev;
  52. return FatVolume::init(part);
  53. }
  54. private:
  55. // friend class FatFile;
  56. bool readBlock(uint32_t block, uint8_t* dst) {
  57. return m_sdCard->readBlock(block, dst);
  58. }
  59. bool writeBlock(uint32_t block, const uint8_t* src) {
  60. return m_sdCard->writeBlock(block, src);
  61. }
  62. bool readBlocks(uint32_t block, uint8_t* dst, size_t n) {
  63. return m_sdCard->readBlocks(block, dst, n);
  64. }
  65. bool writeBlocks(uint32_t block, const uint8_t* src, size_t n) {
  66. return m_sdCard->writeBlocks(block, src, n);
  67. }
  68. Sd2Card* m_sdCard; // Sd2Card object for cache
  69. };
  70. #endif // SdVolume_h