SCSI2SD_Bootloader.hh 1.7 KB

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