SCSI2SD_Bootloader.hh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (C) 2014 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 SCSI2SD_Bootloader_H
  18. #define SCSI2SD_Bootloader_H
  19. #include "hidapi.h"
  20. #include <cstdint>
  21. #include <string>
  22. namespace SCSI2SD
  23. {
  24. class Bootloader
  25. {
  26. public:
  27. static const uint16_t VENDOR_ID = 0x04B4; // Cypress
  28. static const uint16_t PRODUCT_ID = 0xB71D; // Default PSoC3/5LP Bootloader
  29. static const size_t HID_PACKET_SIZE = 64;
  30. static Bootloader* Open();
  31. ~Bootloader();
  32. struct HWInfo
  33. {
  34. std::string desc;
  35. std::string version;
  36. std::string firmwareName;
  37. };
  38. HWInfo getHWInfo() const;
  39. // USB HID data
  40. std::string getDevicePath() const;
  41. std::wstring getManufacturer() const;
  42. std::wstring getProductString() const;
  43. bool isCorrectFirmware(const std::string& path) const;
  44. // progress function accepts flash array ID and row Number
  45. void load(const std::string& path, void (*progress)(uint8_t, uint16_t));
  46. private:
  47. Bootloader(hid_device_info* hidInfo);
  48. hid_device_info* myHidInfo;
  49. hid_device* myBootloaderHandle;
  50. };
  51. } // namespace
  52. #endif