My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

usb_host.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. #include <stdint.h>
  24. typedef enum {
  25. USB_STATE_INIT,
  26. USB_STATE_ERROR,
  27. USB_STATE_RUNNING,
  28. } usb_state_t;
  29. class USBHost {
  30. public:
  31. bool start();
  32. void Task();
  33. uint8_t getUsbTaskState();
  34. void setUsbTaskState(uint8_t state);
  35. uint8_t regRd(uint8_t reg) { return 0x0; };
  36. uint8_t usb_task_state = USB_STATE_INIT;
  37. uint8_t lun = 0;
  38. uint32_t capacity = 0;
  39. uint16_t block_size = 0;
  40. uint32_t block_count = 0;
  41. };
  42. class BulkStorage {
  43. public:
  44. BulkStorage(USBHost *usb) : usb(usb) {};
  45. bool LUNIsGood(uint8_t t);
  46. uint32_t GetCapacity(uint8_t lun);
  47. uint16_t GetSectorSize(uint8_t lun);
  48. uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf);
  49. uint8_t Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf);
  50. USBHost *usb;
  51. };
  52. extern USBHost usb;
  53. extern BulkStorage bulk;