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_controlrw.c@1:ab240722d7ef, 2017-02-15 (annotated)
- Committer:
- frq08711@LMECWL0871.LME.ST.COM
- Date:
- Wed Feb 15 10:49:44 2017 +0100
- Revision:
- 1:ab240722d7ef
update to mbed 5.3.5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2 | * DISCLAIMER |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 4 | * intended for use with Renesas products. No other uses are authorized. This |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 6 | * all applicable laws, including copyright laws. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 16 | * Renesas reserves the right, without notice, to make changes to this software |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 17 | * and to discontinue the availability of this software. By using this software, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 18 | * you agree to the additional terms and conditions found by accessing the |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 19 | * following link: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 20 | * http://www.renesas.com/disclaimer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 21 | * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 22 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 23 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 24 | * File Name : usb0_host_controlrw.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 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 63 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 64 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 65 | Private global variables and functions |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 66 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 67 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 68 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 69 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 70 | * Function Name: usb0_host_CtrlTransStart |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 71 | * Description : Executes USB control transfer. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 72 | * Arguments : uint16_t devadr ; device address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 73 | * : uint16_t Req ; bmRequestType & bRequest |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 74 | * : uint16_t Val ; wValue |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 75 | * : uint16_t Indx ; wIndex |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 76 | * : uint16_t Len ; wLength |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 77 | * : uint8_t *Buf ; Data buffer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 78 | * Return Value : DEVDRV_SUCCESS ; SUCCESS |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 79 | * : DEVDRV_ERROR ; ERROR |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 80 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 81 | int32_t usb0_host_CtrlTransStart (uint16_t devadr, uint16_t Req, uint16_t Val, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 82 | uint16_t Indx, uint16_t Len, uint8_t * Buf) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 83 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 84 | if (g_usb0_host_UsbDeviceSpeed == USB_HOST_LOW_SPEED) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 85 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 86 | RZA_IO_RegWrite_16(&USB200.SOFCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 87 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 88 | USB_SOFCFG_TRNENSEL_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 89 | USB_SOFCFG_TRNENSEL); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 90 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 91 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 92 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 93 | RZA_IO_RegWrite_16(&USB200.SOFCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 94 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 95 | USB_SOFCFG_TRNENSEL_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 96 | USB_SOFCFG_TRNENSEL); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 97 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 98 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 99 | USB200.DCPMAXP = (uint16_t)((uint16_t)(devadr << 12) + g_usb0_host_default_max_packet[devadr]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 100 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 101 | if (g_usb0_host_pipe_status[USB_HOST_PIPE0] == USB_HOST_PIPE_IDLE) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 102 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 103 | g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_WAIT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 104 | g_usb0_host_PipeIgnore[USB_HOST_PIPE0] = 0; /* Ignore count clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 105 | g_usb0_host_CmdStage = (USB_HOST_STAGE_SETUP | USB_HOST_CMD_IDLE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 106 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 107 | if (Len == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 108 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 109 | g_usb0_host_CmdStage |= USB_HOST_MODE_NO_DATA; /* No-data Control */ |
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 | if ((Req & 0x0080) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 114 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 115 | g_usb0_host_CmdStage |= USB_HOST_MODE_READ; /* Control Read */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 116 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 117 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 118 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 119 | g_usb0_host_CmdStage |= USB_HOST_MODE_WRITE; /* Control Write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 120 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 121 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 122 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 123 | g_usb0_host_SavReq = Req; /* save request */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 124 | g_usb0_host_SavVal = Val; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 125 | g_usb0_host_SavIndx = Indx; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 126 | g_usb0_host_SavLen = Len; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 127 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 128 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 129 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 130 | if ((g_usb0_host_SavReq != Req) || (g_usb0_host_SavVal != Val) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 131 | || (g_usb0_host_SavIndx != Indx) || (g_usb0_host_SavLen != Len)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 132 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 133 | return DEVDRV_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 134 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 135 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 136 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 137 | switch ((g_usb0_host_CmdStage & (USB_HOST_STAGE_FIELD | USB_HOST_CMD_FIELD))) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 138 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 139 | /* --------------- SETUP STAGE --------------- */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 140 | case (USB_HOST_STAGE_SETUP | USB_HOST_CMD_IDLE): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 141 | usb0_host_SetupStage(Req, Val, Indx, Len); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 142 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 143 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 144 | case (USB_HOST_STAGE_SETUP | USB_HOST_CMD_DOING): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 145 | /* do nothing */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 146 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 147 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 148 | case (USB_HOST_STAGE_SETUP | USB_HOST_CMD_DONE): /* goto next stage */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 149 | g_usb0_host_PipeIgnore[USB_HOST_PIPE0] = 0; /* Ignore count clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 150 | switch ((g_usb0_host_CmdStage & (USB_HOST_MODE_FIELD))) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 151 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 152 | case USB_HOST_MODE_WRITE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 153 | g_usb0_host_CmdStage &= (~USB_HOST_STAGE_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 154 | g_usb0_host_CmdStage |= USB_HOST_STAGE_DATA; |
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 | case USB_HOST_MODE_READ: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 158 | g_usb0_host_CmdStage &= (~USB_HOST_STAGE_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 159 | g_usb0_host_CmdStage |= USB_HOST_STAGE_DATA; |
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 | case USB_HOST_MODE_NO_DATA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 163 | g_usb0_host_CmdStage &= (~USB_HOST_STAGE_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 164 | g_usb0_host_CmdStage |= USB_HOST_STAGE_STATUS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 165 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 166 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 167 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 168 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 169 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 170 | g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 171 | g_usb0_host_CmdStage |= USB_HOST_CMD_IDLE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 172 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 173 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 174 | case (USB_HOST_STAGE_SETUP | USB_HOST_CMD_NORES): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 175 | if (g_usb0_host_PipeIgnore[USB_HOST_PIPE0] == 3) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 176 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 177 | g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_NORES; /* exit NORES */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 178 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 179 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 180 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 181 | g_usb0_host_PipeIgnore[USB_HOST_PIPE0]++; /* Ignore count */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 182 | g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 183 | g_usb0_host_CmdStage |= USB_HOST_CMD_IDLE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 184 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 185 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 186 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 187 | /* --------------- DATA STAGE --------------- */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 188 | case (USB_HOST_STAGE_DATA | USB_HOST_CMD_IDLE): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 189 | switch ((g_usb0_host_CmdStage & (USB_HOST_MODE_FIELD))) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 190 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 191 | case USB_HOST_MODE_WRITE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 192 | usb0_host_CtrlWriteStart((uint32_t)Len, Buf); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 193 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 194 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 195 | case USB_HOST_MODE_READ: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 196 | usb0_host_CtrlReadStart((uint32_t)Len, Buf); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 197 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 198 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 199 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 200 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 201 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 202 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 203 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 204 | case (USB_HOST_STAGE_DATA | USB_HOST_CMD_DOING): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 205 | /* do nothing */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 206 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 207 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 208 | case (USB_HOST_STAGE_DATA | USB_HOST_CMD_DONE): /* goto next stage */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 209 | g_usb0_host_PipeIgnore[USB_HOST_PIPE0] = 0; /* Ignore count clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 210 | g_usb0_host_CmdStage &= (~USB_HOST_STAGE_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 211 | g_usb0_host_CmdStage |= USB_HOST_STAGE_STATUS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 212 | g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 213 | g_usb0_host_CmdStage |= USB_HOST_CMD_IDLE; |
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 | case (USB_HOST_STAGE_DATA | USB_HOST_CMD_NORES): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 217 | if (g_usb0_host_PipeIgnore[USB_HOST_PIPE0] == 3) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 218 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 219 | g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_NORES; /* exit NORES */ |
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 | g_usb0_host_PipeIgnore[USB_HOST_PIPE0]++; /* Ignore count */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 224 | g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 225 | g_usb0_host_CmdStage |= USB_HOST_CMD_DOING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 226 | usb0_host_clear_pid_stall(USB_HOST_PIPE0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 227 | usb0_host_set_pid_buf(USB_HOST_PIPE0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 228 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 229 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 230 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 231 | case (USB_HOST_STAGE_DATA | USB_HOST_CMD_STALL): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 232 | g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_STALL; /* exit STALL */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 233 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 234 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 235 | /* --------------- STATUS STAGE --------------- */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 236 | case (USB_HOST_STAGE_STATUS | USB_HOST_CMD_IDLE): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 237 | usb0_host_StatusStage(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 238 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 239 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 240 | case (USB_HOST_STAGE_STATUS | USB_HOST_CMD_DOING): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 241 | /* do nothing */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 242 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 243 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 244 | case (USB_HOST_STAGE_STATUS | USB_HOST_CMD_DONE): /* end of Control transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 245 | usb0_host_set_pid_nak(USB_HOST_PIPE0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 246 | g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_DONE; /* exit DONE */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 247 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 248 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 249 | case (USB_HOST_STAGE_STATUS | USB_HOST_CMD_NORES): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 250 | if (g_usb0_host_PipeIgnore[USB_HOST_PIPE0] == 3) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 251 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 252 | g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_NORES; /* exit NORES */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 253 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 254 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 255 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 256 | g_usb0_host_PipeIgnore[USB_HOST_PIPE0]++; /* Ignore count */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 257 | g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 258 | g_usb0_host_CmdStage |= USB_HOST_CMD_DOING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 259 | usb0_host_clear_pid_stall(USB_HOST_PIPE0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 260 | usb0_host_set_pid_buf(USB_HOST_PIPE0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 261 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 262 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 263 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 264 | case (USB_HOST_STAGE_STATUS | USB_HOST_CMD_STALL): |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 265 | g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_STALL; /* exit STALL */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 266 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 267 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 268 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 269 | break; |
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[USB_HOST_PIPE0] != USB_HOST_PIPE_WAIT) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 273 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 274 | RZA_IO_RegWrite_16(&USB200.SOFCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 275 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 276 | USB_SOFCFG_TRNENSEL_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 277 | USB_SOFCFG_TRNENSEL); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 278 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 279 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 280 | return DEVDRV_SUCCESS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 281 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 282 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 283 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 284 | * Function Name: usb0_host_SetupStage |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 285 | * Description : Executes USB control transfer/set up stage. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 286 | * Arguments : uint16_t Req ; bmRequestType & bRequest |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 287 | * : uint16_t Val ; wValue |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 288 | * : uint16_t Indx ; wIndex |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 289 | * : uint16_t Len ; wLength |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 290 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 291 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 292 | void usb0_host_SetupStage (uint16_t Req, uint16_t Val, uint16_t Indx, uint16_t Len) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 293 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 294 | g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 295 | g_usb0_host_CmdStage |= USB_HOST_CMD_DOING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 296 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 297 | USB200.INTSTS1 = (uint16_t)~(USB_HOST_BITSACK | USB_HOST_BITSIGN); /* Status Clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 298 | USB200.USBREQ = Req; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 299 | USB200.USBVAL = Val; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 300 | USB200.USBINDX = Indx; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 301 | USB200.USBLENG = Len; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 302 | USB200.DCPCTR = USB_HOST_BITSUREQ; /* PID=NAK & Send Setup */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 303 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 304 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 305 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 306 | * Function Name: usb0_host_StatusStage |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 307 | * Description : Executes USB control transfer/status stage. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 308 | * Arguments : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 309 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 310 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 311 | void usb0_host_StatusStage (void) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 312 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 313 | uint8_t Buf1[16]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 314 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 315 | switch ((g_usb0_host_CmdStage & (USB_HOST_MODE_FIELD))) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 316 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 317 | case USB_HOST_MODE_READ: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 318 | usb0_host_CtrlWriteStart((uint32_t)0, (uint8_t *)&Buf1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 319 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 320 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 321 | case USB_HOST_MODE_WRITE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 322 | usb0_host_CtrlReadStart((uint32_t)0, (uint8_t *)&Buf1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 323 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 324 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 325 | case USB_HOST_MODE_NO_DATA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 326 | usb0_host_CtrlReadStart((uint32_t)0, (uint8_t *)&Buf1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 327 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 328 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 329 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 330 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 331 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 332 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 333 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 334 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 335 | * Function Name: usb0_host_CtrlWriteStart |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 336 | * Description : Executes USB control transfer/data stage(write). |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 337 | * Arguments : uint32_t Bsize ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 338 | * : uint8_t *Table ; Data Table Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 339 | * Return Value : USB_HOST_WRITESHRT ; End of data write |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 340 | * : USB_HOST_WRITEEND ; End of data write (not null) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 341 | * : USB_HOST_WRITING ; Continue of data write |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 342 | * : USB_HOST_FIFOERROR ; FIFO access error |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 343 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 344 | uint16_t usb0_host_CtrlWriteStart (uint32_t Bsize, uint8_t * Table) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 345 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 346 | uint16_t EndFlag_K; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 347 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 348 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 349 | g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 350 | g_usb0_host_CmdStage |= USB_HOST_CMD_DOING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 351 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 352 | usb0_host_set_pid_nak(USB_HOST_PIPE0); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 353 | g_usb0_host_data_count[USB_HOST_PIPE0] = Bsize; /* Transfer size set */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 354 | g_usb0_host_data_pointer[USB_HOST_PIPE0] = Table; /* Transfer address set */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 355 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 356 | USB200.DCPCTR = USB_HOST_BITSQSET; /* SQSET=1, PID=NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 357 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 358 | Userdef_USB_usb0_host_delay_10us(3); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 359 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 360 | RZA_IO_RegWrite_16(&USB200.DCPCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 361 | 1, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 362 | USB_DCPCFG_DIR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 363 | USB_DCPCFG_DIR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 364 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 365 | mbw = usb0_host_get_mbw(g_usb0_host_data_count[USB_HOST_PIPE0], (uint32_t)g_usb0_host_data_pointer[USB_HOST_PIPE0]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 366 | usb0_host_set_curpipe(USB_HOST_PIPE0, USB_HOST_CUSE, USB_HOST_BITISEL, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 367 | USB200.CFIFOCTR = USB_HOST_BITBCLR; /* Buffer Clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 368 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 369 | usb0_host_clear_pid_stall(USB_HOST_PIPE0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 370 | EndFlag_K = usb0_host_write_buffer_c(USB_HOST_PIPE0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 371 | /* Host Control sequence */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 372 | switch (EndFlag_K) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 373 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 374 | case USB_HOST_WRITESHRT: /* End of data write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 375 | g_usb0_host_CmdStage &= (~USB_HOST_STAGE_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 376 | g_usb0_host_CmdStage |= USB_HOST_STAGE_STATUS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 377 | usb0_host_enable_nrdy_int(USB_HOST_PIPE0); /* Error (NORES or STALL) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 378 | usb0_host_enable_bemp_int(USB_HOST_PIPE0); /* Enable Empty Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 379 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 380 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 381 | case USB_HOST_WRITEEND: /* End of data write (not null) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 382 | case USB_HOST_WRITING: /* Continue of data write */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 383 | usb0_host_enable_nrdy_int(USB_HOST_PIPE0); /* Error (NORES or STALL) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 384 | usb0_host_enable_bemp_int(USB_HOST_PIPE0); /* Enable Empty Interrupt */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 385 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 386 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 387 | case USB_HOST_FIFOERROR: /* FIFO access error */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 388 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 389 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 390 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 391 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 392 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 393 | usb0_host_set_pid_buf(USB_HOST_PIPE0); /* Set BUF */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 394 | return (EndFlag_K); /* End or Err or Continue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 395 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 396 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 397 | /******************************************************************************* |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 398 | * Function Name: usb0_host_CtrlReadStart |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 399 | * Description : Executes USB control transfer/data stage(read). |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 400 | * Arguments : uint32_t Bsize ; Data Size |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 401 | * : uint8_t *Table ; Data Table Address |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 402 | * Return Value : none |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 403 | *******************************************************************************/ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 404 | void usb0_host_CtrlReadStart (uint32_t Bsize, uint8_t * Table) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 405 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 406 | uint16_t mbw; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 407 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 408 | g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 409 | g_usb0_host_CmdStage |= USB_HOST_CMD_DOING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 410 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 411 | usb0_host_set_pid_nak(USB_HOST_PIPE0); /* Set NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 412 | g_usb0_host_data_count[USB_HOST_PIPE0] = Bsize; /* Transfer size set */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 413 | g_usb0_host_data_pointer[USB_HOST_PIPE0] = Table; /* Transfer address set */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 414 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 415 | USB200.DCPCTR = USB_HOST_BITSQSET; /* SQSET=1, PID=NAK */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 416 | #if(1) /* ohci_wrapp */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 417 | Userdef_USB_usb0_host_delay_10us(3); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 418 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 419 | RZA_IO_RegWrite_16(&USB200.DCPCFG, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 420 | 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 421 | USB_DCPCFG_DIR_SHIFT, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 422 | USB_DCPCFG_DIR); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 423 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 424 | mbw = usb0_host_get_mbw(g_usb0_host_data_count[USB_HOST_PIPE0], (uint32_t)g_usb0_host_data_pointer[USB_HOST_PIPE0]); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 425 | usb0_host_set_curpipe(USB_HOST_PIPE0, USB_HOST_CUSE, USB_HOST_NO, mbw); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 426 | USB200.CFIFOCTR = USB_HOST_BITBCLR; /* Buffer Clear */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 427 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 428 | usb0_host_enable_nrdy_int(USB_HOST_PIPE0); /* Error (NORES or STALL) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 429 | usb0_host_enable_brdy_int(USB_HOST_PIPE0); /* Ok */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 430 | usb0_host_clear_pid_stall(USB_HOST_PIPE0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 431 | usb0_host_set_pid_buf(USB_HOST_PIPE0); /* Set BUF */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 432 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 433 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 434 | /* End of File */ |