USBHost library. NOTE: This library is only officially supported on the LPC1768 platform. For more information, please see the handbook page.
Dependencies: FATFileSystem mbed-rtos
Dependents: BTstack WallbotWii SD to Flash Data Transfer USBHost-MSD_HelloWorld ... more
Legacy Warning
This is an mbed 2 library. To learn more about mbed OS 5, visit the docs.
Pull requests against this repository are no longer supported. Please raise against mbed OS 5 as documented above.
targets/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/host/usb1_host_drv_api.c@39:d96aa62afc5b, 2017-07-27 (annotated)
- Committer:
- Kojto
- Date:
- Thu Jul 27 12:24:30 2017 +0100
- Revision:
- 39:d96aa62afc5b
Update USBHost - add targets directory
This corresponds to mbed-os/master commit 9207365
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 39:d96aa62afc5b | 1 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 2 | * DISCLAIMER |
Kojto | 39:d96aa62afc5b | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
Kojto | 39:d96aa62afc5b | 4 | * intended for use with Renesas products. No other uses are authorized. This |
Kojto | 39:d96aa62afc5b | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
Kojto | 39:d96aa62afc5b | 6 | * all applicable laws, including copyright laws. |
Kojto | 39:d96aa62afc5b | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
Kojto | 39:d96aa62afc5b | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
Kojto | 39:d96aa62afc5b | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
Kojto | 39:d96aa62afc5b | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
Kojto | 39:d96aa62afc5b | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
Kojto | 39:d96aa62afc5b | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
Kojto | 39:d96aa62afc5b | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
Kojto | 39:d96aa62afc5b | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
Kojto | 39:d96aa62afc5b | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
Kojto | 39:d96aa62afc5b | 16 | * Renesas reserves the right, without notice, to make changes to this software |
Kojto | 39:d96aa62afc5b | 17 | * and to discontinue the availability of this software. By using this software, |
Kojto | 39:d96aa62afc5b | 18 | * you agree to the additional terms and conditions found by accessing the |
Kojto | 39:d96aa62afc5b | 19 | * following link: |
Kojto | 39:d96aa62afc5b | 20 | * http://www.renesas.com/disclaimer |
Kojto | 39:d96aa62afc5b | 21 | * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved. |
Kojto | 39:d96aa62afc5b | 22 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 23 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 24 | * File Name : usb1_host_drv_api.c |
Kojto | 39:d96aa62afc5b | 25 | * $Rev: 1116 $ |
Kojto | 39:d96aa62afc5b | 26 | * $Date:: 2014-07-09 16:29:19 +0900#$ |
Kojto | 39:d96aa62afc5b | 27 | * Device(s) : RZ/A1H |
Kojto | 39:d96aa62afc5b | 28 | * Tool-Chain : |
Kojto | 39:d96aa62afc5b | 29 | * OS : None |
Kojto | 39:d96aa62afc5b | 30 | * H/W Platform : |
Kojto | 39:d96aa62afc5b | 31 | * Description : RZ/A1H R7S72100 USB Sample Program |
Kojto | 39:d96aa62afc5b | 32 | * Operation : |
Kojto | 39:d96aa62afc5b | 33 | * Limitations : |
Kojto | 39:d96aa62afc5b | 34 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 35 | |
Kojto | 39:d96aa62afc5b | 36 | |
Kojto | 39:d96aa62afc5b | 37 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 38 | Includes <System Includes> , "Project Includes" |
Kojto | 39:d96aa62afc5b | 39 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 40 | #include "usb1_host.h" |
Kojto | 39:d96aa62afc5b | 41 | #include "dev_drv.h" |
Kojto | 39:d96aa62afc5b | 42 | |
Kojto | 39:d96aa62afc5b | 43 | |
Kojto | 39:d96aa62afc5b | 44 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 45 | Typedef definitions |
Kojto | 39:d96aa62afc5b | 46 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 47 | |
Kojto | 39:d96aa62afc5b | 48 | |
Kojto | 39:d96aa62afc5b | 49 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 50 | Macro definitions |
Kojto | 39:d96aa62afc5b | 51 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 52 | |
Kojto | 39:d96aa62afc5b | 53 | |
Kojto | 39:d96aa62afc5b | 54 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 55 | Imported global variables and functions (from other files) |
Kojto | 39:d96aa62afc5b | 56 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 57 | |
Kojto | 39:d96aa62afc5b | 58 | |
Kojto | 39:d96aa62afc5b | 59 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 60 | Exported global variables and functions (to be accessed by other files) |
Kojto | 39:d96aa62afc5b | 61 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 62 | static void usb1_host_resetEP(USB_HOST_CFG_PIPETBL_t *tbl); |
Kojto | 39:d96aa62afc5b | 63 | |
Kojto | 39:d96aa62afc5b | 64 | |
Kojto | 39:d96aa62afc5b | 65 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 66 | Private global variables and functions |
Kojto | 39:d96aa62afc5b | 67 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 68 | |
Kojto | 39:d96aa62afc5b | 69 | |
Kojto | 39:d96aa62afc5b | 70 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 71 | * Function Name: usb1_api_host_init |
Kojto | 39:d96aa62afc5b | 72 | * Description : Initializes USB module in the USB host mode. |
Kojto | 39:d96aa62afc5b | 73 | * : USB connection is executed when executing this function in |
Kojto | 39:d96aa62afc5b | 74 | * : the states that USB device isconnected to the USB port. |
Kojto | 39:d96aa62afc5b | 75 | * Arguments : uint8_t int_level : USB Module interrupt level |
Kojto | 39:d96aa62afc5b | 76 | * : USBU16 mode : USB_HOST_HIGH_SPEED |
Kojto | 39:d96aa62afc5b | 77 | * : USB_HOST_FULL_SPEED |
Kojto | 39:d96aa62afc5b | 78 | * : uint16_t clockmode : USB Clock mode |
Kojto | 39:d96aa62afc5b | 79 | * Return Value : USB detach or attach |
Kojto | 39:d96aa62afc5b | 80 | * : USB_HOST_ATTACH |
Kojto | 39:d96aa62afc5b | 81 | * : USB_HOST_DETACH |
Kojto | 39:d96aa62afc5b | 82 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 83 | uint16_t usb1_api_host_init (uint8_t int_level, uint16_t mode, uint16_t clockmode) |
Kojto | 39:d96aa62afc5b | 84 | { |
Kojto | 39:d96aa62afc5b | 85 | uint16_t connect; |
Kojto | 39:d96aa62afc5b | 86 | volatile uint8_t dummy_buf; |
Kojto | 39:d96aa62afc5b | 87 | |
Kojto | 39:d96aa62afc5b | 88 | CPG.STBCR7 &= 0xfc; /*The clock of USB0/1 modules is permitted */ |
Kojto | 39:d96aa62afc5b | 89 | dummy_buf = CPG.STBCR7; /* (Dummy read) */ |
Kojto | 39:d96aa62afc5b | 90 | |
Kojto | 39:d96aa62afc5b | 91 | g_usb1_host_SupportUsbDeviceSpeed = mode; |
Kojto | 39:d96aa62afc5b | 92 | |
Kojto | 39:d96aa62afc5b | 93 | usb1_host_setting_interrupt(int_level); |
Kojto | 39:d96aa62afc5b | 94 | usb1_host_reset_module(clockmode); |
Kojto | 39:d96aa62afc5b | 95 | |
Kojto | 39:d96aa62afc5b | 96 | g_usb1_host_bchg_flag = USB_HOST_NO; |
Kojto | 39:d96aa62afc5b | 97 | g_usb1_host_detach_flag = USB_HOST_NO; |
Kojto | 39:d96aa62afc5b | 98 | g_usb1_host_attach_flag = USB_HOST_NO; |
Kojto | 39:d96aa62afc5b | 99 | |
Kojto | 39:d96aa62afc5b | 100 | g_usb1_host_driver_state = USB_HOST_DRV_DETACHED; |
Kojto | 39:d96aa62afc5b | 101 | g_usb1_host_default_max_packet[USB_HOST_DEVICE_0] = 64; |
Kojto | 39:d96aa62afc5b | 102 | |
Kojto | 39:d96aa62afc5b | 103 | usb1_host_InitModule(); |
Kojto | 39:d96aa62afc5b | 104 | |
Kojto | 39:d96aa62afc5b | 105 | connect = usb1_host_CheckAttach(); |
Kojto | 39:d96aa62afc5b | 106 | |
Kojto | 39:d96aa62afc5b | 107 | if (connect == USB_HOST_ATTACH) |
Kojto | 39:d96aa62afc5b | 108 | { |
Kojto | 39:d96aa62afc5b | 109 | g_usb1_host_attach_flag = USB_HOST_YES; |
Kojto | 39:d96aa62afc5b | 110 | } |
Kojto | 39:d96aa62afc5b | 111 | else |
Kojto | 39:d96aa62afc5b | 112 | { |
Kojto | 39:d96aa62afc5b | 113 | usb1_host_UsbDetach2(); |
Kojto | 39:d96aa62afc5b | 114 | } |
Kojto | 39:d96aa62afc5b | 115 | |
Kojto | 39:d96aa62afc5b | 116 | return connect; |
Kojto | 39:d96aa62afc5b | 117 | } |
Kojto | 39:d96aa62afc5b | 118 | |
Kojto | 39:d96aa62afc5b | 119 | #if(1) /* ohci_wrapp */ |
Kojto | 39:d96aa62afc5b | 120 | #else |
Kojto | 39:d96aa62afc5b | 121 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 122 | * Function Name: usb1_api_host_enumeration |
Kojto | 39:d96aa62afc5b | 123 | * Description : Initializes USB module in the USB host mode. |
Kojto | 39:d96aa62afc5b | 124 | * : USB connection is executed when executing this function in |
Kojto | 39:d96aa62afc5b | 125 | * : the states that USB device isconnected to the USB port. |
Kojto | 39:d96aa62afc5b | 126 | * Arguments : uint16_t devadr : device address |
Kojto | 39:d96aa62afc5b | 127 | * Return Value : DEVDRV_USBH_DETACH_ERR : device detach |
Kojto | 39:d96aa62afc5b | 128 | * : DEVDRV_SUCCESS : device enumeration success |
Kojto | 39:d96aa62afc5b | 129 | * : DEVDRV_ERROR : device enumeration error |
Kojto | 39:d96aa62afc5b | 130 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 131 | int32_t usb1_api_host_enumeration (uint16_t devadr) |
Kojto | 39:d96aa62afc5b | 132 | { |
Kojto | 39:d96aa62afc5b | 133 | int32_t ret; |
Kojto | 39:d96aa62afc5b | 134 | uint16_t driver_sts; |
Kojto | 39:d96aa62afc5b | 135 | |
Kojto | 39:d96aa62afc5b | 136 | g_usb1_host_setUsbAddress = devadr; |
Kojto | 39:d96aa62afc5b | 137 | |
Kojto | 39:d96aa62afc5b | 138 | while (1) |
Kojto | 39:d96aa62afc5b | 139 | { |
Kojto | 39:d96aa62afc5b | 140 | driver_sts = usb1_api_host_GetUsbDeviceState(); |
Kojto | 39:d96aa62afc5b | 141 | |
Kojto | 39:d96aa62afc5b | 142 | if (driver_sts == USB_HOST_DRV_DETACHED) |
Kojto | 39:d96aa62afc5b | 143 | { |
Kojto | 39:d96aa62afc5b | 144 | ret = DEVDRV_USBH_DETACH_ERR; |
Kojto | 39:d96aa62afc5b | 145 | break; |
Kojto | 39:d96aa62afc5b | 146 | } |
Kojto | 39:d96aa62afc5b | 147 | else if (driver_sts == USB_HOST_DRV_CONFIGURED) |
Kojto | 39:d96aa62afc5b | 148 | { |
Kojto | 39:d96aa62afc5b | 149 | ret = DEVDRV_SUCCESS; |
Kojto | 39:d96aa62afc5b | 150 | break; |
Kojto | 39:d96aa62afc5b | 151 | } |
Kojto | 39:d96aa62afc5b | 152 | else if (driver_sts == USB_HOST_DRV_STALL) |
Kojto | 39:d96aa62afc5b | 153 | { |
Kojto | 39:d96aa62afc5b | 154 | ret = DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 155 | break; |
Kojto | 39:d96aa62afc5b | 156 | } |
Kojto | 39:d96aa62afc5b | 157 | else if (driver_sts == USB_HOST_DRV_NORES) |
Kojto | 39:d96aa62afc5b | 158 | { |
Kojto | 39:d96aa62afc5b | 159 | ret = DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 160 | break; |
Kojto | 39:d96aa62afc5b | 161 | } |
Kojto | 39:d96aa62afc5b | 162 | else |
Kojto | 39:d96aa62afc5b | 163 | { |
Kojto | 39:d96aa62afc5b | 164 | /* Do Nothing */ |
Kojto | 39:d96aa62afc5b | 165 | } |
Kojto | 39:d96aa62afc5b | 166 | } |
Kojto | 39:d96aa62afc5b | 167 | |
Kojto | 39:d96aa62afc5b | 168 | if (driver_sts == USB_HOST_DRV_NORES) |
Kojto | 39:d96aa62afc5b | 169 | { |
Kojto | 39:d96aa62afc5b | 170 | while (1) |
Kojto | 39:d96aa62afc5b | 171 | { |
Kojto | 39:d96aa62afc5b | 172 | driver_sts = usb1_api_host_GetUsbDeviceState(); |
Kojto | 39:d96aa62afc5b | 173 | |
Kojto | 39:d96aa62afc5b | 174 | if (driver_sts == USB_HOST_DRV_DETACHED) |
Kojto | 39:d96aa62afc5b | 175 | { |
Kojto | 39:d96aa62afc5b | 176 | break; |
Kojto | 39:d96aa62afc5b | 177 | } |
Kojto | 39:d96aa62afc5b | 178 | } |
Kojto | 39:d96aa62afc5b | 179 | } |
Kojto | 39:d96aa62afc5b | 180 | |
Kojto | 39:d96aa62afc5b | 181 | return ret; |
Kojto | 39:d96aa62afc5b | 182 | } |
Kojto | 39:d96aa62afc5b | 183 | |
Kojto | 39:d96aa62afc5b | 184 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 185 | * Function Name: usb1_api_host_detach |
Kojto | 39:d96aa62afc5b | 186 | * Description : USB detach routine |
Kojto | 39:d96aa62afc5b | 187 | * Arguments : none |
Kojto | 39:d96aa62afc5b | 188 | * Return Value : USB_HOST_DETACH : USB detach |
Kojto | 39:d96aa62afc5b | 189 | * : USB_HOST_ATTACH : USB attach |
Kojto | 39:d96aa62afc5b | 190 | * : DEVDRV_ERROR : error |
Kojto | 39:d96aa62afc5b | 191 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 192 | int32_t usb1_api_host_detach (void) |
Kojto | 39:d96aa62afc5b | 193 | { |
Kojto | 39:d96aa62afc5b | 194 | int32_t ret; |
Kojto | 39:d96aa62afc5b | 195 | uint16_t driver_sts; |
Kojto | 39:d96aa62afc5b | 196 | |
Kojto | 39:d96aa62afc5b | 197 | while (1) |
Kojto | 39:d96aa62afc5b | 198 | { |
Kojto | 39:d96aa62afc5b | 199 | driver_sts = usb1_api_host_GetUsbDeviceState(); |
Kojto | 39:d96aa62afc5b | 200 | |
Kojto | 39:d96aa62afc5b | 201 | if (driver_sts == USB_HOST_DRV_DETACHED) |
Kojto | 39:d96aa62afc5b | 202 | { |
Kojto | 39:d96aa62afc5b | 203 | ret = USB_HOST_DETACH; |
Kojto | 39:d96aa62afc5b | 204 | break; |
Kojto | 39:d96aa62afc5b | 205 | } |
Kojto | 39:d96aa62afc5b | 206 | else if (driver_sts == USB_HOST_DRV_CONFIGURED) |
Kojto | 39:d96aa62afc5b | 207 | { |
Kojto | 39:d96aa62afc5b | 208 | ret = USB_HOST_ATTACH; |
Kojto | 39:d96aa62afc5b | 209 | break; |
Kojto | 39:d96aa62afc5b | 210 | } |
Kojto | 39:d96aa62afc5b | 211 | else if (driver_sts == USB_HOST_DRV_STALL) |
Kojto | 39:d96aa62afc5b | 212 | { |
Kojto | 39:d96aa62afc5b | 213 | ret = DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 214 | break; |
Kojto | 39:d96aa62afc5b | 215 | } |
Kojto | 39:d96aa62afc5b | 216 | else if (driver_sts == USB_HOST_DRV_NORES) |
Kojto | 39:d96aa62afc5b | 217 | { |
Kojto | 39:d96aa62afc5b | 218 | ret = DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 219 | break; |
Kojto | 39:d96aa62afc5b | 220 | } |
Kojto | 39:d96aa62afc5b | 221 | else |
Kojto | 39:d96aa62afc5b | 222 | { |
Kojto | 39:d96aa62afc5b | 223 | /* Do Nothing */ |
Kojto | 39:d96aa62afc5b | 224 | } |
Kojto | 39:d96aa62afc5b | 225 | } |
Kojto | 39:d96aa62afc5b | 226 | |
Kojto | 39:d96aa62afc5b | 227 | if (driver_sts == USB_HOST_DRV_NORES) |
Kojto | 39:d96aa62afc5b | 228 | { |
Kojto | 39:d96aa62afc5b | 229 | while (1) |
Kojto | 39:d96aa62afc5b | 230 | { |
Kojto | 39:d96aa62afc5b | 231 | driver_sts = usb1_api_host_GetUsbDeviceState(); |
Kojto | 39:d96aa62afc5b | 232 | |
Kojto | 39:d96aa62afc5b | 233 | if (driver_sts == USB_HOST_DRV_DETACHED) |
Kojto | 39:d96aa62afc5b | 234 | { |
Kojto | 39:d96aa62afc5b | 235 | break; |
Kojto | 39:d96aa62afc5b | 236 | } |
Kojto | 39:d96aa62afc5b | 237 | } |
Kojto | 39:d96aa62afc5b | 238 | } |
Kojto | 39:d96aa62afc5b | 239 | |
Kojto | 39:d96aa62afc5b | 240 | return ret; |
Kojto | 39:d96aa62afc5b | 241 | } |
Kojto | 39:d96aa62afc5b | 242 | |
Kojto | 39:d96aa62afc5b | 243 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 244 | * Function Name: usb1_api_host_data_in |
Kojto | 39:d96aa62afc5b | 245 | * Description : Executes USB transfer as data-in in the argument specified pipe. |
Kojto | 39:d96aa62afc5b | 246 | * Arguments : uint16_t devadr ; device address |
Kojto | 39:d96aa62afc5b | 247 | * : uint16_t Pipe ; Pipe Number |
Kojto | 39:d96aa62afc5b | 248 | * : uint32_t Size ; Data Size |
Kojto | 39:d96aa62afc5b | 249 | * : uint8_t *data_buf ; Data data_buf Address |
Kojto | 39:d96aa62afc5b | 250 | * Return Value : DEVDRV_SUCCESS ; success |
Kojto | 39:d96aa62afc5b | 251 | * : DEVDRV_ERROR ; error |
Kojto | 39:d96aa62afc5b | 252 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 253 | int32_t usb1_api_host_data_in (uint16_t devadr, uint16_t Pipe, uint32_t Size, uint8_t * data_buf) |
Kojto | 39:d96aa62afc5b | 254 | { |
Kojto | 39:d96aa62afc5b | 255 | int32_t ret; |
Kojto | 39:d96aa62afc5b | 256 | |
Kojto | 39:d96aa62afc5b | 257 | if (Pipe == USB_HOST_PIPE0) |
Kojto | 39:d96aa62afc5b | 258 | { |
Kojto | 39:d96aa62afc5b | 259 | return DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 260 | } |
Kojto | 39:d96aa62afc5b | 261 | |
Kojto | 39:d96aa62afc5b | 262 | if (RZA_IO_RegRead_16(&g_usb1_host_pipemaxp[Pipe], USB_PIPEMAXP_DEVSEL_SHIFT, USB_PIPEMAXP_DEVSEL) != devadr) |
Kojto | 39:d96aa62afc5b | 263 | { |
Kojto | 39:d96aa62afc5b | 264 | return DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 265 | } |
Kojto | 39:d96aa62afc5b | 266 | |
Kojto | 39:d96aa62afc5b | 267 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[Pipe], USB_PIPECFG_DIR_SHIFT, USB_PIPECFG_DIR) == 1) |
Kojto | 39:d96aa62afc5b | 268 | { |
Kojto | 39:d96aa62afc5b | 269 | return DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 270 | } |
Kojto | 39:d96aa62afc5b | 271 | |
Kojto | 39:d96aa62afc5b | 272 | if (g_usb1_host_pipe_status[Pipe] == USB_HOST_PIPE_IDLE) |
Kojto | 39:d96aa62afc5b | 273 | { |
Kojto | 39:d96aa62afc5b | 274 | usb1_host_start_receive_transfer(Pipe, Size, data_buf); |
Kojto | 39:d96aa62afc5b | 275 | } |
Kojto | 39:d96aa62afc5b | 276 | else |
Kojto | 39:d96aa62afc5b | 277 | { |
Kojto | 39:d96aa62afc5b | 278 | return DEVDRV_ERROR; /* Now pipe is busy */ |
Kojto | 39:d96aa62afc5b | 279 | } |
Kojto | 39:d96aa62afc5b | 280 | |
Kojto | 39:d96aa62afc5b | 281 | /* waiting for completing routine */ |
Kojto | 39:d96aa62afc5b | 282 | do |
Kojto | 39:d96aa62afc5b | 283 | { |
Kojto | 39:d96aa62afc5b | 284 | if (g_usb1_host_detach_flag == USB_HOST_YES) |
Kojto | 39:d96aa62afc5b | 285 | { |
Kojto | 39:d96aa62afc5b | 286 | break; |
Kojto | 39:d96aa62afc5b | 287 | } |
Kojto | 39:d96aa62afc5b | 288 | |
Kojto | 39:d96aa62afc5b | 289 | if ((g_usb1_host_pipe_status[Pipe] != USB_HOST_PIPE_IDLE) && (g_usb1_host_pipe_status[Pipe] != USB_HOST_PIPE_WAIT)) |
Kojto | 39:d96aa62afc5b | 290 | { |
Kojto | 39:d96aa62afc5b | 291 | break; |
Kojto | 39:d96aa62afc5b | 292 | } |
Kojto | 39:d96aa62afc5b | 293 | |
Kojto | 39:d96aa62afc5b | 294 | } while (1); |
Kojto | 39:d96aa62afc5b | 295 | |
Kojto | 39:d96aa62afc5b | 296 | if (g_usb1_host_detach_flag == USB_HOST_YES) |
Kojto | 39:d96aa62afc5b | 297 | { |
Kojto | 39:d96aa62afc5b | 298 | return DEVDRV_USBH_DETACH_ERR; |
Kojto | 39:d96aa62afc5b | 299 | } |
Kojto | 39:d96aa62afc5b | 300 | |
Kojto | 39:d96aa62afc5b | 301 | switch (g_usb1_host_pipe_status[Pipe]) |
Kojto | 39:d96aa62afc5b | 302 | { |
Kojto | 39:d96aa62afc5b | 303 | case USB_HOST_PIPE_DONE: |
Kojto | 39:d96aa62afc5b | 304 | ret = DEVDRV_SUCCESS; |
Kojto | 39:d96aa62afc5b | 305 | break; |
Kojto | 39:d96aa62afc5b | 306 | |
Kojto | 39:d96aa62afc5b | 307 | case USB_HOST_PIPE_STALL: |
Kojto | 39:d96aa62afc5b | 308 | ret = DEVDRV_USBH_STALL; |
Kojto | 39:d96aa62afc5b | 309 | break; |
Kojto | 39:d96aa62afc5b | 310 | |
Kojto | 39:d96aa62afc5b | 311 | case USB_HOST_PIPE_NORES: |
Kojto | 39:d96aa62afc5b | 312 | ret = DEVDRV_USBH_COM_ERR; |
Kojto | 39:d96aa62afc5b | 313 | break; |
Kojto | 39:d96aa62afc5b | 314 | |
Kojto | 39:d96aa62afc5b | 315 | default: |
Kojto | 39:d96aa62afc5b | 316 | ret = DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 317 | break; |
Kojto | 39:d96aa62afc5b | 318 | } |
Kojto | 39:d96aa62afc5b | 319 | |
Kojto | 39:d96aa62afc5b | 320 | usb1_host_stop_transfer(Pipe); |
Kojto | 39:d96aa62afc5b | 321 | |
Kojto | 39:d96aa62afc5b | 322 | g_usb1_host_pipe_status[Pipe] = USB_HOST_PIPE_IDLE; |
Kojto | 39:d96aa62afc5b | 323 | |
Kojto | 39:d96aa62afc5b | 324 | return ret; |
Kojto | 39:d96aa62afc5b | 325 | } |
Kojto | 39:d96aa62afc5b | 326 | |
Kojto | 39:d96aa62afc5b | 327 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 328 | * Function Name: usb1_api_host_data_out |
Kojto | 39:d96aa62afc5b | 329 | * Description : Executes USB transfer as data-out in the argument specified pipe. |
Kojto | 39:d96aa62afc5b | 330 | * Arguments : uint16_t devadr ; device address |
Kojto | 39:d96aa62afc5b | 331 | * : uint16_t Pipe ; Pipe Number |
Kojto | 39:d96aa62afc5b | 332 | * : uint32_t Size ; Data Size |
Kojto | 39:d96aa62afc5b | 333 | * : uint8_t *data_buf ; Data data_buf Address |
Kojto | 39:d96aa62afc5b | 334 | * Return Value : DEVDRV_SUCCESS ; success |
Kojto | 39:d96aa62afc5b | 335 | * : DEVDRV_ERROR ; error |
Kojto | 39:d96aa62afc5b | 336 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 337 | int32_t usb1_api_host_data_out (uint16_t devadr, uint16_t Pipe, uint32_t Size, uint8_t * data_buf) |
Kojto | 39:d96aa62afc5b | 338 | { |
Kojto | 39:d96aa62afc5b | 339 | int32_t ret; |
Kojto | 39:d96aa62afc5b | 340 | |
Kojto | 39:d96aa62afc5b | 341 | if (Pipe == USB_HOST_PIPE0) |
Kojto | 39:d96aa62afc5b | 342 | { |
Kojto | 39:d96aa62afc5b | 343 | return DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 344 | } |
Kojto | 39:d96aa62afc5b | 345 | |
Kojto | 39:d96aa62afc5b | 346 | if (RZA_IO_RegRead_16(&g_usb1_host_pipemaxp[Pipe], USB_PIPEMAXP_DEVSEL_SHIFT, USB_PIPEMAXP_DEVSEL) != devadr) |
Kojto | 39:d96aa62afc5b | 347 | { |
Kojto | 39:d96aa62afc5b | 348 | return DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 349 | } |
Kojto | 39:d96aa62afc5b | 350 | |
Kojto | 39:d96aa62afc5b | 351 | if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg[Pipe], USB_PIPECFG_DIR_SHIFT, USB_PIPECFG_DIR) == 0) |
Kojto | 39:d96aa62afc5b | 352 | { |
Kojto | 39:d96aa62afc5b | 353 | return DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 354 | } |
Kojto | 39:d96aa62afc5b | 355 | |
Kojto | 39:d96aa62afc5b | 356 | if (g_usb1_host_pipe_status[Pipe] == USB_HOST_PIPE_IDLE) |
Kojto | 39:d96aa62afc5b | 357 | { |
Kojto | 39:d96aa62afc5b | 358 | usb1_host_start_send_transfer(Pipe, Size, data_buf); |
Kojto | 39:d96aa62afc5b | 359 | } |
Kojto | 39:d96aa62afc5b | 360 | else |
Kojto | 39:d96aa62afc5b | 361 | { |
Kojto | 39:d96aa62afc5b | 362 | return DEVDRV_ERROR; /* Now pipe is busy */ |
Kojto | 39:d96aa62afc5b | 363 | } |
Kojto | 39:d96aa62afc5b | 364 | |
Kojto | 39:d96aa62afc5b | 365 | /* waiting for completing routine */ |
Kojto | 39:d96aa62afc5b | 366 | do |
Kojto | 39:d96aa62afc5b | 367 | { |
Kojto | 39:d96aa62afc5b | 368 | if (g_usb1_host_detach_flag == USB_HOST_YES) |
Kojto | 39:d96aa62afc5b | 369 | { |
Kojto | 39:d96aa62afc5b | 370 | break; |
Kojto | 39:d96aa62afc5b | 371 | } |
Kojto | 39:d96aa62afc5b | 372 | |
Kojto | 39:d96aa62afc5b | 373 | if ((g_usb1_host_pipe_status[Pipe] != USB_HOST_PIPE_IDLE) && (g_usb1_host_pipe_status[Pipe] != USB_HOST_PIPE_WAIT)) |
Kojto | 39:d96aa62afc5b | 374 | { |
Kojto | 39:d96aa62afc5b | 375 | break; |
Kojto | 39:d96aa62afc5b | 376 | } |
Kojto | 39:d96aa62afc5b | 377 | |
Kojto | 39:d96aa62afc5b | 378 | } while (1); |
Kojto | 39:d96aa62afc5b | 379 | |
Kojto | 39:d96aa62afc5b | 380 | if (g_usb1_host_detach_flag == USB_HOST_YES) |
Kojto | 39:d96aa62afc5b | 381 | { |
Kojto | 39:d96aa62afc5b | 382 | return DEVDRV_USBH_DETACH_ERR; |
Kojto | 39:d96aa62afc5b | 383 | } |
Kojto | 39:d96aa62afc5b | 384 | |
Kojto | 39:d96aa62afc5b | 385 | switch (g_usb1_host_pipe_status[Pipe]) |
Kojto | 39:d96aa62afc5b | 386 | { |
Kojto | 39:d96aa62afc5b | 387 | case USB_HOST_PIPE_DONE: |
Kojto | 39:d96aa62afc5b | 388 | ret = DEVDRV_SUCCESS; |
Kojto | 39:d96aa62afc5b | 389 | break; |
Kojto | 39:d96aa62afc5b | 390 | |
Kojto | 39:d96aa62afc5b | 391 | case USB_HOST_PIPE_STALL: |
Kojto | 39:d96aa62afc5b | 392 | ret = DEVDRV_USBH_STALL; |
Kojto | 39:d96aa62afc5b | 393 | break; |
Kojto | 39:d96aa62afc5b | 394 | |
Kojto | 39:d96aa62afc5b | 395 | case USB_HOST_PIPE_NORES: |
Kojto | 39:d96aa62afc5b | 396 | ret = DEVDRV_USBH_COM_ERR; |
Kojto | 39:d96aa62afc5b | 397 | break; |
Kojto | 39:d96aa62afc5b | 398 | |
Kojto | 39:d96aa62afc5b | 399 | default: |
Kojto | 39:d96aa62afc5b | 400 | ret = DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 401 | break; |
Kojto | 39:d96aa62afc5b | 402 | } |
Kojto | 39:d96aa62afc5b | 403 | |
Kojto | 39:d96aa62afc5b | 404 | usb1_host_stop_transfer(Pipe); |
Kojto | 39:d96aa62afc5b | 405 | |
Kojto | 39:d96aa62afc5b | 406 | g_usb1_host_pipe_status[Pipe] = USB_HOST_PIPE_IDLE; |
Kojto | 39:d96aa62afc5b | 407 | |
Kojto | 39:d96aa62afc5b | 408 | return ret; |
Kojto | 39:d96aa62afc5b | 409 | } |
Kojto | 39:d96aa62afc5b | 410 | |
Kojto | 39:d96aa62afc5b | 411 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 412 | * Function Name: usb1_api_host_control_transfer |
Kojto | 39:d96aa62afc5b | 413 | * Description : Executes USB control transfer. |
Kojto | 39:d96aa62afc5b | 414 | * Arguments : uint16_t devadr ; device address |
Kojto | 39:d96aa62afc5b | 415 | * : uint16_t Req ; bmRequestType & bRequest |
Kojto | 39:d96aa62afc5b | 416 | * : uint16_t Val ; wValue |
Kojto | 39:d96aa62afc5b | 417 | * : uint16_t Indx ; wIndex |
Kojto | 39:d96aa62afc5b | 418 | * : uint16_t Len ; wLength |
Kojto | 39:d96aa62afc5b | 419 | * : uint8_t *buf ; Buffer |
Kojto | 39:d96aa62afc5b | 420 | * Return Value : DEVDRV_SUCCESS ; success |
Kojto | 39:d96aa62afc5b | 421 | * : DEVDRV_USBH_DETACH_ERR ; device detach |
Kojto | 39:d96aa62afc5b | 422 | * : DEVDRV_USBH_CTRL_COM_ERR ; device no response |
Kojto | 39:d96aa62afc5b | 423 | * : DEVDRV_USBH_STALL ; STALL |
Kojto | 39:d96aa62afc5b | 424 | * : DEVDRV_ERROR ; error |
Kojto | 39:d96aa62afc5b | 425 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 426 | int32_t usb1_api_host_control_transfer (uint16_t devadr, uint16_t Req, uint16_t Val, uint16_t Indx, |
Kojto | 39:d96aa62afc5b | 427 | uint16_t Len, uint8_t * Buf) |
Kojto | 39:d96aa62afc5b | 428 | { |
Kojto | 39:d96aa62afc5b | 429 | int32_t ret; |
Kojto | 39:d96aa62afc5b | 430 | |
Kojto | 39:d96aa62afc5b | 431 | do |
Kojto | 39:d96aa62afc5b | 432 | { |
Kojto | 39:d96aa62afc5b | 433 | ret = usb1_host_CtrlTransStart(devadr, Req, Val, Indx, Len, Buf); |
Kojto | 39:d96aa62afc5b | 434 | |
Kojto | 39:d96aa62afc5b | 435 | if (ret == DEVDRV_SUCCESS) |
Kojto | 39:d96aa62afc5b | 436 | { |
Kojto | 39:d96aa62afc5b | 437 | if (g_usb1_host_detach_flag == USB_HOST_YES) |
Kojto | 39:d96aa62afc5b | 438 | { |
Kojto | 39:d96aa62afc5b | 439 | break; |
Kojto | 39:d96aa62afc5b | 440 | } |
Kojto | 39:d96aa62afc5b | 441 | |
Kojto | 39:d96aa62afc5b | 442 | if ((g_usb1_host_pipe_status[USB_HOST_PIPE0] != USB_HOST_PIPE_IDLE) |
Kojto | 39:d96aa62afc5b | 443 | && (g_usb1_host_pipe_status[USB_HOST_PIPE0] != USB_HOST_PIPE_WAIT)) |
Kojto | 39:d96aa62afc5b | 444 | { |
Kojto | 39:d96aa62afc5b | 445 | break; |
Kojto | 39:d96aa62afc5b | 446 | } |
Kojto | 39:d96aa62afc5b | 447 | } |
Kojto | 39:d96aa62afc5b | 448 | else |
Kojto | 39:d96aa62afc5b | 449 | { |
Kojto | 39:d96aa62afc5b | 450 | return DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 451 | } |
Kojto | 39:d96aa62afc5b | 452 | } while (1); |
Kojto | 39:d96aa62afc5b | 453 | |
Kojto | 39:d96aa62afc5b | 454 | if (g_usb1_host_detach_flag == USB_HOST_YES) |
Kojto | 39:d96aa62afc5b | 455 | { |
Kojto | 39:d96aa62afc5b | 456 | return DEVDRV_USBH_DETACH_ERR; |
Kojto | 39:d96aa62afc5b | 457 | } |
Kojto | 39:d96aa62afc5b | 458 | |
Kojto | 39:d96aa62afc5b | 459 | switch (g_usb1_host_pipe_status[USB_HOST_PIPE0]) |
Kojto | 39:d96aa62afc5b | 460 | { |
Kojto | 39:d96aa62afc5b | 461 | case USB_HOST_PIPE_DONE: |
Kojto | 39:d96aa62afc5b | 462 | ret = DEVDRV_SUCCESS; |
Kojto | 39:d96aa62afc5b | 463 | break; |
Kojto | 39:d96aa62afc5b | 464 | |
Kojto | 39:d96aa62afc5b | 465 | case USB_HOST_PIPE_STALL: |
Kojto | 39:d96aa62afc5b | 466 | ret = DEVDRV_USBH_STALL; |
Kojto | 39:d96aa62afc5b | 467 | break; |
Kojto | 39:d96aa62afc5b | 468 | |
Kojto | 39:d96aa62afc5b | 469 | case USB_HOST_PIPE_NORES: |
Kojto | 39:d96aa62afc5b | 470 | ret = DEVDRV_USBH_CTRL_COM_ERR; |
Kojto | 39:d96aa62afc5b | 471 | break; |
Kojto | 39:d96aa62afc5b | 472 | |
Kojto | 39:d96aa62afc5b | 473 | default: |
Kojto | 39:d96aa62afc5b | 474 | ret = DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 475 | break; |
Kojto | 39:d96aa62afc5b | 476 | } |
Kojto | 39:d96aa62afc5b | 477 | |
Kojto | 39:d96aa62afc5b | 478 | g_usb1_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_IDLE; |
Kojto | 39:d96aa62afc5b | 479 | |
Kojto | 39:d96aa62afc5b | 480 | return ret; |
Kojto | 39:d96aa62afc5b | 481 | } |
Kojto | 39:d96aa62afc5b | 482 | |
Kojto | 39:d96aa62afc5b | 483 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 484 | * Function Name: usb1_api_host_set_endpoint |
Kojto | 39:d96aa62afc5b | 485 | * Description : Sets end point on the information specified in the argument. |
Kojto | 39:d96aa62afc5b | 486 | * Arguments : uint16_t devadr ; device address |
Kojto | 39:d96aa62afc5b | 487 | * : uint8_t *configdescriptor ; device configration descriptor |
Kojto | 39:d96aa62afc5b | 488 | * : USB_HOST_CFG_PIPETBL_t *user_table ; pipe table |
Kojto | 39:d96aa62afc5b | 489 | * Return Value : DEVDRV_SUCCESS ; success |
Kojto | 39:d96aa62afc5b | 490 | * : DEVDRV_ERROR ; error |
Kojto | 39:d96aa62afc5b | 491 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 492 | int32_t usb1_api_host_set_endpoint (uint16_t devadr, USB_HOST_CFG_PIPETBL_t * user_table, uint8_t * configdescriptor) |
Kojto | 39:d96aa62afc5b | 493 | { |
Kojto | 39:d96aa62afc5b | 494 | uint16_t ret; |
Kojto | 39:d96aa62afc5b | 495 | uint32_t end_point; |
Kojto | 39:d96aa62afc5b | 496 | uint32_t offset; |
Kojto | 39:d96aa62afc5b | 497 | uint32_t totalLength; |
Kojto | 39:d96aa62afc5b | 498 | USB_HOST_CFG_PIPETBL_t * pipe_table; |
Kojto | 39:d96aa62afc5b | 499 | |
Kojto | 39:d96aa62afc5b | 500 | /* End Point Search */ |
Kojto | 39:d96aa62afc5b | 501 | end_point = 0; |
Kojto | 39:d96aa62afc5b | 502 | offset = configdescriptor[0]; |
Kojto | 39:d96aa62afc5b | 503 | totalLength = (uint16_t)(configdescriptor[2] + ((uint16_t)configdescriptor[3] << 8)); |
Kojto | 39:d96aa62afc5b | 504 | |
Kojto | 39:d96aa62afc5b | 505 | do |
Kojto | 39:d96aa62afc5b | 506 | { |
Kojto | 39:d96aa62afc5b | 507 | if (configdescriptor[offset + 1] == USB_HOST_ENDPOINT_DESC) |
Kojto | 39:d96aa62afc5b | 508 | { |
Kojto | 39:d96aa62afc5b | 509 | pipe_table = &user_table[end_point]; |
Kojto | 39:d96aa62afc5b | 510 | |
Kojto | 39:d96aa62afc5b | 511 | if (pipe_table->pipe_number == 0xffff) |
Kojto | 39:d96aa62afc5b | 512 | { |
Kojto | 39:d96aa62afc5b | 513 | break; |
Kojto | 39:d96aa62afc5b | 514 | } |
Kojto | 39:d96aa62afc5b | 515 | |
Kojto | 39:d96aa62afc5b | 516 | ret = usb1_api_host_SetEndpointTable(devadr, pipe_table, (uint8_t *)&configdescriptor[offset]); |
Kojto | 39:d96aa62afc5b | 517 | |
Kojto | 39:d96aa62afc5b | 518 | if ((ret != USB_HOST_PIPE_IN) && (ret != USB_HOST_PIPE_OUT)) |
Kojto | 39:d96aa62afc5b | 519 | { |
Kojto | 39:d96aa62afc5b | 520 | return DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 521 | } |
Kojto | 39:d96aa62afc5b | 522 | |
Kojto | 39:d96aa62afc5b | 523 | ++end_point; |
Kojto | 39:d96aa62afc5b | 524 | } |
Kojto | 39:d96aa62afc5b | 525 | |
Kojto | 39:d96aa62afc5b | 526 | /* Next End Point Search */ |
Kojto | 39:d96aa62afc5b | 527 | offset += configdescriptor[offset]; |
Kojto | 39:d96aa62afc5b | 528 | |
Kojto | 39:d96aa62afc5b | 529 | } while (offset < totalLength); |
Kojto | 39:d96aa62afc5b | 530 | |
Kojto | 39:d96aa62afc5b | 531 | return DEVDRV_SUCCESS; |
Kojto | 39:d96aa62afc5b | 532 | } |
Kojto | 39:d96aa62afc5b | 533 | |
Kojto | 39:d96aa62afc5b | 534 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 535 | * Function Name: usb1_api_host_clear_endpoint |
Kojto | 39:d96aa62afc5b | 536 | * Description : Clears the pipe definition table specified in the argument. |
Kojto | 39:d96aa62afc5b | 537 | * Arguments : uint16_t pipe_sel : Pipe Number |
Kojto | 39:d96aa62afc5b | 538 | * : USB_HOST_CFG_PIPETBL_t *user_table : pipe table |
Kojto | 39:d96aa62afc5b | 539 | * Return Value : DEVDRV_SUCCESS ; success |
Kojto | 39:d96aa62afc5b | 540 | * : DEVDRV_ERROR ; error |
Kojto | 39:d96aa62afc5b | 541 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 542 | int32_t usb1_api_host_clear_endpoint (USB_HOST_CFG_PIPETBL_t * user_table) |
Kojto | 39:d96aa62afc5b | 543 | { |
Kojto | 39:d96aa62afc5b | 544 | uint16_t pipe; |
Kojto | 39:d96aa62afc5b | 545 | |
Kojto | 39:d96aa62afc5b | 546 | for (pipe = USB_HOST_PIPE0; pipe <= USB_HOST_MAX_PIPE_NO; ++pipe) |
Kojto | 39:d96aa62afc5b | 547 | { |
Kojto | 39:d96aa62afc5b | 548 | if (user_table->pipe_number == 0xffff) |
Kojto | 39:d96aa62afc5b | 549 | { |
Kojto | 39:d96aa62afc5b | 550 | break; |
Kojto | 39:d96aa62afc5b | 551 | } |
Kojto | 39:d96aa62afc5b | 552 | user_table->pipe_cfg &= (USB_HOST_DBLBFIELD | USB_HOST_CNTMDFIELD); |
Kojto | 39:d96aa62afc5b | 553 | user_table->pipe_max_pktsize = 0; |
Kojto | 39:d96aa62afc5b | 554 | user_table->pipe_cycle = 0; |
Kojto | 39:d96aa62afc5b | 555 | |
Kojto | 39:d96aa62afc5b | 556 | user_table++; |
Kojto | 39:d96aa62afc5b | 557 | } |
Kojto | 39:d96aa62afc5b | 558 | |
Kojto | 39:d96aa62afc5b | 559 | return DEVDRV_SUCCESS; |
Kojto | 39:d96aa62afc5b | 560 | } |
Kojto | 39:d96aa62afc5b | 561 | |
Kojto | 39:d96aa62afc5b | 562 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 563 | * Function Name: usb1_api_host_clear_endpoint_pipe |
Kojto | 39:d96aa62afc5b | 564 | * Description : Clears the pipe definition table specified in the argument. |
Kojto | 39:d96aa62afc5b | 565 | * Arguments : USB_HOST_CFG_PIPETBL_t *user_table : pipe table |
Kojto | 39:d96aa62afc5b | 566 | * Return Value : DEVDRV_SUCCESS ; success |
Kojto | 39:d96aa62afc5b | 567 | * : DEVDRV_ERROR ; error |
Kojto | 39:d96aa62afc5b | 568 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 569 | int32_t usb1_api_host_clear_endpoint_pipe (uint16_t pipe_sel, USB_HOST_CFG_PIPETBL_t * user_table) |
Kojto | 39:d96aa62afc5b | 570 | { |
Kojto | 39:d96aa62afc5b | 571 | uint16_t pipe; |
Kojto | 39:d96aa62afc5b | 572 | |
Kojto | 39:d96aa62afc5b | 573 | for (pipe = USB_HOST_PIPE0; pipe <= USB_HOST_MAX_PIPE_NO; ++pipe) |
Kojto | 39:d96aa62afc5b | 574 | { |
Kojto | 39:d96aa62afc5b | 575 | if (user_table->pipe_number == 0xffff) |
Kojto | 39:d96aa62afc5b | 576 | { |
Kojto | 39:d96aa62afc5b | 577 | break; |
Kojto | 39:d96aa62afc5b | 578 | } |
Kojto | 39:d96aa62afc5b | 579 | |
Kojto | 39:d96aa62afc5b | 580 | if (user_table->pipe_number == pipe_sel) |
Kojto | 39:d96aa62afc5b | 581 | { |
Kojto | 39:d96aa62afc5b | 582 | user_table->pipe_cfg &= (USB_HOST_DBLBFIELD | USB_HOST_CNTMDFIELD); |
Kojto | 39:d96aa62afc5b | 583 | user_table->pipe_max_pktsize = 0; |
Kojto | 39:d96aa62afc5b | 584 | user_table->pipe_cycle = 0; |
Kojto | 39:d96aa62afc5b | 585 | break; |
Kojto | 39:d96aa62afc5b | 586 | } |
Kojto | 39:d96aa62afc5b | 587 | |
Kojto | 39:d96aa62afc5b | 588 | user_table++; |
Kojto | 39:d96aa62afc5b | 589 | } |
Kojto | 39:d96aa62afc5b | 590 | |
Kojto | 39:d96aa62afc5b | 591 | return DEVDRV_SUCCESS; |
Kojto | 39:d96aa62afc5b | 592 | } |
Kojto | 39:d96aa62afc5b | 593 | #endif |
Kojto | 39:d96aa62afc5b | 594 | |
Kojto | 39:d96aa62afc5b | 595 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 596 | * Function Name: usb1_api_host_SetEndpointTable |
Kojto | 39:d96aa62afc5b | 597 | * Description : Sets the end point on the information specified by the argument. |
Kojto | 39:d96aa62afc5b | 598 | * Arguments : uint16_t devadr : device address |
Kojto | 39:d96aa62afc5b | 599 | * : USB_HOST_CFG_PIPETBL_t *user_table : pipe table |
Kojto | 39:d96aa62afc5b | 600 | * : uint8_t *Table : Endpoint descriptor |
Kojto | 39:d96aa62afc5b | 601 | * Return Value : USB_HOST_DIR_H_IN ; IN endpoint |
Kojto | 39:d96aa62afc5b | 602 | * : USB_HOST_DIR_H_OUT ; OUT endpoint |
Kojto | 39:d96aa62afc5b | 603 | * : USB_END_POINT_ERROR ; error |
Kojto | 39:d96aa62afc5b | 604 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 605 | uint16_t usb1_api_host_SetEndpointTable (uint16_t devadr, USB_HOST_CFG_PIPETBL_t * user_table, uint8_t * Table) |
Kojto | 39:d96aa62afc5b | 606 | { |
Kojto | 39:d96aa62afc5b | 607 | uint16_t PipeCfg; |
Kojto | 39:d96aa62afc5b | 608 | uint16_t PipeMaxp; |
Kojto | 39:d96aa62afc5b | 609 | uint16_t pipe_number; |
Kojto | 39:d96aa62afc5b | 610 | uint16_t ret; |
Kojto | 39:d96aa62afc5b | 611 | uint16_t ret_flag = 0; // avoid warning. |
Kojto | 39:d96aa62afc5b | 612 | |
Kojto | 39:d96aa62afc5b | 613 | pipe_number = user_table->pipe_number; |
Kojto | 39:d96aa62afc5b | 614 | |
Kojto | 39:d96aa62afc5b | 615 | if (Table[1] != USB_HOST_ENDPOINT_DESC) |
Kojto | 39:d96aa62afc5b | 616 | { |
Kojto | 39:d96aa62afc5b | 617 | return USB_END_POINT_ERROR; |
Kojto | 39:d96aa62afc5b | 618 | } |
Kojto | 39:d96aa62afc5b | 619 | |
Kojto | 39:d96aa62afc5b | 620 | switch (Table[3] & USB_HOST_EP_TYPE) |
Kojto | 39:d96aa62afc5b | 621 | { |
Kojto | 39:d96aa62afc5b | 622 | case USB_HOST_EP_CNTRL: |
Kojto | 39:d96aa62afc5b | 623 | ret_flag = USB_END_POINT_ERROR; |
Kojto | 39:d96aa62afc5b | 624 | break; |
Kojto | 39:d96aa62afc5b | 625 | |
Kojto | 39:d96aa62afc5b | 626 | case USB_HOST_EP_ISO: |
Kojto | 39:d96aa62afc5b | 627 | if ((pipe_number != USB_HOST_PIPE1) && (pipe_number != USB_HOST_PIPE2)) |
Kojto | 39:d96aa62afc5b | 628 | { |
Kojto | 39:d96aa62afc5b | 629 | return USB_END_POINT_ERROR; |
Kojto | 39:d96aa62afc5b | 630 | } |
Kojto | 39:d96aa62afc5b | 631 | |
Kojto | 39:d96aa62afc5b | 632 | PipeCfg = USB_HOST_ISO; |
Kojto | 39:d96aa62afc5b | 633 | break; |
Kojto | 39:d96aa62afc5b | 634 | |
Kojto | 39:d96aa62afc5b | 635 | case USB_HOST_EP_BULK: |
Kojto | 39:d96aa62afc5b | 636 | if ((pipe_number < USB_HOST_PIPE1) || (pipe_number > USB_HOST_PIPE5)) |
Kojto | 39:d96aa62afc5b | 637 | { |
Kojto | 39:d96aa62afc5b | 638 | return USB_END_POINT_ERROR; |
Kojto | 39:d96aa62afc5b | 639 | } |
Kojto | 39:d96aa62afc5b | 640 | |
Kojto | 39:d96aa62afc5b | 641 | PipeCfg = USB_HOST_BULK; |
Kojto | 39:d96aa62afc5b | 642 | break; |
Kojto | 39:d96aa62afc5b | 643 | |
Kojto | 39:d96aa62afc5b | 644 | case USB_HOST_EP_INT: |
Kojto | 39:d96aa62afc5b | 645 | if ((pipe_number < USB_HOST_PIPE6) || (pipe_number > USB_HOST_PIPE9)) |
Kojto | 39:d96aa62afc5b | 646 | { |
Kojto | 39:d96aa62afc5b | 647 | return USB_END_POINT_ERROR; |
Kojto | 39:d96aa62afc5b | 648 | } |
Kojto | 39:d96aa62afc5b | 649 | |
Kojto | 39:d96aa62afc5b | 650 | PipeCfg = USB_HOST_INTERRUPT; |
Kojto | 39:d96aa62afc5b | 651 | break; |
Kojto | 39:d96aa62afc5b | 652 | |
Kojto | 39:d96aa62afc5b | 653 | default: |
Kojto | 39:d96aa62afc5b | 654 | ret_flag = USB_END_POINT_ERROR; |
Kojto | 39:d96aa62afc5b | 655 | break; |
Kojto | 39:d96aa62afc5b | 656 | } |
Kojto | 39:d96aa62afc5b | 657 | |
Kojto | 39:d96aa62afc5b | 658 | if (ret_flag == USB_END_POINT_ERROR) |
Kojto | 39:d96aa62afc5b | 659 | { |
Kojto | 39:d96aa62afc5b | 660 | return ret_flag; |
Kojto | 39:d96aa62afc5b | 661 | } |
Kojto | 39:d96aa62afc5b | 662 | |
Kojto | 39:d96aa62afc5b | 663 | /* Set pipe configuration table */ |
Kojto | 39:d96aa62afc5b | 664 | if ((Table[2] & USB_HOST_EP_DIR_MASK) == USB_HOST_EP_IN) /* IN(receive) */ |
Kojto | 39:d96aa62afc5b | 665 | { |
Kojto | 39:d96aa62afc5b | 666 | if (PipeCfg == USB_HOST_ISO) |
Kojto | 39:d96aa62afc5b | 667 | { |
Kojto | 39:d96aa62afc5b | 668 | /* Transfer Type is ISO*/ |
Kojto | 39:d96aa62afc5b | 669 | PipeCfg |= USB_HOST_DIR_H_IN; |
Kojto | 39:d96aa62afc5b | 670 | |
Kojto | 39:d96aa62afc5b | 671 | switch (user_table->fifo_port) |
Kojto | 39:d96aa62afc5b | 672 | { |
Kojto | 39:d96aa62afc5b | 673 | case USB_HOST_CUSE: |
Kojto | 39:d96aa62afc5b | 674 | case USB_HOST_D0USE: |
Kojto | 39:d96aa62afc5b | 675 | case USB_HOST_D1USE: |
Kojto | 39:d96aa62afc5b | 676 | case USB_HOST_D0DMA: |
Kojto | 39:d96aa62afc5b | 677 | case USB_HOST_D1DMA: |
Kojto | 39:d96aa62afc5b | 678 | PipeCfg |= (uint16_t)(user_table->pipe_cfg & USB_HOST_DBLBFIELD); |
Kojto | 39:d96aa62afc5b | 679 | break; |
Kojto | 39:d96aa62afc5b | 680 | |
Kojto | 39:d96aa62afc5b | 681 | default: |
Kojto | 39:d96aa62afc5b | 682 | ret_flag = USB_END_POINT_ERROR; |
Kojto | 39:d96aa62afc5b | 683 | break; |
Kojto | 39:d96aa62afc5b | 684 | } |
Kojto | 39:d96aa62afc5b | 685 | |
Kojto | 39:d96aa62afc5b | 686 | if (ret_flag == USB_END_POINT_ERROR) |
Kojto | 39:d96aa62afc5b | 687 | { |
Kojto | 39:d96aa62afc5b | 688 | return ret_flag; |
Kojto | 39:d96aa62afc5b | 689 | } |
Kojto | 39:d96aa62afc5b | 690 | } |
Kojto | 39:d96aa62afc5b | 691 | else |
Kojto | 39:d96aa62afc5b | 692 | { |
Kojto | 39:d96aa62afc5b | 693 | /* Transfer Type is BULK or INT */ |
Kojto | 39:d96aa62afc5b | 694 | PipeCfg |= (USB_HOST_SHTNAKON | USB_HOST_DIR_H_IN); /* Compulsory SHTNAK */ |
Kojto | 39:d96aa62afc5b | 695 | |
Kojto | 39:d96aa62afc5b | 696 | switch (user_table->fifo_port) |
Kojto | 39:d96aa62afc5b | 697 | { |
Kojto | 39:d96aa62afc5b | 698 | case USB_HOST_CUSE: |
Kojto | 39:d96aa62afc5b | 699 | case USB_HOST_D0USE: |
Kojto | 39:d96aa62afc5b | 700 | case USB_HOST_D1USE: |
Kojto | 39:d96aa62afc5b | 701 | PipeCfg |= (uint16_t)(user_table->pipe_cfg & (USB_HOST_DBLBFIELD | USB_HOST_CNTMDFIELD)); |
Kojto | 39:d96aa62afc5b | 702 | break; |
Kojto | 39:d96aa62afc5b | 703 | |
Kojto | 39:d96aa62afc5b | 704 | case USB_HOST_D0DMA: |
Kojto | 39:d96aa62afc5b | 705 | case USB_HOST_D1DMA: |
Kojto | 39:d96aa62afc5b | 706 | PipeCfg |= (uint16_t)(user_table->pipe_cfg & (USB_HOST_DBLBFIELD | USB_HOST_CNTMDFIELD)); |
Kojto | 39:d96aa62afc5b | 707 | #ifdef __USB_DMA_BFRE_ENABLE__ |
Kojto | 39:d96aa62afc5b | 708 | /* this routine cannnot be perfomred if read operation is executed in buffer size */ |
Kojto | 39:d96aa62afc5b | 709 | PipeCfg |= USB_HOST_BFREON; |
Kojto | 39:d96aa62afc5b | 710 | #endif |
Kojto | 39:d96aa62afc5b | 711 | break; |
Kojto | 39:d96aa62afc5b | 712 | |
Kojto | 39:d96aa62afc5b | 713 | default: |
Kojto | 39:d96aa62afc5b | 714 | ret_flag = USB_END_POINT_ERROR; |
Kojto | 39:d96aa62afc5b | 715 | break; |
Kojto | 39:d96aa62afc5b | 716 | } |
Kojto | 39:d96aa62afc5b | 717 | |
Kojto | 39:d96aa62afc5b | 718 | if (ret_flag == USB_END_POINT_ERROR) |
Kojto | 39:d96aa62afc5b | 719 | { |
Kojto | 39:d96aa62afc5b | 720 | return ret_flag; |
Kojto | 39:d96aa62afc5b | 721 | } |
Kojto | 39:d96aa62afc5b | 722 | } |
Kojto | 39:d96aa62afc5b | 723 | ret = USB_HOST_PIPE_IN; |
Kojto | 39:d96aa62afc5b | 724 | } |
Kojto | 39:d96aa62afc5b | 725 | else /* OUT(send) */ |
Kojto | 39:d96aa62afc5b | 726 | { |
Kojto | 39:d96aa62afc5b | 727 | if (PipeCfg == USB_HOST_ISO) |
Kojto | 39:d96aa62afc5b | 728 | { |
Kojto | 39:d96aa62afc5b | 729 | /* Transfer Type is ISO*/ |
Kojto | 39:d96aa62afc5b | 730 | PipeCfg |= (uint16_t)(user_table->pipe_cfg & USB_HOST_DBLBFIELD); |
Kojto | 39:d96aa62afc5b | 731 | } |
Kojto | 39:d96aa62afc5b | 732 | else |
Kojto | 39:d96aa62afc5b | 733 | { |
Kojto | 39:d96aa62afc5b | 734 | /* Transfer Type is BULK or INT */ |
Kojto | 39:d96aa62afc5b | 735 | PipeCfg |= (uint16_t)(user_table->pipe_cfg & (USB_HOST_DBLBFIELD | USB_HOST_CNTMDFIELD)); |
Kojto | 39:d96aa62afc5b | 736 | } |
Kojto | 39:d96aa62afc5b | 737 | PipeCfg |= USB_HOST_DIR_H_OUT; |
Kojto | 39:d96aa62afc5b | 738 | ret = USB_HOST_PIPE_OUT; |
Kojto | 39:d96aa62afc5b | 739 | } |
Kojto | 39:d96aa62afc5b | 740 | |
Kojto | 39:d96aa62afc5b | 741 | switch (user_table->fifo_port) |
Kojto | 39:d96aa62afc5b | 742 | { |
Kojto | 39:d96aa62afc5b | 743 | case USB_HOST_CUSE: |
Kojto | 39:d96aa62afc5b | 744 | g_usb1_host_PipeTbl[pipe_number] = (uint16_t)USB_HOST_CFIFO_USE; |
Kojto | 39:d96aa62afc5b | 745 | break; |
Kojto | 39:d96aa62afc5b | 746 | |
Kojto | 39:d96aa62afc5b | 747 | case USB_HOST_D0USE: |
Kojto | 39:d96aa62afc5b | 748 | g_usb1_host_PipeTbl[pipe_number] = (uint16_t)USB_HOST_D0FIFO_USE; |
Kojto | 39:d96aa62afc5b | 749 | break; |
Kojto | 39:d96aa62afc5b | 750 | |
Kojto | 39:d96aa62afc5b | 751 | case USB_HOST_D1USE: |
Kojto | 39:d96aa62afc5b | 752 | g_usb1_host_PipeTbl[pipe_number] = (uint16_t)USB_HOST_D1FIFO_USE; |
Kojto | 39:d96aa62afc5b | 753 | break; |
Kojto | 39:d96aa62afc5b | 754 | |
Kojto | 39:d96aa62afc5b | 755 | case USB_HOST_D0DMA: |
Kojto | 39:d96aa62afc5b | 756 | g_usb1_host_PipeTbl[pipe_number] = (uint16_t)USB_HOST_D0FIFO_DMA; |
Kojto | 39:d96aa62afc5b | 757 | break; |
Kojto | 39:d96aa62afc5b | 758 | |
Kojto | 39:d96aa62afc5b | 759 | case USB_HOST_D1DMA: |
Kojto | 39:d96aa62afc5b | 760 | g_usb1_host_PipeTbl[pipe_number] = (uint16_t)USB_HOST_D1FIFO_DMA; |
Kojto | 39:d96aa62afc5b | 761 | break; |
Kojto | 39:d96aa62afc5b | 762 | |
Kojto | 39:d96aa62afc5b | 763 | default: |
Kojto | 39:d96aa62afc5b | 764 | ret_flag = USB_END_POINT_ERROR; |
Kojto | 39:d96aa62afc5b | 765 | break; |
Kojto | 39:d96aa62afc5b | 766 | } |
Kojto | 39:d96aa62afc5b | 767 | |
Kojto | 39:d96aa62afc5b | 768 | if (ret_flag == USB_END_POINT_ERROR) |
Kojto | 39:d96aa62afc5b | 769 | { |
Kojto | 39:d96aa62afc5b | 770 | return ret_flag; |
Kojto | 39:d96aa62afc5b | 771 | } |
Kojto | 39:d96aa62afc5b | 772 | |
Kojto | 39:d96aa62afc5b | 773 | /* Endpoint number set */ |
Kojto | 39:d96aa62afc5b | 774 | PipeCfg |= (uint16_t)(Table[2] & USB_HOST_EP_NUM_MASK); |
Kojto | 39:d96aa62afc5b | 775 | g_usb1_host_PipeTbl[pipe_number] |= (uint16_t)(Table[2] & USB_HOST_EP_NUM_MASK); |
Kojto | 39:d96aa62afc5b | 776 | |
Kojto | 39:d96aa62afc5b | 777 | /* Max packet size set */ |
Kojto | 39:d96aa62afc5b | 778 | PipeMaxp = (uint16_t)((uint16_t)Table[4] | (uint16_t)((uint16_t)Table[5] << 8)); |
Kojto | 39:d96aa62afc5b | 779 | |
Kojto | 39:d96aa62afc5b | 780 | if (PipeMaxp == 0u) |
Kojto | 39:d96aa62afc5b | 781 | { |
Kojto | 39:d96aa62afc5b | 782 | return USB_END_POINT_ERROR; |
Kojto | 39:d96aa62afc5b | 783 | } |
Kojto | 39:d96aa62afc5b | 784 | |
Kojto | 39:d96aa62afc5b | 785 | /* Set device address */ |
Kojto | 39:d96aa62afc5b | 786 | PipeMaxp |= (uint16_t)(devadr << 12); |
Kojto | 39:d96aa62afc5b | 787 | |
Kojto | 39:d96aa62afc5b | 788 | user_table->pipe_cfg = PipeCfg; |
Kojto | 39:d96aa62afc5b | 789 | user_table->pipe_max_pktsize = PipeMaxp; |
Kojto | 39:d96aa62afc5b | 790 | |
Kojto | 39:d96aa62afc5b | 791 | usb1_host_resetEP(user_table); |
Kojto | 39:d96aa62afc5b | 792 | |
Kojto | 39:d96aa62afc5b | 793 | return ret; |
Kojto | 39:d96aa62afc5b | 794 | } |
Kojto | 39:d96aa62afc5b | 795 | |
Kojto | 39:d96aa62afc5b | 796 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 797 | * Function Name: usb1_host_resetEP |
Kojto | 39:d96aa62afc5b | 798 | * Description : Sets the end point on the information specified by the argument. |
Kojto | 39:d96aa62afc5b | 799 | * Arguments : USB_HOST_CFG_PIPETBL_t *tbl : pipe table |
Kojto | 39:d96aa62afc5b | 800 | * Return Value : none |
Kojto | 39:d96aa62afc5b | 801 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 802 | static void usb1_host_resetEP (USB_HOST_CFG_PIPETBL_t * tbl) |
Kojto | 39:d96aa62afc5b | 803 | { |
Kojto | 39:d96aa62afc5b | 804 | |
Kojto | 39:d96aa62afc5b | 805 | uint16_t pipe; |
Kojto | 39:d96aa62afc5b | 806 | |
Kojto | 39:d96aa62afc5b | 807 | /* Host pipe */ |
Kojto | 39:d96aa62afc5b | 808 | /* The pipe number of pipe definition table is obtained */ |
Kojto | 39:d96aa62afc5b | 809 | pipe = (uint16_t)(tbl->pipe_number & USB_HOST_BITCURPIPE); /* Pipe Number */ |
Kojto | 39:d96aa62afc5b | 810 | |
Kojto | 39:d96aa62afc5b | 811 | /* FIFO port access pipe is set to initial value */ |
Kojto | 39:d96aa62afc5b | 812 | /* The connection with FIFO should be cut before setting the pipe */ |
Kojto | 39:d96aa62afc5b | 813 | if (RZA_IO_RegRead_16(&USB201.CFIFOSEL, |
Kojto | 39:d96aa62afc5b | 814 | USB_CFIFOSEL_CURPIPE_SHIFT, |
Kojto | 39:d96aa62afc5b | 815 | USB_CFIFOSEL_CURPIPE) == pipe) |
Kojto | 39:d96aa62afc5b | 816 | { |
Kojto | 39:d96aa62afc5b | 817 | usb1_host_change_fifo_port(USB_HOST_PIPE0, USB_HOST_CUSE, USB_HOST_NO, USB_HOST_BITMBW_16); |
Kojto | 39:d96aa62afc5b | 818 | } |
Kojto | 39:d96aa62afc5b | 819 | |
Kojto | 39:d96aa62afc5b | 820 | if (RZA_IO_RegRead_16(&USB201.D0FIFOSEL, |
Kojto | 39:d96aa62afc5b | 821 | USB_DnFIFOSEL_CURPIPE_SHIFT, |
Kojto | 39:d96aa62afc5b | 822 | USB_DnFIFOSEL_CURPIPE) == pipe) |
Kojto | 39:d96aa62afc5b | 823 | { |
Kojto | 39:d96aa62afc5b | 824 | usb1_host_change_fifo_port(USB_HOST_PIPE0, USB_HOST_D0USE, USB_HOST_NO, USB_HOST_BITMBW_16); |
Kojto | 39:d96aa62afc5b | 825 | } |
Kojto | 39:d96aa62afc5b | 826 | |
Kojto | 39:d96aa62afc5b | 827 | if (RZA_IO_RegRead_16(&USB201.D1FIFOSEL, |
Kojto | 39:d96aa62afc5b | 828 | USB_DnFIFOSEL_CURPIPE_SHIFT, |
Kojto | 39:d96aa62afc5b | 829 | USB_DnFIFOSEL_CURPIPE) == pipe) |
Kojto | 39:d96aa62afc5b | 830 | { |
Kojto | 39:d96aa62afc5b | 831 | usb1_host_change_fifo_port(USB_HOST_PIPE0, USB_HOST_D1USE, USB_HOST_NO, USB_HOST_BITMBW_16); |
Kojto | 39:d96aa62afc5b | 832 | } |
Kojto | 39:d96aa62afc5b | 833 | |
Kojto | 39:d96aa62afc5b | 834 | /* Interrupt of pipe set is disabled */ |
Kojto | 39:d96aa62afc5b | 835 | usb1_host_disable_brdy_int(pipe); |
Kojto | 39:d96aa62afc5b | 836 | usb1_host_disable_nrdy_int(pipe); |
Kojto | 39:d96aa62afc5b | 837 | usb1_host_disable_bemp_int(pipe); |
Kojto | 39:d96aa62afc5b | 838 | |
Kojto | 39:d96aa62afc5b | 839 | /* Pipe to set is set to NAK */ |
Kojto | 39:d96aa62afc5b | 840 | usb1_host_set_pid_nak(pipe); |
Kojto | 39:d96aa62afc5b | 841 | |
Kojto | 39:d96aa62afc5b | 842 | /* Pipe is set */ |
Kojto | 39:d96aa62afc5b | 843 | USB201.PIPESEL = pipe; |
Kojto | 39:d96aa62afc5b | 844 | |
Kojto | 39:d96aa62afc5b | 845 | USB201.PIPECFG = tbl->pipe_cfg; |
Kojto | 39:d96aa62afc5b | 846 | USB201.PIPEBUF = tbl->pipe_buf; |
Kojto | 39:d96aa62afc5b | 847 | USB201.PIPEMAXP = tbl->pipe_max_pktsize; |
Kojto | 39:d96aa62afc5b | 848 | USB201.PIPEPERI = tbl->pipe_cycle; |
Kojto | 39:d96aa62afc5b | 849 | |
Kojto | 39:d96aa62afc5b | 850 | g_usb1_host_pipecfg[pipe] = tbl->pipe_cfg; |
Kojto | 39:d96aa62afc5b | 851 | g_usb1_host_pipebuf[pipe] = tbl->pipe_buf; |
Kojto | 39:d96aa62afc5b | 852 | g_usb1_host_pipemaxp[pipe] = tbl->pipe_max_pktsize; |
Kojto | 39:d96aa62afc5b | 853 | g_usb1_host_pipeperi[pipe] = tbl->pipe_cycle; |
Kojto | 39:d96aa62afc5b | 854 | |
Kojto | 39:d96aa62afc5b | 855 | /* Sequence bit clear */ |
Kojto | 39:d96aa62afc5b | 856 | usb1_host_set_sqclr(pipe); |
Kojto | 39:d96aa62afc5b | 857 | |
Kojto | 39:d96aa62afc5b | 858 | usb1_host_aclrm(pipe); |
Kojto | 39:d96aa62afc5b | 859 | usb1_host_set_csclr(pipe); |
Kojto | 39:d96aa62afc5b | 860 | |
Kojto | 39:d96aa62afc5b | 861 | /* Pipe window selection is set to unused */ |
Kojto | 39:d96aa62afc5b | 862 | USB201.PIPESEL = USB_HOST_PIPE0; |
Kojto | 39:d96aa62afc5b | 863 | |
Kojto | 39:d96aa62afc5b | 864 | } |
Kojto | 39:d96aa62afc5b | 865 | |
Kojto | 39:d96aa62afc5b | 866 | #if(1) /* ohci_wrapp */ |
Kojto | 39:d96aa62afc5b | 867 | #else |
Kojto | 39:d96aa62afc5b | 868 | /******************************************************************************* |
Kojto | 39:d96aa62afc5b | 869 | * Function Name: usb1_api_host_data_count |
Kojto | 39:d96aa62afc5b | 870 | * Description : Get g_usb0_host_data_count[pipe] |
Kojto | 39:d96aa62afc5b | 871 | * Arguments : uint16_t pipe ; Pipe Number |
Kojto | 39:d96aa62afc5b | 872 | * : uint32_t *data_count ; return g_usb0_data_count[pipe] |
Kojto | 39:d96aa62afc5b | 873 | * Return Value : DEVDRV_SUCCESS ; success |
Kojto | 39:d96aa62afc5b | 874 | * : DEVDRV_ERROR ; error |
Kojto | 39:d96aa62afc5b | 875 | *******************************************************************************/ |
Kojto | 39:d96aa62afc5b | 876 | int32_t usb1_api_host_data_count (uint16_t pipe, uint32_t * data_count) |
Kojto | 39:d96aa62afc5b | 877 | { |
Kojto | 39:d96aa62afc5b | 878 | if (pipe > USB_HOST_MAX_PIPE_NO) |
Kojto | 39:d96aa62afc5b | 879 | { |
Kojto | 39:d96aa62afc5b | 880 | return DEVDRV_ERROR; |
Kojto | 39:d96aa62afc5b | 881 | } |
Kojto | 39:d96aa62afc5b | 882 | |
Kojto | 39:d96aa62afc5b | 883 | *data_count = g_usb1_host_PipeDataSize[pipe]; |
Kojto | 39:d96aa62afc5b | 884 | |
Kojto | 39:d96aa62afc5b | 885 | return DEVDRV_SUCCESS; |
Kojto | 39:d96aa62afc5b | 886 | } |
Kojto | 39:d96aa62afc5b | 887 | #endif |
Kojto | 39:d96aa62afc5b | 888 | |
Kojto | 39:d96aa62afc5b | 889 | /* End of File */ |