USBDevice with MAX32620HSP platform support

Fork of USBDevice by mbed official

Committer:
mbed_official
Date:
Fri Apr 29 01:16:25 2016 +0100
Revision:
62:c1549af978d6
Synchronized with git revision fe9720f24b1adc71ab6962506ec51290f6afd270

Full URL: https://github.com/mbedmicro/mbed/commit/fe9720f24b1adc71ab6962506ec51290f6afd270/

[Renesas RZ/A1H] Enable asynchronous communications

Who changed what in which revision?

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