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