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