1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
25
26
29
30
34
35
38
41
42
45
48
49
50
53
56
57
58
61
62
65
66
67
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
92
93
94
101
107
108
109
116
117
118
119
120
121
122
126
127
128
129
130
131
138
147
148
149
155
156
157
158
159
166
167
168
169
172
173
176
177
180
181
184
185
/* ... */
#include "usbh_pipes.h"
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
static uint16_t USBH_GetFreePipe(USBH_HandleTypeDef *phost);
/* ... */
USBH_StatusTypeDef USBH_OpenPipe(USBH_HandleTypeDef *phost, uint8_t pipe_num,
uint8_t epnum, uint8_t dev_address,
uint8_t speed, uint8_t ep_type, uint16_t mps)
{
(void)USBH_LL_OpenPipe(phost, pipe_num, epnum, dev_address, speed, ep_type, mps);
return USBH_OK;
}{ ... }
/* ... */
USBH_StatusTypeDef USBH_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe_num)
{
(void)USBH_LL_ClosePipe(phost, pipe_num);
return USBH_OK;
}{ ... }
/* ... */
uint8_t USBH_AllocPipe(USBH_HandleTypeDef *phost, uint8_t ep_addr)
{
uint16_t pipe;
pipe = USBH_GetFreePipe(phost);
if (pipe != 0xFFFFU)
{
phost->Pipes[pipe & 0xFU] = (uint32_t)(0x8000U | ep_addr);
}if (pipe != 0xFFFFU) { ... }
return (uint8_t)pipe;
}{ ... }
/* ... */
USBH_StatusTypeDef USBH_FreePipe(USBH_HandleTypeDef *phost, uint8_t idx)
{
if (idx < USBH_MAX_PIPES_NBR)
{
phost->Pipes[idx] &= 0x7FFFU;
}if (idx < USBH_MAX_PIPES_NBR) { ... }
return USBH_OK;
}{ ... }
/* ... */
static uint16_t USBH_GetFreePipe(USBH_HandleTypeDef *phost)
{
uint8_t idx = 0U;
for (idx = 0U; idx < USBH_MAX_PIPES_NBR; idx++)
{
if ((phost->Pipes[idx] & 0x8000U) == 0U)
{
return (uint16_t)idx;
}if ((phost->Pipes[idx] & 0x8000U) == 0U) { ... }
}for (idx = 0U; idx < USBH_MAX_PIPES_NBR; idx++) { ... }
return 0xFFFFU;
}{ ... }
/* ... */
/* ... */
/* ... */
/* ... */
Includes