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_dma.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
Kojto 71:53949e6131f6 57
Kojto 71:53949e6131f6 58 /*******************************************************************************
Kojto 71:53949e6131f6 59 Exported global variables and functions (to be accessed by other files)
Kojto 71:53949e6131f6 60 *******************************************************************************/
Kojto 71:53949e6131f6 61
Kojto 71:53949e6131f6 62
Kojto 71:53949e6131f6 63 /*******************************************************************************
Kojto 71:53949e6131f6 64 Private global variables and functions
Kojto 71:53949e6131f6 65 *******************************************************************************/
Kojto 71:53949e6131f6 66 static void usb0_function_dmaint(uint16_t fifo);
Kojto 71:53949e6131f6 67 static void usb0_function_dmaint_buf2fifo(uint16_t pipe);
Kojto 71:53949e6131f6 68 static void usb0_function_dmaint_fifo2buf(uint16_t pipe);
Kojto 71:53949e6131f6 69
Kojto 71:53949e6131f6 70
Kojto 71:53949e6131f6 71 /*******************************************************************************
Kojto 71:53949e6131f6 72 * Function Name: usb0_function_dma_stop_d0
Kojto 71:53949e6131f6 73 * Description : D0FIFO DMA stop
Kojto 71:53949e6131f6 74 * Arguments : uint16_t pipe : pipe number
Kojto 71:53949e6131f6 75 * : uint32_t remain : transfer byte
Kojto 71:53949e6131f6 76 * Return Value : none
Kojto 71:53949e6131f6 77 *******************************************************************************/
Kojto 71:53949e6131f6 78 void usb0_function_dma_stop_d0 (uint16_t pipe, uint32_t remain)
Kojto 71:53949e6131f6 79 {
Kojto 71:53949e6131f6 80 uint16_t dtln;
Kojto 71:53949e6131f6 81 uint16_t dfacc;
Kojto 71:53949e6131f6 82 uint16_t buffer;
Kojto 71:53949e6131f6 83 uint16_t sds_b = 1;
Kojto 71:53949e6131f6 84
Kojto 71:53949e6131f6 85 dfacc = RZA_IO_RegRead_16(&USB200.D0FBCFG, USB_DnFBCFG_DFACC_SHIFT, USB_DnFBCFG_DFACC);
Kojto 71:53949e6131f6 86
Kojto 71:53949e6131f6 87 if (dfacc == 2)
Kojto 71:53949e6131f6 88 {
Kojto 71:53949e6131f6 89 sds_b = 32;
Kojto 71:53949e6131f6 90 }
Kojto 71:53949e6131f6 91 else if (dfacc == 1)
Kojto 71:53949e6131f6 92 {
Kojto 71:53949e6131f6 93 sds_b = 16;
Kojto 71:53949e6131f6 94 }
Kojto 71:53949e6131f6 95 else
Kojto 71:53949e6131f6 96 {
Kojto 71:53949e6131f6 97 if (g_usb0_function_DmaInfo[USB_FUNCTION_D0FIFO].size == 2)
Kojto 71:53949e6131f6 98 {
Kojto 71:53949e6131f6 99 sds_b = 4;
Kojto 71:53949e6131f6 100 }
Kojto 71:53949e6131f6 101 else if (g_usb0_function_DmaInfo[USB_FUNCTION_D0FIFO].size == 1)
Kojto 71:53949e6131f6 102 {
Kojto 71:53949e6131f6 103 sds_b = 2;
Kojto 71:53949e6131f6 104 }
Kojto 71:53949e6131f6 105 else
Kojto 71:53949e6131f6 106 {
Kojto 71:53949e6131f6 107 sds_b = 1;
Kojto 71:53949e6131f6 108 }
Kojto 71:53949e6131f6 109 }
Kojto 71:53949e6131f6 110
Kojto 71:53949e6131f6 111 if (RZA_IO_RegRead_16(&g_usb0_function_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 1)
Kojto 71:53949e6131f6 112 {
Kojto 71:53949e6131f6 113 if (g_usb0_function_pipe_status[pipe] != DEVDRV_USBF_PIPE_DONE)
Kojto 71:53949e6131f6 114 {
Kojto 71:53949e6131f6 115 buffer = USB200.D0FIFOCTR;
Kojto 71:53949e6131f6 116 dtln = (buffer & USB_FUNCTION_BITDTLN);
Kojto 71:53949e6131f6 117
Kojto 71:53949e6131f6 118 if ((dtln % sds_b) != 0)
Kojto 71:53949e6131f6 119 {
Kojto 71:53949e6131f6 120 remain += (sds_b - (dtln % sds_b));
Kojto 71:53949e6131f6 121 }
Kojto 71:53949e6131f6 122 g_usb0_function_PipeDataSize[pipe] = (g_usb0_function_data_count[pipe] - remain);
Kojto 71:53949e6131f6 123 g_usb0_function_data_count[pipe] = remain;
Kojto 71:53949e6131f6 124 }
Kojto 71:53949e6131f6 125 }
Kojto 71:53949e6131f6 126
Kojto 71:53949e6131f6 127 RZA_IO_RegWrite_16(&USB200.D0FIFOSEL, 0, USB_DnFIFOSEL_DREQE_SHIFT, USB_DnFIFOSEL_DREQE);
Kojto 71:53949e6131f6 128 }
Kojto 71:53949e6131f6 129
Kojto 71:53949e6131f6 130 /*******************************************************************************
Kojto 71:53949e6131f6 131 * Function Name: usb0_function_dma_stop_d1
Kojto 71:53949e6131f6 132 * Description : D1FIFO DMA stop
Kojto 71:53949e6131f6 133 * Arguments : uint16_t pipe : pipe number
Kojto 71:53949e6131f6 134 * : uint32_t remain : transfer byte
Kojto 71:53949e6131f6 135 * Return Value : none
Kojto 71:53949e6131f6 136 *******************************************************************************/
Kojto 71:53949e6131f6 137 void usb0_function_dma_stop_d1 (uint16_t pipe, uint32_t remain)
Kojto 71:53949e6131f6 138 {
Kojto 71:53949e6131f6 139 uint16_t dtln;
Kojto 71:53949e6131f6 140 uint16_t dfacc;
Kojto 71:53949e6131f6 141 uint16_t buffer;
Kojto 71:53949e6131f6 142 uint16_t sds_b = 1;
Kojto 71:53949e6131f6 143
Kojto 71:53949e6131f6 144 dfacc = RZA_IO_RegRead_16(&USB200.D1FBCFG, USB_DnFBCFG_DFACC_SHIFT, USB_DnFBCFG_DFACC);
Kojto 71:53949e6131f6 145
Kojto 71:53949e6131f6 146 if (dfacc == 2)
Kojto 71:53949e6131f6 147 {
Kojto 71:53949e6131f6 148 sds_b = 32;
Kojto 71:53949e6131f6 149 }
Kojto 71:53949e6131f6 150 else if (dfacc == 1)
Kojto 71:53949e6131f6 151 {
Kojto 71:53949e6131f6 152 sds_b = 16;
Kojto 71:53949e6131f6 153 }
Kojto 71:53949e6131f6 154 else
Kojto 71:53949e6131f6 155 {
Kojto 71:53949e6131f6 156 if (g_usb0_function_DmaInfo[USB_FUNCTION_D1FIFO].size == 2)
Kojto 71:53949e6131f6 157 {
Kojto 71:53949e6131f6 158 sds_b = 4;
Kojto 71:53949e6131f6 159 }
Kojto 71:53949e6131f6 160 else if (g_usb0_function_DmaInfo[USB_FUNCTION_D1FIFO].size == 1)
Kojto 71:53949e6131f6 161 {
Kojto 71:53949e6131f6 162 sds_b = 2;
Kojto 71:53949e6131f6 163 }
Kojto 71:53949e6131f6 164 else
Kojto 71:53949e6131f6 165 {
Kojto 71:53949e6131f6 166 sds_b = 1;
Kojto 71:53949e6131f6 167 }
Kojto 71:53949e6131f6 168 }
Kojto 71:53949e6131f6 169
Kojto 71:53949e6131f6 170 if (RZA_IO_RegRead_16(&g_usb0_function_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 1)
Kojto 71:53949e6131f6 171 {
Kojto 71:53949e6131f6 172 if (g_usb0_function_pipe_status[pipe] != DEVDRV_USBF_PIPE_DONE)
Kojto 71:53949e6131f6 173 {
Kojto 71:53949e6131f6 174 buffer = USB200.D1FIFOCTR;
Kojto 71:53949e6131f6 175 dtln = (buffer & USB_FUNCTION_BITDTLN);
Kojto 71:53949e6131f6 176
Kojto 71:53949e6131f6 177 if ((dtln % sds_b) != 0)
Kojto 71:53949e6131f6 178 {
Kojto 71:53949e6131f6 179 remain += (sds_b - (dtln % sds_b));
Kojto 71:53949e6131f6 180 }
Kojto 71:53949e6131f6 181 g_usb0_function_PipeDataSize[pipe] = (g_usb0_function_data_count[pipe] - remain);
Kojto 71:53949e6131f6 182 g_usb0_function_data_count[pipe] = remain;
Kojto 71:53949e6131f6 183 }
Kojto 71:53949e6131f6 184 }
Kojto 71:53949e6131f6 185
Kojto 71:53949e6131f6 186 RZA_IO_RegWrite_16(&USB200.D1FIFOSEL, 0, USB_DnFIFOSEL_DREQE_SHIFT, USB_DnFIFOSEL_DREQE);
Kojto 71:53949e6131f6 187 }
Kojto 71:53949e6131f6 188
Kojto 71:53949e6131f6 189 /*******************************************************************************
Kojto 71:53949e6131f6 190 * Function Name: usb0_function_dma_interrupt_d0fifo
Kojto 71:53949e6131f6 191 * Description : This function is DMA interrupt handler entry.
Kojto 71:53949e6131f6 192 * : Execute usb0_function_dmaint() after disabling DMA interrupt in this function.
Kojto 71:53949e6131f6 193 * : Disable DMA interrupt to DMAC executed when USB_FUNCTION_D0FIFO_DMA is
Kojto 71:53949e6131f6 194 * : specified by dma->fifo.
Kojto 71:53949e6131f6 195 * : Register this function as DMA complete interrupt.
Kojto 71:53949e6131f6 196 * Arguments : uint32_t int_sense ; Interrupts detection mode
Kojto 71:53949e6131f6 197 * : ; INTC_LEVEL_SENSITIVE : Level sense
Kojto 71:53949e6131f6 198 * : ; INTC_EDGE_TRIGGER : Edge trigger
Kojto 71:53949e6131f6 199 * Return Value : none
Kojto 71:53949e6131f6 200 *******************************************************************************/
Kojto 71:53949e6131f6 201 void usb0_function_dma_interrupt_d0fifo (uint32_t int_sense)
Kojto 71:53949e6131f6 202 {
Kojto 71:53949e6131f6 203 usb0_function_dmaint(USB_FUNCTION_D0FIFO);
Kojto 71:53949e6131f6 204 g_usb0_function_DmaStatus[USB_FUNCTION_D0FIFO] = USB_FUNCTION_DMA_READY;
Kojto 71:53949e6131f6 205 }
Kojto 71:53949e6131f6 206
Kojto 71:53949e6131f6 207 /*******************************************************************************
Kojto 71:53949e6131f6 208 * Function Name: usb0_function_dma_interrupt_d1fifo
Kojto 71:53949e6131f6 209 * Description : This function is DMA interrupt handler entry.
Kojto 71:53949e6131f6 210 * : Execute usb0_function_dmaint() after disabling DMA interrupt in this function.
Kojto 71:53949e6131f6 211 * : Disable DMA interrupt to DMAC executed when USB_FUNCTION_D1FIFO_DMA is
Kojto 71:53949e6131f6 212 * : specified by dma->fifo.
Kojto 71:53949e6131f6 213 * : Register this function as DMA complete interrupt.
Kojto 71:53949e6131f6 214 * Arguments : uint32_t int_sense ; Interrupts detection mode
Kojto 71:53949e6131f6 215 * : ; INTC_LEVEL_SENSITIVE : Level sense
Kojto 71:53949e6131f6 216 * : ; INTC_EDGE_TRIGGER : Edge trigger
Kojto 71:53949e6131f6 217 * Return Value : none
Kojto 71:53949e6131f6 218 *******************************************************************************/
Kojto 71:53949e6131f6 219 void usb0_function_dma_interrupt_d1fifo (uint32_t int_sense)
Kojto 71:53949e6131f6 220 {
Kojto 71:53949e6131f6 221 usb0_function_dmaint(USB_FUNCTION_D1FIFO);
Kojto 71:53949e6131f6 222 g_usb0_function_DmaStatus[USB_FUNCTION_D1FIFO] = USB_FUNCTION_DMA_READY;
Kojto 71:53949e6131f6 223 }
Kojto 71:53949e6131f6 224
Kojto 71:53949e6131f6 225 /*******************************************************************************
Kojto 71:53949e6131f6 226 * Function Name: usb0_function_dmaint
Kojto 71:53949e6131f6 227 * Description : This function is DMA transfer end interrupt
Kojto 71:53949e6131f6 228 * Arguments : uint16_t fifo ; fifo number
Kojto 71:53949e6131f6 229 * : ; USB_FUNCTION_D0FIFO
Kojto 71:53949e6131f6 230 * : ; USB_FUNCTION_D1FIFO
Kojto 71:53949e6131f6 231 * Return Value : none
Kojto 71:53949e6131f6 232 *******************************************************************************/
Kojto 71:53949e6131f6 233 static void usb0_function_dmaint (uint16_t fifo)
Kojto 71:53949e6131f6 234 {
Kojto 71:53949e6131f6 235 uint16_t pipe;
Kojto 71:53949e6131f6 236
Kojto 71:53949e6131f6 237 pipe = g_usb0_function_DmaPipe[fifo];
Kojto 71:53949e6131f6 238
Kojto 71:53949e6131f6 239 if (g_usb0_function_DmaInfo[fifo].dir == USB_FUNCTION_BUF2FIFO)
Kojto 71:53949e6131f6 240 {
Kojto 71:53949e6131f6 241 usb0_function_dmaint_buf2fifo(pipe);
Kojto 71:53949e6131f6 242 }
Kojto 71:53949e6131f6 243 else
Kojto 71:53949e6131f6 244 {
Kojto 71:53949e6131f6 245 usb0_function_dmaint_fifo2buf(pipe);
Kojto 71:53949e6131f6 246 }
Kojto 71:53949e6131f6 247 }
Kojto 71:53949e6131f6 248
Kojto 71:53949e6131f6 249 /*******************************************************************************
Kojto 71:53949e6131f6 250 * Function Name: usb0_function_dmaint_fifo2buf
Kojto 71:53949e6131f6 251 * Description : Executes read completion from FIFO by DMAC.
Kojto 71:53949e6131f6 252 * Arguments : uint16_t pipe : pipe number
Kojto 71:53949e6131f6 253 * Return Value : none
Kojto 71:53949e6131f6 254 *******************************************************************************/
Kojto 71:53949e6131f6 255 static void usb0_function_dmaint_fifo2buf (uint16_t pipe)
Kojto 71:53949e6131f6 256 {
Kojto 71:53949e6131f6 257 uint32_t remain;
Kojto 71:53949e6131f6 258 uint16_t useport;
Kojto 71:53949e6131f6 259
Kojto 71:53949e6131f6 260 if (g_usb0_function_pipe_status[pipe] != DEVDRV_USBF_PIPE_DONE)
Kojto 71:53949e6131f6 261 {
Kojto 71:53949e6131f6 262 useport = (uint16_t)(g_usb0_function_PipeTbl[pipe] & USB_FUNCTION_FIFO_USE);
Kojto 71:53949e6131f6 263
Kojto 71:53949e6131f6 264 if (useport == USB_FUNCTION_D0FIFO_DMA)
Kojto 71:53949e6131f6 265 {
Kojto 71:53949e6131f6 266 remain = Userdef_USB_usb0_function_stop_dma0();
Kojto 71:53949e6131f6 267 usb0_function_dma_stop_d0(pipe, remain);
Kojto 71:53949e6131f6 268
Kojto 71:53949e6131f6 269 if (RZA_IO_RegRead_16(&g_usb0_function_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0)
Kojto 71:53949e6131f6 270 {
Kojto 71:53949e6131f6 271 if (g_usb0_function_DmaStatus[USB_FUNCTION_D0FIFO] == USB_FUNCTION_DMA_BUSYEND)
Kojto 71:53949e6131f6 272 {
Kojto 71:53949e6131f6 273 USB200.D0FIFOCTR = USB_FUNCTION_BITBCLR;
Kojto 71:53949e6131f6 274 g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE;
Kojto 71:53949e6131f6 275 }
Kojto 71:53949e6131f6 276 else
Kojto 71:53949e6131f6 277 {
Kojto 71:53949e6131f6 278 usb0_function_enable_brdy_int(pipe);
Kojto 71:53949e6131f6 279 }
Kojto 71:53949e6131f6 280 }
Kojto 71:53949e6131f6 281 }
Kojto 71:53949e6131f6 282 else
Kojto 71:53949e6131f6 283 {
Kojto 71:53949e6131f6 284 remain = Userdef_USB_usb0_function_stop_dma1();
Kojto 71:53949e6131f6 285 usb0_function_dma_stop_d1(pipe, remain);
Kojto 71:53949e6131f6 286
Kojto 71:53949e6131f6 287 if (RZA_IO_RegRead_16(&g_usb0_function_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0)
Kojto 71:53949e6131f6 288 {
Kojto 71:53949e6131f6 289 if (g_usb0_function_DmaStatus[USB_FUNCTION_D1FIFO] == USB_FUNCTION_DMA_BUSYEND)
Kojto 71:53949e6131f6 290 {
Kojto 71:53949e6131f6 291 USB200.D1FIFOCTR = USB_FUNCTION_BITBCLR;
Kojto 71:53949e6131f6 292 g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE;
Kojto 71:53949e6131f6 293 }
Kojto 71:53949e6131f6 294 else
Kojto 71:53949e6131f6 295 {
Kojto 71:53949e6131f6 296 usb0_function_enable_brdy_int(pipe);
Kojto 71:53949e6131f6 297 }
Kojto 71:53949e6131f6 298 }
Kojto 71:53949e6131f6 299 }
Kojto 71:53949e6131f6 300 }
Kojto 71:53949e6131f6 301 }
Kojto 71:53949e6131f6 302
Kojto 71:53949e6131f6 303 /*******************************************************************************
Kojto 71:53949e6131f6 304 * Function Name: usb0_function_dmaint_buf2fifo
Kojto 71:53949e6131f6 305 * Description : Executes write completion in FIFO by DMAC.
Kojto 71:53949e6131f6 306 * Arguments : uint16_t pipe : pipe number
Kojto 71:53949e6131f6 307 * Return Value : none
Kojto 71:53949e6131f6 308 *******************************************************************************/
Kojto 71:53949e6131f6 309 static void usb0_function_dmaint_buf2fifo (uint16_t pipe)
Kojto 71:53949e6131f6 310 {
Kojto 71:53949e6131f6 311 uint32_t remain;
Kojto 71:53949e6131f6 312 uint16_t useport;
Kojto 71:53949e6131f6 313
Kojto 71:53949e6131f6 314 useport = (uint16_t)(g_usb0_function_PipeTbl[pipe] & USB_FUNCTION_FIFO_USE);
Kojto 71:53949e6131f6 315
Kojto 71:53949e6131f6 316 if (useport == USB_FUNCTION_D0FIFO_DMA)
Kojto 71:53949e6131f6 317 {
Kojto 71:53949e6131f6 318 remain = Userdef_USB_usb0_function_stop_dma0();
Kojto 71:53949e6131f6 319 usb0_function_dma_stop_d0(pipe, remain);
Kojto 71:53949e6131f6 320
Kojto 71:53949e6131f6 321 if (g_usb0_function_DmaBval[USB_FUNCTION_D0FIFO] != 0)
Kojto 71:53949e6131f6 322 {
Kojto 71:53949e6131f6 323 RZA_IO_RegWrite_16(&USB200.D0FIFOCTR,
Kojto 71:53949e6131f6 324 1,
Kojto 71:53949e6131f6 325 USB_DnFIFOCTR_BVAL_SHIFT,
Kojto 71:53949e6131f6 326 USB_DnFIFOCTR_BVAL);
Kojto 71:53949e6131f6 327 }
Kojto 71:53949e6131f6 328 }
Kojto 71:53949e6131f6 329 else
Kojto 71:53949e6131f6 330 {
Kojto 71:53949e6131f6 331 remain = Userdef_USB_usb0_function_stop_dma1();
Kojto 71:53949e6131f6 332 usb0_function_dma_stop_d1(pipe, remain);
Kojto 71:53949e6131f6 333
Kojto 71:53949e6131f6 334 if (g_usb0_function_DmaBval[USB_FUNCTION_D1FIFO] != 0)
Kojto 71:53949e6131f6 335 {
Kojto 71:53949e6131f6 336 RZA_IO_RegWrite_16(&USB200.D1FIFOCTR,
Kojto 71:53949e6131f6 337 1,
Kojto 71:53949e6131f6 338 USB_DnFIFOCTR_BVAL_SHIFT,
Kojto 71:53949e6131f6 339 USB_DnFIFOCTR_BVAL);
Kojto 71:53949e6131f6 340 }
Kojto 71:53949e6131f6 341 }
Kojto 71:53949e6131f6 342
Kojto 71:53949e6131f6 343 usb0_function_enable_bemp_int(pipe);
Kojto 71:53949e6131f6 344 }
Kojto 71:53949e6131f6 345
Kojto 71:53949e6131f6 346 /* End of File */