dap_main.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2023 ~ 2025, sakumisu
  3. * Copyright (c) 2023 ~ 2025, HalfSweet
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. #ifndef DAP_MAIN_H
  8. #define DAP_MAIN_H
  9. #include "usbd_core.h"
  10. #include "usbd_cdc.h"
  11. #include "usbd_msc.h"
  12. #include "usbd_hid.h"
  13. #include "chry_ringbuffer.h"
  14. #include "DAP_config.h"
  15. #include "DAP.h"
  16. #define DAP_IN_EP 0x81
  17. #define DAP_OUT_EP 0x02
  18. #define CDC_IN_EP 0x83
  19. #define CDC_OUT_EP 0x04
  20. #define CDC_INT_EP 0x85
  21. #define MSC_IN_EP 0x86
  22. #define MSC_OUT_EP 0x07
  23. #define HID_IN_EP 0x88
  24. #define HID_OUT_EP 0x09
  25. #define USBD_VID 0x0D28
  26. #define USBD_PID 0x0204
  27. #define USBD_MAX_POWER 500
  28. #define USBD_LANGID_STRING 1033
  29. #ifdef CONFIG_USB_HS
  30. #if DAP_PACKET_SIZE != 512
  31. #error "DAP_PACKET_SIZE must be 512 in hs"
  32. #endif
  33. #else
  34. #if DAP_PACKET_SIZE != 64
  35. #error "DAP_PACKET_SIZE must be 64 in fs"
  36. #endif
  37. #endif
  38. #ifdef CONFIG_USB_HS
  39. #define HID_PACKET_SIZE 1024
  40. #else
  41. #define HID_PACKET_SIZE 64
  42. #endif
  43. #define CONFIG_UARTRX_RINGBUF_SIZE (8 * 1024)
  44. #define CONFIG_USBRX_RINGBUF_SIZE (8 * 1024)
  45. #ifndef CONFIG_CHERRYDAP_USE_MSC
  46. #define CONFIG_CHERRYDAP_USE_MSC 0
  47. #endif
  48. #ifndef CONFIG_CHERRYDAP_USE_CUSTOM_HID
  49. #define CONFIG_CHERRYDAP_USE_CUSTOM_HID 0
  50. #endif
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. extern char serial_number_dynamic[36];
  55. extern struct usbd_interface hid_intf;
  56. extern chry_ringbuffer_t g_uartrx;
  57. extern chry_ringbuffer_t g_usbrx;
  58. void chry_dap_init(uint8_t busid, uint32_t reg_base);
  59. void chry_dap_handle(void);
  60. void chry_dap_usb2uart_handle(void);
  61. /* implment by user */
  62. extern void chry_dap_usb2uart_uart_config_callback(struct cdc_line_coding *line_coding);
  63. /* implment by user */
  64. extern void chry_dap_usb2uart_uart_send_bydma(uint8_t *data, uint16_t len);
  65. void chry_dap_usb2uart_uart_send_complete(uint32_t size);
  66. /* implment by user */
  67. extern void hid_custom_notify_handler(uint8_t busid, uint8_t event, void *arg);
  68. /* implment by user */
  69. extern void usbd_hid_custom_in_callback(uint8_t busid, uint8_t ep, uint32_t nbytes);
  70. /* implment by user */
  71. extern void usbd_hid_custom_out_callback(uint8_t busid, uint8_t ep, uint32_t nbytes);
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif