IOTON boards API using mbed SDK - http://ioton.cc/plataforma-ton

Dependents:   ton-bot_teste ton-bot_seguidor_linha ton-bot_seguidor_parede

Fork of IOTON-API by Kleber Silva

Committer:
krebyy
Date:
Thu Jun 29 20:11:00 2017 +0000
Revision:
1:3a73d77c2cef
Update to TON Board V1.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
krebyy 1:3a73d77c2cef 1 /**
krebyy 1:3a73d77c2cef 2 ******************************************************************************
krebyy 1:3a73d77c2cef 3 * @file usbd_ioreq.c
krebyy 1:3a73d77c2cef 4 * @author MCD Application Team
krebyy 1:3a73d77c2cef 5 * @version V2.3.0
krebyy 1:3a73d77c2cef 6 * @date 04-November-2014
krebyy 1:3a73d77c2cef 7 * @brief This file provides the IO requests APIs for control endpoints.
krebyy 1:3a73d77c2cef 8 ******************************************************************************
krebyy 1:3a73d77c2cef 9 * @attention
krebyy 1:3a73d77c2cef 10 *
krebyy 1:3a73d77c2cef 11 * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
krebyy 1:3a73d77c2cef 12 *
krebyy 1:3a73d77c2cef 13 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
krebyy 1:3a73d77c2cef 14 * You may not use this file except in compliance with the License.
krebyy 1:3a73d77c2cef 15 * You may obtain a copy of the License at:
krebyy 1:3a73d77c2cef 16 *
krebyy 1:3a73d77c2cef 17 * http://www.st.com/software_license_agreement_liberty_v2
krebyy 1:3a73d77c2cef 18 *
krebyy 1:3a73d77c2cef 19 * Unless required by applicable law or agreed to in writing, software
krebyy 1:3a73d77c2cef 20 * distributed under the License is distributed on an "AS IS" BASIS,
krebyy 1:3a73d77c2cef 21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
krebyy 1:3a73d77c2cef 22 * See the License for the specific language governing permissions and
krebyy 1:3a73d77c2cef 23 * limitations under the License.
krebyy 1:3a73d77c2cef 24 *
krebyy 1:3a73d77c2cef 25 ******************************************************************************
krebyy 1:3a73d77c2cef 26 */
krebyy 1:3a73d77c2cef 27
krebyy 1:3a73d77c2cef 28 /* Includes ------------------------------------------------------------------*/
krebyy 1:3a73d77c2cef 29 #include "usbd_ioreq.h"
krebyy 1:3a73d77c2cef 30
krebyy 1:3a73d77c2cef 31 /** @addtogroup STM32_USB_DEVICE_LIBRARY
krebyy 1:3a73d77c2cef 32 * @{
krebyy 1:3a73d77c2cef 33 */
krebyy 1:3a73d77c2cef 34
krebyy 1:3a73d77c2cef 35
krebyy 1:3a73d77c2cef 36 /** @defgroup USBD_IOREQ
krebyy 1:3a73d77c2cef 37 * @brief control I/O requests module
krebyy 1:3a73d77c2cef 38 * @{
krebyy 1:3a73d77c2cef 39 */
krebyy 1:3a73d77c2cef 40
krebyy 1:3a73d77c2cef 41 /** @defgroup USBD_IOREQ_Private_TypesDefinitions
krebyy 1:3a73d77c2cef 42 * @{
krebyy 1:3a73d77c2cef 43 */
krebyy 1:3a73d77c2cef 44 /**
krebyy 1:3a73d77c2cef 45 * @}
krebyy 1:3a73d77c2cef 46 */
krebyy 1:3a73d77c2cef 47
krebyy 1:3a73d77c2cef 48
krebyy 1:3a73d77c2cef 49 /** @defgroup USBD_IOREQ_Private_Defines
krebyy 1:3a73d77c2cef 50 * @{
krebyy 1:3a73d77c2cef 51 */
krebyy 1:3a73d77c2cef 52
krebyy 1:3a73d77c2cef 53 /**
krebyy 1:3a73d77c2cef 54 * @}
krebyy 1:3a73d77c2cef 55 */
krebyy 1:3a73d77c2cef 56
krebyy 1:3a73d77c2cef 57
krebyy 1:3a73d77c2cef 58 /** @defgroup USBD_IOREQ_Private_Macros
krebyy 1:3a73d77c2cef 59 * @{
krebyy 1:3a73d77c2cef 60 */
krebyy 1:3a73d77c2cef 61 /**
krebyy 1:3a73d77c2cef 62 * @}
krebyy 1:3a73d77c2cef 63 */
krebyy 1:3a73d77c2cef 64
krebyy 1:3a73d77c2cef 65
krebyy 1:3a73d77c2cef 66 /** @defgroup USBD_IOREQ_Private_Variables
krebyy 1:3a73d77c2cef 67 * @{
krebyy 1:3a73d77c2cef 68 */
krebyy 1:3a73d77c2cef 69
krebyy 1:3a73d77c2cef 70 /**
krebyy 1:3a73d77c2cef 71 * @}
krebyy 1:3a73d77c2cef 72 */
krebyy 1:3a73d77c2cef 73
krebyy 1:3a73d77c2cef 74
krebyy 1:3a73d77c2cef 75 /** @defgroup USBD_IOREQ_Private_FunctionPrototypes
krebyy 1:3a73d77c2cef 76 * @{
krebyy 1:3a73d77c2cef 77 */
krebyy 1:3a73d77c2cef 78 /**
krebyy 1:3a73d77c2cef 79 * @}
krebyy 1:3a73d77c2cef 80 */
krebyy 1:3a73d77c2cef 81
krebyy 1:3a73d77c2cef 82
krebyy 1:3a73d77c2cef 83 /** @defgroup USBD_IOREQ_Private_Functions
krebyy 1:3a73d77c2cef 84 * @{
krebyy 1:3a73d77c2cef 85 */
krebyy 1:3a73d77c2cef 86
krebyy 1:3a73d77c2cef 87 /**
krebyy 1:3a73d77c2cef 88 * @brief USBD_CtlSendData
krebyy 1:3a73d77c2cef 89 * send data on the ctl pipe
krebyy 1:3a73d77c2cef 90 * @param pdev: device instance
krebyy 1:3a73d77c2cef 91 * @param buff: pointer to data buffer
krebyy 1:3a73d77c2cef 92 * @param len: length of data to be sent
krebyy 1:3a73d77c2cef 93 * @retval status
krebyy 1:3a73d77c2cef 94 */
krebyy 1:3a73d77c2cef 95 USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev,
krebyy 1:3a73d77c2cef 96 uint8_t *pbuf,
krebyy 1:3a73d77c2cef 97 uint16_t len)
krebyy 1:3a73d77c2cef 98 {
krebyy 1:3a73d77c2cef 99 /* Set EP0 State */
krebyy 1:3a73d77c2cef 100 pdev->ep0_state = USBD_EP0_DATA_IN;
krebyy 1:3a73d77c2cef 101 pdev->ep_in[0].total_length = len;
krebyy 1:3a73d77c2cef 102 pdev->ep_in[0].rem_length = len;
krebyy 1:3a73d77c2cef 103 /* Start the transfer */
krebyy 1:3a73d77c2cef 104 USBD_LL_Transmit (pdev, 0x00, pbuf, len);
krebyy 1:3a73d77c2cef 105
krebyy 1:3a73d77c2cef 106 return USBD_OK;
krebyy 1:3a73d77c2cef 107 }
krebyy 1:3a73d77c2cef 108
krebyy 1:3a73d77c2cef 109 /**
krebyy 1:3a73d77c2cef 110 * @brief USBD_CtlContinueSendData
krebyy 1:3a73d77c2cef 111 * continue sending data on the ctl pipe
krebyy 1:3a73d77c2cef 112 * @param pdev: device instance
krebyy 1:3a73d77c2cef 113 * @param buff: pointer to data buffer
krebyy 1:3a73d77c2cef 114 * @param len: length of data to be sent
krebyy 1:3a73d77c2cef 115 * @retval status
krebyy 1:3a73d77c2cef 116 */
krebyy 1:3a73d77c2cef 117 USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev,
krebyy 1:3a73d77c2cef 118 uint8_t *pbuf,
krebyy 1:3a73d77c2cef 119 uint16_t len)
krebyy 1:3a73d77c2cef 120 {
krebyy 1:3a73d77c2cef 121 /* Start the next transfer */
krebyy 1:3a73d77c2cef 122 USBD_LL_Transmit (pdev, 0x00, pbuf, len);
krebyy 1:3a73d77c2cef 123
krebyy 1:3a73d77c2cef 124 return USBD_OK;
krebyy 1:3a73d77c2cef 125 }
krebyy 1:3a73d77c2cef 126
krebyy 1:3a73d77c2cef 127 /**
krebyy 1:3a73d77c2cef 128 * @brief USBD_CtlPrepareRx
krebyy 1:3a73d77c2cef 129 * receive data on the ctl pipe
krebyy 1:3a73d77c2cef 130 * @param pdev: device instance
krebyy 1:3a73d77c2cef 131 * @param buff: pointer to data buffer
krebyy 1:3a73d77c2cef 132 * @param len: length of data to be received
krebyy 1:3a73d77c2cef 133 * @retval status
krebyy 1:3a73d77c2cef 134 */
krebyy 1:3a73d77c2cef 135 USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev,
krebyy 1:3a73d77c2cef 136 uint8_t *pbuf,
krebyy 1:3a73d77c2cef 137 uint16_t len)
krebyy 1:3a73d77c2cef 138 {
krebyy 1:3a73d77c2cef 139 /* Set EP0 State */
krebyy 1:3a73d77c2cef 140 pdev->ep0_state = USBD_EP0_DATA_OUT;
krebyy 1:3a73d77c2cef 141 pdev->ep_out[0].total_length = len;
krebyy 1:3a73d77c2cef 142 pdev->ep_out[0].rem_length = len;
krebyy 1:3a73d77c2cef 143 /* Start the transfer */
krebyy 1:3a73d77c2cef 144 USBD_LL_PrepareReceive (pdev,
krebyy 1:3a73d77c2cef 145 0,
krebyy 1:3a73d77c2cef 146 pbuf,
krebyy 1:3a73d77c2cef 147 len);
krebyy 1:3a73d77c2cef 148
krebyy 1:3a73d77c2cef 149 return USBD_OK;
krebyy 1:3a73d77c2cef 150 }
krebyy 1:3a73d77c2cef 151
krebyy 1:3a73d77c2cef 152 /**
krebyy 1:3a73d77c2cef 153 * @brief USBD_CtlContinueRx
krebyy 1:3a73d77c2cef 154 * continue receive data on the ctl pipe
krebyy 1:3a73d77c2cef 155 * @param pdev: device instance
krebyy 1:3a73d77c2cef 156 * @param buff: pointer to data buffer
krebyy 1:3a73d77c2cef 157 * @param len: length of data to be received
krebyy 1:3a73d77c2cef 158 * @retval status
krebyy 1:3a73d77c2cef 159 */
krebyy 1:3a73d77c2cef 160 USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev,
krebyy 1:3a73d77c2cef 161 uint8_t *pbuf,
krebyy 1:3a73d77c2cef 162 uint16_t len)
krebyy 1:3a73d77c2cef 163 {
krebyy 1:3a73d77c2cef 164
krebyy 1:3a73d77c2cef 165 USBD_LL_PrepareReceive (pdev,
krebyy 1:3a73d77c2cef 166 0,
krebyy 1:3a73d77c2cef 167 pbuf,
krebyy 1:3a73d77c2cef 168 len);
krebyy 1:3a73d77c2cef 169 return USBD_OK;
krebyy 1:3a73d77c2cef 170 }
krebyy 1:3a73d77c2cef 171 /**
krebyy 1:3a73d77c2cef 172 * @brief USBD_CtlSendStatus
krebyy 1:3a73d77c2cef 173 * send zero lzngth packet on the ctl pipe
krebyy 1:3a73d77c2cef 174 * @param pdev: device instance
krebyy 1:3a73d77c2cef 175 * @retval status
krebyy 1:3a73d77c2cef 176 */
krebyy 1:3a73d77c2cef 177 USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev)
krebyy 1:3a73d77c2cef 178 {
krebyy 1:3a73d77c2cef 179
krebyy 1:3a73d77c2cef 180 /* Set EP0 State */
krebyy 1:3a73d77c2cef 181 pdev->ep0_state = USBD_EP0_STATUS_IN;
krebyy 1:3a73d77c2cef 182
krebyy 1:3a73d77c2cef 183 /* Start the transfer */
krebyy 1:3a73d77c2cef 184 USBD_LL_Transmit (pdev, 0x00, NULL, 0);
krebyy 1:3a73d77c2cef 185
krebyy 1:3a73d77c2cef 186 return USBD_OK;
krebyy 1:3a73d77c2cef 187 }
krebyy 1:3a73d77c2cef 188
krebyy 1:3a73d77c2cef 189 /**
krebyy 1:3a73d77c2cef 190 * @brief USBD_CtlReceiveStatus
krebyy 1:3a73d77c2cef 191 * receive zero lzngth packet on the ctl pipe
krebyy 1:3a73d77c2cef 192 * @param pdev: device instance
krebyy 1:3a73d77c2cef 193 * @retval status
krebyy 1:3a73d77c2cef 194 */
krebyy 1:3a73d77c2cef 195 USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev)
krebyy 1:3a73d77c2cef 196 {
krebyy 1:3a73d77c2cef 197 /* Set EP0 State */
krebyy 1:3a73d77c2cef 198 pdev->ep0_state = USBD_EP0_STATUS_OUT;
krebyy 1:3a73d77c2cef 199
krebyy 1:3a73d77c2cef 200 /* Start the transfer */
krebyy 1:3a73d77c2cef 201 USBD_LL_PrepareReceive ( pdev,
krebyy 1:3a73d77c2cef 202 0,
krebyy 1:3a73d77c2cef 203 NULL,
krebyy 1:3a73d77c2cef 204 0);
krebyy 1:3a73d77c2cef 205
krebyy 1:3a73d77c2cef 206 return USBD_OK;
krebyy 1:3a73d77c2cef 207 }
krebyy 1:3a73d77c2cef 208
krebyy 1:3a73d77c2cef 209
krebyy 1:3a73d77c2cef 210 /**
krebyy 1:3a73d77c2cef 211 * @brief USBD_GetRxCount
krebyy 1:3a73d77c2cef 212 * returns the received data length
krebyy 1:3a73d77c2cef 213 * @param pdev: device instance
krebyy 1:3a73d77c2cef 214 * @param ep_addr: endpoint address
krebyy 1:3a73d77c2cef 215 * @retval Rx Data blength
krebyy 1:3a73d77c2cef 216 */
krebyy 1:3a73d77c2cef 217 uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , uint8_t ep_addr)
krebyy 1:3a73d77c2cef 218 {
krebyy 1:3a73d77c2cef 219 return USBD_LL_GetRxDataSize(pdev, ep_addr);
krebyy 1:3a73d77c2cef 220 }
krebyy 1:3a73d77c2cef 221
krebyy 1:3a73d77c2cef 222 /**
krebyy 1:3a73d77c2cef 223 * @}
krebyy 1:3a73d77c2cef 224 */
krebyy 1:3a73d77c2cef 225
krebyy 1:3a73d77c2cef 226
krebyy 1:3a73d77c2cef 227 /**
krebyy 1:3a73d77c2cef 228 * @}
krebyy 1:3a73d77c2cef 229 */
krebyy 1:3a73d77c2cef 230
krebyy 1:3a73d77c2cef 231
krebyy 1:3a73d77c2cef 232 /**
krebyy 1:3a73d77c2cef 233 * @}
krebyy 1:3a73d77c2cef 234 */
krebyy 1:3a73d77c2cef 235
krebyy 1:3a73d77c2cef 236 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/