forked for unsupported target
Dependents: stm32-disco-example DISCO-F469NI_BD_SD_Card_Control
Fork of USBHOST by
USBHost/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/host/usb0_host_drv_api.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 : usb0_host_drv_api.c |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 25 | * $Rev: 1116 $ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 26 | * $Date:: 2014-07-09 16:29:19 +0900#$ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 27 | * Device(s) : RZ/A1H |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 28 | * Tool-Chain : |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 29 | * OS : None |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 30 | * H/W Platform : |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 31 | * Description : RZ/A1H R7S72100 USB Sample Program |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 32 | * Operation : |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 33 | * Limitations : |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 34 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 35 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 36 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 37 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 38 | Includes <System Includes> , "Project Includes" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 39 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 40 | #include "usb0_host.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 41 | #include "dev_drv.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 42 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 43 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 44 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 45 | Typedef definitions |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 46 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 47 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 48 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 49 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 50 | Macro definitions |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 51 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 52 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 53 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 54 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 55 | Imported global variables and functions (from other files) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 56 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 57 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 58 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 59 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 60 | Exported global variables and functions (to be accessed by other files) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 61 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 62 | static void usb0_host_resetEP(USB_HOST_CFG_PIPETBL_t *tbl); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 63 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 64 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 65 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 66 | Private global variables and functions |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 67 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 68 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 69 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 70 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 71 | * Function Name: usb0_api_host_init |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 72 | * Description : Initializes USB module in the USB host mode. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 73 | * : USB connection is executed when executing this function in |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 74 | * : the states that USB device isconnected to the USB port. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 75 | * Arguments : uint8_t int_level : USB Module interrupt level |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 76 | * : USBU16 mode : USB_HOST_HIGH_SPEED |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 77 | * : USB_HOST_FULL_SPEED |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 78 | * : uint16_t clockmode : USB Clock mode |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 79 | * Return Value : USB detach or attach |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 80 | * : USB_HOST_ATTACH |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 81 | * : USB_HOST_DETACH |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 82 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 83 | uint16_t usb0_api_host_init (uint8_t int_level, uint16_t mode, uint16_t clockmode) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 84 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 85 | uint16_t connect; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 86 | volatile uint8_t dummy_buf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 87 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 88 | CPG.STBCR7 &= 0xfd; /*The clock of USB0 modules is permitted */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 89 | dummy_buf = CPG.STBCR7; /* (Dummy read) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 90 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 91 | g_usb0_host_SupportUsbDeviceSpeed = mode; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 92 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 93 | usb0_host_setting_interrupt(int_level); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 94 | usb0_host_reset_module(clockmode); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 95 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 96 | g_usb0_host_bchg_flag = USB_HOST_NO; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 97 | g_usb0_host_detach_flag = USB_HOST_NO; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 98 | g_usb0_host_attach_flag = USB_HOST_NO; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 99 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 100 | g_usb0_host_driver_state = USB_HOST_DRV_DETACHED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 101 | g_usb0_host_default_max_packet[USB_HOST_DEVICE_0] = 64; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 102 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 103 | usb0_host_InitModule(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 104 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 105 | connect = usb0_host_CheckAttach(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 106 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 107 | if (connect == USB_HOST_ATTACH) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 108 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 109 | g_usb0_host_attach_flag = USB_HOST_YES; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 110 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 111 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 112 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 113 | usb0_host_UsbDetach2(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 114 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 115 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 116 | return connect; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 117 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 118 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 119 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 120 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 121 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 122 | * Function Name: usb0_api_host_enumeration |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 123 | * Description : Initializes USB module in the USB host mode. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 124 | * : USB connection is executed when executing this function in |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 125 | * : the states that USB device isconnected to the USB port. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 126 | * Arguments : uint16_t devadr : device address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 127 | * Return Value : DEVDRV_USBH_DETACH_ERR : device detach |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 128 | * : DEVDRV_SUCCESS : device enumeration success |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 129 | * : DEVDRV_ERROR : device enumeration error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 130 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 131 | int32_t usb0_api_host_enumeration (uint16_t devadr) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 132 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 133 | int32_t ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 134 | uint16_t driver_sts; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 135 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 136 | g_usb0_host_setUsbAddress = devadr; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 137 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 138 | while (1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 139 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 140 | driver_sts = usb0_api_host_GetUsbDeviceState(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 141 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 142 | if (driver_sts == USB_HOST_DRV_DETACHED) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 143 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 144 | ret = DEVDRV_USBH_DETACH_ERR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 145 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 146 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 147 | else if (driver_sts == USB_HOST_DRV_CONFIGURED) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 148 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 149 | ret = DEVDRV_SUCCESS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 150 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 151 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 152 | else if (driver_sts == USB_HOST_DRV_STALL) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 153 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 154 | ret = DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 155 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 156 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 157 | else if (driver_sts == USB_HOST_DRV_NORES) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 158 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 159 | ret = DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 160 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 161 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 162 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 163 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 164 | /* Do Nothing */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 165 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 166 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 167 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 168 | if (driver_sts == USB_HOST_DRV_NORES) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 169 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 170 | while (1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 171 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 172 | driver_sts = usb0_api_host_GetUsbDeviceState(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 173 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 174 | if (driver_sts == USB_HOST_DRV_DETACHED) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 175 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 176 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 177 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 178 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 179 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 180 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 181 | return ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 182 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 183 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 184 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 185 | * Function Name: usb0_api_host_detach |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 186 | * Description : USB detach routine |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 187 | * Arguments : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 188 | * Return Value : USB_HOST_DETACH : USB detach |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 189 | * : USB_HOST_ATTACH : USB attach |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 190 | * : DEVDRV_ERROR : error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 191 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 192 | int32_t usb0_api_host_detach (void) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 193 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 194 | int32_t ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 195 | uint16_t driver_sts; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 196 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 197 | while (1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 198 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 199 | driver_sts = usb0_api_host_GetUsbDeviceState(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 200 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 201 | if (driver_sts == USB_HOST_DRV_DETACHED) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 202 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 203 | ret = USB_HOST_DETACH; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 204 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 205 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 206 | else if (driver_sts == USB_HOST_DRV_CONFIGURED) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 207 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 208 | ret = USB_HOST_ATTACH; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 209 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 210 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 211 | else if (driver_sts == USB_HOST_DRV_STALL) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 212 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 213 | ret = DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 214 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 215 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 216 | else if (driver_sts == USB_HOST_DRV_NORES) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 217 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 218 | ret = DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 219 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 220 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 221 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 222 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 223 | /* Do Nothing */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 224 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 225 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 226 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 227 | if (driver_sts == USB_HOST_DRV_NORES) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 228 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 229 | while (1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 230 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 231 | driver_sts = usb0_api_host_GetUsbDeviceState(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 232 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 233 | if (driver_sts == USB_HOST_DRV_DETACHED) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 234 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 235 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 236 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 237 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 238 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 239 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 240 | return ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 241 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 242 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 243 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 244 | * Function Name: usb0_api_host_data_in |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 245 | * Description : Executes USB transfer as data-in in the argument specified pipe. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 246 | * Arguments : uint16_t devadr ; device address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 247 | * : uint16_t Pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 248 | * : uint32_t Size ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 249 | * : uint8_t *data_buf ; Data data_buf Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 250 | * Return Value : DEVDRV_SUCCESS ; success |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 251 | * : DEVDRV_ERROR ; error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 252 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 253 | int32_t usb0_api_host_data_in (uint16_t devadr, uint16_t Pipe, uint32_t Size, uint8_t * data_buf) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 254 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 255 | int32_t ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 256 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 257 | if (Pipe == USB_HOST_PIPE0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 258 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 259 | return DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 260 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 261 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 262 | if (RZA_IO_RegRead_16(&g_usb0_host_pipemaxp[Pipe], USB_PIPEMAXP_DEVSEL_SHIFT, USB_PIPEMAXP_DEVSEL) != devadr) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 263 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 264 | return DEVDRV_ERROR; |
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 (RZA_IO_RegRead_16(&g_usb0_host_pipecfg[Pipe], USB_PIPECFG_DIR_SHIFT, USB_PIPECFG_DIR) == 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 268 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 269 | return DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 270 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 271 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 272 | if (g_usb0_host_pipe_status[Pipe] == USB_HOST_PIPE_IDLE) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 273 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 274 | usb0_host_start_receive_transfer(Pipe, Size, data_buf); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 275 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 276 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 277 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 278 | return DEVDRV_ERROR; /* Now pipe is busy */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 279 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 280 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 281 | /* waiting for completing routine */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 282 | do |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 283 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 284 | if (g_usb0_host_detach_flag == USB_HOST_YES) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 285 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 286 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 287 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 288 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 289 | if ((g_usb0_host_pipe_status[Pipe] != USB_HOST_PIPE_IDLE) && (g_usb0_host_pipe_status[Pipe] != USB_HOST_PIPE_WAIT)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 290 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 291 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 292 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 293 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 294 | } while (1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 295 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 296 | if (g_usb0_host_detach_flag == USB_HOST_YES) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 297 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 298 | return DEVDRV_USBH_DETACH_ERR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 299 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 300 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 301 | switch (g_usb0_host_pipe_status[Pipe]) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 302 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 303 | case USB_HOST_PIPE_DONE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 304 | ret = DEVDRV_SUCCESS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 305 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 306 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 307 | case USB_HOST_PIPE_STALL: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 308 | ret = DEVDRV_USBH_STALL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 309 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 310 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 311 | case USB_HOST_PIPE_NORES: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 312 | ret = DEVDRV_USBH_COM_ERR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 313 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 314 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 315 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 316 | ret = DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 317 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 318 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 319 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 320 | usb0_host_stop_transfer(Pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 321 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 322 | g_usb0_host_pipe_status[Pipe] = USB_HOST_PIPE_IDLE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 323 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 324 | return ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 325 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 326 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 327 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 328 | * Function Name: usb0_api_host_data_out |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 329 | * Description : Executes USB transfer as data-out in the argument specified pipe. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 330 | * Arguments : uint16_t devadr ; device address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 331 | * : uint16_t Pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 332 | * : uint32_t Size ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 333 | * : uint8_t *data_buf ; Data data_buf Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 334 | * Return Value : DEVDRV_SUCCESS ; success |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 335 | * : DEVDRV_ERROR ; error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 336 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 337 | int32_t usb0_api_host_data_out (uint16_t devadr, uint16_t Pipe, uint32_t Size, uint8_t * data_buf) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 338 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 339 | int32_t ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 340 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 341 | if (Pipe == USB_HOST_PIPE0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 342 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 343 | return DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 344 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 345 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 346 | if (RZA_IO_RegRead_16(&g_usb0_host_pipemaxp[Pipe], USB_PIPEMAXP_DEVSEL_SHIFT, USB_PIPEMAXP_DEVSEL) != devadr) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 347 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 348 | return DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 349 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 350 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 351 | if (RZA_IO_RegRead_16(&g_usb0_host_pipecfg[Pipe], USB_PIPECFG_DIR_SHIFT, USB_PIPECFG_DIR) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 352 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 353 | return DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 354 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 355 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 356 | if (g_usb0_host_pipe_status[Pipe] == USB_HOST_PIPE_IDLE) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 357 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 358 | usb0_host_start_send_transfer(Pipe, Size, data_buf); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 359 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 360 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 361 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 362 | return DEVDRV_ERROR; /* Now pipe is busy */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 363 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 364 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 365 | /* waiting for completing routine */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 366 | do |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 367 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 368 | if (g_usb0_host_detach_flag == USB_HOST_YES) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 369 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 370 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 371 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 372 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 373 | if ((g_usb0_host_pipe_status[Pipe] != USB_HOST_PIPE_IDLE) && (g_usb0_host_pipe_status[Pipe] != USB_HOST_PIPE_WAIT)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 374 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 375 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 376 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 377 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 378 | } while (1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 379 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 380 | if (g_usb0_host_detach_flag == USB_HOST_YES) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 381 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 382 | return DEVDRV_USBH_DETACH_ERR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 383 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 384 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 385 | switch (g_usb0_host_pipe_status[Pipe]) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 386 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 387 | case USB_HOST_PIPE_DONE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 388 | ret = DEVDRV_SUCCESS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 389 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 390 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 391 | case USB_HOST_PIPE_STALL: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 392 | ret = DEVDRV_USBH_STALL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 393 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 394 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 395 | case USB_HOST_PIPE_NORES: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 396 | ret = DEVDRV_USBH_COM_ERR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 397 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 398 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 399 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 400 | ret = DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 401 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 402 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 403 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 404 | usb0_host_stop_transfer(Pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 405 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 406 | g_usb0_host_pipe_status[Pipe] = USB_HOST_PIPE_IDLE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 407 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 408 | return ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 409 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 410 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 411 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 412 | * Function Name: usb0_api_host_control_transfer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 413 | * Description : Executes USB control transfer. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 414 | * Arguments : uint16_t devadr ; device address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 415 | * : uint16_t Req ; bmRequestType & bRequest |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 416 | * : uint16_t Val ; wValue |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 417 | * : uint16_t Indx ; wIndex |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 418 | * : uint16_t Len ; wLength |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 419 | * : uint8_t *buf ; Buffer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 420 | * Return Value : DEVDRV_SUCCESS ; success |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 421 | * : DEVDRV_USBH_DETACH_ERR ; device detach |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 422 | * : DEVDRV_USBH_CTRL_COM_ERR ; device no response |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 423 | * : DEVDRV_USBH_STALL ; STALL |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 424 | * : DEVDRV_ERROR ; error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 425 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 426 | int32_t usb0_api_host_control_transfer (uint16_t devadr, uint16_t Req, uint16_t Val, uint16_t Indx, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 427 | uint16_t Len, uint8_t * Buf) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 428 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 429 | int32_t ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 430 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 431 | do |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 432 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 433 | ret = usb0_host_CtrlTransStart(devadr, Req, Val, Indx, Len, Buf); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 434 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 435 | if (ret == DEVDRV_SUCCESS) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 436 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 437 | if (g_usb0_host_detach_flag == USB_HOST_YES) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 438 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 439 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 440 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 441 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 442 | if ((g_usb0_host_pipe_status[USB_HOST_PIPE0] != USB_HOST_PIPE_IDLE) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 443 | && (g_usb0_host_pipe_status[USB_HOST_PIPE0] != USB_HOST_PIPE_WAIT)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 444 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 445 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 446 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 447 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 448 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 449 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 450 | return DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 451 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 452 | } while (1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 453 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 454 | if (g_usb0_host_detach_flag == USB_HOST_YES) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 455 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 456 | return DEVDRV_USBH_DETACH_ERR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 457 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 458 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 459 | switch (g_usb0_host_pipe_status[USB_HOST_PIPE0]) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 460 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 461 | case USB_HOST_PIPE_DONE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 462 | ret = DEVDRV_SUCCESS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 463 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 464 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 465 | case USB_HOST_PIPE_STALL: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 466 | ret = DEVDRV_USBH_STALL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 467 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 468 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 469 | case USB_HOST_PIPE_NORES: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 470 | ret = DEVDRV_USBH_CTRL_COM_ERR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 471 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 472 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 473 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 474 | ret = DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 475 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 476 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 477 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 478 | g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_IDLE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 479 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 480 | return ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 481 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 482 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 483 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 484 | * Function Name: usb0_api_host_set_endpoint |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 485 | * Description : Sets end point on the information specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 486 | * Arguments : uint16_t devadr ; device address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 487 | * : uint8_t *configdescriptor ; device configration descriptor |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 488 | * : USB_HOST_CFG_PIPETBL_t *user_table ; pipe table |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 489 | * Return Value : DEVDRV_SUCCESS ; success |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 490 | * : DEVDRV_ERROR ; error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 491 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 492 | int32_t usb0_api_host_set_endpoint (uint16_t devadr, USB_HOST_CFG_PIPETBL_t * user_table, uint8_t * configdescriptor) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 493 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 494 | uint16_t ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 495 | uint32_t end_point; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 496 | uint32_t offset; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 497 | uint32_t totalLength; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 498 | USB_HOST_CFG_PIPETBL_t * pipe_table; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 499 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 500 | /* End Point Search */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 501 | end_point = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 502 | offset = configdescriptor[0]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 503 | totalLength = (uint16_t)(configdescriptor[2] + ((uint16_t)configdescriptor[3] << 8)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 504 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 505 | do |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 506 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 507 | if (configdescriptor[offset + 1] == USB_HOST_ENDPOINT_DESC) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 508 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 509 | pipe_table = &user_table[end_point]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 510 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 511 | if (pipe_table->pipe_number == 0xffff) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 512 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 513 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 514 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 515 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 516 | ret = usb0_api_host_SetEndpointTable(devadr, pipe_table, (uint8_t *)&configdescriptor[offset]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 517 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 518 | if ((ret != USB_HOST_PIPE_IN) && (ret != USB_HOST_PIPE_OUT)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 519 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 520 | return DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 521 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 522 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 523 | ++end_point; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 524 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 525 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 526 | /* Next End Point Search */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 527 | offset += configdescriptor[offset]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 528 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 529 | } while (offset < totalLength); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 530 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 531 | return DEVDRV_SUCCESS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 532 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 533 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 534 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 535 | * Function Name: usb0_api_host_clear_endpoint |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 536 | * Description : Clears the pipe definition table specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 537 | * Arguments : USB_HOST_CFG_PIPETBL_t *user_table : pipe table |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 538 | * Return Value : DEVDRV_SUCCESS ; success |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 539 | * : DEVDRV_ERROR ; error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 540 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 541 | int32_t usb0_api_host_clear_endpoint (USB_HOST_CFG_PIPETBL_t * user_table) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 542 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 543 | uint16_t pipe; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 544 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 545 | for (pipe = USB_HOST_PIPE0; pipe <= USB_HOST_MAX_PIPE_NO; ++pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 546 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 547 | if (user_table->pipe_number == 0xffff) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 548 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 549 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 550 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 551 | user_table->pipe_cfg &= (USB_HOST_DBLBFIELD | USB_HOST_CNTMDFIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 552 | user_table->pipe_max_pktsize = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 553 | user_table->pipe_cycle = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 554 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 555 | user_table++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 556 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 557 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 558 | return DEVDRV_SUCCESS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 559 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 560 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 561 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 562 | * Function Name: usb0_api_host_clear_endpoint_pipe |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 563 | * Description : Clears the pipe definition table specified in the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 564 | * Arguments : uint16_t pipe_sel : Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 565 | * : USB_HOST_CFG_PIPETBL_t *user_table : pipe table |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 566 | * Return Value : DEVDRV_SUCCESS ; success |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 567 | * : DEVDRV_ERROR ; error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 568 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 569 | int32_t usb0_api_host_clear_endpoint_pipe (uint16_t pipe_sel, USB_HOST_CFG_PIPETBL_t * user_table) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 570 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 571 | uint16_t pipe; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 572 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 573 | for (pipe = USB_HOST_PIPE0; pipe <= USB_HOST_MAX_PIPE_NO; ++pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 574 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 575 | if (user_table->pipe_number == 0xffff) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 576 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 577 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 578 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 579 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 580 | if (user_table->pipe_number == pipe_sel) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 581 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 582 | user_table->pipe_cfg &= (USB_HOST_DBLBFIELD | USB_HOST_CNTMDFIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 583 | user_table->pipe_max_pktsize = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 584 | user_table->pipe_cycle = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 585 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 586 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 587 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 588 | user_table++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 589 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 590 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 591 | return DEVDRV_SUCCESS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 592 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 593 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 594 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 595 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 596 | * Function Name: usb0_api_host_SetEndpointTable |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 597 | * Description : Sets the end point on the information specified by the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 598 | * Arguments : uint16_t devadr : device address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 599 | * : USB_HOST_CFG_PIPETBL_t *user_table : pipe table |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 600 | * : uint8_t *Table : Endpoint descriptor |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 601 | * Return Value : USB_HOST_DIR_H_IN ; IN endpoint |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 602 | * : USB_HOST_DIR_H_OUT ; OUT endpoint |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 603 | * : USB_END_POINT_ERROR ; error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 604 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 605 | uint16_t usb0_api_host_SetEndpointTable (uint16_t devadr, USB_HOST_CFG_PIPETBL_t * user_table, uint8_t * Table) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 606 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 607 | uint16_t PipeCfg; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 608 | uint16_t PipeMaxp; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 609 | uint16_t pipe_number; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 610 | uint16_t ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 611 | uint16_t ret_flag = 0; // avoid warning. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 612 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 613 | pipe_number = user_table->pipe_number; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 614 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 615 | if (Table[1] != USB_HOST_ENDPOINT_DESC) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 616 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 617 | return USB_END_POINT_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 618 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 619 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 620 | switch (Table[3] & USB_HOST_EP_TYPE) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 621 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 622 | case USB_HOST_EP_CNTRL: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 623 | ret_flag = USB_END_POINT_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 624 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 625 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 626 | case USB_HOST_EP_ISO: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 627 | if ((pipe_number != USB_HOST_PIPE1) && (pipe_number != USB_HOST_PIPE2)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 628 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 629 | return USB_END_POINT_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 630 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 631 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 632 | PipeCfg = USB_HOST_ISO; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 633 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 634 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 635 | case USB_HOST_EP_BULK: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 636 | if ((pipe_number < USB_HOST_PIPE1) || (pipe_number > USB_HOST_PIPE5)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 637 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 638 | return USB_END_POINT_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 639 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 640 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 641 | PipeCfg = USB_HOST_BULK; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 642 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 643 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 644 | case USB_HOST_EP_INT: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 645 | if ((pipe_number < USB_HOST_PIPE6) || (pipe_number > USB_HOST_PIPE9)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 646 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 647 | return USB_END_POINT_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 648 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 649 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 650 | PipeCfg = USB_HOST_INTERRUPT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 651 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 652 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 653 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 654 | ret_flag = USB_END_POINT_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 655 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 656 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 657 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 658 | if (ret_flag == USB_END_POINT_ERROR) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 659 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 660 | return ret_flag; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 661 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 662 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 663 | /* Set pipe configuration table */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 664 | if ((Table[2] & USB_HOST_EP_DIR_MASK) == USB_HOST_EP_IN) /* IN(receive) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 665 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 666 | if (PipeCfg == USB_HOST_ISO) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 667 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 668 | /* Transfer Type is ISO*/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 669 | PipeCfg |= USB_HOST_DIR_H_IN; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 670 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 671 | switch (user_table->fifo_port) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 672 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 673 | case USB_HOST_CUSE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 674 | case USB_HOST_D0USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 675 | case USB_HOST_D1USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 676 | case USB_HOST_D0DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 677 | case USB_HOST_D1DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 678 | PipeCfg |= (uint16_t)(user_table->pipe_cfg & USB_HOST_DBLBFIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 679 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 680 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 681 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 682 | ret_flag = USB_END_POINT_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 683 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 684 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 685 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 686 | if (ret_flag == USB_END_POINT_ERROR) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 687 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 688 | return ret_flag; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 689 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 690 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 691 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 692 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 693 | /* Transfer Type is BULK or INT */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 694 | PipeCfg |= (USB_HOST_SHTNAKON | USB_HOST_DIR_H_IN); /* Compulsory SHTNAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 695 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 696 | switch (user_table->fifo_port) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 697 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 698 | case USB_HOST_CUSE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 699 | case USB_HOST_D0USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 700 | case USB_HOST_D1USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 701 | PipeCfg |= (uint16_t)(user_table->pipe_cfg & (USB_HOST_DBLBFIELD | USB_HOST_CNTMDFIELD)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 702 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 703 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 704 | case USB_HOST_D0DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 705 | case USB_HOST_D1DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 706 | PipeCfg |= (uint16_t)(user_table->pipe_cfg & (USB_HOST_DBLBFIELD | USB_HOST_CNTMDFIELD)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 707 | #ifdef __USB_DMA_BFRE_ENABLE__ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 708 | /* this routine cannnot be perfomred if read operation is executed in buffer size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 709 | PipeCfg |= USB_HOST_BFREON; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 710 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 711 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 712 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 713 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 714 | ret_flag = USB_END_POINT_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 715 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 716 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 717 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 718 | if (ret_flag == USB_END_POINT_ERROR) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 719 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 720 | return ret_flag; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 721 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 722 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 723 | ret = USB_HOST_PIPE_IN; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 724 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 725 | else /* OUT(send) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 726 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 727 | if (PipeCfg == USB_HOST_ISO) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 728 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 729 | /* Transfer Type is ISO*/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 730 | PipeCfg |= (uint16_t)(user_table->pipe_cfg & USB_HOST_DBLBFIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 731 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 732 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 733 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 734 | /* Transfer Type is BULK or INT */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 735 | PipeCfg |= (uint16_t)(user_table->pipe_cfg & (USB_HOST_DBLBFIELD | USB_HOST_CNTMDFIELD)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 736 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 737 | PipeCfg |= USB_HOST_DIR_H_OUT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 738 | ret = USB_HOST_PIPE_OUT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 739 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 740 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 741 | switch (user_table->fifo_port) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 742 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 743 | case USB_HOST_CUSE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 744 | g_usb0_host_PipeTbl[pipe_number] = (uint16_t)USB_HOST_CFIFO_USE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 745 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 746 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 747 | case USB_HOST_D0USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 748 | g_usb0_host_PipeTbl[pipe_number] = (uint16_t)USB_HOST_D0FIFO_USE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 749 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 750 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 751 | case USB_HOST_D1USE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 752 | g_usb0_host_PipeTbl[pipe_number] = (uint16_t)USB_HOST_D1FIFO_USE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 753 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 754 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 755 | case USB_HOST_D0DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 756 | g_usb0_host_PipeTbl[pipe_number] = (uint16_t)USB_HOST_D0FIFO_DMA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 757 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 758 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 759 | case USB_HOST_D1DMA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 760 | g_usb0_host_PipeTbl[pipe_number] = (uint16_t)USB_HOST_D1FIFO_DMA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 761 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 762 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 763 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 764 | ret_flag = USB_END_POINT_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 765 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 766 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 767 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 768 | if (ret_flag == USB_END_POINT_ERROR) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 769 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 770 | return ret_flag; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 771 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 772 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 773 | /* Endpoint number set */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 774 | PipeCfg |= (uint16_t)(Table[2] & USB_HOST_EP_NUM_MASK); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 775 | g_usb0_host_PipeTbl[pipe_number] |= (uint16_t)(Table[2] & USB_HOST_EP_NUM_MASK); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 776 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 777 | /* Max packet size set */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 778 | PipeMaxp = (uint16_t)((uint16_t)Table[4] | (uint16_t)((uint16_t)Table[5] << 8)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 779 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 780 | if (PipeMaxp == 0u) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 781 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 782 | return USB_END_POINT_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 783 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 784 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 785 | /* Set device address */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 786 | PipeMaxp |= (uint16_t)(devadr << 12); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 787 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 788 | user_table->pipe_cfg = PipeCfg; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 789 | user_table->pipe_max_pktsize = PipeMaxp; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 790 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 791 | usb0_host_resetEP(user_table); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 792 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 793 | return ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 794 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 795 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 796 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 797 | * Function Name: usb0_host_resetEP |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 798 | * Description : Sets the end point on the information specified by the argument. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 799 | * Arguments : USB_HOST_CFG_PIPETBL_t *tbl : pipe table |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 800 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 801 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 802 | static void usb0_host_resetEP (USB_HOST_CFG_PIPETBL_t * tbl) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 803 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 804 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 805 | uint16_t pipe; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 806 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 807 | /* Host pipe */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 808 | /* The pipe number of pipe definition table is obtained */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 809 | pipe = (uint16_t)(tbl->pipe_number & USB_HOST_BITCURPIPE); /* Pipe Number */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 810 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 811 | /* FIFO port access pipe is set to initial value */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 812 | /* The connection with FIFO should be cut before setting the pipe */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 813 | if (RZA_IO_RegRead_16(&USB200.CFIFOSEL, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 814 | USB_CFIFOSEL_CURPIPE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 815 | USB_CFIFOSEL_CURPIPE) == pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 816 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 817 | usb0_host_change_fifo_port(USB_HOST_PIPE0, USB_HOST_CUSE, USB_HOST_NO, USB_HOST_BITMBW_16); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 818 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 819 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 820 | if (RZA_IO_RegRead_16(&USB200.D0FIFOSEL, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 821 | USB_DnFIFOSEL_CURPIPE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 822 | USB_DnFIFOSEL_CURPIPE) == pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 823 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 824 | usb0_host_change_fifo_port(USB_HOST_PIPE0, USB_HOST_D0USE, USB_HOST_NO, USB_HOST_BITMBW_16); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 825 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 826 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 827 | if (RZA_IO_RegRead_16(&USB200.D1FIFOSEL, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 828 | USB_DnFIFOSEL_CURPIPE_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 829 | USB_DnFIFOSEL_CURPIPE) == pipe) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 830 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 831 | usb0_host_change_fifo_port(USB_HOST_PIPE0, USB_HOST_D1USE, USB_HOST_NO, USB_HOST_BITMBW_16); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 832 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 833 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 834 | /* Interrupt of pipe set is disabled */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 835 | usb0_host_disable_brdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 836 | usb0_host_disable_nrdy_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 837 | usb0_host_disable_bemp_int(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 838 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 839 | /* Pipe to set is set to NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 840 | usb0_host_set_pid_nak(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 841 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 842 | /* Pipe is set */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 843 | USB200.PIPESEL = pipe; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 844 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 845 | USB200.PIPECFG = tbl->pipe_cfg; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 846 | USB200.PIPEBUF = tbl->pipe_buf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 847 | USB200.PIPEMAXP = tbl->pipe_max_pktsize; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 848 | USB200.PIPEPERI = tbl->pipe_cycle; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 849 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 850 | g_usb0_host_pipecfg[pipe] = tbl->pipe_cfg; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 851 | g_usb0_host_pipebuf[pipe] = tbl->pipe_buf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 852 | g_usb0_host_pipemaxp[pipe] = tbl->pipe_max_pktsize; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 853 | g_usb0_host_pipeperi[pipe] = tbl->pipe_cycle; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 854 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 855 | /* Sequence bit clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 856 | usb0_host_set_sqclr(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 857 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 858 | usb0_host_aclrm(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 859 | usb0_host_set_csclr(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 860 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 861 | /* Pipe window selection is set to unused */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 862 | USB200.PIPESEL = USB_HOST_PIPE0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 863 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 864 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 865 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 866 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 867 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 868 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 869 | * Function Name: usb0_api_host_data_count |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 870 | * Description : Get g_usb0_host_data_count[pipe] |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 871 | * Arguments : uint16_t pipe ; Pipe Number |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 872 | * : uint32_t *data_count ; return g_usb0_data_count[pipe] |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 873 | * Return Value : DEVDRV_SUCCESS ; success |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 874 | * : DEVDRV_ERROR ; error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 875 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 876 | int32_t usb0_api_host_data_count (uint16_t pipe, uint32_t * data_count) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 877 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 878 | if (pipe > USB_HOST_MAX_PIPE_NO) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 879 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 880 | return DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 881 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 882 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 883 | *data_count = g_usb0_host_PipeDataSize[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 884 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 885 | return DEVDRV_SUCCESS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 886 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 887 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 888 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 889 | /* End of File */ |