tusb322.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef _TUSB_322_H_
  2. #define _TUSB_322_H_
  3. #include "mbed.h"
  4. #include "main.h"
  5. #define TUSB322_ADDR 0x47
  6. typedef union {
  7. struct {
  8. uint8_t ACTIVE_CABLE : 1;
  9. uint8_t ACCESSORY : 3;
  10. uint8_t CURRENT_DETECT : 2;
  11. uint8_t CURRENT_ADVERTISE : 2;
  12. };
  13. uint8_t AS_BYTE;
  14. } CONN_STATUS1;
  15. typedef union {
  16. struct {
  17. uint8_t UFP_ACCESSORY : 1;
  18. uint8_t DRP_DUTY_CYCLE : 2;
  19. uint8_t VCONN_FAULT : 1;
  20. uint8_t INTERRUPT : 1;
  21. uint8_t CABLE_DIR : 1;
  22. uint8_t ATTACHED_STATE : 2;
  23. };
  24. uint8_t AS_BYTE;
  25. } CONN_STATUS2;
  26. typedef union {
  27. struct {
  28. uint8_t DISABLE_TERM : 1;
  29. uint8_t SOURCE_PERF : 2;
  30. uint8_t RESET : 1;
  31. uint8_t MODE_SELECT : 2;
  32. uint8_t DEBOUNCE : 2;
  33. };
  34. uint8_t AS_BYTE;
  35. } CTRL;
  36. typedef union {
  37. struct {
  38. uint8_t ID[8]; // +0x00
  39. CONN_STATUS1 Status1; // +0x08
  40. CONN_STATUS2 Status2; // +0x09
  41. CTRL Control; // +0x0A
  42. };
  43. uint8_t AS_BYTE[11];
  44. } TUSB322_REGS;
  45. void TUSB322_Init(void);
  46. #endif