Subversion Repositories LedShow

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 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 mjames 9
  * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
10
  * All rights reserved.</center></h2>
2 mjames 11
  *
9 mjames 12
  * This software component is licensed by ST under Ultimate Liberty license
13
  * SLA0044, the "License"; You may not use this file except in compliance with
14
  * the License. You may obtain a copy of the License at:
15
  *                      www.st.com/SLA0044
2 mjames 16
  *
17
  ******************************************************************************
9 mjames 18
  */
2 mjames 19
 
20
/* Includes ------------------------------------------------------------------*/
21
#include "usbd_ioreq.h"
22
 
23
/** @addtogroup STM32_USB_DEVICE_LIBRARY
24
  * @{
25
  */
26
 
27
 
9 mjames 28
/** @defgroup USBD_IOREQ
2 mjames 29
  * @brief control I/O requests module
30
  * @{
9 mjames 31
  */
2 mjames 32
 
33
/** @defgroup USBD_IOREQ_Private_TypesDefinitions
34
  * @{
9 mjames 35
  */
2 mjames 36
/**
37
  * @}
9 mjames 38
  */
2 mjames 39
 
40
 
41
/** @defgroup USBD_IOREQ_Private_Defines
42
  * @{
9 mjames 43
  */
2 mjames 44
 
45
/**
46
  * @}
9 mjames 47
  */
2 mjames 48
 
49
 
50
/** @defgroup USBD_IOREQ_Private_Macros
51
  * @{
9 mjames 52
  */
2 mjames 53
/**
54
  * @}
9 mjames 55
  */
2 mjames 56
 
57
 
58
/** @defgroup USBD_IOREQ_Private_Variables
59
  * @{
9 mjames 60
  */
2 mjames 61
 
62
/**
63
  * @}
9 mjames 64
  */
2 mjames 65
 
66
 
67
/** @defgroup USBD_IOREQ_Private_FunctionPrototypes
68
  * @{
9 mjames 69
  */
2 mjames 70
/**
71
  * @}
9 mjames 72
  */
2 mjames 73
 
74
 
75
/** @defgroup USBD_IOREQ_Private_Functions
76
  * @{
9 mjames 77
  */
2 mjames 78
 
79
/**
80
* @brief  USBD_CtlSendData
81
*         send data on the ctl pipe
82
* @param  pdev: device instance
83
* @param  buff: pointer to data buffer
84
* @param  len: length of data to be sent
85
* @retval status
86
*/
9 mjames 87
USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
88
                                    uint8_t *pbuf, uint16_t len)
2 mjames 89
{
90
  /* Set EP0 State */
9 mjames 91
  pdev->ep0_state = USBD_EP0_DATA_IN;
2 mjames 92
  pdev->ep_in[0].total_length = len;
93
  pdev->ep_in[0].rem_length   = len;
9 mjames 94
 
95
  /* Start the transfer */
96
  USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
97
 
2 mjames 98
  return USBD_OK;
99
}
100
 
101
/**
102
* @brief  USBD_CtlContinueSendData
103
*         continue sending data on the ctl pipe
104
* @param  pdev: device instance
105
* @param  buff: pointer to data buffer
106
* @param  len: length of data to be sent
107
* @retval status
108
*/
9 mjames 109
USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
110
                                            uint8_t *pbuf, uint16_t len)
2 mjames 111
{
9 mjames 112
  /* Start the next transfer */
113
  USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
114
 
2 mjames 115
  return USBD_OK;
116
}
117
 
118
/**
119
* @brief  USBD_CtlPrepareRx
120
*         receive data on the ctl pipe
121
* @param  pdev: device instance
122
* @param  buff: pointer to data buffer
123
* @param  len: length of data to be received
124
* @retval status
125
*/
9 mjames 126
USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
127
                                     uint8_t *pbuf, uint16_t len)
2 mjames 128
{
129
  /* Set EP0 State */
9 mjames 130
  pdev->ep0_state = USBD_EP0_DATA_OUT;
2 mjames 131
  pdev->ep_out[0].total_length = len;
132
  pdev->ep_out[0].rem_length   = len;
9 mjames 133
 
2 mjames 134
  /* Start the transfer */
9 mjames 135
  USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
136
 
2 mjames 137
  return USBD_OK;
138
}
139
 
140
/**
141
* @brief  USBD_CtlContinueRx
142
*         continue receive data on the ctl pipe
143
* @param  pdev: device instance
144
* @param  buff: pointer to data buffer
145
* @param  len: length of data to be received
146
* @retval status
147
*/
9 mjames 148
USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
149
                                      uint8_t *pbuf, uint16_t len)
2 mjames 150
{
9 mjames 151
  USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
2 mjames 152
 
153
  return USBD_OK;
154
}
9 mjames 155
 
2 mjames 156
/**
157
* @brief  USBD_CtlSendStatus
158
*         send zero lzngth packet on the ctl pipe
159
* @param  pdev: device instance
160
* @retval status
161
*/
9 mjames 162
USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev)
2 mjames 163
{
164
  /* Set EP0 State */
165
  pdev->ep0_state = USBD_EP0_STATUS_IN;
9 mjames 166
 
167
  /* Start the transfer */
168
  USBD_LL_Transmit(pdev, 0x00U, NULL, 0U);
169
 
2 mjames 170
  return USBD_OK;
171
}
172
 
173
/**
174
* @brief  USBD_CtlReceiveStatus
175
*         receive zero lzngth packet on the ctl pipe
176
* @param  pdev: device instance
177
* @retval status
178
*/
9 mjames 179
USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev)
2 mjames 180
{
181
  /* Set EP0 State */
9 mjames 182
  pdev->ep0_state = USBD_EP0_STATUS_OUT;
2 mjames 183
 
9 mjames 184
  /* Start the transfer */
185
  USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
186
 
2 mjames 187
  return USBD_OK;
188
}
189
 
190
/**
191
* @brief  USBD_GetRxCount
192
*         returns the received data length
193
* @param  pdev: device instance
194
* @param  ep_addr: endpoint address
195
* @retval Rx Data blength
196
*/
9 mjames 197
uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
2 mjames 198
{
199
  return USBD_LL_GetRxDataSize(pdev, ep_addr);
200
}
201
 
202
/**
203
  * @}
9 mjames 204
  */
2 mjames 205
 
206
 
207
/**
208
  * @}
9 mjames 209
  */
2 mjames 210
 
211
 
212
/**
213
  * @}
9 mjames 214
  */
2 mjames 215
 
216
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/