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