usb_dfu_proto.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * usb_dfu_proto.h
  3. *
  4. * Copyright (C) 2019 Sylvain Munaut
  5. * All rights reserved.
  6. *
  7. * LGPL v3+, see LICENSE.lgpl3
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 3 of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. */
  23. #pragma once
  24. #define USB_REQ_DFU_DETACH (0)
  25. #define USB_REQ_DFU_DNLOAD (1)
  26. #define USB_REQ_DFU_UPLOAD (2)
  27. #define USB_REQ_DFU_GETSTATUS (3)
  28. #define USB_REQ_DFU_CLRSTATUS (4)
  29. #define USB_REQ_DFU_GETSTATE (5)
  30. #define USB_REQ_DFU_ABORT (6)
  31. #define USB_RT_DFU_DETACH ((0 << 8) | 0x21)
  32. #define USB_RT_DFU_DNLOAD ((1 << 8) | 0x21)
  33. #define USB_RT_DFU_UPLOAD ((2 << 8) | 0xa1)
  34. #define USB_RT_DFU_GETSTATUS ((3 << 8) | 0xa1)
  35. #define USB_RT_DFU_CLRSTATUS ((4 << 8) | 0x21)
  36. #define USB_RT_DFU_GETSTATE ((5 << 8) | 0xa1)
  37. #define USB_RT_DFU_ABORT ((6 << 8) | 0x21)
  38. enum dfu_state {
  39. appIDLE = 0,
  40. appDETACH,
  41. dfuIDLE,
  42. dfuDNLOAD_SYNC,
  43. dfuDNBUSY,
  44. dfuDNLOAD_IDLE,
  45. dfuMANIFEST_SYNC,
  46. dfuMANIFEST,
  47. dfuMANIFEST_WAIT_RESET,
  48. dfuUPLOAD_IDLE,
  49. dfuERROR,
  50. _DFU_MAX_STATE
  51. };
  52. enum dfu_status {
  53. OK = 0,
  54. errTARGET,
  55. errFILE,
  56. errWRITE,
  57. errERASE,
  58. errCHECK_ERASED,
  59. errPROG,
  60. errVERIFY,
  61. errADDRESS,
  62. errNOTDONE,
  63. errFIRMWARE,
  64. errVENDOR,
  65. errUSBR,
  66. errPOR,
  67. errUNKNOWN,
  68. errSTALLEDPKT,
  69. _DFU_MAX_STATUS
  70. };