sd.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (C) 2013 Michael McMaster <michael@codesrc.com>
  2. //
  3. // This file is part of SCSI2SD.
  4. //
  5. // SCSI2SD is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // SCSI2SD is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with SCSI2SD. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef S2S_SD_H
  18. #define S2S_SD_H
  19. #include <stdint.h>
  20. #define SD_SECTOR_SIZE 512
  21. typedef struct
  22. {
  23. int version; // SDHC = version 2.
  24. uint32_t capacity; // in 512 byte blocks
  25. uint8_t csd[16]; // Unparsed CSD
  26. uint8_t cid[16]; // Unparsed CID
  27. } SdDevice;
  28. extern SdDevice sdDev;
  29. int sdInit(void);
  30. void sdReadDMA(uint32_t lba, uint32_t sectors, uint8_t* outputBuffer);
  31. int sdReadDMAPoll(uint32_t remainingSectors);
  32. void sdReadCmd(uint32_t lba, uint32_t sectors);
  33. void sdReadPIOData(uint32_t sectors);
  34. void sdCompleteTransfer();
  35. void sdKeepAlive();
  36. int sdIsBusy();
  37. #endif