USB device stack

Dependents:   mbed-mX-USB-TEST1 USBMSD_SD_HID_HelloWorld HidTest MIDI_usb_bridge ... more

Legacy Warning

This is an mbed 2 library. To learn more about mbed OS 5, visit the docs.

Pull requests against this repository are no longer supported. Please raise against mbed OS 5 as documented above.

Committer:
Kojto
Date:
Thu Jul 27 12:14:04 2017 +0100
Revision:
71:53949e6131f6
Update libraries

Fixes the previous commmit, as some devices were not copied. USBDevice contains
now targets directory with all targets implementations

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 71:53949e6131f6 1 /*******************************************************************************
Kojto 71:53949e6131f6 2 * DISCLAIMER
Kojto 71:53949e6131f6 3 * This software is supplied by Renesas Electronics Corporation and is only
Kojto 71:53949e6131f6 4 * intended for use with Renesas products. No other uses are authorized. This
Kojto 71:53949e6131f6 5 * software is owned by Renesas Electronics Corporation and is protected under
Kojto 71:53949e6131f6 6 * all applicable laws, including copyright laws.
Kojto 71:53949e6131f6 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
Kojto 71:53949e6131f6 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
Kojto 71:53949e6131f6 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
Kojto 71:53949e6131f6 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
Kojto 71:53949e6131f6 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
Kojto 71:53949e6131f6 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
Kojto 71:53949e6131f6 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
Kojto 71:53949e6131f6 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
Kojto 71:53949e6131f6 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Kojto 71:53949e6131f6 16 * Renesas reserves the right, without notice, to make changes to this software
Kojto 71:53949e6131f6 17 * and to discontinue the availability of this software. By using this software,
Kojto 71:53949e6131f6 18 * you agree to the additional terms and conditions found by accessing the
Kojto 71:53949e6131f6 19 * following link:
Kojto 71:53949e6131f6 20 * http://www.renesas.com/disclaimer
Kojto 71:53949e6131f6 21 * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
Kojto 71:53949e6131f6 22 *******************************************************************************/
Kojto 71:53949e6131f6 23 /*******************************************************************************
Kojto 71:53949e6131f6 24 * File Name : usb0_function_sub.c
Kojto 71:53949e6131f6 25 * $Rev: 1116 $
Kojto 71:53949e6131f6 26 * $Date:: 2014-07-09 16:29:19 +0900#$
Kojto 71:53949e6131f6 27 * Device(s) : RZ/A1H
Kojto 71:53949e6131f6 28 * Tool-Chain :
Kojto 71:53949e6131f6 29 * OS : None
Kojto 71:53949e6131f6 30 * H/W Platform :
Kojto 71:53949e6131f6 31 * Description : RZ/A1H R7S72100 USB Sample Program
Kojto 71:53949e6131f6 32 * Operation :
Kojto 71:53949e6131f6 33 * Limitations :
Kojto 71:53949e6131f6 34 *******************************************************************************/
Kojto 71:53949e6131f6 35
Kojto 71:53949e6131f6 36
Kojto 71:53949e6131f6 37 /*******************************************************************************
Kojto 71:53949e6131f6 38 Includes <System Includes> , "Project Includes"
Kojto 71:53949e6131f6 39 *******************************************************************************/
Kojto 71:53949e6131f6 40 #include "usb0_function.h"
Kojto 71:53949e6131f6 41
Kojto 71:53949e6131f6 42
Kojto 71:53949e6131f6 43 /*******************************************************************************
Kojto 71:53949e6131f6 44 Typedef definitions
Kojto 71:53949e6131f6 45 *******************************************************************************/
Kojto 71:53949e6131f6 46
Kojto 71:53949e6131f6 47
Kojto 71:53949e6131f6 48 /*******************************************************************************
Kojto 71:53949e6131f6 49 Macro definitions
Kojto 71:53949e6131f6 50 *******************************************************************************/
Kojto 71:53949e6131f6 51
Kojto 71:53949e6131f6 52
Kojto 71:53949e6131f6 53 /*******************************************************************************
Kojto 71:53949e6131f6 54 Imported global variables and functions (from other files)
Kojto 71:53949e6131f6 55 *******************************************************************************/
Kojto 71:53949e6131f6 56 #if 0
Kojto 71:53949e6131f6 57 extern const uint16_t *g_usb0_function_EndPntPtr[];
Kojto 71:53949e6131f6 58 extern uint8_t g_usb0_function_DeviceDescriptor[];
Kojto 71:53949e6131f6 59 extern uint8_t *g_usb0_function_ConfigurationPtr[];
Kojto 71:53949e6131f6 60 #endif
Kojto 71:53949e6131f6 61
Kojto 71:53949e6131f6 62
Kojto 71:53949e6131f6 63 /*******************************************************************************
Kojto 71:53949e6131f6 64 Exported global variables and functions (to be accessed by other files)
Kojto 71:53949e6131f6 65 *******************************************************************************/
Kojto 71:53949e6131f6 66
Kojto 71:53949e6131f6 67
Kojto 71:53949e6131f6 68 /*******************************************************************************
Kojto 71:53949e6131f6 69 Private global variables and functions
Kojto 71:53949e6131f6 70 *******************************************************************************/
Kojto 71:53949e6131f6 71
Kojto 71:53949e6131f6 72
Kojto 71:53949e6131f6 73 /*******************************************************************************
Kojto 71:53949e6131f6 74 * Function Name: usb0_function_ResetDCP
Kojto 71:53949e6131f6 75 * Description : Initializes the default control pipe(DCP).
Kojto 71:53949e6131f6 76 * Outline : Reset default control pipe
Kojto 71:53949e6131f6 77 * Arguments : none
Kojto 71:53949e6131f6 78 * Return Value : none
Kojto 71:53949e6131f6 79 *******************************************************************************/
Kojto 71:53949e6131f6 80 void usb0_function_ResetDCP (void)
Kojto 71:53949e6131f6 81 {
Kojto 71:53949e6131f6 82 USB200.DCPCFG = 0;
Kojto 71:53949e6131f6 83 #if 0
Kojto 71:53949e6131f6 84 USB200.DCPMAXP = g_usb0_function_DeviceDescriptor[7];
Kojto 71:53949e6131f6 85 #else
Kojto 71:53949e6131f6 86 USB200.DCPMAXP = 64;
Kojto 71:53949e6131f6 87 #endif
Kojto 71:53949e6131f6 88
Kojto 71:53949e6131f6 89 USB200.CFIFOSEL = (uint16_t)(USB_FUNCTION_BITMBW_8 | USB_FUNCTION_BITBYTE_LITTLE);
Kojto 71:53949e6131f6 90 USB200.D0FIFOSEL = (uint16_t)(USB_FUNCTION_BITMBW_8 | USB_FUNCTION_BITBYTE_LITTLE);
Kojto 71:53949e6131f6 91 USB200.D1FIFOSEL = (uint16_t)(USB_FUNCTION_BITMBW_8 | USB_FUNCTION_BITBYTE_LITTLE);
Kojto 71:53949e6131f6 92 }
Kojto 71:53949e6131f6 93
Kojto 71:53949e6131f6 94 /*******************************************************************************
Kojto 71:53949e6131f6 95 * Function Name: usb0_function_ResetEP
Kojto 71:53949e6131f6 96 * Description : Initializes the end point.
Kojto 71:53949e6131f6 97 * Arguments : uint16_t num ; Configuration Number
Kojto 71:53949e6131f6 98 * Return Value : none
Kojto 71:53949e6131f6 99 *******************************************************************************/
Kojto 71:53949e6131f6 100 #if 0
Kojto 71:53949e6131f6 101 void usb0_function_ResetEP (uint16_t num)
Kojto 71:53949e6131f6 102 {
Kojto 71:53949e6131f6 103 uint16_t pipe;
Kojto 71:53949e6131f6 104 uint16_t ep;
Kojto 71:53949e6131f6 105 uint16_t index;
Kojto 71:53949e6131f6 106 uint16_t buf;
Kojto 71:53949e6131f6 107 uint16_t * tbl;
Kojto 71:53949e6131f6 108
Kojto 71:53949e6131f6 109 tbl = (uint16_t *)(g_usb0_function_EndPntPtr[num - 1]);
Kojto 71:53949e6131f6 110
Kojto 71:53949e6131f6 111 for (ep = 1; ep <= USB_FUNCTION_MAX_EP_NO; ++ep)
Kojto 71:53949e6131f6 112 {
Kojto 71:53949e6131f6 113 if (g_usb0_function_EPTableIndex[ep] != USB_FUNCTION_EP_ERROR)
Kojto 71:53949e6131f6 114 {
Kojto 71:53949e6131f6 115 index = (uint16_t)(USB_FUNCTION_EPTABLE_LENGTH * g_usb0_function_EPTableIndex[ep]);
Kojto 71:53949e6131f6 116 pipe = (uint16_t)(tbl[index + 0] & USB_FUNCTION_BITCURPIPE);
Kojto 71:53949e6131f6 117
Kojto 71:53949e6131f6 118 g_usb0_function_PipeTbl[pipe] = (uint16_t)( ((tbl[index + 1] & USB_FUNCTION_DIRFIELD) << 3) |
Kojto 71:53949e6131f6 119 ep |
Kojto 71:53949e6131f6 120 (tbl[index + 0] & USB_FUNCTION_FIFO_USE) );
Kojto 71:53949e6131f6 121
Kojto 71:53949e6131f6 122 if ((tbl[index + 1] & USB_FUNCTION_DIRFIELD) == USB_FUNCTION_DIR_P_OUT)
Kojto 71:53949e6131f6 123 {
Kojto 71:53949e6131f6 124 tbl[index + 1] |= USB_FUNCTION_SHTNAKON;
Kojto 71:53949e6131f6 125 #ifdef __USB_DMA_BFRE_ENABLE__
Kojto 71:53949e6131f6 126 /* this routine cannnot be perfomred if read operation is executed in buffer size */
Kojto 71:53949e6131f6 127 if (((tbl[index + 0] & USB_FUNCTION_FIFO_USE) == USB_FUNCTION_D0FIFO_DMA) ||
Kojto 71:53949e6131f6 128 ((tbl[index + 0] & USB_FUNCTION_FIFO_USE) == USB_FUNCTION_D1FIFO_DMA))
Kojto 71:53949e6131f6 129 {
Kojto 71:53949e6131f6 130 tbl[index + 1] |= USB_FUNCTION_BFREON;
Kojto 71:53949e6131f6 131 }
Kojto 71:53949e6131f6 132 #endif
Kojto 71:53949e6131f6 133 }
Kojto 71:53949e6131f6 134
Kojto 71:53949e6131f6 135 /* Interrupt Disable */
Kojto 71:53949e6131f6 136 buf = USB200.BRDYENB;
Kojto 71:53949e6131f6 137 buf &= (uint16_t)~g_usb0_function_bit_set[pipe];
Kojto 71:53949e6131f6 138 USB200.BRDYENB = buf;
Kojto 71:53949e6131f6 139 buf = USB200.NRDYENB;
Kojto 71:53949e6131f6 140 buf &= (uint16_t)~g_usb0_function_bit_set[pipe];
Kojto 71:53949e6131f6 141 USB200.NRDYENB = buf;
Kojto 71:53949e6131f6 142 buf = USB200.BEMPENB;
Kojto 71:53949e6131f6 143 buf &= (uint16_t)~g_usb0_function_bit_set[pipe];
Kojto 71:53949e6131f6 144 USB200.BEMPENB = buf;
Kojto 71:53949e6131f6 145
Kojto 71:53949e6131f6 146 usb0_function_set_pid_nak(pipe);
Kojto 71:53949e6131f6 147
Kojto 71:53949e6131f6 148 /* CurrentPIPE Clear */
Kojto 71:53949e6131f6 149 if (RZA_IO_RegRead_16(&USB200.CFIFOSEL,
Kojto 71:53949e6131f6 150 USB_CFIFOSEL_CURPIPE_SHIFT,
Kojto 71:53949e6131f6 151 USB_CFIFOSEL_CURPIPE) == pipe)
Kojto 71:53949e6131f6 152 {
Kojto 71:53949e6131f6 153 RZA_IO_RegWrite_16(&USB200.CFIFOSEL,
Kojto 71:53949e6131f6 154 0,
Kojto 71:53949e6131f6 155 USB_CFIFOSEL_CURPIPE_SHIFT,
Kojto 71:53949e6131f6 156 USB_CFIFOSEL_CURPIPE);
Kojto 71:53949e6131f6 157 }
Kojto 71:53949e6131f6 158
Kojto 71:53949e6131f6 159 if (RZA_IO_RegRead_16(&USB200.D0FIFOSEL,
Kojto 71:53949e6131f6 160 USB_DnFIFOSEL_CURPIPE_SHIFT,
Kojto 71:53949e6131f6 161 USB_DnFIFOSEL_CURPIPE) == pipe)
Kojto 71:53949e6131f6 162 {
Kojto 71:53949e6131f6 163 RZA_IO_RegWrite_16(&USB200.D0FIFOSEL,
Kojto 71:53949e6131f6 164 0,
Kojto 71:53949e6131f6 165 USB_DnFIFOSEL_CURPIPE_SHIFT,
Kojto 71:53949e6131f6 166 USB_DnFIFOSEL_CURPIPE);
Kojto 71:53949e6131f6 167 }
Kojto 71:53949e6131f6 168
Kojto 71:53949e6131f6 169 if (RZA_IO_RegRead_16(&USB200.D1FIFOSEL,
Kojto 71:53949e6131f6 170 USB_DnFIFOSEL_CURPIPE_SHIFT,
Kojto 71:53949e6131f6 171 USB_DnFIFOSEL_CURPIPE) == pipe)
Kojto 71:53949e6131f6 172 {
Kojto 71:53949e6131f6 173 RZA_IO_RegWrite_16(&USB200.D1FIFOSEL,
Kojto 71:53949e6131f6 174 0,
Kojto 71:53949e6131f6 175 USB_DnFIFOSEL_CURPIPE_SHIFT,
Kojto 71:53949e6131f6 176 USB_DnFIFOSEL_CURPIPE);
Kojto 71:53949e6131f6 177 }
Kojto 71:53949e6131f6 178
Kojto 71:53949e6131f6 179 /* PIPE Configuration */
Kojto 71:53949e6131f6 180 USB200.PIPESEL = pipe;
Kojto 71:53949e6131f6 181 USB200.PIPECFG = tbl[index + 1];
Kojto 71:53949e6131f6 182 USB200.PIPEBUF = tbl[index + 2];
Kojto 71:53949e6131f6 183 USB200.PIPEMAXP = tbl[index + 3];
Kojto 71:53949e6131f6 184 USB200.PIPEPERI = tbl[index + 4];
Kojto 71:53949e6131f6 185
Kojto 71:53949e6131f6 186 g_usb0_function_pipecfg[pipe] = tbl[index + 1];
Kojto 71:53949e6131f6 187 g_usb0_function_pipebuf[pipe] = tbl[index + 2];
Kojto 71:53949e6131f6 188 g_usb0_function_pipemaxp[pipe] = tbl[index + 3];
Kojto 71:53949e6131f6 189 g_usb0_function_pipeperi[pipe] = tbl[index + 4];
Kojto 71:53949e6131f6 190
Kojto 71:53949e6131f6 191 /* Buffer Clear */
Kojto 71:53949e6131f6 192 usb0_function_set_sqclr(pipe);
Kojto 71:53949e6131f6 193 usb0_function_aclrm(pipe);
Kojto 71:53949e6131f6 194
Kojto 71:53949e6131f6 195 /* init Global */
Kojto 71:53949e6131f6 196 g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_IDLE;
Kojto 71:53949e6131f6 197 g_usb0_function_PipeDataSize[pipe] = 0;
Kojto 71:53949e6131f6 198 }
Kojto 71:53949e6131f6 199 }
Kojto 71:53949e6131f6 200 }
Kojto 71:53949e6131f6 201 #endif
Kojto 71:53949e6131f6 202
Kojto 71:53949e6131f6 203 /*******************************************************************************
Kojto 71:53949e6131f6 204 * Function Name: usb0_function_EpToPipe
Kojto 71:53949e6131f6 205 * Description : Returns the pipe which end point specified by the argument is
Kojto 71:53949e6131f6 206 * : allocated to.
Kojto 71:53949e6131f6 207 * Arguments : uint16_t ep ; Direction + Endpoint Number
Kojto 71:53949e6131f6 208 * Return Value : USB_FUNCTION_EP_ERROR : Error
Kojto 71:53949e6131f6 209 * : Others : Pipe Number
Kojto 71:53949e6131f6 210 *******************************************************************************/
Kojto 71:53949e6131f6 211 uint16_t usb0_function_EpToPipe (uint16_t ep)
Kojto 71:53949e6131f6 212 {
Kojto 71:53949e6131f6 213 uint16_t pipe;
Kojto 71:53949e6131f6 214
Kojto 71:53949e6131f6 215 for (pipe = 1; pipe <= USB_FUNCTION_MAX_PIPE_NO; pipe++)
Kojto 71:53949e6131f6 216 {
Kojto 71:53949e6131f6 217 if ((g_usb0_function_PipeTbl[pipe] & 0x00ff) == ep)
Kojto 71:53949e6131f6 218 {
Kojto 71:53949e6131f6 219 return pipe;
Kojto 71:53949e6131f6 220 }
Kojto 71:53949e6131f6 221 }
Kojto 71:53949e6131f6 222
Kojto 71:53949e6131f6 223 return USB_FUNCTION_EP_ERROR;
Kojto 71:53949e6131f6 224 }
Kojto 71:53949e6131f6 225
Kojto 71:53949e6131f6 226 /*******************************************************************************
Kojto 71:53949e6131f6 227 * Function Name: usb0_function_InitEPTable
Kojto 71:53949e6131f6 228 * Description : Sets the end point by the Alternate setting value of the
Kojto 71:53949e6131f6 229 * : configuration number and the interface number specified by the
Kojto 71:53949e6131f6 230 * : argument.
Kojto 71:53949e6131f6 231 * Arguments : uint16_t Con_Num ; Configuration Number
Kojto 71:53949e6131f6 232 * : uint16_t Int_Num ; Interface Number
Kojto 71:53949e6131f6 233 * : uint16_t Alt_Num ; Alternate Setting
Kojto 71:53949e6131f6 234 * Return Value : none
Kojto 71:53949e6131f6 235 *******************************************************************************/
Kojto 71:53949e6131f6 236 #if 0
Kojto 71:53949e6131f6 237 void usb0_function_InitEPTable (uint16_t Con_Num, uint16_t Int_Num, uint16_t Alt_Num)
Kojto 71:53949e6131f6 238 {
Kojto 71:53949e6131f6 239 uint8_t * ptr;
Kojto 71:53949e6131f6 240 uint16_t point_interface;
Kojto 71:53949e6131f6 241 uint16_t point_endpoint;
Kojto 71:53949e6131f6 242 uint16_t length;
Kojto 71:53949e6131f6 243 uint16_t start;
Kojto 71:53949e6131f6 244 uint16_t numbers;
Kojto 71:53949e6131f6 245 uint16_t endpoint;
Kojto 71:53949e6131f6 246
Kojto 71:53949e6131f6 247 ptr = (uint8_t *)g_usb0_function_ConfigurationPtr[Con_Num - 1];
Kojto 71:53949e6131f6 248 point_interface = *ptr;
Kojto 71:53949e6131f6 249 length = (uint16_t)((uint16_t)*(ptr + 3) << 8 | (uint16_t)*(ptr + 2));
Kojto 71:53949e6131f6 250 ptr += *ptr;
Kojto 71:53949e6131f6 251 start = 0;
Kojto 71:53949e6131f6 252 numbers = 0;
Kojto 71:53949e6131f6 253 point_endpoint = 0;
Kojto 71:53949e6131f6 254
Kojto 71:53949e6131f6 255 for (; point_interface < length;)
Kojto 71:53949e6131f6 256 {
Kojto 71:53949e6131f6 257 switch (*(ptr + 1)) /* Descriptor Type ? */
Kojto 71:53949e6131f6 258 {
Kojto 71:53949e6131f6 259 case USB_FUNCTION_DT_INTERFACE: /* Interface */
Kojto 71:53949e6131f6 260 if ((*(ptr + 2) == Int_Num) && (*(ptr + 3) == Alt_Num))
Kojto 71:53949e6131f6 261 {
Kojto 71:53949e6131f6 262 numbers = *(ptr + 4);
Kojto 71:53949e6131f6 263 }
Kojto 71:53949e6131f6 264 else
Kojto 71:53949e6131f6 265 {
Kojto 71:53949e6131f6 266 start += *(ptr + 4);
Kojto 71:53949e6131f6 267 }
Kojto 71:53949e6131f6 268 point_interface += *ptr;
Kojto 71:53949e6131f6 269 ptr += *ptr;
Kojto 71:53949e6131f6 270 break;
Kojto 71:53949e6131f6 271
Kojto 71:53949e6131f6 272 case USB_FUNCTION_DT_ENDPOINT: /* Endpoint */
Kojto 71:53949e6131f6 273 if (point_endpoint < numbers)
Kojto 71:53949e6131f6 274 {
Kojto 71:53949e6131f6 275 endpoint = (uint16_t)(*(ptr + 2) & 0x0f);
Kojto 71:53949e6131f6 276 g_usb0_function_EPTableIndex[endpoint] = (uint16_t)(start + point_endpoint);
Kojto 71:53949e6131f6 277 ++point_endpoint;
Kojto 71:53949e6131f6 278 }
Kojto 71:53949e6131f6 279 point_interface += *ptr;
Kojto 71:53949e6131f6 280 ptr += *ptr;
Kojto 71:53949e6131f6 281 break;
Kojto 71:53949e6131f6 282
Kojto 71:53949e6131f6 283 case USB_FUNCTION_DT_DEVICE: /* Device */
Kojto 71:53949e6131f6 284 case USB_FUNCTION_DT_CONFIGURATION: /* Configuration */
Kojto 71:53949e6131f6 285 case USB_FUNCTION_DT_STRING: /* String */
Kojto 71:53949e6131f6 286 default: /* Class, Vendor, else */
Kojto 71:53949e6131f6 287 point_interface += *ptr;
Kojto 71:53949e6131f6 288 ptr += *ptr;
Kojto 71:53949e6131f6 289 break;
Kojto 71:53949e6131f6 290 }
Kojto 71:53949e6131f6 291 }
Kojto 71:53949e6131f6 292 }
Kojto 71:53949e6131f6 293 #endif
Kojto 71:53949e6131f6 294
Kojto 71:53949e6131f6 295 /*******************************************************************************
Kojto 71:53949e6131f6 296 * Function Name: usb0_function_GetConfigNum
Kojto 71:53949e6131f6 297 * Description : Returns the number of configuration referring to the number of
Kojto 71:53949e6131f6 298 * : configuration described in the device descriptor.
Kojto 71:53949e6131f6 299 * Arguments : none
Kojto 71:53949e6131f6 300 * Return Value : Number of possible configurations (bNumConfigurations).
Kojto 71:53949e6131f6 301 *******************************************************************************/
Kojto 71:53949e6131f6 302 #if 0
Kojto 71:53949e6131f6 303 uint16_t usb0_function_GetConfigNum (void)
Kojto 71:53949e6131f6 304 {
Kojto 71:53949e6131f6 305 return (uint16_t)g_usb0_function_DeviceDescriptor[17];
Kojto 71:53949e6131f6 306 }
Kojto 71:53949e6131f6 307 #endif
Kojto 71:53949e6131f6 308
Kojto 71:53949e6131f6 309 /*******************************************************************************
Kojto 71:53949e6131f6 310 * Function Name: usb0_function_GetInterfaceNum
Kojto 71:53949e6131f6 311 * Description : Returns the number of interface referring to the number of
Kojto 71:53949e6131f6 312 * : interface described in the configuration descriptor.
Kojto 71:53949e6131f6 313 * Arguments : uint16_t num ; Configuration Number
Kojto 71:53949e6131f6 314 * Return Value : Number of this interface (bNumInterfaces).
Kojto 71:53949e6131f6 315 *******************************************************************************/
Kojto 71:53949e6131f6 316 #if 0
Kojto 71:53949e6131f6 317 uint16_t usb0_function_GetInterfaceNum (uint16_t num)
Kojto 71:53949e6131f6 318 {
Kojto 71:53949e6131f6 319 return (uint16_t)(*(g_usb0_function_ConfigurationPtr[num - 1] + 4));
Kojto 71:53949e6131f6 320 }
Kojto 71:53949e6131f6 321 #endif
Kojto 71:53949e6131f6 322
Kojto 71:53949e6131f6 323 /*******************************************************************************
Kojto 71:53949e6131f6 324 * Function Name: usb0_function_GetAltNum
Kojto 71:53949e6131f6 325 * Description : Returns the Alternate setting value of the configuration number
Kojto 71:53949e6131f6 326 * : and the interface number specified by the argument.
Kojto 71:53949e6131f6 327 * Arguments : uint16_t Con_Num ; Configuration Number
Kojto 71:53949e6131f6 328 * : uint16_t Int_Num ; Interface Number
Kojto 71:53949e6131f6 329 * Return Value : Value used to select this alternate setting(bAlternateSetting).
Kojto 71:53949e6131f6 330 *******************************************************************************/
Kojto 71:53949e6131f6 331 #if 0
Kojto 71:53949e6131f6 332 uint16_t usb0_function_GetAltNum (uint16_t Con_Num, uint16_t Int_Num)
Kojto 71:53949e6131f6 333 {
Kojto 71:53949e6131f6 334 uint8_t * ptr;
Kojto 71:53949e6131f6 335 uint16_t point;
Kojto 71:53949e6131f6 336 uint16_t alt_num = 0;
Kojto 71:53949e6131f6 337 uint16_t length;
Kojto 71:53949e6131f6 338
Kojto 71:53949e6131f6 339 ptr = (uint8_t *)(g_usb0_function_ConfigurationPtr[Con_Num - 1]);
Kojto 71:53949e6131f6 340 point = ptr[0];
Kojto 71:53949e6131f6 341 ptr += ptr[0]; /* InterfaceDescriptor[0] */
Kojto 71:53949e6131f6 342 length = (uint16_t)(*(g_usb0_function_ConfigurationPtr[Con_Num - 1] + 2));
Kojto 71:53949e6131f6 343 length |= (uint16_t)((uint16_t)(*(g_usb0_function_ConfigurationPtr[Con_Num - 1] + 3)) << 8);
Kojto 71:53949e6131f6 344
Kojto 71:53949e6131f6 345 for (; point < length;) /* Search Descriptor Table size */
Kojto 71:53949e6131f6 346 {
Kojto 71:53949e6131f6 347 switch (ptr[1]) /* Descriptor Type ? */
Kojto 71:53949e6131f6 348 {
Kojto 71:53949e6131f6 349 case USB_FUNCTION_DT_INTERFACE: /* Interface */
Kojto 71:53949e6131f6 350 if (Int_Num == ptr[2])
Kojto 71:53949e6131f6 351 {
Kojto 71:53949e6131f6 352 alt_num = (uint16_t)ptr[3]; /* Alternate Number count */
Kojto 71:53949e6131f6 353 }
Kojto 71:53949e6131f6 354 point += ptr[0];
Kojto 71:53949e6131f6 355 ptr += ptr[0];
Kojto 71:53949e6131f6 356 break;
Kojto 71:53949e6131f6 357
Kojto 71:53949e6131f6 358 case USB_FUNCTION_DT_DEVICE: /* Device */
Kojto 71:53949e6131f6 359 case USB_FUNCTION_DT_CONFIGURATION: /* Configuration */
Kojto 71:53949e6131f6 360 case USB_FUNCTION_DT_STRING: /* String */
Kojto 71:53949e6131f6 361 case USB_FUNCTION_DT_ENDPOINT: /* Endpoint */
Kojto 71:53949e6131f6 362 default: /* Class, Vendor, else */
Kojto 71:53949e6131f6 363 point += ptr[0];
Kojto 71:53949e6131f6 364 ptr += ptr[0];
Kojto 71:53949e6131f6 365 break;
Kojto 71:53949e6131f6 366 }
Kojto 71:53949e6131f6 367 }
Kojto 71:53949e6131f6 368 return alt_num;
Kojto 71:53949e6131f6 369 }
Kojto 71:53949e6131f6 370 #endif
Kojto 71:53949e6131f6 371
Kojto 71:53949e6131f6 372 /*******************************************************************************
Kojto 71:53949e6131f6 373 * Function Name: usb0_function_CheckRemoteWakeup
Kojto 71:53949e6131f6 374 * Description : Returns the result of the remote wake up function is supported
Kojto 71:53949e6131f6 375 * : or not referring to the configuration descriptor.
Kojto 71:53949e6131f6 376 * Arguments : none
Kojto 71:53949e6131f6 377 * Return Value : DEVDRV_USBF_ON : Support Remote Wakeup
Kojto 71:53949e6131f6 378 * : DEVDRV_USBF_OFF : not Support Remote Wakeup
Kojto 71:53949e6131f6 379 *******************************************************************************/
Kojto 71:53949e6131f6 380 #if 0
Kojto 71:53949e6131f6 381 uint16_t usb0_function_CheckRemoteWakeup (void)
Kojto 71:53949e6131f6 382 {
Kojto 71:53949e6131f6 383 uint8_t atr;
Kojto 71:53949e6131f6 384
Kojto 71:53949e6131f6 385 if (g_usb0_function_ConfigNum == 0)
Kojto 71:53949e6131f6 386 {
Kojto 71:53949e6131f6 387 return DEVDRV_USBF_OFF;
Kojto 71:53949e6131f6 388 }
Kojto 71:53949e6131f6 389
Kojto 71:53949e6131f6 390 atr = *(g_usb0_function_ConfigurationPtr[g_usb0_function_ConfigNum - 1] + 7);
Kojto 71:53949e6131f6 391
Kojto 71:53949e6131f6 392 if (atr & USB_FUNCTION_CF_RWUP)
Kojto 71:53949e6131f6 393 {
Kojto 71:53949e6131f6 394 return DEVDRV_USBF_ON;
Kojto 71:53949e6131f6 395 }
Kojto 71:53949e6131f6 396
Kojto 71:53949e6131f6 397 return DEVDRV_USBF_OFF;
Kojto 71:53949e6131f6 398 }
Kojto 71:53949e6131f6 399 #endif
Kojto 71:53949e6131f6 400
Kojto 71:53949e6131f6 401 /*******************************************************************************
Kojto 71:53949e6131f6 402 * Function Name: usb0_function_clear_alt
Kojto 71:53949e6131f6 403 * Description : Initializes the Alternate setting area.
Kojto 71:53949e6131f6 404 * Arguments : none
Kojto 71:53949e6131f6 405 * Return Value : none
Kojto 71:53949e6131f6 406 *******************************************************************************/
Kojto 71:53949e6131f6 407 #if 0
Kojto 71:53949e6131f6 408 void usb0_function_clear_alt (void)
Kojto 71:53949e6131f6 409 {
Kojto 71:53949e6131f6 410 int i;
Kojto 71:53949e6131f6 411
Kojto 71:53949e6131f6 412 for (i = 0; i < USB_FUNCTION_ALT_NO; ++i)
Kojto 71:53949e6131f6 413 {
Kojto 71:53949e6131f6 414 g_usb0_function_Alternate[i] = 0; /* Alternate */
Kojto 71:53949e6131f6 415 }
Kojto 71:53949e6131f6 416 }
Kojto 71:53949e6131f6 417 #endif
Kojto 71:53949e6131f6 418
Kojto 71:53949e6131f6 419 /*******************************************************************************
Kojto 71:53949e6131f6 420 * Function Name: usb0_function_clear_pipe_tbl
Kojto 71:53949e6131f6 421 * Description : Initializes pipe definition table.
Kojto 71:53949e6131f6 422 * Arguments : none
Kojto 71:53949e6131f6 423 * Return Value : none
Kojto 71:53949e6131f6 424 *******************************************************************************/
Kojto 71:53949e6131f6 425 void usb0_function_clear_pipe_tbl (void)
Kojto 71:53949e6131f6 426 {
Kojto 71:53949e6131f6 427 int pipe;
Kojto 71:53949e6131f6 428
Kojto 71:53949e6131f6 429 for (pipe = 0; pipe < (USB_FUNCTION_MAX_PIPE_NO + 1); ++pipe)
Kojto 71:53949e6131f6 430 {
Kojto 71:53949e6131f6 431 g_usb0_function_PipeTbl[pipe] = 0;
Kojto 71:53949e6131f6 432 }
Kojto 71:53949e6131f6 433 }
Kojto 71:53949e6131f6 434
Kojto 71:53949e6131f6 435 /*******************************************************************************
Kojto 71:53949e6131f6 436 * Function Name: usb0_function_clear_ep_table_index
Kojto 71:53949e6131f6 437 * Description : Initializes the end point table index.
Kojto 71:53949e6131f6 438 * Arguments : none
Kojto 71:53949e6131f6 439 * Return Value : none
Kojto 71:53949e6131f6 440 *******************************************************************************/
Kojto 71:53949e6131f6 441 #if 0
Kojto 71:53949e6131f6 442 void usb0_function_clear_ep_table_index (void)
Kojto 71:53949e6131f6 443 {
Kojto 71:53949e6131f6 444 int ep;
Kojto 71:53949e6131f6 445
Kojto 71:53949e6131f6 446 for (ep = 0; ep <= USB_FUNCTION_MAX_EP_NO; ++ep)
Kojto 71:53949e6131f6 447 {
Kojto 71:53949e6131f6 448 g_usb0_function_EPTableIndex[ep] = USB_FUNCTION_EP_ERROR;
Kojto 71:53949e6131f6 449 }
Kojto 71:53949e6131f6 450 }
Kojto 71:53949e6131f6 451 #endif
Kojto 71:53949e6131f6 452
Kojto 71:53949e6131f6 453 /* End of File */