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/usb1/src/common/usb1_host_dataio.c@7:75f3e275934b, 2017-08-08 (annotated)
- Committer:
- bcjun@aname.co.kr
- Date:
- Tue Aug 08 16:20:39 2017 +0900
- Revision:
- 7:75f3e275934b
- Parent:
- 1:ab240722d7ef
change usbhost library that forked in my account
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 : usb1_host_dataio.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 "usb1_host.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 41 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 42 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 43 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 44 | Typedef definitions |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 45 | *******************************************************************************/ |
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 | Macro definitions |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 50 | *******************************************************************************/ |
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 | Imported global variables and functions (from other files) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 55 | *******************************************************************************/ |
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 | Exported global variables and functions (to be accessed by other files) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 60 | *******************************************************************************/ |
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 | Private global variables and functions |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 65 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 66 | static uint16_t g_usb1_host_mbw[(USB_HOST_MAX_PIPE_NO + 1)]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 67 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 68 | static void usb1_host_start_receive_trns_c(uint16_t pipe, uint32_t size, uint8_t *data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 69 | static void usb1_host_start_receive_trns_d0(uint16_t pipe, uint32_t size, uint8_t *data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 70 | static void usb1_host_start_receive_trns_d1(uint16_t pipe, uint32_t size, uint8_t *data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 71 | static void usb1_host_start_receive_dma_d0(uint16_t pipe, uint32_t size, uint8_t *data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 72 | static void usb1_host_start_receive_dma_d1(uint16_t pipe, uint32_t size, uint8_t *data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 73 | static uint16_t usb1_host_read_dma_d0(uint16_t pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 74 | static uint16_t usb1_host_read_dma_d1(uint16_t pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 75 | static uint16_t usb1_host_write_dma_d0(uint16_t pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 76 | static uint16_t usb1_host_write_dma_d1(uint16_t pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 77 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 78 | static void usb1_host_read_c_fifo(uint16_t pipe, uint16_t count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 79 | static void usb1_host_write_c_fifo(uint16_t Pipe, uint16_t count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 80 | static void usb1_host_read_d0_fifo(uint16_t pipe, uint16_t count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 81 | static void usb1_host_write_d0_fifo(uint16_t pipe, uint16_t count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 82 | static void usb1_host_read_d1_fifo(uint16_t pipe, uint16_t count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 83 | static void usb1_host_write_d1_fifo(uint16_t pipe, uint16_t count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 84 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 85 | static void usb1_host_clear_transaction_counter(uint16_t pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 86 | static void usb1_host_set_transaction_counter(uint16_t pipe, uint32_t count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 87 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 88 | static uint32_t usb1_host_com_get_dmasize(uint32_t trncount, uint32_t dtptr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 89 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 90 | static uint16_t usb1_host_set_dfacc_d0(uint16_t mbw, uint32_t count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 91 | static uint16_t usb1_host_set_dfacc_d1(uint16_t mbw, uint32_t count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 92 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 93 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 94 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 95 | * Function Name: usb1_host_start_send_transfer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 96 | * Description : Starts the USB data communication using pipe specified by the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 97 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 98 | * : uint32_t size ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 99 | * : uint8_t *data ; Data data Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 100 | * Return Value : USB_HOST_WRITEEND ; Write end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 101 | * : USB_HOST_WRITESHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 102 | * : USB_HOST_WRITING ; Continue of data write |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 103 | * : USB_HOST_WRITEDMA ; Write DMA |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 104 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 105 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 106 | uint16_t usb1_host_start_send_transfer (uint16_t pipe, uint32_t size, uint8_t * data) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 107 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 108 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 109 | uint16_t usefifo; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 110 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 111 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 112 | g_usb1_host_data_count[pipe] = size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 113 | g_usb1_host_data_pointer[pipe] = (uint8_t *)data; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 114 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_WAIT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 115 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 116 | usb1_host_clear_bemp_sts(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 117 | usb1_host_clear_brdy_sts(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 118 | usb1_host_clear_nrdy_sts(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 119 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 120 | mbw = usb1_host_get_mbw(size, (uint32_t)data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 121 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 122 | usefifo = (uint16_t)(g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 123 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 124 | switch (usefifo) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 125 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 126 | case USB_HOST_D0FIFO_USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 127 | case USB_HOST_D0FIFO_DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 128 | usefifo = USB_HOST_D0USE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 129 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 130 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 131 | case USB_HOST_D1FIFO_USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 132 | case USB_HOST_D1FIFO_DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 133 | usefifo = USB_HOST_D1USE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 134 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 135 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 136 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 137 | usefifo = USB_HOST_CUSE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 138 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 139 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 140 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 141 | usb1_host_set_curpipe(USB_HOST_PIPE0, usefifo, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 142 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 143 | usb1_host_clear_transaction_counter(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 144 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 145 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 146 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 147 | usb1_host_aclrm(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 148 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 149 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 150 | status = usb1_host_write_buffer(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 151 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 152 | if (status != USB_HOST_FIFOERROR) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 153 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 154 | usb1_host_set_pid_buf(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 155 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 156 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 157 | return status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 158 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 159 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 160 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 161 | * Function Name: usb1_host_write_buffer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 162 | * Description : Writes data in the buffer allocated in the pipe specified by |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 163 | * : the argument. The FIFO for using is set in the pipe definition table. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 164 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 165 | * Return Value : USB_HOST_WRITEEND ; Write end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 166 | * : USB_HOST_WRITESHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 167 | * : USB_HOST_WRITING ; Continue of data write |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 168 | * : USB_HOST_WRITEDMA ; Write DMA |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 169 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 170 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 171 | uint16_t usb1_host_write_buffer (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 172 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 173 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 174 | uint16_t usefifo; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 175 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 176 | g_usb1_host_PipeIgnore[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 177 | usefifo = (uint16_t)(g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 178 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 179 | switch (usefifo) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 180 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 181 | case USB_HOST_D0FIFO_USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 182 | status = usb1_host_write_buffer_d0(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 183 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 184 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 185 | case USB_HOST_D1FIFO_USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 186 | status = usb1_host_write_buffer_d1(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 187 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 188 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 189 | case USB_HOST_D0FIFO_DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 190 | status = usb1_host_write_dma_d0(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 191 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 192 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 193 | case USB_HOST_D1FIFO_DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 194 | status = usb1_host_write_dma_d1(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 195 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 196 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 197 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 198 | status = usb1_host_write_buffer_c(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 199 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 200 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 201 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 202 | switch (status) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 203 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 204 | case USB_HOST_WRITING: /* Continue of data write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 205 | usb1_host_enable_nrdy_int(pipe); /* Error (NORES or STALL) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 206 | usb1_host_enable_brdy_int(pipe); /* Enable Ready Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 207 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 208 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 209 | case USB_HOST_WRITEEND: /* End of data write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 210 | case USB_HOST_WRITESHRT: /* End of data write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 211 | usb1_host_disable_brdy_int(pipe); /* Disable Ready Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 212 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 213 | usb1_host_clear_nrdy_sts(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 214 | usb1_host_enable_nrdy_int(pipe); /* Error (NORES or STALL) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 215 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 216 | /* for last transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 217 | usb1_host_enable_bemp_int(pipe); /* Enable Empty Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 218 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 219 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 220 | case USB_HOST_WRITEDMA: /* DMA write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 221 | usb1_host_clear_nrdy_sts(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 222 | usb1_host_enable_nrdy_int(pipe); /* Error (NORES or STALL) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 223 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 224 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 225 | case USB_HOST_FIFOERROR: /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 226 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 227 | usb1_host_disable_brdy_int(pipe); /* Disable Ready Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 228 | usb1_host_disable_bemp_int(pipe); /* Disable Empty Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 229 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 230 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 231 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 232 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 233 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 234 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 235 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 236 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 237 | * Function Name: usb1_host_write_buffer_c |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 238 | * Description : Writes data in the buffer allocated in the pipe specified in |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 239 | * : the argument. Writes data by CPU transfer using CFIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 240 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 241 | * Return Value : USB_HOST_WRITEEND ; Write end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 242 | * : USB_HOST_WRITESHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 243 | * : USB_HOST_WRITING ; Continue of data write |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 244 | * : USB_HOST_WRITEDMA ; Write DMA |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 245 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 246 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 247 | uint16_t usb1_host_write_buffer_c (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 248 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 249 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 250 | uint16_t size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 251 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 252 | uint16_t mxps; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 253 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 254 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 255 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 256 | mbw = usb1_host_get_mbw(g_usb1_host_data_count[pipe], (uint32_t)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 257 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 258 | if (pipe == USB_HOST_PIPE0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 259 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 260 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_CUSE, USB_HOST_CFIFO_WRITE, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 261 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 262 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 263 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 264 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_CUSE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 265 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 266 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 267 | if (buffer == USB_HOST_FIFOERROR) /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 268 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 269 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 270 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 271 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 272 | size = usb1_host_get_buf_size(pipe); /* Data buffer size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 273 | mxps = usb1_host_get_mxps(pipe); /* Max Packet Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 274 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 275 | if (g_usb1_host_data_count[pipe] <= (uint32_t)size) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 276 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 277 | status = USB_HOST_WRITEEND; /* write continues */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 278 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 279 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 280 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 281 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 282 | status = USB_HOST_WRITESHRT; /* Null Packet is end of write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 283 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 284 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 285 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 286 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 287 | status = USB_HOST_WRITESHRT; /* Short Packet is end of write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 288 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 289 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 290 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 291 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 292 | status = USB_HOST_WRITING; /* write continues */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 293 | count = (uint32_t)size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 294 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 295 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 296 | usb1_host_write_c_fifo(pipe, (uint16_t)count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 297 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 298 | if (g_usb1_host_data_count[pipe] < (uint32_t)size) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 299 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 300 | g_usb1_host_data_count[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 301 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 302 | if (RZA_IO_RegRead_16(&USB201.CFIFOCTR, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 303 | USB_CFIFOCTR_BVAL_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 304 | USB_CFIFOCTR_BVAL) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 305 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 306 | USB201.CFIFOCTR = USB_HOST_BITBVAL; /* Short Packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 307 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 308 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 309 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 310 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 311 | g_usb1_host_data_count[pipe] -= count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 312 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 313 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 314 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 315 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 316 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 317 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 318 | * Function Name: usb1_host_write_buffer_d0 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 319 | * Description : Writes data in the buffer allocated in the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 320 | * : Writes data by CPU transfer using D0FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 321 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 322 | * Return Value : USB_HOST_WRITEEND ; Write end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 323 | * : USB_HOST_WRITESHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 324 | * : USB_HOST_WRITING ; Continue of data write |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 325 | * : USB_HOST_WRITEDMA ; Write DMA |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 326 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 327 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 328 | uint16_t usb1_host_write_buffer_d0 (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 329 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 330 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 331 | uint16_t size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 332 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 333 | uint16_t mxps; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 334 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 335 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 336 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 337 | mbw = usb1_host_get_mbw(g_usb1_host_data_count[pipe], (uint32_t)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 338 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_D0USE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 339 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 340 | if (buffer == USB_HOST_FIFOERROR) /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 341 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 342 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 343 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 344 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 345 | size = usb1_host_get_buf_size(pipe); /* Data buffer size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 346 | mxps = usb1_host_get_mxps(pipe); /* Max Packet Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 347 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 348 | if (g_usb1_host_data_count[pipe] <= (uint32_t)size) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 349 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 350 | status = USB_HOST_WRITEEND; /* write continues */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 351 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 352 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 353 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 354 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 355 | status = USB_HOST_WRITESHRT; /* Null Packet is end of write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 356 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 357 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 358 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 359 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 360 | status = USB_HOST_WRITESHRT; /* Short Packet is end of write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 361 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 362 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 363 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 364 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 365 | status = USB_HOST_WRITING; /* write continues */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 366 | count = (uint32_t)size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 367 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 368 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 369 | usb1_host_write_d0_fifo(pipe, (uint16_t)count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 370 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 371 | if (g_usb1_host_data_count[pipe] < (uint32_t)size) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 372 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 373 | g_usb1_host_data_count[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 374 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 375 | if (RZA_IO_RegRead_16(&USB201.D0FIFOCTR, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 376 | USB_DnFIFOCTR_BVAL_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 377 | USB_DnFIFOCTR_BVAL) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 378 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 379 | USB201.D0FIFOCTR = USB_HOST_BITBVAL; /* Short Packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 380 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 381 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 382 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 383 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 384 | g_usb1_host_data_count[pipe] -= count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 385 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 386 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 387 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 388 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 389 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 390 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 391 | * Function Name: usb1_host_write_buffer_d1 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 392 | * Description : Writes data in the buffer allocated in the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 393 | * : Writes data by CPU transfer using D1FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 394 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 395 | * Return Value : USB_HOST_WRITEEND ; Write end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 396 | * : USB_HOST_WRITESHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 397 | * : USB_HOST_WRITING ; Continue of data write |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 398 | * : USB_HOST_WRITEDMA ; Write DMA |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 399 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 400 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 401 | uint16_t usb1_host_write_buffer_d1 (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 402 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 403 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 404 | uint16_t size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 405 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 406 | uint16_t mxps; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 407 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 408 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 409 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 410 | mbw = usb1_host_get_mbw(g_usb1_host_data_count[pipe], (uint32_t)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 411 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_D1USE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 412 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 413 | if (buffer == USB_HOST_FIFOERROR) /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 414 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 415 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 416 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 417 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 418 | size = usb1_host_get_buf_size(pipe); /* Data buffer size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 419 | mxps = usb1_host_get_mxps(pipe); /* Max Packet Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 420 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 421 | if (g_usb1_host_data_count[pipe] <= (uint32_t)size) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 422 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 423 | status = USB_HOST_WRITEEND; /* write continues */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 424 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 425 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 426 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 427 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 428 | status = USB_HOST_WRITESHRT; /* Null Packet is end of write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 429 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 430 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 431 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 432 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 433 | status = USB_HOST_WRITESHRT; /* Short Packet is end of write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 434 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 435 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 436 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 437 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 438 | status = USB_HOST_WRITING; /* write continues */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 439 | count = (uint32_t)size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 440 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 441 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 442 | usb1_host_write_d1_fifo(pipe, (uint16_t)count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 443 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 444 | if (g_usb1_host_data_count[pipe] < (uint32_t)size) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 445 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 446 | g_usb1_host_data_count[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 447 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 448 | if (RZA_IO_RegRead_16(&USB201.D1FIFOCTR, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 449 | USB_DnFIFOCTR_BVAL_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 450 | USB_DnFIFOCTR_BVAL) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 451 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 452 | USB201.D1FIFOCTR = USB_HOST_BITBVAL; /* Short Packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 453 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 454 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 455 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 456 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 457 | g_usb1_host_data_count[pipe] -= count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 458 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 459 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 460 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 461 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 462 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 463 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 464 | * Function Name: usb1_host_write_dma_d0 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 465 | * Description : Writes data in the buffer allocated in the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 466 | * : Writes data by DMA transfer using D0FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 467 | * : The DMA-ch for using is specified by Userdef_USB_usb1_host_start_dma(). |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 468 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 469 | * Return Value : USB_HOST_WRITEEND : Write end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 470 | * : USB_HOST_WRITESHRT : short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 471 | * : USB_HOST_WRITING : Continue of data write |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 472 | * : USB_HOST_WRITEDMA : Write DMA |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 473 | * : USB_HOST_FIFOERROR : FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 474 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 475 | static uint16_t usb1_host_write_dma_d0 (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 476 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 477 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 478 | uint16_t size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 479 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 480 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 481 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 482 | uint16_t dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 483 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 484 | mbw = usb1_host_get_mbw(g_usb1_host_data_count[pipe], (uint32_t)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 485 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_D0DMA, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 486 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 487 | if (buffer == USB_HOST_FIFOERROR) /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 488 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 489 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 490 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 491 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 492 | size = usb1_host_get_buf_size(pipe); /* Data buffer size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 493 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 494 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 495 | if (count != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 496 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 497 | g_usb1_host_DmaPipe[USB_HOST_D0FIFO] = pipe; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 498 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 499 | if ((count % size) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 500 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 501 | g_usb1_host_DmaBval[USB_HOST_D0FIFO] = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 502 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 503 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 504 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 505 | g_usb1_host_DmaBval[USB_HOST_D0FIFO] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 506 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 507 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 508 | dfacc = usb1_host_set_dfacc_d0(mbw, count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 509 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 510 | if (mbw == USB_HOST_BITMBW_32) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 511 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 512 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].size = 2; /* 32bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 513 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 514 | else if (mbw == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 515 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 516 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].size = 1; /* 16bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 517 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 518 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 519 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 520 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].size = 0; /* 8bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 521 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 522 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 523 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].fifo = USB_HOST_D0FIFO_DMA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 524 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].dir = USB_HOST_BUF2FIFO; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 525 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].buffer = (uint32_t)g_usb1_host_data_pointer[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 526 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].bytes = count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 527 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 528 | Userdef_USB_usb1_host_start_dma(&g_usb1_host_DmaInfo[USB_HOST_D0FIFO], dfacc); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 529 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 530 | usb1_host_set_curpipe2(pipe, USB_HOST_D0DMA, USB_HOST_NO, mbw, dfacc); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 531 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 532 | RZA_IO_RegWrite_16(&USB201.D0FIFOSEL, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 533 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 534 | USB_DnFIFOSEL_DREQE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 535 | USB_DnFIFOSEL_DREQE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 536 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 537 | g_usb1_host_data_count[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 538 | g_usb1_host_data_pointer[pipe] += count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 539 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 540 | status = USB_HOST_WRITEDMA; /* DMA write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 541 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 542 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 543 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 544 | if (RZA_IO_RegRead_16(&USB201.D0FIFOCTR, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 545 | USB_DnFIFOCTR_BVAL_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 546 | USB_DnFIFOCTR_BVAL) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 547 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 548 | RZA_IO_RegWrite_16(&USB201.D0FIFOCTR, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 549 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 550 | USB_DnFIFOCTR_BVAL_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 551 | USB_DnFIFOCTR_BVAL); /* Short Packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 552 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 553 | status = USB_HOST_WRITESHRT; /* Short Packet is end of write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 554 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 555 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 556 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 557 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 558 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 559 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 560 | * Function Name: usb1_host_write_dma_d1 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 561 | * Description : Writes data in the buffer allocated in the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 562 | * : Writes data by DMA transfer using D1FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 563 | * : The DMA-ch for using is specified by Userdef_USB_usb1_host_start_dma(). |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 564 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 565 | * Return Value : USB_HOST_WRITEEND : Write end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 566 | * : USB_HOST_WRITESHRT : short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 567 | * : USB_HOST_WRITING : Continue of data write |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 568 | * : USB_HOST_WRITEDMA : Write DMA |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 569 | * : USB_HOST_FIFOERROR : FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 570 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 571 | static uint16_t usb1_host_write_dma_d1 (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 572 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 573 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 574 | uint16_t size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 575 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 576 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 577 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 578 | uint16_t dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 579 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 580 | mbw = usb1_host_get_mbw(g_usb1_host_data_count[pipe], (uint32_t)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 581 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_D1DMA, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 582 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 583 | if (buffer == USB_HOST_FIFOERROR) /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 584 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 585 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 586 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 587 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 588 | size = usb1_host_get_buf_size(pipe); /* Data buffer size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 589 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 590 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 591 | if (count != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 592 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 593 | g_usb1_host_DmaPipe[USB_HOST_D1FIFO] = pipe; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 594 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 595 | if ((count % size) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 596 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 597 | g_usb1_host_DmaBval[USB_HOST_D1FIFO] = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 598 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 599 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 600 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 601 | g_usb1_host_DmaBval[USB_HOST_D1FIFO] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 602 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 603 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 604 | dfacc = usb1_host_set_dfacc_d1(mbw, count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 605 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 606 | if (mbw == USB_HOST_BITMBW_32) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 607 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 608 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].size = 2; /* 32bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 609 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 610 | else if (mbw == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 611 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 612 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].size = 1; /* 16bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 613 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 614 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 615 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 616 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].size = 0; /* 8bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 617 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 618 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 619 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].fifo = USB_HOST_D1FIFO_DMA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 620 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].dir = USB_HOST_BUF2FIFO; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 621 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].buffer = (uint32_t)g_usb1_host_data_pointer[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 622 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].bytes = count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 623 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 624 | Userdef_USB_usb1_host_start_dma(&g_usb1_host_DmaInfo[USB_HOST_D1FIFO], dfacc); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 625 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 626 | usb1_host_set_curpipe2(pipe, USB_HOST_D1DMA, USB_HOST_NO, mbw , dfacc); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 627 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 628 | RZA_IO_RegWrite_16(&USB201.D1FIFOSEL, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 629 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 630 | USB_DnFIFOSEL_DREQE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 631 | USB_DnFIFOSEL_DREQE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 632 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 633 | g_usb1_host_data_count[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 634 | g_usb1_host_data_pointer[pipe] += count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 635 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 636 | status = USB_HOST_WRITEDMA; /* DMA write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 637 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 638 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 639 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 640 | if (RZA_IO_RegRead_16(&USB201.D1FIFOCTR, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 641 | USB_DnFIFOCTR_BVAL_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 642 | USB_DnFIFOCTR_BVAL) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 643 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 644 | RZA_IO_RegWrite_16(&USB201.D1FIFOCTR, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 645 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 646 | USB_DnFIFOCTR_BVAL_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 647 | USB_DnFIFOCTR_BVAL); /* Short Packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 648 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 649 | status = USB_HOST_WRITESHRT; /* Short Packet is end of write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 650 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 651 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 652 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 653 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 654 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 655 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 656 | * Function Name: usb1_host_start_receive_transfer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 657 | * Description : Starts USB data reception using the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 658 | * : The FIFO for using is set in the pipe definition table. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 659 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 660 | * : uint32_t size ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 661 | * : uint8_t *data ; Data Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 662 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 663 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 664 | void usb1_host_start_receive_transfer (uint16_t pipe, uint32_t size, uint8_t * data) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 665 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 666 | uint16_t usefifo; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 667 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 668 | usb1_host_clear_bemp_sts(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 669 | usb1_host_clear_brdy_sts(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 670 | usb1_host_clear_nrdy_sts(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 671 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 672 | usefifo = (uint16_t)(g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 673 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 674 | switch (usefifo) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 675 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 676 | case USB_HOST_D0FIFO_USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 677 | usb1_host_start_receive_trns_d0(pipe, size, data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 678 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 679 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 680 | case USB_HOST_D1FIFO_USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 681 | usb1_host_start_receive_trns_d1(pipe, size, data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 682 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 683 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 684 | case USB_HOST_D0FIFO_DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 685 | usb1_host_start_receive_dma_d0(pipe, size, data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 686 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 687 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 688 | case USB_HOST_D1FIFO_DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 689 | usb1_host_start_receive_dma_d1(pipe, size, data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 690 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 691 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 692 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 693 | usb1_host_start_receive_trns_c(pipe, size, data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 694 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 695 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 696 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 697 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 698 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 699 | * Function Name: usb1_host_start_receive_trns_c |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 700 | * Description : Reads data from the buffer allocated in the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 701 | * : Reads data by CPU transfer using CFIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 702 | * : When storing data in the buffer allocated in the pipe specified in the |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 703 | * : argument, BRDY interrupt is generated to read data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 704 | * : in the interrupt. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 705 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 706 | * : uint32_t size ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 707 | * : uint8_t *data ; Data Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 708 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 709 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 710 | static void usb1_host_start_receive_trns_c (uint16_t pipe, uint32_t size, uint8_t * data) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 711 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 712 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 713 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 714 | usb1_host_set_pid_nak(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 715 | g_usb1_host_data_count[pipe] = size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 716 | g_usb1_host_data_pointer[pipe] = (uint8_t *)data; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 717 | g_usb1_host_PipeIgnore[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 718 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 719 | g_usb1_host_PipeDataSize[pipe] = size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 720 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_WAIT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 721 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 722 | mbw = usb1_host_get_mbw(size, (uint32_t)data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 723 | usb1_host_set_curpipe(USB_HOST_PIPE0, USB_HOST_CUSE, USB_HOST_CFIFO_READ, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 724 | USB201.CFIFOCTR = USB_HOST_BITBCLR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 725 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 726 | usb1_host_set_transaction_counter(pipe, size); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 727 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 728 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 729 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 730 | usb1_host_aclrm(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 731 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 732 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 733 | usb1_host_enable_nrdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 734 | usb1_host_enable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 735 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 736 | usb1_host_set_pid_buf(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 737 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 738 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 739 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 740 | * Function Name: usb1_host_start_receive_trns_d0 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 741 | * Description : Reads data from the buffer allocated in the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 742 | * : Reads data by CPU transfer using D0FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 743 | * : This function does not read data from the buffer. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 744 | * : When storing data in the buffer allocated in the pipe specified |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 745 | * : in the argument, BRDY interrupt is generated to read data in the |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 746 | * : interrupt. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 747 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 748 | * : uint32_t size ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 749 | * : uint8_t *data ; Data Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 750 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 751 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 752 | static void usb1_host_start_receive_trns_d0 (uint16_t pipe, uint32_t size, uint8_t * data) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 753 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 754 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 755 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 756 | usb1_host_set_pid_nak(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 757 | g_usb1_host_data_count[pipe] = size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 758 | g_usb1_host_data_pointer[pipe] = (uint8_t *)data; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 759 | g_usb1_host_PipeIgnore[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 760 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 761 | g_usb1_host_PipeDataSize[pipe] = size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 762 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_WAIT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 763 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 764 | mbw = usb1_host_get_mbw(size, (uint32_t)data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 765 | usb1_host_set_curpipe(USB_HOST_PIPE0, USB_HOST_D0USE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 766 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 767 | usb1_host_set_transaction_counter(pipe, size); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 768 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 769 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 770 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 771 | usb1_host_aclrm(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 772 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 773 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 774 | usb1_host_enable_nrdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 775 | usb1_host_enable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 776 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 777 | usb1_host_set_pid_buf(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 778 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 779 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 780 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 781 | * Function Name: usb1_host_start_receive_trns_d1 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 782 | * Description : Reads data from the buffer allocated in the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 783 | * : Reads data by CPU transfer using D1FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 784 | * : This function does not read data from the buffer. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 785 | * : When storing data in the buffer allocated in the pipe specified |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 786 | * : in the argument, BRDY interrupt is generated to read data. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 787 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 788 | * : uint32_t size ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 789 | * : uint8_t *data ; Data Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 790 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 791 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 792 | static void usb1_host_start_receive_trns_d1 (uint16_t pipe, uint32_t size, uint8_t * data) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 793 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 794 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 795 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 796 | usb1_host_set_pid_nak(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 797 | g_usb1_host_data_count[pipe] = size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 798 | g_usb1_host_data_pointer[pipe] = (uint8_t *)data; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 799 | g_usb1_host_PipeIgnore[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 800 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 801 | g_usb1_host_PipeDataSize[pipe] = size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 802 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_WAIT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 803 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 804 | mbw = usb1_host_get_mbw(size, (uint32_t)data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 805 | usb1_host_set_curpipe(USB_HOST_PIPE0, USB_HOST_D1USE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 806 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 807 | usb1_host_set_transaction_counter(pipe, size); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 808 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 809 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 810 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 811 | usb1_host_aclrm(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 812 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 813 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 814 | usb1_host_enable_nrdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 815 | usb1_host_enable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 816 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 817 | usb1_host_set_pid_buf(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 818 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 819 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 820 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 821 | * Function Name: usb1_host_start_receive_dma_d0 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 822 | * Description : Reads data from the buffer allocated in the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 823 | * : Reads data by DMA transfer using D0FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 824 | * : This function does not read data from the buffer. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 825 | * : When storing data in the buffer allocated in the pipe specified |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 826 | * : in the argument, delivered read request to DMAC to read data from |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 827 | * : the buffer by DMAC. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 828 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 829 | * : uint32_t size ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 830 | * : uint8_t *data ; Data Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 831 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 832 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 833 | static void usb1_host_start_receive_dma_d0 (uint16_t pipe, uint32_t size, uint8_t * data) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 834 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 835 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 836 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 837 | usb1_host_set_pid_nak(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 838 | g_usb1_host_data_count[pipe] = size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 839 | g_usb1_host_data_pointer[pipe] = (uint8_t *)data; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 840 | g_usb1_host_PipeIgnore[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 841 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 842 | g_usb1_host_PipeDataSize[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 843 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_WAIT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 844 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 845 | mbw = usb1_host_get_mbw(size, (uint32_t)data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 846 | usb1_host_set_curpipe(USB_HOST_PIPE0, USB_HOST_D0USE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 847 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 848 | usb1_host_set_transaction_counter(pipe, size); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 849 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 850 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 851 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 852 | usb1_host_aclrm(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 853 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 854 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 855 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 856 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 857 | usb1_host_read_dma(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 858 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 859 | usb1_host_enable_nrdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 860 | usb1_host_enable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 861 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 862 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 863 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 864 | usb1_host_enable_nrdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 865 | usb1_host_enable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 866 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 867 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 868 | usb1_host_set_pid_buf(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 869 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 870 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 871 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 872 | * Function Name: usb1_host_start_receive_dma_d1 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 873 | * Description : Read data from the buffer allocated in the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 874 | * : Reads data by DMA transfer using D0FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 875 | * : This function does not read data from the buffer. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 876 | * : When storing data in the buffer allocated in the pipe specified |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 877 | * : in the argument, delivered read request to DMAC to read data from |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 878 | * : the buffer by DMAC. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 879 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 880 | * : uint32_t size ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 881 | * : uint8_t *data ; Data Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 882 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 883 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 884 | static void usb1_host_start_receive_dma_d1 (uint16_t pipe, uint32_t size, uint8_t * data) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 885 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 886 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 887 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 888 | usb1_host_set_pid_nak(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 889 | g_usb1_host_data_count[pipe] = size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 890 | g_usb1_host_data_pointer[pipe] = (uint8_t *)data; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 891 | g_usb1_host_PipeIgnore[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 892 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 893 | g_usb1_host_PipeDataSize[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 894 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_WAIT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 895 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 896 | mbw = usb1_host_get_mbw(size, (uint32_t)data); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 897 | usb1_host_set_curpipe(USB_HOST_PIPE0, USB_HOST_D1USE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 898 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 899 | usb1_host_set_transaction_counter(pipe, size); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 900 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 901 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 902 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 903 | usb1_host_aclrm(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 904 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 905 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 906 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 907 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 908 | usb1_host_read_dma(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 909 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 910 | usb1_host_enable_nrdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 911 | usb1_host_enable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 912 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 913 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 914 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 915 | usb1_host_enable_nrdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 916 | usb1_host_enable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 917 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 918 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 919 | usb1_host_set_pid_buf(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 920 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 921 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 922 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 923 | * Function Name: usb1_host_read_buffer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 924 | * Description : Reads data from the buffer allocated in the pipe specified |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 925 | * : in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 926 | * : Uses FIF0 set in the pipe definition table. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 927 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 928 | * Return Value : USB_HOST_READEND ; Read end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 929 | * : USB_HOST_READSHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 930 | * : USB_HOST_READING ; Continue of data read |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 931 | * : USB_HOST_READOVER ; buffer over |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 932 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 933 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 934 | uint16_t usb1_host_read_buffer (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 935 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 936 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 937 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 938 | g_usb1_host_PipeIgnore[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 939 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 940 | if ((g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE) == USB_HOST_D0FIFO_USE) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 941 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 942 | status = usb1_host_read_buffer_d0(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 943 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 944 | else if ((g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE) == USB_HOST_D1FIFO_USE) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 945 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 946 | status = usb1_host_read_buffer_d1(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 947 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 948 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 949 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 950 | status = usb1_host_read_buffer_c(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 951 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 952 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 953 | switch (status) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 954 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 955 | case USB_HOST_READING: /* Continue of data read */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 956 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 957 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 958 | case USB_HOST_READEND: /* End of data read */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 959 | case USB_HOST_READSHRT: /* End of data read */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 960 | usb1_host_disable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 961 | g_usb1_host_PipeDataSize[pipe] -= g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 962 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_DONE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 963 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 964 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 965 | case USB_HOST_READOVER: /* buffer over */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 966 | if ((g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE) == USB_HOST_D0FIFO_USE) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 967 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 968 | USB201.D0FIFOCTR = USB_HOST_BITBCLR; /* Clear BCLR */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 969 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 970 | else if ((g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE) == USB_HOST_D1FIFO_USE) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 971 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 972 | USB201.D1FIFOCTR = USB_HOST_BITBCLR; /* Clear BCLR */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 973 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 974 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 975 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 976 | USB201.CFIFOCTR = USB_HOST_BITBCLR; /* Clear BCLR */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 977 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 978 | usb1_host_disable_brdy_int(pipe); /* Disable Ready Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 979 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 980 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_DONE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 981 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 982 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 983 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 984 | g_usb1_host_PipeDataSize[pipe] -= g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 985 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 986 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 987 | case USB_HOST_FIFOERROR: /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 988 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 989 | usb1_host_disable_brdy_int(pipe); /* Disable Ready Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 990 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 991 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 992 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 993 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 994 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 995 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 996 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 997 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 998 | * Function Name: usb1_host_read_buffer_c |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 999 | * Description : Reads data from the buffer allocated in the pipe specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1000 | * : Reads data by CPU transfer using CFIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1001 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1002 | * Return Value : USB_HOST_READEND ; Read end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1003 | * : USB_HOST_READSHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1004 | * : USB_HOST_READING ; Continue of data read |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1005 | * : USB_HOST_READOVER ; buffer over |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1006 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1007 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1008 | uint16_t usb1_host_read_buffer_c (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1009 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1010 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1011 | uint32_t dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1012 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1013 | uint16_t mxps; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1014 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1015 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1016 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1017 | mbw = usb1_host_get_mbw(g_usb1_host_data_count[pipe], (uint32_t)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1018 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_CUSE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1019 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1020 | if (buffer == USB_HOST_FIFOERROR) /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1021 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1022 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1023 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1024 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1025 | dtln = (uint32_t)(buffer & USB_HOST_BITDTLN); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1026 | mxps = usb1_host_get_mxps(pipe); /* Max Packet Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1027 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1028 | if (g_usb1_host_data_count[pipe] < dtln) /* Buffer Over ? */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1029 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1030 | status = USB_HOST_READOVER; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1031 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1032 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1033 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1034 | else if (g_usb1_host_data_count[pipe] == dtln) /* just Receive Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1035 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1036 | status = USB_HOST_READEND; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1037 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1038 | count = dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1039 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1040 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1041 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1042 | status = USB_HOST_READSHRT; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1043 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1044 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1045 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1046 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1047 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1048 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1049 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1050 | else /* continue Receive data */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1051 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1052 | status = USB_HOST_READING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1053 | count = dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1054 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1055 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1056 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1057 | status = USB_HOST_READSHRT; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1058 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1059 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1060 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1061 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1062 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1063 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1064 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1065 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1066 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1067 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1068 | if (count == 0) /* 0 length packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1069 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1070 | USB201.CFIFOCTR = USB_HOST_BITBCLR; /* Clear BCLR */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1071 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1072 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1073 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1074 | usb1_host_read_c_fifo(pipe, (uint16_t)count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1075 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1076 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1077 | g_usb1_host_data_count[pipe] -= count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1078 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1079 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1080 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1081 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1082 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1083 | * Function Name: usb1_host_read_buffer_d0 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1084 | * Description : Reads data from the buffer allocated in the pipe specified in |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1085 | * : the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1086 | * : Reads data by CPU transfer using D0FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1087 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1088 | * Return Value : USB_HOST_READEND ; Read end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1089 | * : USB_HOST_READSHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1090 | * : USB_HOST_READING ; Continue of data read |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1091 | * : USB_HOST_READOVER ; buffer over |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1092 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1093 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1094 | uint16_t usb1_host_read_buffer_d0 (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1095 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1096 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1097 | uint32_t dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1098 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1099 | uint16_t mxps; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1100 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1101 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1102 | uint16_t pipebuf_size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1103 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1104 | mbw = usb1_host_get_mbw(g_usb1_host_data_count[pipe], (uint32_t)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1105 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_D0USE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1106 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1107 | if (buffer == USB_HOST_FIFOERROR) /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1108 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1109 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1110 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1111 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1112 | dtln = (uint32_t)(buffer & USB_HOST_BITDTLN); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1113 | mxps = usb1_host_get_mxps(pipe); /* Max Packet Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1114 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1115 | if (g_usb1_host_data_count[pipe] < dtln) /* Buffer Over ? */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1116 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1117 | status = USB_HOST_READOVER; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1118 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1119 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1120 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1121 | else if (g_usb1_host_data_count[pipe] == dtln) /* just Receive Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1122 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1123 | status = USB_HOST_READEND; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1124 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1125 | count = dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1126 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1127 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1128 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1129 | status = USB_HOST_READSHRT; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1130 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1131 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1132 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1133 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1134 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1135 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1136 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1137 | else /* continue Receive data */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1138 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1139 | status = USB_HOST_READING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1140 | count = dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1141 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1142 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1143 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1144 | status = USB_HOST_READSHRT; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1145 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1146 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1147 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1148 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1149 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1150 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1151 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1152 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1153 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1154 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1155 | pipebuf_size = usb1_host_get_buf_size(pipe); /* Data buffer size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1156 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1157 | if (count != pipebuf_size) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1158 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1159 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1160 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1161 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1162 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1163 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1164 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1165 | if (count == 0) /* 0 length packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1166 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1167 | USB201.D0FIFOCTR = USB_HOST_BITBCLR; /* Clear BCLR */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1168 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1169 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1170 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1171 | usb1_host_read_d0_fifo(pipe, (uint16_t)count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1172 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1173 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1174 | g_usb1_host_data_count[pipe] -= count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1175 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1176 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1177 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1178 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1179 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1180 | * Function Name: usb1_host_read_buffer_d1 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1181 | * Description : Reads data from the buffer allocated in the pipe specified |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1182 | * : in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1183 | * : Reads data by CPU transfer using D1FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1184 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1185 | * Return Value : USB_HOST_READEND ; Read end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1186 | * : USB_HOST_READSHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1187 | * : USB_HOST_READING ; Continue of data read |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1188 | * : USB_HOST_READOVER ; buffer over |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1189 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1190 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1191 | uint16_t usb1_host_read_buffer_d1 (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1192 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1193 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1194 | uint32_t dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1195 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1196 | uint16_t mxps; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1197 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1198 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1199 | uint16_t pipebuf_size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1200 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1201 | mbw = usb1_host_get_mbw(g_usb1_host_data_count[pipe], (uint32_t)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1202 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_D1USE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1203 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1204 | if (buffer == USB_HOST_FIFOERROR) /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1205 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1206 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1207 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1208 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1209 | dtln = (uint32_t)(buffer & USB_HOST_BITDTLN); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1210 | mxps = usb1_host_get_mxps(pipe); /* Max Packet Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1211 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1212 | if (g_usb1_host_data_count[pipe] < dtln) /* Buffer Over ? */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1213 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1214 | status = USB_HOST_READOVER; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1215 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1216 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1217 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1218 | else if (g_usb1_host_data_count[pipe] == dtln) /* just Receive Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1219 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1220 | status = USB_HOST_READEND; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1221 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1222 | count = dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1223 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1224 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1225 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1226 | status = USB_HOST_READSHRT; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1227 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1228 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1229 | if ((count % mxps) !=0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1230 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1231 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1232 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1233 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1234 | else /* continue Receive data */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1235 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1236 | status = USB_HOST_READING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1237 | count = dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1238 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1239 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1240 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1241 | status = USB_HOST_READSHRT; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1242 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1243 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1244 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1245 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1246 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1247 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1248 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1249 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1250 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1251 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1252 | pipebuf_size = usb1_host_get_buf_size(pipe); /* Data buffer size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1253 | if (count != pipebuf_size) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1254 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1255 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1256 | usb1_host_set_pid_nak(pipe); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1257 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1258 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1259 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1260 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1261 | if (count == 0) /* 0 length packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1262 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1263 | USB201.D1FIFOCTR = USB_HOST_BITBCLR; /* Clear BCLR */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1264 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1265 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1266 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1267 | usb1_host_read_d1_fifo(pipe, (uint16_t)count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1268 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1269 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1270 | g_usb1_host_data_count[pipe] -= count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1271 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1272 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1273 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1274 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1275 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1276 | * Function Name: usb1_host_read_dma |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1277 | * Description : Reads data from the buffer allocated in the pipe specified |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1278 | * : in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1279 | * : Reads data by DMA transfer using D0FIFO or D1FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1280 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1281 | * Return Value : USB_HOST_READEND ; Read end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1282 | * : USB_HOST_READSHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1283 | * : USB_HOST_READZERO ; zero data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1284 | * : USB_HOST_READING ; Continue of data read |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1285 | * : USB_HOST_READOVER ; buffer over |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1286 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1287 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1288 | uint16_t usb1_host_read_dma (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1289 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1290 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1291 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1292 | g_usb1_host_PipeIgnore[pipe] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1293 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1294 | if ((g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE) == USB_HOST_D0FIFO_DMA) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1295 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1296 | status = usb1_host_read_dma_d0(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1297 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1298 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1299 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1300 | status = usb1_host_read_dma_d1(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1301 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1302 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1303 | switch (status) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1304 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1305 | case USB_HOST_READING: /* Continue of data read */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1306 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1307 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1308 | case USB_HOST_READZERO: /* End of data read */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1309 | usb1_host_disable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1310 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_DONE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1311 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1312 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1313 | case USB_HOST_READEND: /* End of data read */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1314 | case USB_HOST_READSHRT: /* End of data read */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1315 | usb1_host_disable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1316 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1317 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1318 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1319 | g_usb1_host_PipeDataSize[pipe] -= g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1320 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1321 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1322 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1323 | case USB_HOST_READOVER: /* buffer over */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1324 | usb1_host_disable_brdy_int(pipe); /* Disable Ready Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1325 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1326 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1327 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1328 | g_usb1_host_PipeDataSize[pipe] -= g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1329 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1330 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1331 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_DONE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1332 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1333 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1334 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1335 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1336 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1337 | case USB_HOST_FIFOERROR: /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1338 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1339 | usb1_host_disable_brdy_int(pipe); /* Disable Ready Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1340 | g_usb1_host_pipe_status[pipe] = USB_HOST_PIPE_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1341 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1342 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1343 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1344 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1345 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1346 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1347 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1348 | * Function Name: usb1_host_read_dma_d0 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1349 | * Description : Writes data in the buffer allocated in the pipe specified |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1350 | * : in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1351 | * : Reads data by DMA transfer using D0FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1352 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1353 | * Return Value : USB_HOST_READEND ; Read end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1354 | * : USB_HOST_READSHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1355 | * : USB_HOST_READZERO ; zero data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1356 | * : USB_HOST_READING ; Continue of data read |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1357 | * : USB_HOST_READOVER ; buffer over |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1358 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1359 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1360 | static uint16_t usb1_host_read_dma_d0 (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1361 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1362 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1363 | uint32_t dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1364 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1365 | uint16_t mxps; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1366 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1367 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1368 | uint16_t dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1369 | uint16_t pipebuf_size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1370 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1371 | g_usb1_host_DmaStatus[USB_HOST_D0FIFO] = USB_HOST_DMA_READY; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1372 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1373 | mbw = usb1_host_get_mbw(g_usb1_host_data_count[pipe], (uint32_t)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1374 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1375 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1376 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1377 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1378 | status = USB_HOST_READING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1379 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1380 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1381 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1382 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_D0DMA, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1383 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1384 | if (buffer == USB_HOST_FIFOERROR) /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1385 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1386 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1387 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1388 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1389 | dtln = (uint32_t)(buffer & USB_HOST_BITDTLN); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1390 | mxps = usb1_host_get_mxps(pipe); /* Max Packet Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1391 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1392 | if (g_usb1_host_data_count[pipe] < dtln) /* Buffer Over ? */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1393 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1394 | status = USB_HOST_READOVER; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1395 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1396 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1397 | else if (g_usb1_host_data_count[pipe] == dtln) /* just Receive Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1398 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1399 | status = USB_HOST_READEND; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1400 | count = dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1401 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1402 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1403 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1404 | status = USB_HOST_READSHRT; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1405 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1406 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1407 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1408 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1409 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1410 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1411 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1412 | else /* continue Receive data */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1413 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1414 | status = USB_HOST_READING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1415 | count = dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1416 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1417 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1418 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1419 | status = USB_HOST_READSHRT; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1420 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1421 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1422 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1423 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1424 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1425 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1426 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1427 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1428 | pipebuf_size = usb1_host_get_buf_size(pipe); /* Data buffer size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1429 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1430 | if (count != pipebuf_size) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1431 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1432 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1433 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1434 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1435 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1436 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1437 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1438 | if (count == 0) /* 0 length packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1439 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1440 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1441 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1442 | USB201.D0FIFOCTR = USB_HOST_BITBCLR; /* Clear BCLR */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1443 | status = USB_HOST_READZERO; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1444 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1445 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1446 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1447 | usb1_host_set_curpipe(pipe, USB_HOST_D0DMA, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1448 | /* transaction counter No set */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1449 | /* FRDY = 1, DTLN = 0 -> BRDY */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1450 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1451 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1452 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1453 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1454 | dfacc = usb1_host_set_dfacc_d0(mbw, count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1455 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1456 | if (mbw == USB_HOST_BITMBW_32) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1457 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1458 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].size = 2; /* 32bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1459 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1460 | else if (mbw == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1461 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1462 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].size = 1; /* 16bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1463 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1464 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1465 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1466 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].size = 0; /* 8bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1467 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1468 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1469 | g_usb1_host_DmaPipe[USB_HOST_D0FIFO] = pipe; /* not use in read operation */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1470 | g_usb1_host_DmaBval[USB_HOST_D0FIFO] = 0; /* not use in read operation */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1471 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1472 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].fifo = USB_HOST_D0FIFO_DMA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1473 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].dir = USB_HOST_FIFO2BUF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1474 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].buffer = (uint32_t)g_usb1_host_data_pointer[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1475 | g_usb1_host_DmaInfo[USB_HOST_D0FIFO].bytes = count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1476 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1477 | if (status == USB_HOST_READING) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1478 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1479 | g_usb1_host_DmaStatus[USB_HOST_D0FIFO] = USB_HOST_DMA_BUSY; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1480 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1481 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1482 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1483 | g_usb1_host_DmaStatus[USB_HOST_D0FIFO] = USB_HOST_DMA_BUSYEND; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1484 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1485 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1486 | Userdef_USB_usb1_host_start_dma(&g_usb1_host_DmaInfo[USB_HOST_D0FIFO], dfacc); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1487 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1488 | usb1_host_set_curpipe2(pipe, USB_HOST_D0DMA, USB_HOST_NO, mbw , dfacc); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1489 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1490 | RZA_IO_RegWrite_16(&USB201.D0FIFOSEL, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1491 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1492 | USB_DnFIFOSEL_DREQE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1493 | USB_DnFIFOSEL_DREQE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1494 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1495 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1496 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1497 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1498 | g_usb1_host_data_count[pipe] -= count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1499 | g_usb1_host_data_pointer[pipe] += count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1500 | g_usb1_host_PipeDataSize[pipe] += count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1501 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1502 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1503 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1504 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1505 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1506 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1507 | * Function Name: usb1_host_read_dma_d1 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1508 | * Description : Reads data from the buffer allocated in the pipe specified in |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1509 | * : the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1510 | * : Reads data by DMA transfer using D1FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1511 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1512 | * Return Value : USB_HOST_READEND ; Read end |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1513 | * : USB_HOST_READSHRT ; short data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1514 | * : USB_HOST_READZERO ; zero data |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1515 | * : USB_HOST_READING ; Continue of data read |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1516 | * : USB_HOST_READOVER ; buffer over |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1517 | * : USB_HOST_FIFOERROR ; FIFO status |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1518 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1519 | static uint16_t usb1_host_read_dma_d1 (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1520 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1521 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1522 | uint32_t dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1523 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1524 | uint16_t mxps; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1525 | uint16_t status; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1526 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1527 | uint16_t dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1528 | uint16_t pipebuf_size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1529 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1530 | g_usb1_host_DmaStatus[USB_HOST_D1FIFO] = USB_HOST_DMA_READY; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1531 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1532 | mbw = usb1_host_get_mbw(g_usb1_host_data_count[pipe], (uint32_t)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1533 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1534 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1535 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1536 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1537 | status = USB_HOST_READING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1538 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1539 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1540 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1541 | buffer = usb1_host_change_fifo_port(pipe, USB_HOST_D1DMA, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1542 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1543 | if (buffer == USB_HOST_FIFOERROR) /* FIFO access status */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1544 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1545 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1546 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1547 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1548 | dtln = (uint32_t)(buffer & USB_HOST_BITDTLN); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1549 | mxps = usb1_host_get_mxps(pipe); /* Max Packet Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1550 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1551 | if (g_usb1_host_data_count[pipe] < dtln) /* Buffer Over ? */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1552 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1553 | status = USB_HOST_READOVER; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1554 | count = g_usb1_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1555 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1556 | else if (g_usb1_host_data_count[pipe] == dtln) /* just Receive Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1557 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1558 | status = USB_HOST_READEND; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1559 | count = dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1560 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1561 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1562 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1563 | status = USB_HOST_READSHRT; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1564 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1565 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1566 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1567 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1568 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1569 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1570 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1571 | else /* continue Receive data */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1572 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1573 | status = USB_HOST_READING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1574 | count = dtln; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1575 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1576 | if (count == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1577 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1578 | status = USB_HOST_READSHRT; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1579 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1580 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1581 | if ((count % mxps) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1582 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1583 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1584 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1585 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1586 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1587 | pipebuf_size = usb1_host_get_buf_size(pipe); /* Data buffer size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1588 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1589 | if (count != pipebuf_size) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1590 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1591 | status = USB_HOST_READSHRT; /* Short Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1592 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1593 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1594 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1595 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1596 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1597 | if (count == 0) /* 0 length packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1598 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1599 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1600 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1601 | USB201.D1FIFOCTR = USB_HOST_BITBCLR; /* Clear BCLR */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1602 | status = USB_HOST_READZERO; /* Null Packet receive */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1603 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1604 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1605 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1606 | usb1_host_set_curpipe(pipe, USB_HOST_D1DMA, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1607 | /* transaction counter No set */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1608 | /* FRDY = 1, DTLN = 0 -> BRDY */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1609 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1610 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1611 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1612 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1613 | dfacc = usb1_host_set_dfacc_d1(mbw, count); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1614 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1615 | if (mbw == USB_HOST_BITMBW_32) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1616 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1617 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].size = 2; /* 32bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1618 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1619 | else if (mbw == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1620 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1621 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].size = 1; /* 16bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1622 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1623 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1624 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1625 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].size = 0; /* 8bit transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1626 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1627 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1628 | g_usb1_host_DmaPipe[USB_HOST_D1FIFO] = pipe; /* not use in read operation */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1629 | g_usb1_host_DmaBval[USB_HOST_D1FIFO] = 0; /* not use in read operation */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1630 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1631 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].fifo = USB_HOST_D1FIFO_DMA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1632 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].dir = USB_HOST_FIFO2BUF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1633 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].buffer = (uint32_t)g_usb1_host_data_pointer[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1634 | g_usb1_host_DmaInfo[USB_HOST_D1FIFO].bytes = count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1635 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1636 | if (status == USB_HOST_READING) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1637 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1638 | g_usb1_host_DmaStatus[USB_HOST_D1FIFO] = USB_HOST_DMA_BUSY; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1639 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1640 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1641 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1642 | g_usb1_host_DmaStatus[USB_HOST_D1FIFO] = USB_HOST_DMA_BUSYEND; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1643 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1644 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1645 | Userdef_USB_usb1_host_start_dma(&g_usb1_host_DmaInfo[USB_HOST_D1FIFO], dfacc); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1646 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1647 | usb1_host_set_curpipe2(pipe, USB_HOST_D1DMA, USB_HOST_NO, mbw , dfacc); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1648 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1649 | RZA_IO_RegWrite_16(&USB201.D1FIFOSEL, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1650 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1651 | USB_DnFIFOSEL_DREQE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1652 | USB_DnFIFOSEL_DREQE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1653 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1654 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1655 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1656 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1657 | g_usb1_host_data_count[pipe] -= count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1658 | g_usb1_host_data_pointer[pipe] += count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1659 | g_usb1_host_PipeDataSize[pipe] += count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1660 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1661 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1662 | return status; /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1663 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1664 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1665 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1666 | * Function Name: usb1_host_change_fifo_port |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1667 | * Description : Allocates FIF0 specified by the argument in the pipe assigned |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1668 | * : by the argument. After allocating FIF0, waits in the software |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1669 | * : till the corresponding pipe becomes ready. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1670 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1671 | * : uint16_t fifosel ; Select FIFO |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1672 | * : uint16_t isel ; FIFO Access Direction |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1673 | * : uint16_t mbw ; FIFO Port Access Bit Width |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1674 | * Return Value : USB_HOST_FIFOERROR ; Error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1675 | * : Others ; CFIFOCTR/D0FIFOCTR/D1FIFOCTR Register Value |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1676 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1677 | uint16_t usb1_host_change_fifo_port (uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1678 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1679 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1680 | uint32_t loop; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1681 | volatile uint32_t loop2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1682 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1683 | usb1_host_set_curpipe(pipe, fifosel, isel, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1684 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1685 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1686 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1687 | switch (fifosel) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1688 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1689 | case USB_HOST_CUSE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1690 | buffer = USB201.CFIFOCTR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1691 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1692 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1693 | case USB_HOST_D0USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1694 | case USB_HOST_D0DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1695 | buffer = USB201.D0FIFOCTR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1696 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1697 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1698 | case USB_HOST_D1USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1699 | case USB_HOST_D1DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1700 | buffer = USB201.D1FIFOCTR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1701 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1702 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1703 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1704 | buffer = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1705 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1706 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1707 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1708 | if ((buffer & USB_HOST_BITFRDY) == USB_HOST_BITFRDY) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1709 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1710 | return buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1711 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1712 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1713 | loop2 = 25; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1714 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1715 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1716 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1717 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1718 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1719 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1720 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1721 | return USB_HOST_FIFOERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1722 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1723 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1724 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1725 | * Function Name: usb1_host_set_curpipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1726 | * Description : Allocates FIF0 specified by the argument in the pipe assigned |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1727 | * : by the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1728 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1729 | * : uint16_t fifosel ; Select FIFO |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1730 | * : uint16_t isel ; FIFO Access Direction |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1731 | * : uint16_t mbw ; FIFO Port Access Bit Width |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1732 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1733 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1734 | void usb1_host_set_curpipe (uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1735 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1736 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1737 | uint32_t loop; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1738 | volatile uint32_t loop2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1739 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1740 | g_usb1_host_mbw[pipe] = mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1741 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1742 | switch (fifosel) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1743 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1744 | case USB_HOST_CUSE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1745 | buffer = USB201.CFIFOSEL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1746 | buffer &= (uint16_t)~(USB_HOST_BITISEL | USB_HOST_BITCURPIPE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1747 | buffer |= (uint16_t)(~isel & USB_HOST_BITISEL); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1748 | USB201.CFIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1749 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1750 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1751 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1752 | if ((USB201.CFIFOSEL & (USB_HOST_BITISEL | USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1753 | == (buffer & (USB_HOST_BITISEL | USB_HOST_BITCURPIPE))) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1754 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1755 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1756 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1757 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1758 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1759 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1760 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1761 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1762 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1763 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1764 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1765 | buffer &= (uint16_t)~(USB_HOST_BITISEL | USB_HOST_BITCURPIPE | USB_HOST_BITMBW); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1766 | buffer |= (uint16_t)(isel | pipe | mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1767 | USB201.CFIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1768 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1769 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1770 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1771 | if ((USB201.CFIFOSEL & (USB_HOST_BITISEL | USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1772 | == (buffer & (USB_HOST_BITISEL | USB_HOST_BITCURPIPE))) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1773 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1774 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1775 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1776 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1777 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1778 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1779 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1780 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1781 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1782 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1783 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1784 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1785 | case USB_HOST_D0DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1786 | case USB_HOST_D0USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1787 | buffer = USB201.D0FIFOSEL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1788 | buffer &= (uint16_t)~(USB_HOST_BITCURPIPE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1789 | USB201.D0FIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1790 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1791 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1792 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1793 | if ((USB201.D0FIFOSEL & USB_HOST_BITCURPIPE) == (buffer & USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1794 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1795 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1796 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1797 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1798 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1799 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1800 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1801 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1802 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1803 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1804 | buffer &= (uint16_t)~(USB_HOST_BITCURPIPE | USB_HOST_BITMBW); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1805 | buffer |= (uint16_t)(pipe | mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1806 | USB201.D0FIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1807 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1808 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1809 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1810 | if ((USB201.D0FIFOSEL & USB_HOST_BITCURPIPE) == (buffer & USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1811 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1812 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1813 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1814 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1815 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1816 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1817 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1818 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1819 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1820 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1821 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1822 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1823 | case USB_HOST_D1DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1824 | case USB_HOST_D1USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1825 | buffer = USB201.D1FIFOSEL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1826 | buffer &= (uint16_t)~(USB_HOST_BITCURPIPE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1827 | USB201.D1FIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1828 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1829 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1830 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1831 | if ((USB201.D1FIFOSEL & USB_HOST_BITCURPIPE) == (buffer & USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1832 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1833 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1834 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1835 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1836 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1837 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1838 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1839 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1840 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1841 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1842 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1843 | buffer &= (uint16_t)~(USB_HOST_BITCURPIPE | USB_HOST_BITMBW); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1844 | buffer |= (uint16_t)(pipe | mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1845 | USB201.D1FIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1846 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1847 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1848 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1849 | if ((USB201.D1FIFOSEL & USB_HOST_BITCURPIPE) == (buffer & USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1850 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1851 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1852 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1853 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1854 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1855 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1856 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1857 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1858 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1859 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1860 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1861 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1862 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1863 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1864 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1865 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1866 | /* Cautions !!! |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1867 | * Depending on the external bus speed of CPU, you may need to wait for 450ns here. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1868 | * For details, please look at the data sheet. */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1869 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1870 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1871 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1872 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1873 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1874 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1875 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1876 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1877 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1878 | * Function Name: usb1_host_set_curpipe2 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1879 | * Description : Allocates FIF0 specified by the argument in the pipe assigned |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1880 | * : by the argument.(DFACC) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1881 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1882 | * : uint16_t fifosel ; Select FIFO |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1883 | * : uint16_t isel ; FIFO Access Direction |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1884 | * : uint16_t mbw ; FIFO Port Access Bit Width |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1885 | * : uint16_t dfacc ; DFACC Access mode |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1886 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1887 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1888 | void usb1_host_set_curpipe2 (uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw, uint16_t dfacc) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1889 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1890 | uint16_t buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1891 | uint32_t loop; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1892 | #ifdef __USB_HOST_DF_ACC_ENABLE__ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1893 | uint32_t dummy; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1894 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1895 | volatile uint32_t loop2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1896 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1897 | g_usb1_host_mbw[pipe] = mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1898 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1899 | switch (fifosel) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1900 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1901 | case USB_HOST_CUSE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1902 | buffer = USB201.CFIFOSEL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1903 | buffer &= (uint16_t)~(USB_HOST_BITISEL | USB_HOST_BITCURPIPE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1904 | buffer |= (uint16_t)(~isel & USB_HOST_BITISEL); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1905 | USB201.CFIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1906 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1907 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1908 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1909 | if ((USB201.CFIFOSEL & (USB_HOST_BITISEL | USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1910 | == (buffer & (USB_HOST_BITISEL | USB_HOST_BITCURPIPE))) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1911 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1912 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1913 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1914 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1915 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1916 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1917 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1918 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1919 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1920 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1921 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1922 | buffer &= (uint16_t)~(USB_HOST_BITISEL | USB_HOST_BITCURPIPE | USB_HOST_BITMBW); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1923 | buffer |= (uint16_t)(isel | pipe | mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1924 | USB201.CFIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1925 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1926 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1927 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1928 | if ((USB201.CFIFOSEL & (USB_HOST_BITISEL | USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1929 | == (buffer & (USB_HOST_BITISEL | USB_HOST_BITCURPIPE))) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1930 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1931 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1932 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1933 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1934 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1935 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1936 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1937 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1938 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1939 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1940 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1941 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1942 | case USB_HOST_D0DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1943 | case USB_HOST_D0USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1944 | buffer = USB201.D0FIFOSEL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1945 | #ifdef __USB_HOST_DF_ACC_ENABLE__ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1946 | buffer &= (uint16_t)~(USB_HOST_BITCURPIPE | USB_HOST_BITMBW); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1947 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1948 | if (dfacc != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1949 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1950 | buffer |= (uint16_t)(USB_HOST_BITMBW_32); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1951 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1952 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1953 | buffer &= (uint16_t)~(USB_HOST_BITCURPIPE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1954 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1955 | USB201.D0FIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1956 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1957 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1958 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1959 | if ((USB201.D0FIFOSEL & USB_HOST_BITCURPIPE) == (buffer & USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1960 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1961 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1962 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1963 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1964 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1965 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1966 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1967 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1968 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1969 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1970 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1971 | #ifdef __USB_HOST_DF_ACC_ENABLE__ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1972 | if (dfacc != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1973 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1974 | dummy = USB201.D0FIFO.UINT32; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1975 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1976 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1977 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1978 | buffer &= (uint16_t)~(USB_HOST_BITCURPIPE | USB_HOST_BITMBW); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1979 | buffer |= (uint16_t)(pipe | mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1980 | USB201.D0FIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1981 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1982 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1983 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1984 | if ((USB201.D0FIFOSEL & USB_HOST_BITCURPIPE) == (buffer & USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1985 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1986 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1987 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1988 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1989 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1990 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1991 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1992 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1993 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1994 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1995 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1996 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1997 | case USB_HOST_D1DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1998 | case USB_HOST_D1USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1999 | buffer = USB201.D1FIFOSEL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2000 | #ifdef __USB_HOST_DF_ACC_ENABLE__ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2001 | buffer &= (uint16_t)~(USB_HOST_BITCURPIPE | USB_HOST_BITMBW); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2002 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2003 | if (dfacc != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2004 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2005 | buffer |= (uint16_t)(USB_HOST_BITMBW_32); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2006 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2007 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2008 | buffer &= (uint16_t)~(USB_HOST_BITCURPIPE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2009 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2010 | USB201.D1FIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2011 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2012 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2013 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2014 | if ((USB201.D1FIFOSEL & USB_HOST_BITCURPIPE) == (buffer & USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2015 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2016 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2017 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2018 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2019 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2020 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2021 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2022 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2023 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2024 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2025 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2026 | #ifdef __USB_HOST_DF_ACC_ENABLE__ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2027 | if (dfacc != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2028 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2029 | dummy = USB201.D1FIFO.UINT32; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2030 | loop = dummy; // avoid warning. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2031 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2032 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2033 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2034 | buffer &= (uint16_t)~(USB_HOST_BITCURPIPE | USB_HOST_BITMBW); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2035 | buffer |= (uint16_t)(pipe | mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2036 | USB201.D1FIFOSEL = buffer; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2037 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2038 | for (loop = 0; loop < 4; loop++) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2039 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2040 | if ((USB201.D1FIFOSEL & USB_HOST_BITCURPIPE) == (buffer & USB_HOST_BITCURPIPE)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2041 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2042 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2043 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2044 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2045 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2046 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2047 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2048 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2049 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2050 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2051 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2052 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2053 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2054 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2055 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2056 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2057 | /* Cautions !!! |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2058 | * Depending on the external bus speed of CPU, you may need to wait for 450ns here. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2059 | * For details, please look at the data sheet. */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2060 | loop2 = 100; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2061 | while (loop2-- > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2062 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2063 | /* wait */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2064 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2065 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2066 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2067 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2068 | * Function Name: usb1_host_write_c_fifo |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2069 | * Description : Writes data in CFIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2070 | * : Writes data by BYTE/WORD/LONG according to access size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2071 | * : to the pipe specified by the arguments. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2072 | * : Before executing this function, allocating CFIF0 in the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2073 | * : should be completed. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2074 | * : Before executing this function, access size to the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2075 | * : should be fixed and set in g_usb1_host_mbw[]. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2076 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2077 | * : uint16_t count ; Data Size(Byte) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2078 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2079 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2080 | static void usb1_host_write_c_fifo (uint16_t pipe, uint16_t count) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2081 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2082 | uint16_t even; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2083 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2084 | if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_8) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2085 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2086 | for (even = count; even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2087 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2088 | USB201.CFIFO.UINT8[HH] = *g_usb1_host_data_pointer[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2089 | g_usb1_host_data_pointer[pipe] += 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2090 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2091 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2092 | else if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2093 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2094 | for (even = (uint16_t)(count / 2); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2095 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2096 | USB201.CFIFO.UINT16[H] = *((uint16_t *)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2097 | g_usb1_host_data_pointer[pipe] += 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2098 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2099 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2100 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2101 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2102 | for (even = (uint16_t)(count / 4); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2103 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2104 | USB201.CFIFO.UINT32 = *((uint32_t *)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2105 | g_usb1_host_data_pointer[pipe] += 4; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2106 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2107 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2108 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2109 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2110 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2111 | * Function Name: usb1_host_read_c_fifo |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2112 | * Description : Reads data from CFIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2113 | * : Reads data by BYTE/WORD/LONG according to access size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2114 | * : to the pipe specified by the arguments. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2115 | * : Before executing this function, allocating CFIF0 in the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2116 | * : should be completed. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2117 | * : Before executing this function, access size to the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2118 | * : should be fixed and set in g_usb0_host_mbw[]. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2119 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2120 | * : uint16_t count ; Data Size(Byte) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2121 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2122 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2123 | static void usb1_host_read_c_fifo (uint16_t pipe, uint16_t count) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2124 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2125 | uint16_t even; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2126 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2127 | if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_8) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2128 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2129 | for (even = count; even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2130 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2131 | *g_usb1_host_data_pointer[pipe] = USB201.CFIFO.UINT8[HH]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2132 | g_usb1_host_data_pointer[pipe] += 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2133 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2134 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2135 | else if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2136 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2137 | for (even = (uint16_t)((count + 1) / 2); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2138 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2139 | *((uint16_t *)g_usb1_host_data_pointer[pipe]) = USB201.CFIFO.UINT16[H]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2140 | g_usb1_host_data_pointer[pipe] += 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2141 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2142 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2143 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2144 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2145 | for (even = (uint16_t)((count + 3) / 4); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2146 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2147 | *((uint32_t *)g_usb1_host_data_pointer[pipe]) = USB201.CFIFO.UINT32; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2148 | g_usb1_host_data_pointer[pipe] += 4; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2149 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2150 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2151 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2152 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2153 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2154 | * Function Name: usb1_host_write_d0_fifo |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2155 | * Description : Writes data in D0FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2156 | * : Writes data by BYTE/WORD/LONG according to access size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2157 | * : to the pipe specified by the arguments. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2158 | * : Before executing this function, allocating CFIF0 in the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2159 | * : should be completed. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2160 | * : Before executing this function, access size to the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2161 | * : should be fixed and set in g_usb0_host_mbw[]. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2162 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2163 | * : uint16_t count ; Data Size(Byte) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2164 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2165 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2166 | static void usb1_host_write_d0_fifo (uint16_t pipe, uint16_t count) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2167 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2168 | uint16_t even; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2169 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2170 | if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_8) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2171 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2172 | for (even = count; even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2173 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2174 | USB201.D0FIFO.UINT8[HH] = *g_usb1_host_data_pointer[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2175 | g_usb1_host_data_pointer[pipe] += 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2176 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2177 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2178 | else if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2179 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2180 | for (even = (uint16_t)(count / 2); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2181 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2182 | USB201.D0FIFO.UINT16[H] = *((uint16_t *)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2183 | g_usb1_host_data_pointer[pipe] += 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2184 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2185 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2186 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2187 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2188 | for (even = (uint16_t)(count / 4); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2189 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2190 | USB201.D0FIFO.UINT32 = *((uint32_t *)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2191 | g_usb1_host_data_pointer[pipe] += 4; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2192 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2193 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2194 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2195 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2196 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2197 | * Function Name: usb1_host_read_d0_fifo |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2198 | * Description : Reads data from D0FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2199 | * : Reads data by BYTE/WORD/LONG according to access size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2200 | * : to the pipe specified by the arguments. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2201 | * : Before executing this function, allocating DOFIF0 in the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2202 | * : should be completed. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2203 | * : Before executing this function, access size to the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2204 | * : should be fixed and set in g_usb0_host_mbw[]. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2205 | * Arguments : uint16_t Pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2206 | * : uint16_t count ; Data Size(Byte) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2207 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2208 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2209 | static void usb1_host_read_d0_fifo (uint16_t pipe, uint16_t count) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2210 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2211 | uint16_t even; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2212 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2213 | if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_8) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2214 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2215 | for (even = count; even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2216 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2217 | *g_usb1_host_data_pointer[pipe] = USB201.D0FIFO.UINT8[HH]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2218 | g_usb1_host_data_pointer[pipe] += 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2219 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2220 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2221 | else if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2222 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2223 | for (even = (uint16_t)((count + 1) / 2); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2224 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2225 | *((uint16_t *)g_usb1_host_data_pointer[pipe]) = USB201.D0FIFO.UINT16[H]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2226 | g_usb1_host_data_pointer[pipe] += 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2227 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2228 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2229 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2230 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2231 | for (even = (uint16_t)((count + 3) / 4); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2232 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2233 | *((uint32_t *)g_usb1_host_data_pointer[pipe]) = USB201.D0FIFO.UINT32; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2234 | g_usb1_host_data_pointer[pipe] += 4; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2235 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2236 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2237 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2238 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2239 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2240 | * Function Name: usb1_host_write_d1_fifo |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2241 | * Description : Writes data in D1FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2242 | * : Writes data by BYTE/WORD/LONG according to access size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2243 | * : to the pipe specified by the arguments. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2244 | * : Before executing this function, allocating D1FIF0 in the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2245 | * : should be completed. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2246 | * : Before executing this function, access size to the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2247 | * : should be fixed and set in g_usb1_host_mbw[]. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2248 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2249 | * : uint16_t count ; Data Size(Byte) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2250 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2251 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2252 | static void usb1_host_write_d1_fifo (uint16_t pipe, uint16_t count) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2253 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2254 | uint16_t even; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2255 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2256 | if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_8) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2257 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2258 | for (even = count; even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2259 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2260 | USB201.D1FIFO.UINT8[HH] = *g_usb1_host_data_pointer[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2261 | g_usb1_host_data_pointer[pipe] += 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2262 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2263 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2264 | else if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2265 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2266 | for (even = (uint16_t)(count / 2); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2267 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2268 | USB201.D1FIFO.UINT16[H] = *((uint16_t *)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2269 | g_usb1_host_data_pointer[pipe] += 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2270 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2271 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2272 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2273 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2274 | for (even = (uint16_t)(count / 4); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2275 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2276 | USB201.D1FIFO.UINT32 = *((uint32_t *)g_usb1_host_data_pointer[pipe]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2277 | g_usb1_host_data_pointer[pipe] += 4; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2278 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2279 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2280 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2281 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2282 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2283 | * Function Name: usb1_host_read_d1_fifo |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2284 | * Description : Reads data from D1FIFO. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2285 | * : Reads data by BYTE/WORD/LONG according to access size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2286 | * : to the pipe specified by the arguments. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2287 | * : Before executing this function, allocating D1FIF0 in the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2288 | * : should be completed. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2289 | * : Before executing this function, access size to the specified pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2290 | * : should be fixed and set in g_usb1_host_mbw[]. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2291 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2292 | * : uint16_t count ; Data Size(Byte) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2293 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2294 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2295 | static void usb1_host_read_d1_fifo (uint16_t pipe, uint16_t count) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2296 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2297 | uint16_t even; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2298 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2299 | if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_8) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2300 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2301 | for (even = count; even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2302 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2303 | *g_usb1_host_data_pointer[pipe] = USB201.D1FIFO.UINT8[HH]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2304 | g_usb1_host_data_pointer[pipe] += 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2305 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2306 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2307 | else if (g_usb1_host_mbw[pipe] == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2308 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2309 | for (even = (uint16_t)((count + 1) / 2); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2310 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2311 | *((uint16_t *)g_usb1_host_data_pointer[pipe]) = USB201.D1FIFO.UINT16[H]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2312 | g_usb1_host_data_pointer[pipe] += 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2313 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2314 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2315 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2316 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2317 | for (even = (uint16_t)((count + 3) / 4); even; --even) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2318 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2319 | *((uint32_t *)g_usb1_host_data_pointer[pipe]) = USB201.D1FIFO.UINT32; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2320 | g_usb1_host_data_pointer[pipe] += 4; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2321 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2322 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2323 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2324 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2325 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2326 | * Function Name: usb1_host_com_get_dmasize |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2327 | * Description : Calculates access width of DMA transfer by the argument to |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2328 | return as the Return Value. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2329 | * Arguments : uint32_t trncount : transfer byte |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2330 | * : uint32_t dtptr : transfer data pointer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2331 | * Return Value : DMA transfer size : 0 8bit |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2332 | * : : 1 16bit |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2333 | * : : 2 32bit |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2334 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2335 | static uint32_t usb1_host_com_get_dmasize (uint32_t trncount, uint32_t dtptr) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2336 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2337 | uint32_t size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2338 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2339 | if (((trncount & 0x0001) != 0) || ((dtptr & 0x00000001) != 0)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2340 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2341 | /* When transfer byte count is odd */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2342 | /* or transfer data area is 8-bit alignment */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2343 | size = 0; /* 8bit */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2344 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2345 | else if (((trncount & 0x0003) != 0) || ((dtptr & 0x00000003) != 0)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2346 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2347 | /* When the transfer byte count is multiples of 2 */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2348 | /* or the transfer data area is 16-bit alignment */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2349 | size = 1; /* 16bit */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2350 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2351 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2352 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2353 | /* When the transfer byte count is multiples of 4 */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2354 | /* or the transfer data area is 32-bit alignment */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2355 | size = 2; /* 32bit */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2356 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2357 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2358 | return size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2359 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2360 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2361 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2362 | * Function Name: usb1_host_get_mbw |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2363 | * Description : Calculates access width of DMA to return the value set in MBW. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2364 | * Arguments : uint32_t trncount : transfer byte |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2365 | * : uint32_t dtptr : transfer data pointer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2366 | * Return Value : FIFO transfer size : USB_HOST_BITMBW_8 8bit |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2367 | * : : USB_HOST_BITMBW_16 16bit |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2368 | * : : USB_HOST_BITMBW_32 32bit |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2369 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2370 | uint16_t usb1_host_get_mbw (uint32_t trncount, uint32_t dtptr) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2371 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2372 | uint32_t size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2373 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2374 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2375 | size = usb1_host_com_get_dmasize(trncount, dtptr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2376 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2377 | if (size == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2378 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2379 | /* 8bit */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2380 | mbw = USB_HOST_BITMBW_8; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2381 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2382 | else if (size == 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2383 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2384 | /* 16bit */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2385 | mbw = USB_HOST_BITMBW_16; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2386 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2387 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2388 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2389 | /* 32bit */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2390 | mbw = USB_HOST_BITMBW_32; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2391 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2392 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2393 | return mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2394 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2395 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2396 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2397 | * Function Name: usb1_host_set_transaction_counter |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2398 | * Description : Sets transaction counter by the argument(PIPEnTRN). |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2399 | * : Clears transaction before setting to enable transaction counter setting. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2400 | * Arguments : uint16_t pipe ; Pipe number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2401 | * : uint32_t bsize : Data transfer size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2402 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2403 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2404 | static void usb1_host_set_transaction_counter (uint16_t pipe, uint32_t bsize) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2405 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2406 | uint16_t mxps; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2407 | uint16_t cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2408 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2409 | if (bsize == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2410 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2411 | return; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2412 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2413 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2414 | mxps = usb1_host_get_mxps(pipe); /* Max Packet Size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2415 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2416 | if ((bsize % mxps) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2417 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2418 | cnt = (uint16_t)(bsize / mxps); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2419 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2420 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2421 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2422 | cnt = (uint16_t)((bsize / mxps) + 1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2423 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2424 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2425 | switch (pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2426 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2427 | case USB_HOST_PIPE1: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2428 | RZA_IO_RegWrite_16(&USB201.PIPE1TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2429 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2430 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2431 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2432 | USB201.PIPE1TRN = cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2433 | RZA_IO_RegWrite_16(&USB201.PIPE1TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2434 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2435 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2436 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2437 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2438 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2439 | case USB_HOST_PIPE2: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2440 | RZA_IO_RegWrite_16(&USB201.PIPE2TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2441 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2442 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2443 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2444 | USB201.PIPE2TRN = cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2445 | RZA_IO_RegWrite_16(&USB201.PIPE2TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2446 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2447 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2448 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2449 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2450 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2451 | case USB_HOST_PIPE3: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2452 | RZA_IO_RegWrite_16(&USB201.PIPE3TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2453 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2454 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2455 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2456 | USB201.PIPE3TRN = cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2457 | RZA_IO_RegWrite_16(&USB201.PIPE3TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2458 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2459 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2460 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2461 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2462 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2463 | case USB_HOST_PIPE4: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2464 | RZA_IO_RegWrite_16(&USB201.PIPE4TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2465 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2466 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2467 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2468 | USB201.PIPE4TRN = cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2469 | RZA_IO_RegWrite_16(&USB201.PIPE4TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2470 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2471 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2472 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2473 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2474 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2475 | case USB_HOST_PIPE5: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2476 | RZA_IO_RegWrite_16(&USB201.PIPE5TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2477 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2478 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2479 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2480 | USB201.PIPE5TRN = cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2481 | RZA_IO_RegWrite_16(&USB201.PIPE5TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2482 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2483 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2484 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2485 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2486 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2487 | case USB_HOST_PIPE9: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2488 | RZA_IO_RegWrite_16(&USB201.PIPE9TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2489 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2490 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2491 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2492 | USB201.PIPE9TRN = cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2493 | RZA_IO_RegWrite_16(&USB201.PIPE9TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2494 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2495 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2496 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2497 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2498 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2499 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2500 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2501 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2502 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2503 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2504 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2505 | * Function Name: usb1_host_clear_transaction_counter |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2506 | * Description : Clears the transaction counter by the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2507 | * : After executing this function, the transaction counter is invalid. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2508 | * Arguments : uint16_t pipe ; Pipe number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2509 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2510 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2511 | void usb1_host_clear_transaction_counter (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2512 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2513 | switch (pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2514 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2515 | case USB_HOST_PIPE1: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2516 | RZA_IO_RegWrite_16(&USB201.PIPE1TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2517 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2518 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2519 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2520 | RZA_IO_RegWrite_16(&USB201.PIPE1TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2521 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2522 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2523 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2524 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2525 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2526 | case USB_HOST_PIPE2: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2527 | RZA_IO_RegWrite_16(&USB201.PIPE2TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2528 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2529 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2530 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2531 | RZA_IO_RegWrite_16(&USB201.PIPE2TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2532 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2533 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2534 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2535 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2536 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2537 | case USB_HOST_PIPE3: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2538 | RZA_IO_RegWrite_16(&USB201.PIPE3TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2539 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2540 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2541 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2542 | RZA_IO_RegWrite_16(&USB201.PIPE3TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2543 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2544 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2545 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2546 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2547 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2548 | case USB_HOST_PIPE4: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2549 | RZA_IO_RegWrite_16(&USB201.PIPE4TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2550 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2551 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2552 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2553 | RZA_IO_RegWrite_16(&USB201.PIPE4TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2554 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2555 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2556 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2557 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2558 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2559 | case USB_HOST_PIPE5: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2560 | RZA_IO_RegWrite_16(&USB201.PIPE5TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2561 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2562 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2563 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2564 | RZA_IO_RegWrite_16(&USB201.PIPE5TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2565 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2566 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2567 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2568 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2569 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2570 | case USB_HOST_PIPE9: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2571 | RZA_IO_RegWrite_16(&USB201.PIPE9TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2572 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2573 | USB_PIPEnTRE_TRENB_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2574 | USB_PIPEnTRE_TRENB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2575 | RZA_IO_RegWrite_16(&USB201.PIPE9TRE, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2576 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2577 | USB_PIPEnTRE_TRCLR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2578 | USB_PIPEnTRE_TRCLR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2579 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2580 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2581 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2582 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2583 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2584 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2585 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2586 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2587 | * Function Name: usb1_host_stop_transfer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2588 | * Description : Stops the USB transfer in the pipe specified by the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2589 | * : After stopping the USB transfer, clears the buffer allocated in |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2590 | * : the pipe. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2591 | * : After executing this function, allocation in FIF0 becomes USB_HOST_PIPE0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2592 | * : invalid. After executing this function, BRDY/NRDY/BEMP interrupt |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2593 | * : in the corresponding pipe becomes invalid. Sequence bit is also |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2594 | * : cleared. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2595 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2596 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2597 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2598 | void usb1_host_stop_transfer (uint16_t pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2599 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2600 | uint16_t usefifo; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2601 | uint32_t remain; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2602 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2603 | usb1_host_set_pid_nak(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2604 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2605 | usefifo = (uint16_t)(g_usb1_host_PipeTbl[pipe] & USB_HOST_FIFO_USE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2606 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2607 | switch (usefifo) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2608 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2609 | case USB_HOST_D0FIFO_USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2610 | usb1_host_clear_transaction_counter(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2611 | USB201.D0FIFOCTR = USB_HOST_BITBCLR; /* Buffer Clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2612 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2613 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2614 | case USB_HOST_D1FIFO_USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2615 | usb1_host_clear_transaction_counter(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2616 | USB201.D1FIFOCTR = USB_HOST_BITBCLR; /* Buffer Clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2617 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2618 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2619 | case USB_HOST_D0FIFO_DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2620 | remain = Userdef_USB_usb1_host_stop_dma0(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2621 | usb1_host_dma_stop_d0(pipe, remain); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2622 | usb1_host_clear_transaction_counter(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2623 | USB201.D0FIFOCTR = USB_HOST_BITBCLR; /* Buffer Clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2624 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2625 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2626 | case USB_HOST_D1FIFO_DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2627 | remain = Userdef_USB_usb1_host_stop_dma1(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2628 | usb1_host_dma_stop_d1(pipe, remain); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2629 | usb1_host_clear_transaction_counter(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2630 | USB201.D1FIFOCTR = USB_HOST_BITBCLR; /* Buffer Clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2631 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2632 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2633 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2634 | usb1_host_clear_transaction_counter(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2635 | USB201.CFIFOCTR = USB_HOST_BITBCLR; /* Buffer Clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2636 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2637 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2638 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2639 | /* Interrupt of pipe set is disabled */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2640 | usb1_host_disable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2641 | usb1_host_disable_nrdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2642 | usb1_host_disable_bemp_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2643 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2644 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2645 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2646 | usb1_host_aclrm(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2647 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2648 | usb1_host_set_csclr(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2649 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2650 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2651 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2652 | * Function Name: usb1_host_set_dfacc_d0 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2653 | * Description : Sets the DFACC setting value in D0FIFO using the transfer size. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2654 | * Arguments : uint16_t mbw ; MBW |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2655 | * : uint16_t count ; data count |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2656 | * Return Value : DFACC Access mode |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2657 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2658 | static uint16_t usb1_host_set_dfacc_d0 (uint16_t mbw, uint32_t count) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2659 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2660 | uint16_t dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2661 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2662 | #ifndef __USB_HOST_DF_ACC_ENABLE__ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2663 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2664 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2665 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2666 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2667 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2668 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2669 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2670 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2671 | dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2672 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2673 | if (mbw == USB_HOST_BITMBW_32) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2674 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2675 | if ((count % 32) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2676 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2677 | /* 32byte transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2678 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2679 | 2, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2680 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2681 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2682 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2683 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2684 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2685 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2686 | dfacc = 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2687 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2688 | else if ((count % 16) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2689 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2690 | /* 16byte transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2691 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2692 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2693 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2694 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2695 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2696 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2697 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2698 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2699 | dfacc = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2700 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2701 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2702 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2703 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2704 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2705 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2706 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2707 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2708 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2709 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2710 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2711 | dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2712 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2713 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2714 | else if (mbw == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2715 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2716 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2717 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2718 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2719 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2720 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2721 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2722 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2723 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2724 | dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2725 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2726 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2727 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2728 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2729 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2730 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2731 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2732 | RZA_IO_RegWrite_16(&USB201.D0FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2733 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2734 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2735 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2736 | dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2737 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2738 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2739 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2740 | return dfacc; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2741 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2742 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2743 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2744 | * Function Name: usb1_host_set_dfacc_d1 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2745 | * Description : Sets the DFACC setting value in D0FIFO using the transfer size. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2746 | * Arguments : uint16_t mbw ; MBW |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2747 | * : uint16_t count ; data count |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2748 | * Return Value : DFACC Access mode |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2749 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2750 | static uint16_t usb1_host_set_dfacc_d1 (uint16_t mbw, uint32_t count) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2751 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2752 | uint16_t dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2753 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2754 | #ifndef __USB_HOST_DF_ACC_ENABLE__ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2755 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2756 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2757 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2758 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2759 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2760 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2761 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2762 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2763 | dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2764 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2765 | if (mbw == USB_HOST_BITMBW_32) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2766 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2767 | if ((count % 32) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2768 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2769 | /* 32byte transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2770 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2771 | 2, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2772 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2773 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2774 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2775 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2776 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2777 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2778 | dfacc = 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2779 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2780 | else if ((count % 16) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2781 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2782 | /* 16byte transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2783 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2784 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2785 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2786 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2787 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2788 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2789 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2790 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2791 | dfacc = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2792 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2793 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2794 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2795 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2796 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2797 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2798 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2799 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2800 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2801 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2802 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2803 | dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2804 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2805 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2806 | else if (mbw == USB_HOST_BITMBW_16) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2807 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2808 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2809 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2810 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2811 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2812 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2813 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2814 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2815 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2816 | dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2817 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2818 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2819 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2820 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2821 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2822 | USB_DnFBCFG_DFACC_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2823 | USB_DnFBCFG_DFACC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2824 | RZA_IO_RegWrite_16(&USB201.D1FBCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2825 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2826 | USB_DnFBCFG_TENDE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2827 | USB_DnFBCFG_TENDE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2828 | dfacc = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2829 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2830 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2831 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2832 | return dfacc; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2833 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2834 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2835 | /* End of File */ |