M480 BSP  V3.05.001
The Board Support Package for M480 Series
hub.h
Go to the documentation of this file.
1 /**************************************************************************/
10 #ifndef _USBH_HUB_H_
11 #define _USBH_HUB_H_
12 
13 
15 
16 
17 /*--------------------------------------------------------------------------*/
18 /* Hub class feature selectors (Table 11-17) */
19 /*--------------------------------------------------------------------------*/
20 #define FS_C_HUB_LOCAL_POWER 0
21 #define FS_C_HUB_OVER_CURRENT 1
22 
23 #define FS_PORT_CONNECTION 0
24 #define FS_PORT_ENABLE 1
25 #define FS_PORT_SUSPEND 2
26 #define FS_PORT_OVER_CURRENT 3
27 #define FS_PORT_RESET 4
28 #define FS_PORT_POWER 8
29 #define FS_C_PORT_CONNECTION 16
30 #define FS_C_PORT_ENABLE 17
31 #define FS_C_PORT_SUSPEND 18
32 #define FS_C_PORT_OVER_CURRENT 19
33 #define FS_C_PORT_RESET 20
34 
35 /*--------------------------------------------------------------------------*/
36 /* Hub/Port staus and change bits */
37 /*--------------------------------------------------------------------------*/
38 #define HUB_S_LOCAL_POWER (1UL << 0)
39 #define HUB_S_OVERCURRENT (1UL << 1)
40 
41 #define HUB_C_LOCAL_POWER (1UL << 0)
42 #define HUB_C_OVERCURRENT (1UL << 1)
43 
44 #define PORT_S_CONNECTION (1UL << 0)
45 #define PORT_S_ENABLE (1UL << 1)
46 #define PORT_S_SUSPEND (1UL << 2)
47 #define PORT_S_OVERCURRENT (1UL << 3)
48 #define PORT_S_RESET (1UL << 4)
49 #define PORT_S_PORT_POWER (1UL << 8)
50 #define PORT_S_LOW_SPEED (1UL << 9)
51 #define PORT_S_HIGH_SPEED (1UL << 10)
52 #define PORT_S_TEST (1UL << 11)
53 #define PORT_S_INDICATOR (1UL << 12)
54 
55 #define PORT_C_CONNECTION (1UL << 0)
56 #define PORT_C_ENABLE (1UL << 1)
57 #define PORT_C_SUSPEND (1UL << 2)
58 #define PORT_C_OVERCURRENT (1UL << 3)
59 #define PORT_C_RESET (1UL << 4)
60 
61 
62 /*--------------------------------------------------------------------------*/
63 /* Hub descriptor */
64 /*--------------------------------------------------------------------------*/
65 #ifdef __ICCARM__
66 typedef struct
67 {
68  __packed uint8_t bDescLength;
69  __packed uint8_t bDescriptorType;
70  __packed uint8_t bNbrPorts;
71  __packed uint16_t wHubCharacteristics;
72  __packed uint8_t bPwrOn2PwrGood;
73  __packed uint8_t bHubContrCurrent;
74  __packed uint8_t bDeviceRemovble;
75  __packed uint8_t PortPwrCtrlMask[16];
76 } DESC_HUB_T;
77 #else
78 typedef struct __attribute__((__packed__))
79 {
80  uint8_t bDescLength;
81  uint8_t bDescriptorType;
82  uint8_t bNbrPorts;
83  uint16_t wHubCharacteristics;
84  uint8_t bPwrOn2PwrGood;
85  uint8_t bHubContrCurrent;
86  uint8_t bDeviceRemovble;
87  uint8_t PortPwrCtrlMask[16];
88 }
89 DESC_HUB_T;
90 #endif
91 
92 /*
93  * wHubCharacteristics bit field mask
94  */
95 #define HUB_CHAR_LPSM 0x0003 /* 00b: global port power, 01b: per port power, 1x: reserved */
96 #define HUB_CHAR_COMPOUND 0x0004 /* 1: is part of a compond device, 0: is not. */
97 #define HUB_CHAR_OCPM 0x0018 /* 00b: global over-current protection, 01b: per port, 1x: reserved */
98 #define HUB_CHAR_TTTT 0x0060 /* TT think time. 00b: 8FS, 01b: 16FS, 10b: 24FS, 11b: 32FS */
99 #define HUB_CHAR_PORTIND 0x0080 /* 1: port indicator (LED) supported, 0: not */
100 
101 /* port indicator status selectors */
102 #define HUB_LED_AUTO 0
103 #define HUB_LED_AMBER 1
104 #define HUB_LED_GREEN 2
105 #define HUB_LED_OFF 3
106 
107 
108 /*--------------------------------------------------------------------------*/
109 /* Port reset retry and time-out settings */
110 /*--------------------------------------------------------------------------*/
111 #define HUB_DEBOUNCE_TIME 500 /* Hub connect/disconnect de-bounce time in ms */
112 #define PORT_RESET_RETRY 3 /* port reset retry times */
113 #define PORT_RESET_TIME_MS 50 /* port reset time (ms) */
114 #define PORT_RESET_RETRY_INC_MS 250 /* increased reset time (ms) after reset failed */
115 
116 
117 #define HUB_STATUS_MAX_BYTE 2 /* maximum number of interrupt-in status bytes */
118 /* 2 can support up to 16 port hubs */
119 /* 4 can support up to 32 port hubs */
120 /* Note!! If modeifed to 4, "uint16_t sc_bitmap" */
121 /* MUST be changed as "uint32_t sc_bitmap" */
122 typedef struct hub_dev_t
123 {
124  IFACE_T *iface;
125  UTR_T *utr;
126  uint8_t buff[HUB_STATUS_MAX_BYTE];
127  uint16_t sc_bitmap;
128  uint8_t bNbrPorts;
129  uint8_t bPwrOn2PwrGood;
130  char pos_id[MAX_HUB_DEVICE+1];
131  int (*port_reset)(struct hub_dev_t *hub, int port);
132  UDEV_T *children;
133 } HUB_DEV_T;
134 
135 
137 
138 #endif /* _USBH_HUB_H_ */
void *__dso_handle __attribute__((weak))
Definition: _syscalls.c:35