STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
usbd_ioreq.c
Go to the documentation of this file.
1/**
2 ******************************************************************************
3 * @file usbd_ioreq.c
4 * @author MCD Application Team
5 * @brief This file provides the IO requests APIs for control endpoints.
6 ******************************************************************************
7 * @attention
8 *
9 * Copyright (c) 2015 STMicroelectronics.
10 * All rights reserved.
11 *
12 * This software is licensed under terms that can be found in the LICENSE file
13 * in the root directory of this software component.
14 * If no LICENSE file comes with this software, it is provided AS-IS.
15 *
16 ******************************************************************************
17 */
18
19/* Includes ------------------------------------------------------------------*/
20#include "usbd_ioreq.h"
21
22/** @addtogroup STM32_USB_DEVICE_LIBRARY
23 * @{
24 */
25
26
27/** @defgroup USBD_IOREQ
28 * @brief control I/O requests module
29 * @{
30 */
31
32/** @defgroup USBD_IOREQ_Private_TypesDefinitions
33 * @{
34 */
35/**
36 * @}
37 */
38
39
40/** @defgroup USBD_IOREQ_Private_Defines
41 * @{
42 */
43
44/**
45 * @}
46 */
47
48
49/** @defgroup USBD_IOREQ_Private_Macros
50 * @{
51 */
52/**
53 * @}
54 */
55
56
57/** @defgroup USBD_IOREQ_Private_Variables
58 * @{
59 */
60
61/**
62 * @}
63 */
64
65
66/** @defgroup USBD_IOREQ_Private_FunctionPrototypes
67 * @{
68 */
69/**
70 * @}
71 */
72
73
74/** @defgroup USBD_IOREQ_Private_Functions
75 * @{
76 */
77
78/**
79 * @brief USBD_CtlSendData
80 * send data on the ctl pipe
81 * @param pdev: device instance
82 * @param buff: pointer to data buffer
83 * @param len: length of data to be sent
84 * @retval status
85 */
87 uint8_t *pbuf, uint32_t len)
88{
89 /* Set EP0 State */
91 pdev->ep_in[0].total_length = len;
92 pdev->ep_in[0].pbuffer = pbuf;
93
94#ifdef USBD_AVOID_PACKET_SPLIT_MPS
95 pdev->ep_in[0].rem_length = 0U;
96#else
97 pdev->ep_in[0].rem_length = len;
98#endif /* USBD_AVOID_PACKET_SPLIT_MPS */
99
100 /* Start the transfer */
101 (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
102
103 return USBD_OK;
104}
105
106/**
107 * @brief USBD_CtlContinueSendData
108 * continue sending data on the ctl pipe
109 * @param pdev: device instance
110 * @param buff: pointer to data buffer
111 * @param len: length of data to be sent
112 * @retval status
113 */
115 uint8_t *pbuf, uint32_t len)
116{
117 /* Start the next transfer */
118 (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
119
120 return USBD_OK;
121}
122
123/**
124 * @brief USBD_CtlPrepareRx
125 * receive data on the ctl pipe
126 * @param pdev: device instance
127 * @param buff: pointer to data buffer
128 * @param len: length of data to be received
129 * @retval status
130 */
132 uint8_t *pbuf, uint32_t len)
133{
134 /* Set EP0 State */
136 pdev->ep_out[0].total_length = len;
137 pdev->ep_out[0].pbuffer = pbuf;
138
139#ifdef USBD_AVOID_PACKET_SPLIT_MPS
140 pdev->ep_out[0].rem_length = 0U;
141#else
142 pdev->ep_out[0].rem_length = len;
143#endif /* USBD_AVOID_PACKET_SPLIT_MPS */
144
145 /* Start the transfer */
146 (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
147
148 return USBD_OK;
149}
150
151/**
152 * @brief USBD_CtlContinueRx
153 * continue receive data on the ctl pipe
154 * @param pdev: device instance
155 * @param buff: pointer to data buffer
156 * @param len: length of data to be received
157 * @retval status
158 */
160 uint8_t *pbuf, uint32_t len)
161{
162 (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
163
164 return USBD_OK;
165}
166
167/**
168 * @brief USBD_CtlSendStatus
169 * send zero lzngth packet on the ctl pipe
170 * @param pdev: device instance
171 * @retval status
172 */
174{
175 /* Set EP0 State */
177
178 /* Start the transfer */
179 (void)USBD_LL_Transmit(pdev, 0x00U, NULL, 0U);
180
181 return USBD_OK;
182}
183
184/**
185 * @brief USBD_CtlReceiveStatus
186 * receive zero lzngth packet on the ctl pipe
187 * @param pdev: device instance
188 * @retval status
189 */
191{
192 /* Set EP0 State */
194
195 /* Start the transfer */
196 (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
197
198 return USBD_OK;
199}
200
201/**
202 * @brief USBD_GetRxCount
203 * returns the received data length
204 * @param pdev: device instance
205 * @param ep_addr: endpoint address
206 * @retval Rx Data blength
207 */
208uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
209{
210 return USBD_LL_GetRxDataSize(pdev, ep_addr);
211}
212
213/**
214 * @}
215 */
216
217
218/**
219 * @}
220 */
221
222
223/**
224 * @}
225 */
226
USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
Transmits data over an endpoint.
Definition usbd_conf.c:560
USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
Prepares an endpoint for reception.
Definition usbd_conf.c:580
uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
Returns the last transferred packet size.
Definition usbd_conf.c:598
struct _USBD_HandleTypeDef USBD_HandleTypeDef
USBD_StatusTypeDef
Definition usbd_def.h:280
@ USBD_OK
Definition usbd_def.h:281
USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev)
USBD_CtlSendStatus send zero lzngth packet on the ctl pipe.
Definition usbd_ioreq.c:173
uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
USBD_GetRxCount returns the received data length.
Definition usbd_ioreq.c:208
USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t len)
USBD_CtlContinueSendData continue sending data on the ctl pipe.
Definition usbd_ioreq.c:114
USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t len)
USBD_CtlContinueRx continue receive data on the ctl pipe.
Definition usbd_ioreq.c:159
USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev)
USBD_CtlReceiveStatus receive zero lzngth packet on the ctl pipe.
Definition usbd_ioreq.c:190
USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t len)
USBD_CtlSendData send data on the ctl pipe.
Definition usbd_ioreq.c:86
USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t len)
USBD_CtlPrepareRx receive data on the ctl pipe.
Definition usbd_ioreq.c:131
#define NULL
Definition usbd_def.h:44
#define USBD_EP0_DATA_IN
Definition usbd_def.h:169
#define USBD_EP0_STATUS_OUT
Definition usbd_def.h:172
#define USBD_EP0_DATA_OUT
Definition usbd_def.h:170
#define USBD_EP0_STATUS_IN
Definition usbd_def.h:171
uint32_t total_length
Definition usbd_def.h:308
USBD_EndpointTypeDef ep_in[16]
Definition usbd_def.h:368
USBD_EndpointTypeDef ep_out[16]
Definition usbd_def.h:369
__IO uint32_t ep0_state
Definition usbd_def.h:370
Header file for the usbd_ioreq.c file.