usbh_ch34x.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2024 ~ 2025, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef USBH_CH34X_H
  7. #define USBH_CH34X_H
  8. #include "usb_cdc.h"
  9. /* Requests */
  10. #define CH34X_READ_VERSION 0x5F
  11. #define CH34X_WRITE_REG 0x9A
  12. #define CH34X_READ_REG 0x95
  13. #define CH34X_SERIAL_INIT 0xA1
  14. #define CH34X_MODEM_CTRL 0xA4
  15. // modem control bits
  16. #define CH34X_BIT_RTS (1 << 6)
  17. #define CH34X_BIT_DTR (1 << 5)
  18. #define CH341_CTO_O 0x10
  19. #define CH341_CTO_D 0x20
  20. #define CH341_CTO_R 0x40
  21. #define CH341_CTI_C 0x01
  22. #define CH341_CTI_DS 0x02
  23. #define CH341_CTRL_RI 0x04
  24. #define CH341_CTI_DC 0x08
  25. #define CH341_CTI_ST 0x0f
  26. #define CH341_CTT_M BIT(3)
  27. #define CH341_CTT_F (BIT(2) | BIT(6))
  28. #define CH341_CTT_P BIT(2)
  29. #define CH341_CTT_O BIT(1)
  30. #define CH341_L_ER 0x80
  31. #define CH341_L_ET 0x40
  32. #define CH341_L_PS 0x38
  33. #define CH341_L_PM 0x28
  34. #define CH341_L_PE 0x18
  35. #define CH341_L_PO 0x08
  36. #define CH341_L_SB 0x04
  37. #define CH341_L_D8 0x03
  38. #define CH341_L_D7 0x02
  39. #define CH341_L_D6 0x01
  40. #define CH341_L_D5 0x00
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif /* USBH_CH34X_H */