USBHost library. NOTE: This library is only officially supported on the LPC1768 platform. For more information, please see the handbook page.
Dependencies: FATFileSystem mbed-rtos
Dependents: BTstack WallbotWii SD to Flash Data Transfer USBHost-MSD_HelloWorld ... 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.
targets/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/common/usb1_host_dma.c@39:d96aa62afc5b, 2017-07-27 (annotated)
- Committer:
- Kojto
- Date:
- Thu Jul 27 12:24:30 2017 +0100
- Revision:
- 39:d96aa62afc5b
Update USBHost - add targets directory
This corresponds to mbed-os/master commit 9207365
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 39:d96aa62afc5b | 1 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 2 | * DISCLAIMER |
Kojto | 39:d96aa62afc5b | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
Kojto | 39:d96aa62afc5b | 4 | * intended for use with Renesas products. No other uses are authorized. This |
Kojto | 39:d96aa62afc5b | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
Kojto | 39:d96aa62afc5b | 6 | * all applicable laws, including copyright laws. |
Kojto | 39:d96aa62afc5b | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
Kojto | 39:d96aa62afc5b | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
Kojto | 39:d96aa62afc5b | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
Kojto | 39:d96aa62afc5b | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
Kojto | 39:d96aa62afc5b | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
Kojto | 39:d96aa62afc5b | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
Kojto | 39:d96aa62afc5b | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
Kojto | 39:d96aa62afc5b | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
Kojto | 39:d96aa62afc5b | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
Kojto | 39:d96aa62afc5b | 16 | * Renesas reserves the right, without notice, to make changes to this software |
Kojto | 39:d96aa62afc5b | 17 | * and to discontinue the availability of this software. By using this software, |
Kojto | 39:d96aa62afc5b | 18 | * you agree to the additional terms and conditions found by accessing the |
Kojto | 39:d96aa62afc5b | 19 | * following link: |
Kojto | 39:d96aa62afc5b | 20 | * http://www.renesas.com/disclaimer |
Kojto | 39:d96aa62afc5b | 21 | * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved. |
Kojto | 39:d96aa62afc5b | 22 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 23 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 24 | * File Name : usb1_host_dma.c |
Kojto | 39:d96aa62afc5b | 25 | * $Rev: 1116 $ |
Kojto | 39:d96aa62afc5b | 26 | * $Date:: 2014-07-09 16:29:19 +0900#$ |
Kojto | 39:d96aa62afc5b | 27 | * Device(s) : RZ/A1H |
Kojto | 39:d96aa62afc5b | 28 | * Tool-Chain : |
Kojto | 39:d96aa62afc5b | 29 | * OS : None |
Kojto | 39:d96aa62afc5b | 30 | * H/W Platform : |
Kojto | 39:d96aa62afc5b | 31 | * Description : RZ/A1H R7S72100 USB Sample Program |
Kojto | 39:d96aa62afc5b | 32 | * Operation : |
Kojto | 39:d96aa62afc5b | 33 | * Limitations : |
Kojto | 39:d96aa62afc5b | 34 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 35 | |
Kojto | 39:d96aa62afc5b | 36 | |
Kojto | 39:d96aa62afc5b | 37 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 38 | Includes <System Includes> , "Project Includes" |
Kojto | 39:d96aa62afc5b | 39 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 40 | #include "usb1_host.h" |
Kojto | 39:d96aa62afc5b | 41 | /* #include "usb1_host_dmacdrv.h" */ |
Kojto | 39:d96aa62afc5b | 42 | |
Kojto | 39:d96aa62afc5b | 43 | |
Kojto | 39:d96aa62afc5b | 44 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 45 | Typedef definitions |
Kojto | 39:d96aa62afc5b | 46 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 47 | |
Kojto | 39:d96aa62afc5b | 48 | |
Kojto | 39:d96aa62afc5b | 49 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 50 | Macro definitions |
Kojto | 39:d96aa62afc5b | 51 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 52 | |
Kojto | 39:d96aa62afc5b | 53 | |
Kojto | 39:d96aa62afc5b | 54 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 55 | Imported global variables and functions (from other files) |
Kojto | 39:d96aa62afc5b | 56 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 57 | |
Kojto | 39:d96aa62afc5b | 58 | |
Kojto | 39:d96aa62afc5b | 59 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 60 | Exported global variables and functions (to be accessed by other files) |
Kojto | 39:d96aa62afc5b | 61 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 62 | |
Kojto | 39:d96aa62afc5b | 63 | |
Kojto | 39:d96aa62afc5b | 64 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 65 | Private global variables and functions |
Kojto | 39:d96aa62afc5b | 66 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 67 | static void usb1_host_dmaint(uint16_t fifo); |
Kojto | 39:d96aa62afc5b | 68 | static void usb1_host_dmaint_buf2fifo(uint16_t pipe); |
Kojto | 39:d96aa62afc5b | 69 | static void usb1_host_dmaint_fifo2buf(uint16_t pipe); |
Kojto | 39:d96aa62afc5b | 70 | |
Kojto | 39:d96aa62afc5b | 71 | |
Kojto | 39:d96aa62afc5b | 72 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 73 | * Function Name: usb1_host_dma_stop_d0 |
Kojto | 39:d96aa62afc5b | 74 | * Description : D0FIFO DMA stop |
Kojto | 39:d96aa62afc5b | 75 | * Arguments : uint16_t pipe : pipe number |
Kojto | 39:d96aa62afc5b | 76 | * : uint32_t remain : transfer byte |
Kojto | 39:d96aa62afc5b | 77 | * Return Value : none |
Kojto | 39:d96aa62afc5b | 78 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 79 | void usb1_host_dma_stop_d0 (uint16_t pipe, uint32_t remain) |
Kojto | 39:d96aa62afc5b | 80 | { |
Kojto | 39:d96aa62afc5b | 81 | uint16_t dtln; |
Kojto | 39:d96aa62afc5b | 82 | uint16_t dfacc; |
Kojto | 39:d96aa62afc5b | 83 | uint16_t buffer; |
Kojto | 39:d96aa62afc5b | 84 | uint16_t sds_b = 1; |
Kojto | 39:d96aa62afc5b | 85 | |
Kojto | 39:d96aa62afc5b | 86 | dfacc = RZA_IO_RegRead_16(&USB201.D0FBCFG, |
Kojto | 39:d96aa62afc5b | 87 | USB_DnFBCFG_DFACC_SHIFT, |
Kojto | 39:d96aa62afc5b | 88 | USB_DnFBCFG_DFACC); |
Kojto | 39:d96aa62afc5b | 89 | if (dfacc == 2) |
Kojto | 39:d96aa62afc5b | 90 | { |
Kojto | 39:d96aa62afc5b | 91 | sds_b = 32; |
Kojto | 39:d96aa62afc5b | 92 | } |
Kojto | 39:d96aa62afc5b | 93 | else if (dfacc == 1) |
Kojto | 39:d96aa62afc5b | 94 | { |
Kojto | 39:d96aa62afc5b | 95 | sds_b = 16; |
Kojto | 39:d96aa62afc5b | 96 | } |
Kojto | 39:d96aa62afc5b | 97 | else |
Kojto | 39:d96aa62afc5b | 98 | { |
Kojto | 39:d96aa62afc5b | 99 | if (g_usb1_host_DmaInfo[USB_HOST_D0FIFO].size == 2) |
Kojto | 39:d96aa62afc5b | 100 | { |
Kojto | 39:d96aa62afc5b | 101 | sds_b = 4; |
Kojto | 39:d96aa62afc5b | 102 | } |
Kojto | 39:d96aa62afc5b | 103 | else if (g_usb1_host_DmaInfo[USB_HOST_D0FIFO].size == 1) |
Kojto | 39:d96aa62afc5b | 104 | { |
Kojto | 39:d96aa62afc5b | 105 | sds_b = 2; |
Kojto | 39:d96aa62afc5b | 106 | } |
Kojto | 39:d96aa62afc5b | 107 | else |
Kojto | 39:d96aa62afc5b | 108 | { |
Kojto | 39:d96aa62afc5b | 109 | sds_b = 1; |
Kojto | 39:d96aa62afc5b | 110 | } |
Kojto | 39:d96aa62afc5b | 111 | } |
Kojto | 39:d96aa62afc5b | 112 | |
Kojto | 39:d96aa62afc5b | 113 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 1) |
Kojto | 39:d96aa62afc5b | 114 | { |
Kojto | 39:d96aa62afc5b | 115 | if (g_usb1_host_pipe_status[pipe] != USB_HOST_PIPE_DONE) |
Kojto | 39:d96aa62afc5b | 116 | { |
Kojto | 39:d96aa62afc5b | 117 | buffer = USB201.D0FIFOCTR; |
Kojto | 39:d96aa62afc5b | 118 | dtln = (buffer & USB_HOST_BITDTLN); |
Kojto | 39:d96aa62afc5b | 119 | |
Kojto | 39:d96aa62afc5b | 120 | if ((dtln % sds_b) != 0) |
Kojto | 39:d96aa62afc5b | 121 | { |
Kojto | 39:d96aa62afc5b | 122 | remain += (sds_b - (dtln % sds_b)); |
Kojto | 39:d96aa62afc5b | 123 | } |
Kojto | 39:d96aa62afc5b | 124 | g_usb1_host_PipeDataSize[pipe] = (g_usb1_host_data_count[pipe] - remain); |
Kojto | 39:d96aa62afc5b | 125 | g_usb1_host_data_count[pipe] = remain; |
Kojto | 39:d96aa62afc5b | 126 | } |
Kojto | 39:d96aa62afc5b | 127 | } |
Kojto | 39:d96aa62afc5b | 128 | |
Kojto | 39:d96aa62afc5b | 129 | RZA_IO_RegWrite_16(&USB201.D0FIFOSEL, |
Kojto | 39:d96aa62afc5b | 130 | 0, |
Kojto | 39:d96aa62afc5b | 131 | USB_DnFIFOSEL_DREQE_SHIFT, |
Kojto | 39:d96aa62afc5b | 132 | USB_DnFIFOSEL_DREQE); |
Kojto | 39:d96aa62afc5b | 133 | } |
Kojto | 39:d96aa62afc5b | 134 | |
Kojto | 39:d96aa62afc5b | 135 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 136 | * Function Name: usb1_host_dma_stop_d1 |
Kojto | 39:d96aa62afc5b | 137 | * Description : D1FIFO DMA stop |
Kojto | 39:d96aa62afc5b | 138 | * Arguments : uint16_t pipe : pipe number |
Kojto | 39:d96aa62afc5b | 139 | * : uint32_t remain : transfer byte |
Kojto | 39:d96aa62afc5b | 140 | * Return Value : none |
Kojto | 39:d96aa62afc5b | 141 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 142 | void usb1_host_dma_stop_d1 (uint16_t pipe, uint32_t remain) |
Kojto | 39:d96aa62afc5b | 143 | { |
Kojto | 39:d96aa62afc5b | 144 | uint16_t dtln; |
Kojto | 39:d96aa62afc5b | 145 | uint16_t dfacc; |
Kojto | 39:d96aa62afc5b | 146 | uint16_t buffer; |
Kojto | 39:d96aa62afc5b | 147 | uint16_t sds_b = 1; |
Kojto | 39:d96aa62afc5b | 148 | |
Kojto | 39:d96aa62afc5b | 149 | dfacc = RZA_IO_RegRead_16(&USB201.D1FBCFG, |
Kojto | 39:d96aa62afc5b | 150 | USB_DnFBCFG_DFACC_SHIFT, |
Kojto | 39:d96aa62afc5b | 151 | USB_DnFBCFG_DFACC); |
Kojto | 39:d96aa62afc5b | 152 | if (dfacc == 2) |
Kojto | 39:d96aa62afc5b | 153 | { |
Kojto | 39:d96aa62afc5b | 154 | sds_b = 32; |
Kojto | 39:d96aa62afc5b | 155 | } |
Kojto | 39:d96aa62afc5b | 156 | else if (dfacc == 1) |
Kojto | 39:d96aa62afc5b | 157 | { |
Kojto | 39:d96aa62afc5b | 158 | sds_b = 16; |
Kojto | 39:d96aa62afc5b | 159 | } |
Kojto | 39:d96aa62afc5b | 160 | else |
Kojto | 39:d96aa62afc5b | 161 | { |
Kojto | 39:d96aa62afc5b | 162 | if (g_usb1_host_DmaInfo[USB_HOST_D1FIFO].size == 2) |
Kojto | 39:d96aa62afc5b | 163 | { |
Kojto | 39:d96aa62afc5b | 164 | sds_b = 4; |
Kojto | 39:d96aa62afc5b | 165 | } |
Kojto | 39:d96aa62afc5b | 166 | else if (g_usb1_host_DmaInfo[USB_HOST_D1FIFO].size == 1) |
Kojto | 39:d96aa62afc5b | 167 | { |
Kojto | 39:d96aa62afc5b | 168 | sds_b = 2; |
Kojto | 39:d96aa62afc5b | 169 | } |
Kojto | 39:d96aa62afc5b | 170 | else |
Kojto | 39:d96aa62afc5b | 171 | { |
Kojto | 39:d96aa62afc5b | 172 | sds_b = 1; |
Kojto | 39:d96aa62afc5b | 173 | } |
Kojto | 39:d96aa62afc5b | 174 | } |
Kojto | 39:d96aa62afc5b | 175 | |
Kojto | 39:d96aa62afc5b | 176 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 1) |
Kojto | 39:d96aa62afc5b | 177 | { |
Kojto | 39:d96aa62afc5b | 178 | if (g_usb1_host_pipe_status[pipe] != USB_HOST_PIPE_DONE) |
Kojto | 39:d96aa62afc5b | 179 | { |
Kojto | 39:d96aa62afc5b | 180 | buffer = USB201.D1FIFOCTR; |
Kojto | 39:d96aa62afc5b | 181 | dtln = (buffer & USB_HOST_BITDTLN); |
Kojto | 39:d96aa62afc5b | 182 | |
Kojto | 39:d96aa62afc5b | 183 | if ((dtln % sds_b) != 0) |
Kojto | 39:d96aa62afc5b | 184 | { |
Kojto | 39:d96aa62afc5b | 185 | remain += (sds_b - (dtln % sds_b)); |
Kojto | 39:d96aa62afc5b | 186 | } |
Kojto | 39:d96aa62afc5b | 187 | g_usb1_host_PipeDataSize[pipe] = (g_usb1_host_data_count[pipe] - remain); |
Kojto | 39:d96aa62afc5b | 188 | g_usb1_host_data_count[pipe] = remain; |
Kojto | 39:d96aa62afc5b | 189 | } |
Kojto | 39:d96aa62afc5b | 190 | } |
Kojto | 39:d96aa62afc5b | 191 | |
Kojto | 39:d96aa62afc5b | 192 | RZA_IO_RegWrite_16(&USB201.D1FIFOSEL, |
Kojto | 39:d96aa62afc5b | 193 | 0, |
Kojto | 39:d96aa62afc5b | 194 | USB_DnFIFOSEL_DREQE_SHIFT, |
Kojto | 39:d96aa62afc5b | 195 | USB_DnFIFOSEL_DREQE); |
Kojto | 39:d96aa62afc5b | 196 | } |
Kojto | 39:d96aa62afc5b | 197 | |
Kojto | 39:d96aa62afc5b | 198 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 199 | * Function Name: usb1_host_dma_interrupt_d0fifo |
Kojto | 39:d96aa62afc5b | 200 | * Description : This function is DMA interrupt handler entry. |
Kojto | 39:d96aa62afc5b | 201 | * : Execute usb1_host_dmaint() after disabling DMA interrupt in this function. |
Kojto | 39:d96aa62afc5b | 202 | * : Disable DMA interrupt to DMAC executed when USB_HOST_D0FIFO_DMA is |
Kojto | 39:d96aa62afc5b | 203 | * : specified by dma->fifo. |
Kojto | 39:d96aa62afc5b | 204 | * : Register this function as DMA complete interrupt. |
Kojto | 39:d96aa62afc5b | 205 | * Arguments : uint32_t int_sense ; Interrupts detection mode |
Kojto | 39:d96aa62afc5b | 206 | * : ; INTC_LEVEL_SENSITIVE : Level sense |
Kojto | 39:d96aa62afc5b | 207 | * : ; INTC_EDGE_TRIGGER : Edge trigger |
Kojto | 39:d96aa62afc5b | 208 | * Return Value : none |
Kojto | 39:d96aa62afc5b | 209 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 210 | void usb1_host_dma_interrupt_d0fifo (uint32_t int_sense) |
Kojto | 39:d96aa62afc5b | 211 | { |
Kojto | 39:d96aa62afc5b | 212 | usb1_host_dmaint(USB_HOST_D0FIFO); |
Kojto | 39:d96aa62afc5b | 213 | g_usb1_host_DmaStatus[USB_HOST_D0FIFO] = USB_HOST_DMA_READY; |
Kojto | 39:d96aa62afc5b | 214 | } |
Kojto | 39:d96aa62afc5b | 215 | |
Kojto | 39:d96aa62afc5b | 216 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 217 | * Function Name: usb1_host_dma_interrupt_d1fifo |
Kojto | 39:d96aa62afc5b | 218 | * Description : This function is DMA interrupt handler entry. |
Kojto | 39:d96aa62afc5b | 219 | * : Execute usb0_host_dmaint() after disabling DMA interrupt in this function. |
Kojto | 39:d96aa62afc5b | 220 | * : Disable DMA interrupt to DMAC executed when USB_HOST_D1FIFO_DMA is |
Kojto | 39:d96aa62afc5b | 221 | * : specified by dma->fifo. |
Kojto | 39:d96aa62afc5b | 222 | * : Register this function as DMA complete interrupt. |
Kojto | 39:d96aa62afc5b | 223 | * Arguments : uint32_t int_sense ; Interrupts detection mode |
Kojto | 39:d96aa62afc5b | 224 | * : ; INTC_LEVEL_SENSITIVE : Level sense |
Kojto | 39:d96aa62afc5b | 225 | * : ; INTC_EDGE_TRIGGER : Edge trigger |
Kojto | 39:d96aa62afc5b | 226 | * Return Value : none |
Kojto | 39:d96aa62afc5b | 227 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 228 | void usb1_host_dma_interrupt_d1fifo (uint32_t int_sense) |
Kojto | 39:d96aa62afc5b | 229 | { |
Kojto | 39:d96aa62afc5b | 230 | usb1_host_dmaint(USB_HOST_D1FIFO); |
Kojto | 39:d96aa62afc5b | 231 | g_usb1_host_DmaStatus[USB_HOST_D1FIFO] = USB_HOST_DMA_READY; |
Kojto | 39:d96aa62afc5b | 232 | } |
Kojto | 39:d96aa62afc5b | 233 | |
Kojto | 39:d96aa62afc5b | 234 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 235 | * Function Name: usb1_host_dmaint |
Kojto | 39:d96aa62afc5b | 236 | * Description : This function is DMA transfer end interrupt |
Kojto | 39:d96aa62afc5b | 237 | * Arguments : uint16_t fifo ; fifo number |
Kojto | 39:d96aa62afc5b | 238 | * : ; USB_HOST_D0FIFO |
Kojto | 39:d96aa62afc5b | 239 | * : ; USB_HOST_D1FIFO |
Kojto | 39:d96aa62afc5b | 240 | * Return Value : none |
Kojto | 39:d96aa62afc5b | 241 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 242 | static void usb1_host_dmaint (uint16_t fifo) |
Kojto | 39:d96aa62afc5b | 243 | { |
Kojto | 39:d96aa62afc5b | 244 | uint16_t pipe; |
Kojto | 39:d96aa62afc5b | 245 | |
Kojto | 39:d96aa62afc5b | 246 | pipe = g_usb1_host_DmaPipe[fifo]; |
Kojto | 39:d96aa62afc5b | 247 | |
Kojto | 39:d96aa62afc5b | 248 | if (g_usb1_host_DmaInfo[fifo].dir == USB_HOST_BUF2FIFO) |
Kojto | 39:d96aa62afc5b | 249 | { |
Kojto | 39:d96aa62afc5b | 250 | usb1_host_dmaint_buf2fifo(pipe); |
Kojto | 39:d96aa62afc5b | 251 | } |
Kojto | 39:d96aa62afc5b | 252 | else |
Kojto | 39:d96aa62afc5b | 253 | { |
Kojto | 39:d96aa62afc5b | 254 | usb1_host_dmaint_fifo2buf(pipe); |
Kojto | 39:d96aa62afc5b | 255 | } |
Kojto | 39:d96aa62afc5b | 256 | } |
Kojto | 39:d96aa62afc5b | 257 | |
Kojto | 39:d96aa62afc5b | 258 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 259 | * Function Name: usb1_host_dmaint_fifo2buf |
Kojto | 39:d96aa62afc5b | 260 | * Description : Executes read completion from FIFO by DMAC. |
Kojto | 39:d96aa62afc5b | 261 | * Arguments : uint16_t pipe : pipe number |
Kojto | 39:d96aa62afc5b | 262 | * Return Value : none |
Kojto | 39:d96aa62afc5b | 263 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 264 | static void usb1_host_dmaint_fifo2buf (uint16_t pipe) |
Kojto | 39:d96aa62afc5b | 265 | { |
Kojto | 39:d96aa62afc5b | 266 | uint32_t remain; |
Kojto | 39:d96aa62afc5b | 267 | uint16_t useport; |
Kojto | 39:d96aa62afc5b | 268 | |
Kojto | 39:d96aa62afc5b | 269 | if (g_usb1_host_pipe_status[pipe] != USB_HOST_PIPE_DONE) |
Kojto | 39:d96aa62afc5b | 270 | { |
Kojto | 39:d96aa62afc5b | 271 | useport = (uint16_t)(g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE); |
Kojto | 39:d96aa62afc5b | 272 | |
Kojto | 39:d96aa62afc5b | 273 | if (useport == USB_HOST_D0FIFO_DMA) |
Kojto | 39:d96aa62afc5b | 274 | { |
Kojto | 39:d96aa62afc5b | 275 | remain = Userdef_USB_usb1_host_stop_dma0(); |
Kojto | 39:d96aa62afc5b | 276 | usb1_host_dma_stop_d0(pipe, remain); |
Kojto | 39:d96aa62afc5b | 277 | |
Kojto | 39:d96aa62afc5b | 278 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0) |
Kojto | 39:d96aa62afc5b | 279 | { |
Kojto | 39:d96aa62afc5b | 280 | if (g_usb1_host_DmaStatus[USB_HOST_D0FIFO] == USB_HOST_DMA_BUSYEND) |
Kojto | 39:d96aa62afc5b | 281 | { |
Kojto | 39:d96aa62afc5b | 282 | USB201.D0FIFOCTR = USB_HOST_BITBCLR; |
Kojto | 39:d96aa62afc5b | 283 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_DONE; |
Kojto | 39:d96aa62afc5b | 284 | } |
Kojto | 39:d96aa62afc5b | 285 | else |
Kojto | 39:d96aa62afc5b | 286 | { |
Kojto | 39:d96aa62afc5b | 287 | usb1_host_enable_brdy_int(pipe); |
Kojto | 39:d96aa62afc5b | 288 | } |
Kojto | 39:d96aa62afc5b | 289 | } |
Kojto | 39:d96aa62afc5b | 290 | } |
Kojto | 39:d96aa62afc5b | 291 | else |
Kojto | 39:d96aa62afc5b | 292 | { |
Kojto | 39:d96aa62afc5b | 293 | remain = Userdef_USB_usb1_host_stop_dma1(); |
Kojto | 39:d96aa62afc5b | 294 | usb1_host_dma_stop_d1(pipe, remain); |
Kojto | 39:d96aa62afc5b | 295 | |
Kojto | 39:d96aa62afc5b | 296 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0) |
Kojto | 39:d96aa62afc5b | 297 | { |
Kojto | 39:d96aa62afc5b | 298 | if (g_usb1_host_DmaStatus[USB_HOST_D1FIFO] == USB_HOST_DMA_BUSYEND) |
Kojto | 39:d96aa62afc5b | 299 | { |
Kojto | 39:d96aa62afc5b | 300 | USB201.D1FIFOCTR = USB_HOST_BITBCLR; |
Kojto | 39:d96aa62afc5b | 301 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_DONE; |
Kojto | 39:d96aa62afc5b | 302 | } |
Kojto | 39:d96aa62afc5b | 303 | else |
Kojto | 39:d96aa62afc5b | 304 | { |
Kojto | 39:d96aa62afc5b | 305 | usb1_host_enable_brdy_int(pipe); |
Kojto | 39:d96aa62afc5b | 306 | } |
Kojto | 39:d96aa62afc5b | 307 | } |
Kojto | 39:d96aa62afc5b | 308 | } |
Kojto | 39:d96aa62afc5b | 309 | } |
Kojto | 39:d96aa62afc5b | 310 | } |
Kojto | 39:d96aa62afc5b | 311 | |
Kojto | 39:d96aa62afc5b | 312 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 313 | * Function Name: usb1_host_dmaint_buf2fifo |
Kojto | 39:d96aa62afc5b | 314 | * Description : Executes write completion in FIFO by DMAC. |
Kojto | 39:d96aa62afc5b | 315 | * Arguments : uint16_t pipe : pipe number |
Kojto | 39:d96aa62afc5b | 316 | * Return Value : none |
Kojto | 39:d96aa62afc5b | 317 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 318 | static void usb1_host_dmaint_buf2fifo (uint16_t pipe) |
Kojto | 39:d96aa62afc5b | 319 | { |
Kojto | 39:d96aa62afc5b | 320 | uint16_t useport; |
Kojto | 39:d96aa62afc5b | 321 | uint32_t remain; |
Kojto | 39:d96aa62afc5b | 322 | |
Kojto | 39:d96aa62afc5b | 323 | useport = (uint16_t)(g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE); |
Kojto | 39:d96aa62afc5b | 324 | |
Kojto | 39:d96aa62afc5b | 325 | if (useport == USB_HOST_D0FIFO_DMA) |
Kojto | 39:d96aa62afc5b | 326 | { |
Kojto | 39:d96aa62afc5b | 327 | remain = Userdef_USB_usb1_host_stop_dma0(); |
Kojto | 39:d96aa62afc5b | 328 | usb1_host_dma_stop_d0(pipe, remain); |
Kojto | 39:d96aa62afc5b | 329 | |
Kojto | 39:d96aa62afc5b | 330 | if (g_usb1_host_DmaBval[USB_HOST_D0FIFO] != 0) |
Kojto | 39:d96aa62afc5b | 331 | { |
Kojto | 39:d96aa62afc5b | 332 | RZA_IO_RegWrite_16(&USB201.D0FIFOCTR, |
Kojto | 39:d96aa62afc5b | 333 | 1, |
Kojto | 39:d96aa62afc5b | 334 | USB_DnFIFOCTR_BVAL_SHIFT, |
Kojto | 39:d96aa62afc5b | 335 | USB_DnFIFOCTR_BVAL); |
Kojto | 39:d96aa62afc5b | 336 | } |
Kojto | 39:d96aa62afc5b | 337 | } |
Kojto | 39:d96aa62afc5b | 338 | else |
Kojto | 39:d96aa62afc5b | 339 | { |
Kojto | 39:d96aa62afc5b | 340 | remain = Userdef_USB_usb1_host_stop_dma1(); |
Kojto | 39:d96aa62afc5b | 341 | usb1_host_dma_stop_d1(pipe, remain); |
Kojto | 39:d96aa62afc5b | 342 | |
Kojto | 39:d96aa62afc5b | 343 | if (g_usb1_host_DmaBval[USB_HOST_D1FIFO] != 0) |
Kojto | 39:d96aa62afc5b | 344 | { |
Kojto | 39:d96aa62afc5b | 345 | RZA_IO_RegWrite_16(&USB201.D1FIFOCTR, |
Kojto | 39:d96aa62afc5b | 346 | 1, |
Kojto | 39:d96aa62afc5b | 347 | USB_DnFIFOCTR_BVAL_SHIFT, |
Kojto | 39:d96aa62afc5b | 348 | USB_DnFIFOCTR_BVAL); |
Kojto | 39:d96aa62afc5b | 349 | } |
Kojto | 39:d96aa62afc5b | 350 | } |
Kojto | 39:d96aa62afc5b | 351 | |
Kojto | 39:d96aa62afc5b | 352 | usb1_host_enable_bemp_int(pipe); |
Kojto | 39:d96aa62afc5b | 353 | } |
Kojto | 39:d96aa62afc5b | 354 | |
Kojto | 39:d96aa62afc5b | 355 | /* End of File */ |