USBHost library. NOTE: This library is only officially supported on the LPC1768 platform. For more information, please see the handbook page.

Dependencies:   FATFileSystem mbed-rtos

Dependents:   BTstack WallbotWii SD to Flash Data Transfer USBHost-MSD_HelloWorld ... more

Legacy Warning

This is an mbed 2 library. To learn more about mbed OS 5, visit the docs.

Pull requests against this repository are no longer supported. Please raise against mbed OS 5 as documented above.

Committer:
Kojto
Date:
Thu Jul 27 12:24:30 2017 +0100
Revision:
39:d96aa62afc5b
Update USBHost - add targets directory

This corresponds to mbed-os/master commit 9207365

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 39:d96aa62afc5b 1 /*******************************************************************************
Kojto 39:d96aa62afc5b 2 * DISCLAIMER
Kojto 39:d96aa62afc5b 3 * This software is supplied by Renesas Electronics Corporation and is only
Kojto 39:d96aa62afc5b 4 * intended for use with Renesas products. No other uses are authorized. This
Kojto 39:d96aa62afc5b 5 * software is owned by Renesas Electronics Corporation and is protected under
Kojto 39:d96aa62afc5b 6 * all applicable laws, including copyright laws.
Kojto 39:d96aa62afc5b 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
Kojto 39:d96aa62afc5b 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
Kojto 39:d96aa62afc5b 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
Kojto 39:d96aa62afc5b 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
Kojto 39:d96aa62afc5b 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
Kojto 39:d96aa62afc5b 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
Kojto 39:d96aa62afc5b 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
Kojto 39:d96aa62afc5b 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
Kojto 39:d96aa62afc5b 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Kojto 39:d96aa62afc5b 16 * Renesas reserves the right, without notice, to make changes to this software
Kojto 39:d96aa62afc5b 17 * and to discontinue the availability of this software. By using this software,
Kojto 39:d96aa62afc5b 18 * you agree to the additional terms and conditions found by accessing the
Kojto 39:d96aa62afc5b 19 * following link:
Kojto 39:d96aa62afc5b 20 * http://www.renesas.com/disclaimer
Kojto 39:d96aa62afc5b 21 * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
Kojto 39:d96aa62afc5b 22 *******************************************************************************/
Kojto 39:d96aa62afc5b 23 /*******************************************************************************
Kojto 39:d96aa62afc5b 24 * File Name : usb0_host_lib.c
Kojto 39:d96aa62afc5b 25 * $Rev: 1116 $
Kojto 39:d96aa62afc5b 26 * $Date:: 2014-07-09 16:29:19 +0900#$
Kojto 39:d96aa62afc5b 27 * Device(s) : RZ/A1H
Kojto 39:d96aa62afc5b 28 * Tool-Chain :
Kojto 39:d96aa62afc5b 29 * OS : None
Kojto 39:d96aa62afc5b 30 * H/W Platform :
Kojto 39:d96aa62afc5b 31 * Description : RZ/A1H R7S72100 USB Sample Program
Kojto 39:d96aa62afc5b 32 * Operation :
Kojto 39:d96aa62afc5b 33 * Limitations :
Kojto 39:d96aa62afc5b 34 *******************************************************************************/
Kojto 39:d96aa62afc5b 35
Kojto 39:d96aa62afc5b 36
Kojto 39:d96aa62afc5b 37 /*******************************************************************************
Kojto 39:d96aa62afc5b 38 Includes <System Includes> , "Project Includes"
Kojto 39:d96aa62afc5b 39 *******************************************************************************/
Kojto 39:d96aa62afc5b 40 #include "usb0_host.h"
Kojto 39:d96aa62afc5b 41 #if(1) /* ohci_wrapp */
Kojto 39:d96aa62afc5b 42 #include "VKRZA1H.h" /* INTC Driver Header */
Kojto 39:d96aa62afc5b 43 #else
Kojto 39:d96aa62afc5b 44 #include "devdrv_intc.h" /* INTC Driver Header */
Kojto 39:d96aa62afc5b 45 #endif
Kojto 39:d96aa62afc5b 46
Kojto 39:d96aa62afc5b 47
Kojto 39:d96aa62afc5b 48 /*******************************************************************************
Kojto 39:d96aa62afc5b 49 Typedef definitions
Kojto 39:d96aa62afc5b 50 *******************************************************************************/
Kojto 39:d96aa62afc5b 51
Kojto 39:d96aa62afc5b 52
Kojto 39:d96aa62afc5b 53 /*******************************************************************************
Kojto 39:d96aa62afc5b 54 Macro definitions
Kojto 39:d96aa62afc5b 55 *******************************************************************************/
Kojto 39:d96aa62afc5b 56
Kojto 39:d96aa62afc5b 57
Kojto 39:d96aa62afc5b 58 /*******************************************************************************
Kojto 39:d96aa62afc5b 59 Imported global variables and functions (from other files)
Kojto 39:d96aa62afc5b 60 *******************************************************************************/
Kojto 39:d96aa62afc5b 61
Kojto 39:d96aa62afc5b 62
Kojto 39:d96aa62afc5b 63 /*******************************************************************************
Kojto 39:d96aa62afc5b 64 Exported global variables and functions (to be accessed by other files)
Kojto 39:d96aa62afc5b 65 *******************************************************************************/
Kojto 39:d96aa62afc5b 66
Kojto 39:d96aa62afc5b 67
Kojto 39:d96aa62afc5b 68 /*******************************************************************************
Kojto 39:d96aa62afc5b 69 Private global variables and functions
Kojto 39:d96aa62afc5b 70 *******************************************************************************/
Kojto 39:d96aa62afc5b 71
Kojto 39:d96aa62afc5b 72
Kojto 39:d96aa62afc5b 73 /*******************************************************************************
Kojto 39:d96aa62afc5b 74 * Function Name: usb0_host_enable_brdy_int
Kojto 39:d96aa62afc5b 75 * Description : Enables BRDY interrupt in the pipe spceified by the argument.
Kojto 39:d96aa62afc5b 76 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before enabling
Kojto 39:d96aa62afc5b 77 * : BRDY. Enables BRDY interrupt in the pipe specified by the argument
Kojto 39:d96aa62afc5b 78 * : in the disabled status. After enabling BRDY, recover all
Kojto 39:d96aa62afc5b 79 * : BEMP/NRDY/BRDY disabled/enabled status.
Kojto 39:d96aa62afc5b 80 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 81 * Return Value : none
Kojto 39:d96aa62afc5b 82 *******************************************************************************/
Kojto 39:d96aa62afc5b 83 void usb0_host_enable_brdy_int (uint16_t pipe)
Kojto 39:d96aa62afc5b 84 {
Kojto 39:d96aa62afc5b 85 /* enable brdy interrupt */
Kojto 39:d96aa62afc5b 86 USB200.BRDYENB |= (uint16_t)g_usb0_host_bit_set[pipe];
Kojto 39:d96aa62afc5b 87 }
Kojto 39:d96aa62afc5b 88
Kojto 39:d96aa62afc5b 89 /*******************************************************************************
Kojto 39:d96aa62afc5b 90 * Function Name: usb0_host_disable_brdy_int
Kojto 39:d96aa62afc5b 91 * Description : Disables BRDY interrupt in the pipe spceified by the argument.
Kojto 39:d96aa62afc5b 92 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before disabling
Kojto 39:d96aa62afc5b 93 * : BRDY. Enables BRDY interrupt in the pipe specified by the argument
Kojto 39:d96aa62afc5b 94 * : in the disabled status. After disabling BRDY, recover all
Kojto 39:d96aa62afc5b 95 * : BEMP/NRDY/BRDY disabled/enabled status.
Kojto 39:d96aa62afc5b 96 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 97 * Return Value : none
Kojto 39:d96aa62afc5b 98 *******************************************************************************/
Kojto 39:d96aa62afc5b 99 void usb0_host_disable_brdy_int (uint16_t pipe)
Kojto 39:d96aa62afc5b 100 {
Kojto 39:d96aa62afc5b 101 /* disable brdy interrupt */
Kojto 39:d96aa62afc5b 102 USB200.BRDYENB &= (uint16_t)~(g_usb0_host_bit_set[pipe]);
Kojto 39:d96aa62afc5b 103 }
Kojto 39:d96aa62afc5b 104
Kojto 39:d96aa62afc5b 105 /*******************************************************************************
Kojto 39:d96aa62afc5b 106 * Function Name: usb0_host_clear_brdy_sts
Kojto 39:d96aa62afc5b 107 * Description : Clear BRDY interrupt status in the pipe spceified by the argument.
Kojto 39:d96aa62afc5b 108 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 109 * Return Value : none
Kojto 39:d96aa62afc5b 110 *******************************************************************************/
Kojto 39:d96aa62afc5b 111 void usb0_host_clear_brdy_sts (uint16_t pipe)
Kojto 39:d96aa62afc5b 112 {
Kojto 39:d96aa62afc5b 113 /* clear brdy status */
Kojto 39:d96aa62afc5b 114 USB200.BRDYSTS = (uint16_t)~(g_usb0_host_bit_set[pipe]);
Kojto 39:d96aa62afc5b 115 }
Kojto 39:d96aa62afc5b 116
Kojto 39:d96aa62afc5b 117 /*******************************************************************************
Kojto 39:d96aa62afc5b 118 * Function Name: usb0_host_enable_bemp_int
Kojto 39:d96aa62afc5b 119 * Description : Enables BEMP interrupt in the pipe spceified by the argument.
Kojto 39:d96aa62afc5b 120 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before enabling
Kojto 39:d96aa62afc5b 121 * : BEMP. Enables BEMP interrupt in the pipe specified by the argument
Kojto 39:d96aa62afc5b 122 * : in the disabled status. After enabling BEMP, recover all
Kojto 39:d96aa62afc5b 123 * : BEMP/NRDY/BRDY disabled/enabled status.
Kojto 39:d96aa62afc5b 124 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 125 * Return Value : none
Kojto 39:d96aa62afc5b 126 *******************************************************************************/
Kojto 39:d96aa62afc5b 127 void usb0_host_enable_bemp_int (uint16_t pipe)
Kojto 39:d96aa62afc5b 128 {
Kojto 39:d96aa62afc5b 129 /* enable bemp interrupt */
Kojto 39:d96aa62afc5b 130 USB200.BEMPENB |= (uint16_t)g_usb0_host_bit_set[pipe];
Kojto 39:d96aa62afc5b 131 }
Kojto 39:d96aa62afc5b 132
Kojto 39:d96aa62afc5b 133 /*******************************************************************************
Kojto 39:d96aa62afc5b 134 * Function Name: usb0_host_disable_bemp_int
Kojto 39:d96aa62afc5b 135 * Description : Disables BEMP interrupt in the pipe spceified by the argument.
Kojto 39:d96aa62afc5b 136 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before disabling
Kojto 39:d96aa62afc5b 137 * : BEMP. Enables BEMP interrupt in the pipe specified by the argument
Kojto 39:d96aa62afc5b 138 * : in the disabled status. After enabling BEMP, recover all
Kojto 39:d96aa62afc5b 139 * : BEMP/NRDY/BRDY disabled/enabled status.
Kojto 39:d96aa62afc5b 140 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 141 * Return Value : none
Kojto 39:d96aa62afc5b 142 *******************************************************************************/
Kojto 39:d96aa62afc5b 143 void usb0_host_disable_bemp_int (uint16_t pipe)
Kojto 39:d96aa62afc5b 144 {
Kojto 39:d96aa62afc5b 145 /* disable bemp interrupt */
Kojto 39:d96aa62afc5b 146 USB200.BEMPENB &= (uint16_t)~(g_usb0_host_bit_set[pipe]);
Kojto 39:d96aa62afc5b 147 }
Kojto 39:d96aa62afc5b 148
Kojto 39:d96aa62afc5b 149 /*******************************************************************************
Kojto 39:d96aa62afc5b 150 * Function Name: usb0_host_clear_bemp_sts
Kojto 39:d96aa62afc5b 151 * Description : Clear BEMP interrupt status in the pipe spceified by the argument.
Kojto 39:d96aa62afc5b 152 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 153 * Return Value : none
Kojto 39:d96aa62afc5b 154 *******************************************************************************/
Kojto 39:d96aa62afc5b 155 void usb0_host_clear_bemp_sts (uint16_t pipe)
Kojto 39:d96aa62afc5b 156 {
Kojto 39:d96aa62afc5b 157 /* clear bemp status */
Kojto 39:d96aa62afc5b 158 USB200.BEMPSTS = (uint16_t)~(g_usb0_host_bit_set[pipe]);
Kojto 39:d96aa62afc5b 159 }
Kojto 39:d96aa62afc5b 160
Kojto 39:d96aa62afc5b 161 /*******************************************************************************
Kojto 39:d96aa62afc5b 162 * Function Name: usb0_host_enable_nrdy_int
Kojto 39:d96aa62afc5b 163 * Description : Enables NRDY interrupt in the pipe spceified by the argument.
Kojto 39:d96aa62afc5b 164 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before enabling
Kojto 39:d96aa62afc5b 165 * : NRDY. Enables NRDY interrupt in the pipe specified by the argument
Kojto 39:d96aa62afc5b 166 * : in the disabled status. After enabling NRDY, recover all
Kojto 39:d96aa62afc5b 167 * : BEMP/NRDY/BRDY disabled/enabled status.
Kojto 39:d96aa62afc5b 168 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 169 * Return Value : none
Kojto 39:d96aa62afc5b 170 *******************************************************************************/
Kojto 39:d96aa62afc5b 171 void usb0_host_enable_nrdy_int (uint16_t pipe)
Kojto 39:d96aa62afc5b 172 {
Kojto 39:d96aa62afc5b 173 /* enable nrdy interrupt */
Kojto 39:d96aa62afc5b 174 USB200.NRDYENB |= (uint16_t)g_usb0_host_bit_set[pipe];
Kojto 39:d96aa62afc5b 175 }
Kojto 39:d96aa62afc5b 176
Kojto 39:d96aa62afc5b 177 /*******************************************************************************
Kojto 39:d96aa62afc5b 178 * Function Name: usb0_host_disable_nrdy_int
Kojto 39:d96aa62afc5b 179 * Description : Disables NRDY interrupt in the pipe spceified by the argument.
Kojto 39:d96aa62afc5b 180 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before disabling
Kojto 39:d96aa62afc5b 181 * : NRDY. Disables NRDY interrupt in the pipe specified by the argument
Kojto 39:d96aa62afc5b 182 * : in the disabled status. After disabling NRDY, recover all
Kojto 39:d96aa62afc5b 183 * : BEMP/NRDY/BRDY disabled/enabled status.
Kojto 39:d96aa62afc5b 184 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 185 * Return Value : none
Kojto 39:d96aa62afc5b 186 *******************************************************************************/
Kojto 39:d96aa62afc5b 187 void usb0_host_disable_nrdy_int (uint16_t pipe)
Kojto 39:d96aa62afc5b 188 {
Kojto 39:d96aa62afc5b 189 /* disable nrdy interrupt */
Kojto 39:d96aa62afc5b 190 USB200.NRDYENB &= (uint16_t)~(g_usb0_host_bit_set[pipe]);
Kojto 39:d96aa62afc5b 191 }
Kojto 39:d96aa62afc5b 192
Kojto 39:d96aa62afc5b 193 /*******************************************************************************
Kojto 39:d96aa62afc5b 194 * Function Name: usb0_host_clear_nrdy_sts
Kojto 39:d96aa62afc5b 195 * Description : Clear NRDY interrupt status in the pipe spceified by the argument.
Kojto 39:d96aa62afc5b 196 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 197 * Return Value : none
Kojto 39:d96aa62afc5b 198 *******************************************************************************/
Kojto 39:d96aa62afc5b 199 void usb0_host_clear_nrdy_sts (uint16_t pipe)
Kojto 39:d96aa62afc5b 200 {
Kojto 39:d96aa62afc5b 201 /* clear nrdy status */
Kojto 39:d96aa62afc5b 202 USB200.NRDYSTS = (uint16_t)~(g_usb0_host_bit_set[pipe]);
Kojto 39:d96aa62afc5b 203 }
Kojto 39:d96aa62afc5b 204
Kojto 39:d96aa62afc5b 205 /*******************************************************************************
Kojto 39:d96aa62afc5b 206 * Function Name: usb0_host_is_hispeed
Kojto 39:d96aa62afc5b 207 * Description : Returns the result of USB reset hand shake (RHST) as
Kojto 39:d96aa62afc5b 208 * : return value.
Kojto 39:d96aa62afc5b 209 * Arguments : none
Kojto 39:d96aa62afc5b 210 * Return Value : USB_HOST_HIGH_SPEED ; Hi-Speed
Kojto 39:d96aa62afc5b 211 * : USB_HOST_FULL_SPEED ; Full-Speed
Kojto 39:d96aa62afc5b 212 * : USB_HOST_LOW_SPEED ; Low-Speed
Kojto 39:d96aa62afc5b 213 * : USB_HOST_NON_SPEED ; error
Kojto 39:d96aa62afc5b 214 *******************************************************************************/
Kojto 39:d96aa62afc5b 215 uint16_t usb0_host_is_hispeed (void)
Kojto 39:d96aa62afc5b 216 {
Kojto 39:d96aa62afc5b 217 uint16_t rhst;
Kojto 39:d96aa62afc5b 218 uint16_t speed;
Kojto 39:d96aa62afc5b 219
Kojto 39:d96aa62afc5b 220 rhst = RZA_IO_RegRead_16(&USB200.DVSTCTR0,
Kojto 39:d96aa62afc5b 221 USB_DVSTCTR0_RHST_SHIFT,
Kojto 39:d96aa62afc5b 222 USB_DVSTCTR0_RHST);
Kojto 39:d96aa62afc5b 223 if (rhst == USB_HOST_HSMODE)
Kojto 39:d96aa62afc5b 224 {
Kojto 39:d96aa62afc5b 225 speed = USB_HOST_HIGH_SPEED;
Kojto 39:d96aa62afc5b 226 }
Kojto 39:d96aa62afc5b 227 else if (rhst == USB_HOST_FSMODE)
Kojto 39:d96aa62afc5b 228 {
Kojto 39:d96aa62afc5b 229 speed = USB_HOST_FULL_SPEED;
Kojto 39:d96aa62afc5b 230 }
Kojto 39:d96aa62afc5b 231 else if (rhst == USB_HOST_LSMODE)
Kojto 39:d96aa62afc5b 232 {
Kojto 39:d96aa62afc5b 233 speed = USB_HOST_LOW_SPEED;
Kojto 39:d96aa62afc5b 234 }
Kojto 39:d96aa62afc5b 235 else
Kojto 39:d96aa62afc5b 236 {
Kojto 39:d96aa62afc5b 237 speed = USB_HOST_NON_SPEED;
Kojto 39:d96aa62afc5b 238 }
Kojto 39:d96aa62afc5b 239
Kojto 39:d96aa62afc5b 240 return speed;
Kojto 39:d96aa62afc5b 241 }
Kojto 39:d96aa62afc5b 242
Kojto 39:d96aa62afc5b 243 /*******************************************************************************
Kojto 39:d96aa62afc5b 244 * Function Name: usb0_host_is_hispeed_enable
Kojto 39:d96aa62afc5b 245 * Description : Returns the USB High-Speed connection enabled status as
Kojto 39:d96aa62afc5b 246 * : return value.
Kojto 39:d96aa62afc5b 247 * Arguments : none
Kojto 39:d96aa62afc5b 248 * Return Value : USB_HOST_YES : Hi-Speed Enable
Kojto 39:d96aa62afc5b 249 * : USB_HOST_NO : Hi-Speed Disable
Kojto 39:d96aa62afc5b 250 *******************************************************************************/
Kojto 39:d96aa62afc5b 251 uint16_t usb0_host_is_hispeed_enable (void)
Kojto 39:d96aa62afc5b 252 {
Kojto 39:d96aa62afc5b 253 uint16_t ret;
Kojto 39:d96aa62afc5b 254
Kojto 39:d96aa62afc5b 255 ret = USB_HOST_NO;
Kojto 39:d96aa62afc5b 256
Kojto 39:d96aa62afc5b 257 if (RZA_IO_RegRead_16(&USB200.SYSCFG0,
Kojto 39:d96aa62afc5b 258 USB_SYSCFG_HSE_SHIFT,
Kojto 39:d96aa62afc5b 259 USB_SYSCFG_HSE) == 1)
Kojto 39:d96aa62afc5b 260 {
Kojto 39:d96aa62afc5b 261 ret = USB_HOST_YES;
Kojto 39:d96aa62afc5b 262 }
Kojto 39:d96aa62afc5b 263
Kojto 39:d96aa62afc5b 264 return ret;
Kojto 39:d96aa62afc5b 265 }
Kojto 39:d96aa62afc5b 266
Kojto 39:d96aa62afc5b 267 /*******************************************************************************
Kojto 39:d96aa62afc5b 268 * Function Name: usb0_host_set_pid_buf
Kojto 39:d96aa62afc5b 269 * Description : Enables communicaqtion in the pipe specified by the argument
Kojto 39:d96aa62afc5b 270 * : (BUF).
Kojto 39:d96aa62afc5b 271 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 272 * Return Value : none
Kojto 39:d96aa62afc5b 273 *******************************************************************************/
Kojto 39:d96aa62afc5b 274 void usb0_host_set_pid_buf (uint16_t pipe)
Kojto 39:d96aa62afc5b 275 {
Kojto 39:d96aa62afc5b 276 uint16_t pid;
Kojto 39:d96aa62afc5b 277
Kojto 39:d96aa62afc5b 278 pid = usb0_host_get_pid(pipe);
Kojto 39:d96aa62afc5b 279
Kojto 39:d96aa62afc5b 280 if (pid == USB_HOST_PID_STALL2)
Kojto 39:d96aa62afc5b 281 {
Kojto 39:d96aa62afc5b 282 usb0_host_set_pid_nak(pipe);
Kojto 39:d96aa62afc5b 283 }
Kojto 39:d96aa62afc5b 284
Kojto 39:d96aa62afc5b 285 switch (pipe)
Kojto 39:d96aa62afc5b 286 {
Kojto 39:d96aa62afc5b 287 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 288 RZA_IO_RegWrite_16(&USB200.DCPCTR,
Kojto 39:d96aa62afc5b 289 USB_HOST_PID_BUF,
Kojto 39:d96aa62afc5b 290 USB_DCPCTR_PID_SHIFT,
Kojto 39:d96aa62afc5b 291 USB_DCPCTR_PID);
Kojto 39:d96aa62afc5b 292 break;
Kojto 39:d96aa62afc5b 293
Kojto 39:d96aa62afc5b 294 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 295 RZA_IO_RegWrite_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 296 USB_HOST_PID_BUF,
Kojto 39:d96aa62afc5b 297 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 298 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 299 break;
Kojto 39:d96aa62afc5b 300
Kojto 39:d96aa62afc5b 301 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 302 RZA_IO_RegWrite_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 303 USB_HOST_PID_BUF,
Kojto 39:d96aa62afc5b 304 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 305 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 306 break;
Kojto 39:d96aa62afc5b 307
Kojto 39:d96aa62afc5b 308 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 309 RZA_IO_RegWrite_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 310 USB_HOST_PID_BUF,
Kojto 39:d96aa62afc5b 311 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 312 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 313 break;
Kojto 39:d96aa62afc5b 314
Kojto 39:d96aa62afc5b 315 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 316 RZA_IO_RegWrite_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 317 USB_HOST_PID_BUF,
Kojto 39:d96aa62afc5b 318 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 319 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 320 break;
Kojto 39:d96aa62afc5b 321
Kojto 39:d96aa62afc5b 322 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 323 RZA_IO_RegWrite_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 324 USB_HOST_PID_BUF,
Kojto 39:d96aa62afc5b 325 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 326 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 327 break;
Kojto 39:d96aa62afc5b 328
Kojto 39:d96aa62afc5b 329 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 330 RZA_IO_RegWrite_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 331 USB_HOST_PID_BUF,
Kojto 39:d96aa62afc5b 332 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 333 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 334 break;
Kojto 39:d96aa62afc5b 335
Kojto 39:d96aa62afc5b 336 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 337 RZA_IO_RegWrite_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 338 USB_HOST_PID_BUF,
Kojto 39:d96aa62afc5b 339 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 340 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 341 break;
Kojto 39:d96aa62afc5b 342
Kojto 39:d96aa62afc5b 343 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 344 RZA_IO_RegWrite_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 345 USB_HOST_PID_BUF,
Kojto 39:d96aa62afc5b 346 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 347 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 348 break;
Kojto 39:d96aa62afc5b 349
Kojto 39:d96aa62afc5b 350 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 351 RZA_IO_RegWrite_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 352 USB_HOST_PID_BUF,
Kojto 39:d96aa62afc5b 353 USB_PIPEnCTR_9_PID_SHIFT,
Kojto 39:d96aa62afc5b 354 USB_PIPEnCTR_9_PID);
Kojto 39:d96aa62afc5b 355 break;
Kojto 39:d96aa62afc5b 356
Kojto 39:d96aa62afc5b 357 default:
Kojto 39:d96aa62afc5b 358 break;
Kojto 39:d96aa62afc5b 359 }
Kojto 39:d96aa62afc5b 360 }
Kojto 39:d96aa62afc5b 361
Kojto 39:d96aa62afc5b 362 /*******************************************************************************
Kojto 39:d96aa62afc5b 363 * Function Name: usb0_host_set_pid_nak
Kojto 39:d96aa62afc5b 364 * Description : Disables communication (NAK) in the pipe specified by the argument.
Kojto 39:d96aa62afc5b 365 * : When the pipe status was enabling communication (BUF) before
Kojto 39:d96aa62afc5b 366 * : executing before executing this function, waits in the software
Kojto 39:d96aa62afc5b 367 * : until the pipe becomes ready after setting disabled.
Kojto 39:d96aa62afc5b 368 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 369 * Return Value : none
Kojto 39:d96aa62afc5b 370 *******************************************************************************/
Kojto 39:d96aa62afc5b 371 void usb0_host_set_pid_nak (uint16_t pipe)
Kojto 39:d96aa62afc5b 372 {
Kojto 39:d96aa62afc5b 373 uint16_t pid;
Kojto 39:d96aa62afc5b 374 uint16_t pbusy;
Kojto 39:d96aa62afc5b 375 uint32_t loop;
Kojto 39:d96aa62afc5b 376
Kojto 39:d96aa62afc5b 377 pid = usb0_host_get_pid(pipe);
Kojto 39:d96aa62afc5b 378
Kojto 39:d96aa62afc5b 379 if (pid == USB_HOST_PID_STALL2)
Kojto 39:d96aa62afc5b 380 {
Kojto 39:d96aa62afc5b 381 usb0_host_set_pid_stall(pipe);
Kojto 39:d96aa62afc5b 382 }
Kojto 39:d96aa62afc5b 383
Kojto 39:d96aa62afc5b 384 switch (pipe)
Kojto 39:d96aa62afc5b 385 {
Kojto 39:d96aa62afc5b 386 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 387 RZA_IO_RegWrite_16(&USB200.DCPCTR,
Kojto 39:d96aa62afc5b 388 USB_HOST_PID_NAK,
Kojto 39:d96aa62afc5b 389 USB_DCPCTR_PID_SHIFT,
Kojto 39:d96aa62afc5b 390 USB_DCPCTR_PID);
Kojto 39:d96aa62afc5b 391 break;
Kojto 39:d96aa62afc5b 392
Kojto 39:d96aa62afc5b 393 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 394 RZA_IO_RegWrite_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 395 USB_HOST_PID_NAK,
Kojto 39:d96aa62afc5b 396 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 397 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 398 break;
Kojto 39:d96aa62afc5b 399
Kojto 39:d96aa62afc5b 400 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 401 RZA_IO_RegWrite_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 402 USB_HOST_PID_NAK,
Kojto 39:d96aa62afc5b 403 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 404 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 405 break;
Kojto 39:d96aa62afc5b 406
Kojto 39:d96aa62afc5b 407 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 408 RZA_IO_RegWrite_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 409 USB_HOST_PID_NAK,
Kojto 39:d96aa62afc5b 410 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 411 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 412 break;
Kojto 39:d96aa62afc5b 413
Kojto 39:d96aa62afc5b 414 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 415 RZA_IO_RegWrite_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 416 USB_HOST_PID_NAK,
Kojto 39:d96aa62afc5b 417 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 418 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 419 break;
Kojto 39:d96aa62afc5b 420
Kojto 39:d96aa62afc5b 421 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 422 RZA_IO_RegWrite_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 423 USB_HOST_PID_NAK,
Kojto 39:d96aa62afc5b 424 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 425 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 426 break;
Kojto 39:d96aa62afc5b 427
Kojto 39:d96aa62afc5b 428 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 429 RZA_IO_RegWrite_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 430 USB_HOST_PID_NAK,
Kojto 39:d96aa62afc5b 431 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 432 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 433 break;
Kojto 39:d96aa62afc5b 434
Kojto 39:d96aa62afc5b 435 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 436 RZA_IO_RegWrite_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 437 USB_HOST_PID_NAK,
Kojto 39:d96aa62afc5b 438 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 439 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 440 break;
Kojto 39:d96aa62afc5b 441
Kojto 39:d96aa62afc5b 442 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 443 RZA_IO_RegWrite_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 444 USB_HOST_PID_NAK,
Kojto 39:d96aa62afc5b 445 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 446 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 447 break;
Kojto 39:d96aa62afc5b 448
Kojto 39:d96aa62afc5b 449 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 450 RZA_IO_RegWrite_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 451 USB_HOST_PID_NAK,
Kojto 39:d96aa62afc5b 452 USB_PIPEnCTR_9_PID_SHIFT,
Kojto 39:d96aa62afc5b 453 USB_PIPEnCTR_9_PID);
Kojto 39:d96aa62afc5b 454 break;
Kojto 39:d96aa62afc5b 455
Kojto 39:d96aa62afc5b 456 default:
Kojto 39:d96aa62afc5b 457 break;
Kojto 39:d96aa62afc5b 458 }
Kojto 39:d96aa62afc5b 459
Kojto 39:d96aa62afc5b 460 if (pid == USB_HOST_PID_BUF)
Kojto 39:d96aa62afc5b 461 {
Kojto 39:d96aa62afc5b 462 for (loop = 0; loop < 200; loop++)
Kojto 39:d96aa62afc5b 463 {
Kojto 39:d96aa62afc5b 464 switch (pipe)
Kojto 39:d96aa62afc5b 465 {
Kojto 39:d96aa62afc5b 466 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 467 pbusy = RZA_IO_RegRead_16(&USB200.DCPCTR,
Kojto 39:d96aa62afc5b 468 USB_DCPCTR_PBUSY_SHIFT,
Kojto 39:d96aa62afc5b 469 USB_DCPCTR_PBUSY);
Kojto 39:d96aa62afc5b 470 break;
Kojto 39:d96aa62afc5b 471
Kojto 39:d96aa62afc5b 472 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 473 pbusy = RZA_IO_RegRead_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 474 USB_PIPEnCTR_1_5_PBUSY_SHIFT,
Kojto 39:d96aa62afc5b 475 USB_PIPEnCTR_1_5_PBUSY);
Kojto 39:d96aa62afc5b 476 break;
Kojto 39:d96aa62afc5b 477
Kojto 39:d96aa62afc5b 478 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 479 pbusy = RZA_IO_RegRead_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 480 USB_PIPEnCTR_1_5_PBUSY_SHIFT,
Kojto 39:d96aa62afc5b 481 USB_PIPEnCTR_1_5_PBUSY);
Kojto 39:d96aa62afc5b 482 break;
Kojto 39:d96aa62afc5b 483
Kojto 39:d96aa62afc5b 484 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 485 pbusy = RZA_IO_RegRead_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 486 USB_PIPEnCTR_1_5_PBUSY_SHIFT,
Kojto 39:d96aa62afc5b 487 USB_PIPEnCTR_1_5_PBUSY);
Kojto 39:d96aa62afc5b 488 break;
Kojto 39:d96aa62afc5b 489
Kojto 39:d96aa62afc5b 490 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 491 pbusy = RZA_IO_RegRead_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 492 USB_PIPEnCTR_1_5_PBUSY_SHIFT,
Kojto 39:d96aa62afc5b 493 USB_PIPEnCTR_1_5_PBUSY);
Kojto 39:d96aa62afc5b 494 break;
Kojto 39:d96aa62afc5b 495
Kojto 39:d96aa62afc5b 496 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 497 pbusy = RZA_IO_RegRead_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 498 USB_PIPEnCTR_1_5_PBUSY_SHIFT,
Kojto 39:d96aa62afc5b 499 USB_PIPEnCTR_1_5_PBUSY);
Kojto 39:d96aa62afc5b 500 break;
Kojto 39:d96aa62afc5b 501
Kojto 39:d96aa62afc5b 502 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 503 pbusy = RZA_IO_RegRead_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 504 USB_PIPEnCTR_6_8_PBUSY_SHIFT,
Kojto 39:d96aa62afc5b 505 USB_PIPEnCTR_6_8_PBUSY);
Kojto 39:d96aa62afc5b 506 break;
Kojto 39:d96aa62afc5b 507
Kojto 39:d96aa62afc5b 508 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 509 pbusy = RZA_IO_RegRead_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 510 USB_PIPEnCTR_6_8_PBUSY_SHIFT,
Kojto 39:d96aa62afc5b 511 USB_PIPEnCTR_6_8_PBUSY);
Kojto 39:d96aa62afc5b 512 break;
Kojto 39:d96aa62afc5b 513
Kojto 39:d96aa62afc5b 514 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 515 pbusy = RZA_IO_RegRead_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 516 USB_PIPEnCTR_6_8_PBUSY_SHIFT,
Kojto 39:d96aa62afc5b 517 USB_PIPEnCTR_6_8_PBUSY);
Kojto 39:d96aa62afc5b 518 break;
Kojto 39:d96aa62afc5b 519
Kojto 39:d96aa62afc5b 520 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 521 pbusy = RZA_IO_RegRead_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 522 USB_PIPEnCTR_9_PBUSY_SHIFT,
Kojto 39:d96aa62afc5b 523 USB_PIPEnCTR_9_PBUSY);
Kojto 39:d96aa62afc5b 524 break;
Kojto 39:d96aa62afc5b 525
Kojto 39:d96aa62afc5b 526 default:
Kojto 39:d96aa62afc5b 527 pbusy = 1;
Kojto 39:d96aa62afc5b 528 break;
Kojto 39:d96aa62afc5b 529 }
Kojto 39:d96aa62afc5b 530
Kojto 39:d96aa62afc5b 531 if (pbusy == 0)
Kojto 39:d96aa62afc5b 532 {
Kojto 39:d96aa62afc5b 533 break;
Kojto 39:d96aa62afc5b 534 }
Kojto 39:d96aa62afc5b 535
Kojto 39:d96aa62afc5b 536 Userdef_USB_usb0_host_delay_500ns();
Kojto 39:d96aa62afc5b 537 }
Kojto 39:d96aa62afc5b 538 }
Kojto 39:d96aa62afc5b 539 }
Kojto 39:d96aa62afc5b 540
Kojto 39:d96aa62afc5b 541 /*******************************************************************************
Kojto 39:d96aa62afc5b 542 * Function Name: usb0_host_set_pid_stall
Kojto 39:d96aa62afc5b 543 * Description : Disables communication (STALL) in the pipe specified by the
Kojto 39:d96aa62afc5b 544 * : argument.
Kojto 39:d96aa62afc5b 545 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 546 * Return Value : none
Kojto 39:d96aa62afc5b 547 *******************************************************************************/
Kojto 39:d96aa62afc5b 548 void usb0_host_set_pid_stall (uint16_t pipe)
Kojto 39:d96aa62afc5b 549 {
Kojto 39:d96aa62afc5b 550 uint16_t pid;
Kojto 39:d96aa62afc5b 551
Kojto 39:d96aa62afc5b 552 pid = usb0_host_get_pid(pipe);
Kojto 39:d96aa62afc5b 553
Kojto 39:d96aa62afc5b 554 if (pid == USB_HOST_PID_BUF)
Kojto 39:d96aa62afc5b 555 {
Kojto 39:d96aa62afc5b 556 switch (pipe)
Kojto 39:d96aa62afc5b 557 {
Kojto 39:d96aa62afc5b 558 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 559 RZA_IO_RegWrite_16(&USB200.DCPCTR,
Kojto 39:d96aa62afc5b 560 USB_HOST_PID_STALL2,
Kojto 39:d96aa62afc5b 561 USB_DCPCTR_PID_SHIFT,
Kojto 39:d96aa62afc5b 562 USB_DCPCTR_PID);
Kojto 39:d96aa62afc5b 563 break;
Kojto 39:d96aa62afc5b 564
Kojto 39:d96aa62afc5b 565 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 566 RZA_IO_RegWrite_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 567 USB_HOST_PID_STALL2,
Kojto 39:d96aa62afc5b 568 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 569 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 570 break;
Kojto 39:d96aa62afc5b 571
Kojto 39:d96aa62afc5b 572 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 573 RZA_IO_RegWrite_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 574 USB_HOST_PID_STALL2,
Kojto 39:d96aa62afc5b 575 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 576 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 577 break;
Kojto 39:d96aa62afc5b 578
Kojto 39:d96aa62afc5b 579 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 580 RZA_IO_RegWrite_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 581 USB_HOST_PID_STALL2,
Kojto 39:d96aa62afc5b 582 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 583 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 584 break;
Kojto 39:d96aa62afc5b 585
Kojto 39:d96aa62afc5b 586 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 587 RZA_IO_RegWrite_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 588 USB_HOST_PID_STALL2,
Kojto 39:d96aa62afc5b 589 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 590 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 591 break;
Kojto 39:d96aa62afc5b 592
Kojto 39:d96aa62afc5b 593 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 594 RZA_IO_RegWrite_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 595 USB_HOST_PID_STALL2,
Kojto 39:d96aa62afc5b 596 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 597 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 598 break;
Kojto 39:d96aa62afc5b 599
Kojto 39:d96aa62afc5b 600 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 601 RZA_IO_RegWrite_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 602 USB_HOST_PID_STALL2,
Kojto 39:d96aa62afc5b 603 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 604 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 605 break;
Kojto 39:d96aa62afc5b 606
Kojto 39:d96aa62afc5b 607 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 608 RZA_IO_RegWrite_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 609 USB_HOST_PID_STALL2,
Kojto 39:d96aa62afc5b 610 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 611 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 612 break;
Kojto 39:d96aa62afc5b 613
Kojto 39:d96aa62afc5b 614 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 615 RZA_IO_RegWrite_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 616 USB_HOST_PID_STALL2,
Kojto 39:d96aa62afc5b 617 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 618 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 619 break;
Kojto 39:d96aa62afc5b 620
Kojto 39:d96aa62afc5b 621 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 622 RZA_IO_RegWrite_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 623 USB_HOST_PID_STALL2,
Kojto 39:d96aa62afc5b 624 USB_PIPEnCTR_9_PID_SHIFT,
Kojto 39:d96aa62afc5b 625 USB_PIPEnCTR_9_PID);
Kojto 39:d96aa62afc5b 626 break;
Kojto 39:d96aa62afc5b 627
Kojto 39:d96aa62afc5b 628 default:
Kojto 39:d96aa62afc5b 629 break;
Kojto 39:d96aa62afc5b 630 }
Kojto 39:d96aa62afc5b 631 }
Kojto 39:d96aa62afc5b 632 else
Kojto 39:d96aa62afc5b 633 {
Kojto 39:d96aa62afc5b 634 switch (pipe)
Kojto 39:d96aa62afc5b 635 {
Kojto 39:d96aa62afc5b 636 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 637 RZA_IO_RegWrite_16(&USB200.DCPCTR,
Kojto 39:d96aa62afc5b 638 USB_HOST_PID_STALL,
Kojto 39:d96aa62afc5b 639 USB_DCPCTR_PID_SHIFT,
Kojto 39:d96aa62afc5b 640 USB_DCPCTR_PID);
Kojto 39:d96aa62afc5b 641 break;
Kojto 39:d96aa62afc5b 642
Kojto 39:d96aa62afc5b 643 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 644 RZA_IO_RegWrite_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 645 USB_HOST_PID_STALL,
Kojto 39:d96aa62afc5b 646 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 647 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 648 break;
Kojto 39:d96aa62afc5b 649
Kojto 39:d96aa62afc5b 650 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 651 RZA_IO_RegWrite_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 652 USB_HOST_PID_STALL,
Kojto 39:d96aa62afc5b 653 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 654 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 655 break;
Kojto 39:d96aa62afc5b 656
Kojto 39:d96aa62afc5b 657 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 658 RZA_IO_RegWrite_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 659 USB_HOST_PID_STALL,
Kojto 39:d96aa62afc5b 660 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 661 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 662 break;
Kojto 39:d96aa62afc5b 663
Kojto 39:d96aa62afc5b 664 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 665 RZA_IO_RegWrite_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 666 USB_HOST_PID_STALL,
Kojto 39:d96aa62afc5b 667 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 668 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 669 break;
Kojto 39:d96aa62afc5b 670
Kojto 39:d96aa62afc5b 671 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 672 RZA_IO_RegWrite_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 673 USB_HOST_PID_STALL,
Kojto 39:d96aa62afc5b 674 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 675 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 676 break;
Kojto 39:d96aa62afc5b 677
Kojto 39:d96aa62afc5b 678 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 679 RZA_IO_RegWrite_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 680 USB_HOST_PID_STALL,
Kojto 39:d96aa62afc5b 681 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 682 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 683 break;
Kojto 39:d96aa62afc5b 684
Kojto 39:d96aa62afc5b 685 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 686 RZA_IO_RegWrite_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 687 USB_HOST_PID_STALL,
Kojto 39:d96aa62afc5b 688 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 689 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 690 break;
Kojto 39:d96aa62afc5b 691
Kojto 39:d96aa62afc5b 692 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 693 RZA_IO_RegWrite_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 694 USB_HOST_PID_STALL,
Kojto 39:d96aa62afc5b 695 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 696 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 697 break;
Kojto 39:d96aa62afc5b 698
Kojto 39:d96aa62afc5b 699 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 700 RZA_IO_RegWrite_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 701 USB_HOST_PID_STALL,
Kojto 39:d96aa62afc5b 702 USB_PIPEnCTR_9_PID_SHIFT,
Kojto 39:d96aa62afc5b 703 USB_PIPEnCTR_9_PID);
Kojto 39:d96aa62afc5b 704 break;
Kojto 39:d96aa62afc5b 705
Kojto 39:d96aa62afc5b 706 default:
Kojto 39:d96aa62afc5b 707 break;
Kojto 39:d96aa62afc5b 708 }
Kojto 39:d96aa62afc5b 709 }
Kojto 39:d96aa62afc5b 710 }
Kojto 39:d96aa62afc5b 711
Kojto 39:d96aa62afc5b 712 /*******************************************************************************
Kojto 39:d96aa62afc5b 713 * Function Name: usb0_host_clear_pid_stall
Kojto 39:d96aa62afc5b 714 * Description : Disables communication (NAK) in the pipe specified by the argument.
Kojto 39:d96aa62afc5b 715 * Arguments : uint16_t pipe ; pipe Number
Kojto 39:d96aa62afc5b 716 * Return Value : none
Kojto 39:d96aa62afc5b 717 *******************************************************************************/
Kojto 39:d96aa62afc5b 718 void usb0_host_clear_pid_stall (uint16_t pipe)
Kojto 39:d96aa62afc5b 719 {
Kojto 39:d96aa62afc5b 720 usb0_host_set_pid_nak(pipe);
Kojto 39:d96aa62afc5b 721 }
Kojto 39:d96aa62afc5b 722
Kojto 39:d96aa62afc5b 723 /*******************************************************************************
Kojto 39:d96aa62afc5b 724 * Function Name: usb0_host_get_pid
Kojto 39:d96aa62afc5b 725 * Description : Returns the pipe state specified by the argument.
Kojto 39:d96aa62afc5b 726 * Arguments : uint16_t pipe ; Pipe Number
Kojto 39:d96aa62afc5b 727 * Return Value : PID
Kojto 39:d96aa62afc5b 728 *******************************************************************************/
Kojto 39:d96aa62afc5b 729 uint16_t usb0_host_get_pid (uint16_t pipe)
Kojto 39:d96aa62afc5b 730 {
Kojto 39:d96aa62afc5b 731 uint16_t pid;
Kojto 39:d96aa62afc5b 732
Kojto 39:d96aa62afc5b 733 switch (pipe)
Kojto 39:d96aa62afc5b 734 {
Kojto 39:d96aa62afc5b 735 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 736 pid = RZA_IO_RegRead_16(&USB200.DCPCTR,
Kojto 39:d96aa62afc5b 737 USB_DCPCTR_PID_SHIFT,
Kojto 39:d96aa62afc5b 738 USB_DCPCTR_PID);
Kojto 39:d96aa62afc5b 739 break;
Kojto 39:d96aa62afc5b 740
Kojto 39:d96aa62afc5b 741 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 742 pid = RZA_IO_RegRead_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 743 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 744 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 745 break;
Kojto 39:d96aa62afc5b 746
Kojto 39:d96aa62afc5b 747 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 748 pid = RZA_IO_RegRead_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 749 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 750 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 751 break;
Kojto 39:d96aa62afc5b 752
Kojto 39:d96aa62afc5b 753 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 754 pid = RZA_IO_RegRead_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 755 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 756 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 757 break;
Kojto 39:d96aa62afc5b 758
Kojto 39:d96aa62afc5b 759 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 760 pid = RZA_IO_RegRead_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 761 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 762 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 763 break;
Kojto 39:d96aa62afc5b 764
Kojto 39:d96aa62afc5b 765 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 766 pid = RZA_IO_RegRead_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 767 USB_PIPEnCTR_1_5_PID_SHIFT,
Kojto 39:d96aa62afc5b 768 USB_PIPEnCTR_1_5_PID);
Kojto 39:d96aa62afc5b 769 break;
Kojto 39:d96aa62afc5b 770
Kojto 39:d96aa62afc5b 771 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 772 pid = RZA_IO_RegRead_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 773 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 774 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 775 break;
Kojto 39:d96aa62afc5b 776
Kojto 39:d96aa62afc5b 777 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 778 pid = RZA_IO_RegRead_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 779 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 780 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 781 break;
Kojto 39:d96aa62afc5b 782
Kojto 39:d96aa62afc5b 783 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 784 pid = RZA_IO_RegRead_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 785 USB_PIPEnCTR_6_8_PID_SHIFT,
Kojto 39:d96aa62afc5b 786 USB_PIPEnCTR_6_8_PID);
Kojto 39:d96aa62afc5b 787 break;
Kojto 39:d96aa62afc5b 788
Kojto 39:d96aa62afc5b 789 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 790 pid = RZA_IO_RegRead_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 791 USB_PIPEnCTR_9_PID_SHIFT,
Kojto 39:d96aa62afc5b 792 USB_PIPEnCTR_9_PID);
Kojto 39:d96aa62afc5b 793 break;
Kojto 39:d96aa62afc5b 794
Kojto 39:d96aa62afc5b 795 default:
Kojto 39:d96aa62afc5b 796 pid = 0;
Kojto 39:d96aa62afc5b 797 break;
Kojto 39:d96aa62afc5b 798 }
Kojto 39:d96aa62afc5b 799
Kojto 39:d96aa62afc5b 800 return pid;
Kojto 39:d96aa62afc5b 801 }
Kojto 39:d96aa62afc5b 802
Kojto 39:d96aa62afc5b 803 /*******************************************************************************
Kojto 39:d96aa62afc5b 804 * Function Name: usb0_host_set_csclr
Kojto 39:d96aa62afc5b 805 * Description : CSPLIT status clear setting of sprit transaction in specified
Kojto 39:d96aa62afc5b 806 * : pipe is performed.
Kojto 39:d96aa62afc5b 807 * : When SQSET bit or SQCLR bit, and SQSET bit or SQCLR bit
Kojto 39:d96aa62afc5b 808 * : in DCPCTR register are continuously changed (when the sequence
Kojto 39:d96aa62afc5b 809 * : toggle bit of data PID is continuously changed over two or more pipes),
Kojto 39:d96aa62afc5b 810 * : the access cycle with 120 ns and more than 5 cycle bus clock is necessary.
Kojto 39:d96aa62afc5b 811 * : Do not set both SQCLR bit and SQSET bit to 1 at the same time.
Kojto 39:d96aa62afc5b 812 * : In addition, both bits should be operated after PID is set to NAK.
Kojto 39:d96aa62afc5b 813 * : However, when it is set to the isochronous transfer as the transfer type
Kojto 39:d96aa62afc5b 814 * : (TYPE=11), writing in SQSET bit is disabled.
Kojto 39:d96aa62afc5b 815 * Arguments : uint16_t pipe ; Pipe number
Kojto 39:d96aa62afc5b 816 * Return Value : none
Kojto 39:d96aa62afc5b 817 *******************************************************************************/
Kojto 39:d96aa62afc5b 818 void usb0_host_set_csclr (uint16_t pipe)
Kojto 39:d96aa62afc5b 819 {
Kojto 39:d96aa62afc5b 820 switch (pipe)
Kojto 39:d96aa62afc5b 821 {
Kojto 39:d96aa62afc5b 822 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 823 RZA_IO_RegWrite_16(&USB200.DCPCTR,
Kojto 39:d96aa62afc5b 824 1,
Kojto 39:d96aa62afc5b 825 USB_DCPCTR_CSCLR_SHIFT,
Kojto 39:d96aa62afc5b 826 USB_DCPCTR_CSCLR);
Kojto 39:d96aa62afc5b 827 break;
Kojto 39:d96aa62afc5b 828
Kojto 39:d96aa62afc5b 829 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 830 RZA_IO_RegWrite_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 831 1,
Kojto 39:d96aa62afc5b 832 USB_PIPEnCTR_1_5_CSCLR_SHIFT,
Kojto 39:d96aa62afc5b 833 USB_PIPEnCTR_1_5_CSCLR);
Kojto 39:d96aa62afc5b 834 break;
Kojto 39:d96aa62afc5b 835
Kojto 39:d96aa62afc5b 836 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 837 RZA_IO_RegWrite_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 838 1,
Kojto 39:d96aa62afc5b 839 USB_PIPEnCTR_1_5_CSCLR_SHIFT,
Kojto 39:d96aa62afc5b 840 USB_PIPEnCTR_1_5_CSCLR);
Kojto 39:d96aa62afc5b 841 break;
Kojto 39:d96aa62afc5b 842
Kojto 39:d96aa62afc5b 843 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 844 RZA_IO_RegWrite_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 845 1,
Kojto 39:d96aa62afc5b 846 USB_PIPEnCTR_1_5_CSCLR_SHIFT,
Kojto 39:d96aa62afc5b 847 USB_PIPEnCTR_1_5_CSCLR);
Kojto 39:d96aa62afc5b 848 break;
Kojto 39:d96aa62afc5b 849
Kojto 39:d96aa62afc5b 850 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 851 RZA_IO_RegWrite_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 852 1,
Kojto 39:d96aa62afc5b 853 USB_PIPEnCTR_1_5_CSCLR_SHIFT,
Kojto 39:d96aa62afc5b 854 USB_PIPEnCTR_1_5_CSCLR);
Kojto 39:d96aa62afc5b 855 break;
Kojto 39:d96aa62afc5b 856
Kojto 39:d96aa62afc5b 857 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 858 RZA_IO_RegWrite_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 859 1,
Kojto 39:d96aa62afc5b 860 USB_PIPEnCTR_1_5_CSCLR_SHIFT,
Kojto 39:d96aa62afc5b 861 USB_PIPEnCTR_1_5_CSCLR);
Kojto 39:d96aa62afc5b 862 break;
Kojto 39:d96aa62afc5b 863
Kojto 39:d96aa62afc5b 864 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 865 RZA_IO_RegWrite_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 866 1,
Kojto 39:d96aa62afc5b 867 USB_PIPEnCTR_6_8_CSCLR_SHIFT,
Kojto 39:d96aa62afc5b 868 USB_PIPEnCTR_6_8_CSCLR);
Kojto 39:d96aa62afc5b 869 break;
Kojto 39:d96aa62afc5b 870
Kojto 39:d96aa62afc5b 871 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 872 RZA_IO_RegWrite_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 873 1,
Kojto 39:d96aa62afc5b 874 USB_PIPEnCTR_6_8_CSCLR_SHIFT,
Kojto 39:d96aa62afc5b 875 USB_PIPEnCTR_6_8_CSCLR);
Kojto 39:d96aa62afc5b 876 break;
Kojto 39:d96aa62afc5b 877
Kojto 39:d96aa62afc5b 878 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 879 RZA_IO_RegWrite_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 880 1,
Kojto 39:d96aa62afc5b 881 USB_PIPEnCTR_6_8_CSCLR_SHIFT,
Kojto 39:d96aa62afc5b 882 USB_PIPEnCTR_6_8_CSCLR);
Kojto 39:d96aa62afc5b 883 break;
Kojto 39:d96aa62afc5b 884
Kojto 39:d96aa62afc5b 885 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 886 RZA_IO_RegWrite_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 887 1,
Kojto 39:d96aa62afc5b 888 USB_PIPEnCTR_9_CSCLR_SHIFT,
Kojto 39:d96aa62afc5b 889 USB_PIPEnCTR_9_CSCLR);
Kojto 39:d96aa62afc5b 890 break;
Kojto 39:d96aa62afc5b 891
Kojto 39:d96aa62afc5b 892 default:
Kojto 39:d96aa62afc5b 893 break;
Kojto 39:d96aa62afc5b 894 }
Kojto 39:d96aa62afc5b 895 }
Kojto 39:d96aa62afc5b 896
Kojto 39:d96aa62afc5b 897 /*******************************************************************************
Kojto 39:d96aa62afc5b 898 * Function Name: usb0_host_set_sqclr
Kojto 39:d96aa62afc5b 899 * Description : Sets the sequence bit of the pipe specified by the argument to
Kojto 39:d96aa62afc5b 900 * : DATA0.
Kojto 39:d96aa62afc5b 901 * Arguments : uint16_t pipe ; Pipe Number
Kojto 39:d96aa62afc5b 902 * Return Value : none
Kojto 39:d96aa62afc5b 903 *******************************************************************************/
Kojto 39:d96aa62afc5b 904 void usb0_host_set_sqclr (uint16_t pipe)
Kojto 39:d96aa62afc5b 905 {
Kojto 39:d96aa62afc5b 906 switch (pipe)
Kojto 39:d96aa62afc5b 907 {
Kojto 39:d96aa62afc5b 908 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 909 RZA_IO_RegWrite_16(&USB200.DCPCTR,
Kojto 39:d96aa62afc5b 910 1,
Kojto 39:d96aa62afc5b 911 USB_DCPCTR_SQCLR_SHIFT,
Kojto 39:d96aa62afc5b 912 USB_DCPCTR_SQCLR);
Kojto 39:d96aa62afc5b 913 break;
Kojto 39:d96aa62afc5b 914
Kojto 39:d96aa62afc5b 915 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 916 RZA_IO_RegWrite_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 917 1,
Kojto 39:d96aa62afc5b 918 USB_PIPEnCTR_1_5_SQCLR_SHIFT,
Kojto 39:d96aa62afc5b 919 USB_PIPEnCTR_1_5_SQCLR);
Kojto 39:d96aa62afc5b 920 break;
Kojto 39:d96aa62afc5b 921
Kojto 39:d96aa62afc5b 922 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 923 RZA_IO_RegWrite_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 924 1,
Kojto 39:d96aa62afc5b 925 USB_PIPEnCTR_1_5_SQCLR_SHIFT,
Kojto 39:d96aa62afc5b 926 USB_PIPEnCTR_1_5_SQCLR);
Kojto 39:d96aa62afc5b 927 break;
Kojto 39:d96aa62afc5b 928
Kojto 39:d96aa62afc5b 929 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 930 RZA_IO_RegWrite_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 931 1,
Kojto 39:d96aa62afc5b 932 USB_PIPEnCTR_1_5_SQCLR_SHIFT,
Kojto 39:d96aa62afc5b 933 USB_PIPEnCTR_1_5_SQCLR);
Kojto 39:d96aa62afc5b 934 break;
Kojto 39:d96aa62afc5b 935
Kojto 39:d96aa62afc5b 936 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 937 RZA_IO_RegWrite_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 938 1,
Kojto 39:d96aa62afc5b 939 USB_PIPEnCTR_1_5_SQCLR_SHIFT,
Kojto 39:d96aa62afc5b 940 USB_PIPEnCTR_1_5_SQCLR);
Kojto 39:d96aa62afc5b 941 break;
Kojto 39:d96aa62afc5b 942
Kojto 39:d96aa62afc5b 943 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 944 RZA_IO_RegWrite_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 945 1,
Kojto 39:d96aa62afc5b 946 USB_PIPEnCTR_1_5_SQCLR_SHIFT,
Kojto 39:d96aa62afc5b 947 USB_PIPEnCTR_1_5_SQCLR);
Kojto 39:d96aa62afc5b 948 break;
Kojto 39:d96aa62afc5b 949
Kojto 39:d96aa62afc5b 950 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 951 RZA_IO_RegWrite_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 952 1,
Kojto 39:d96aa62afc5b 953 USB_PIPEnCTR_6_8_SQCLR_SHIFT,
Kojto 39:d96aa62afc5b 954 USB_PIPEnCTR_6_8_SQCLR);
Kojto 39:d96aa62afc5b 955 break;
Kojto 39:d96aa62afc5b 956
Kojto 39:d96aa62afc5b 957 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 958 RZA_IO_RegWrite_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 959 1,
Kojto 39:d96aa62afc5b 960 USB_PIPEnCTR_6_8_SQCLR_SHIFT,
Kojto 39:d96aa62afc5b 961 USB_PIPEnCTR_6_8_SQCLR);
Kojto 39:d96aa62afc5b 962 break;
Kojto 39:d96aa62afc5b 963
Kojto 39:d96aa62afc5b 964 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 965 RZA_IO_RegWrite_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 966 1,
Kojto 39:d96aa62afc5b 967 USB_PIPEnCTR_6_8_SQCLR_SHIFT,
Kojto 39:d96aa62afc5b 968 USB_PIPEnCTR_6_8_SQCLR);
Kojto 39:d96aa62afc5b 969 break;
Kojto 39:d96aa62afc5b 970
Kojto 39:d96aa62afc5b 971 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 972 RZA_IO_RegWrite_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 973 1,
Kojto 39:d96aa62afc5b 974 USB_PIPEnCTR_9_SQCLR_SHIFT,
Kojto 39:d96aa62afc5b 975 USB_PIPEnCTR_9_SQCLR);
Kojto 39:d96aa62afc5b 976 break;
Kojto 39:d96aa62afc5b 977
Kojto 39:d96aa62afc5b 978 default:
Kojto 39:d96aa62afc5b 979 break;
Kojto 39:d96aa62afc5b 980 }
Kojto 39:d96aa62afc5b 981 }
Kojto 39:d96aa62afc5b 982
Kojto 39:d96aa62afc5b 983 /*******************************************************************************
Kojto 39:d96aa62afc5b 984 * Function Name: usb0_host_set_sqset
Kojto 39:d96aa62afc5b 985 * Description : Sets the sequence bit of the pipe specified by the argument to
Kojto 39:d96aa62afc5b 986 * : DATA1.
Kojto 39:d96aa62afc5b 987 * Arguments : uint16_t pipe ; Pipe number
Kojto 39:d96aa62afc5b 988 * Return Value : none
Kojto 39:d96aa62afc5b 989 *******************************************************************************/
Kojto 39:d96aa62afc5b 990 void usb0_host_set_sqset (uint16_t pipe)
Kojto 39:d96aa62afc5b 991 {
Kojto 39:d96aa62afc5b 992 switch (pipe)
Kojto 39:d96aa62afc5b 993 {
Kojto 39:d96aa62afc5b 994 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 995 RZA_IO_RegWrite_16(&USB200.DCPCTR,
Kojto 39:d96aa62afc5b 996 1,
Kojto 39:d96aa62afc5b 997 USB_DCPCTR_SQSET_SHIFT,
Kojto 39:d96aa62afc5b 998 USB_DCPCTR_SQSET);
Kojto 39:d96aa62afc5b 999 break;
Kojto 39:d96aa62afc5b 1000
Kojto 39:d96aa62afc5b 1001 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 1002 RZA_IO_RegWrite_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 1003 1,
Kojto 39:d96aa62afc5b 1004 USB_PIPEnCTR_1_5_SQSET_SHIFT,
Kojto 39:d96aa62afc5b 1005 USB_PIPEnCTR_1_5_SQSET);
Kojto 39:d96aa62afc5b 1006 break;
Kojto 39:d96aa62afc5b 1007
Kojto 39:d96aa62afc5b 1008 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 1009 RZA_IO_RegWrite_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 1010 1,
Kojto 39:d96aa62afc5b 1011 USB_PIPEnCTR_1_5_SQSET_SHIFT,
Kojto 39:d96aa62afc5b 1012 USB_PIPEnCTR_1_5_SQSET);
Kojto 39:d96aa62afc5b 1013 break;
Kojto 39:d96aa62afc5b 1014
Kojto 39:d96aa62afc5b 1015 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 1016 RZA_IO_RegWrite_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 1017 1,
Kojto 39:d96aa62afc5b 1018 USB_PIPEnCTR_1_5_SQSET_SHIFT,
Kojto 39:d96aa62afc5b 1019 USB_PIPEnCTR_1_5_SQSET);
Kojto 39:d96aa62afc5b 1020 break;
Kojto 39:d96aa62afc5b 1021
Kojto 39:d96aa62afc5b 1022 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 1023 RZA_IO_RegWrite_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 1024 1,
Kojto 39:d96aa62afc5b 1025 USB_PIPEnCTR_1_5_SQSET_SHIFT,
Kojto 39:d96aa62afc5b 1026 USB_PIPEnCTR_1_5_SQSET);
Kojto 39:d96aa62afc5b 1027 break;
Kojto 39:d96aa62afc5b 1028
Kojto 39:d96aa62afc5b 1029 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 1030 RZA_IO_RegWrite_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 1031 1,
Kojto 39:d96aa62afc5b 1032 USB_PIPEnCTR_1_5_SQSET_SHIFT,
Kojto 39:d96aa62afc5b 1033 USB_PIPEnCTR_1_5_SQSET);
Kojto 39:d96aa62afc5b 1034 break;
Kojto 39:d96aa62afc5b 1035
Kojto 39:d96aa62afc5b 1036 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 1037 RZA_IO_RegWrite_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 1038 1,
Kojto 39:d96aa62afc5b 1039 USB_PIPEnCTR_6_8_SQSET_SHIFT,
Kojto 39:d96aa62afc5b 1040 USB_PIPEnCTR_6_8_SQSET);
Kojto 39:d96aa62afc5b 1041 break;
Kojto 39:d96aa62afc5b 1042
Kojto 39:d96aa62afc5b 1043 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 1044 RZA_IO_RegWrite_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 1045 1,
Kojto 39:d96aa62afc5b 1046 USB_PIPEnCTR_6_8_SQSET_SHIFT,
Kojto 39:d96aa62afc5b 1047 USB_PIPEnCTR_6_8_SQSET);
Kojto 39:d96aa62afc5b 1048 break;
Kojto 39:d96aa62afc5b 1049
Kojto 39:d96aa62afc5b 1050 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 1051 RZA_IO_RegWrite_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 1052 1,
Kojto 39:d96aa62afc5b 1053 USB_PIPEnCTR_6_8_SQSET_SHIFT,
Kojto 39:d96aa62afc5b 1054 USB_PIPEnCTR_6_8_SQSET);
Kojto 39:d96aa62afc5b 1055 break;
Kojto 39:d96aa62afc5b 1056
Kojto 39:d96aa62afc5b 1057 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 1058 RZA_IO_RegWrite_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 1059 1,
Kojto 39:d96aa62afc5b 1060 USB_PIPEnCTR_9_SQSET_SHIFT,
Kojto 39:d96aa62afc5b 1061 USB_PIPEnCTR_9_SQSET);
Kojto 39:d96aa62afc5b 1062 break;
Kojto 39:d96aa62afc5b 1063
Kojto 39:d96aa62afc5b 1064 default:
Kojto 39:d96aa62afc5b 1065 break;
Kojto 39:d96aa62afc5b 1066 }
Kojto 39:d96aa62afc5b 1067 }
Kojto 39:d96aa62afc5b 1068
Kojto 39:d96aa62afc5b 1069 /*******************************************************************************
Kojto 39:d96aa62afc5b 1070 * Function Name: usb0_host_get_sqmon
Kojto 39:d96aa62afc5b 1071 * Description : Toggle bit of specified pipe is obtained
Kojto 39:d96aa62afc5b 1072 * Arguments : uint16_t pipe ; Pipe number
Kojto 39:d96aa62afc5b 1073 * Return Value : sqmon
Kojto 39:d96aa62afc5b 1074 *******************************************************************************/
Kojto 39:d96aa62afc5b 1075 uint16_t usb0_host_get_sqmon (uint16_t pipe)
Kojto 39:d96aa62afc5b 1076 {
Kojto 39:d96aa62afc5b 1077 uint16_t sqmon;
Kojto 39:d96aa62afc5b 1078
Kojto 39:d96aa62afc5b 1079 switch (pipe)
Kojto 39:d96aa62afc5b 1080 {
Kojto 39:d96aa62afc5b 1081 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 1082 sqmon = RZA_IO_RegRead_16(&USB200.DCPCTR,
Kojto 39:d96aa62afc5b 1083 USB_DCPCTR_SQMON_SHIFT,
Kojto 39:d96aa62afc5b 1084 USB_DCPCTR_SQMON);
Kojto 39:d96aa62afc5b 1085 break;
Kojto 39:d96aa62afc5b 1086
Kojto 39:d96aa62afc5b 1087 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 1088 sqmon = RZA_IO_RegRead_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 1089 USB_PIPEnCTR_1_5_SQMON_SHIFT,
Kojto 39:d96aa62afc5b 1090 USB_PIPEnCTR_1_5_SQMON);
Kojto 39:d96aa62afc5b 1091 break;
Kojto 39:d96aa62afc5b 1092
Kojto 39:d96aa62afc5b 1093 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 1094 sqmon = RZA_IO_RegRead_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 1095 USB_PIPEnCTR_1_5_SQMON_SHIFT,
Kojto 39:d96aa62afc5b 1096 USB_PIPEnCTR_1_5_SQMON);
Kojto 39:d96aa62afc5b 1097 break;
Kojto 39:d96aa62afc5b 1098
Kojto 39:d96aa62afc5b 1099 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 1100 sqmon = RZA_IO_RegRead_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 1101 USB_PIPEnCTR_1_5_SQMON_SHIFT,
Kojto 39:d96aa62afc5b 1102 USB_PIPEnCTR_1_5_SQMON);
Kojto 39:d96aa62afc5b 1103 break;
Kojto 39:d96aa62afc5b 1104
Kojto 39:d96aa62afc5b 1105 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 1106 sqmon = RZA_IO_RegRead_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 1107 USB_PIPEnCTR_1_5_SQMON_SHIFT,
Kojto 39:d96aa62afc5b 1108 USB_PIPEnCTR_1_5_SQMON);
Kojto 39:d96aa62afc5b 1109 break;
Kojto 39:d96aa62afc5b 1110
Kojto 39:d96aa62afc5b 1111 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 1112 sqmon = RZA_IO_RegRead_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 1113 USB_PIPEnCTR_1_5_SQMON_SHIFT,
Kojto 39:d96aa62afc5b 1114 USB_PIPEnCTR_1_5_SQMON);
Kojto 39:d96aa62afc5b 1115 break;
Kojto 39:d96aa62afc5b 1116
Kojto 39:d96aa62afc5b 1117 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 1118 sqmon = RZA_IO_RegRead_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 1119 USB_PIPEnCTR_6_8_SQMON_SHIFT,
Kojto 39:d96aa62afc5b 1120 USB_PIPEnCTR_6_8_SQMON);
Kojto 39:d96aa62afc5b 1121 break;
Kojto 39:d96aa62afc5b 1122
Kojto 39:d96aa62afc5b 1123 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 1124 sqmon = RZA_IO_RegRead_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 1125 USB_PIPEnCTR_6_8_SQMON_SHIFT,
Kojto 39:d96aa62afc5b 1126 USB_PIPEnCTR_6_8_SQMON);
Kojto 39:d96aa62afc5b 1127 break;
Kojto 39:d96aa62afc5b 1128
Kojto 39:d96aa62afc5b 1129 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 1130 sqmon = RZA_IO_RegRead_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 1131 USB_PIPEnCTR_6_8_SQMON_SHIFT,
Kojto 39:d96aa62afc5b 1132 USB_PIPEnCTR_6_8_SQMON);
Kojto 39:d96aa62afc5b 1133 break;
Kojto 39:d96aa62afc5b 1134
Kojto 39:d96aa62afc5b 1135 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 1136 sqmon = RZA_IO_RegRead_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 1137 USB_PIPEnCTR_9_SQMON_SHIFT,
Kojto 39:d96aa62afc5b 1138 USB_PIPEnCTR_9_SQMON);
Kojto 39:d96aa62afc5b 1139 break;
Kojto 39:d96aa62afc5b 1140
Kojto 39:d96aa62afc5b 1141 default:
Kojto 39:d96aa62afc5b 1142 sqmon = 0;
Kojto 39:d96aa62afc5b 1143 break;
Kojto 39:d96aa62afc5b 1144 }
Kojto 39:d96aa62afc5b 1145
Kojto 39:d96aa62afc5b 1146 return sqmon;
Kojto 39:d96aa62afc5b 1147 }
Kojto 39:d96aa62afc5b 1148
Kojto 39:d96aa62afc5b 1149 /*******************************************************************************
Kojto 39:d96aa62afc5b 1150 * Function Name: usb0_host_aclrm
Kojto 39:d96aa62afc5b 1151 * Description : The buffer of specified pipe is initialized
Kojto 39:d96aa62afc5b 1152 * Arguments : uint16_t pipe : Pipe
Kojto 39:d96aa62afc5b 1153 * Return Value : none
Kojto 39:d96aa62afc5b 1154 *******************************************************************************/
Kojto 39:d96aa62afc5b 1155 void usb0_host_aclrm (uint16_t pipe)
Kojto 39:d96aa62afc5b 1156 {
Kojto 39:d96aa62afc5b 1157 usb0_host_set_aclrm(pipe);
Kojto 39:d96aa62afc5b 1158 usb0_host_clr_aclrm(pipe);
Kojto 39:d96aa62afc5b 1159 }
Kojto 39:d96aa62afc5b 1160
Kojto 39:d96aa62afc5b 1161 /*******************************************************************************
Kojto 39:d96aa62afc5b 1162 * Function Name: usb0_host_set_aclrm
Kojto 39:d96aa62afc5b 1163 * Description : The auto buffer clear mode of specified pipe is enabled
Kojto 39:d96aa62afc5b 1164 * Arguments : uint16_t pipe : Pipe
Kojto 39:d96aa62afc5b 1165 * Return Value : none
Kojto 39:d96aa62afc5b 1166 *******************************************************************************/
Kojto 39:d96aa62afc5b 1167 void usb0_host_set_aclrm (uint16_t pipe)
Kojto 39:d96aa62afc5b 1168 {
Kojto 39:d96aa62afc5b 1169 switch (pipe)
Kojto 39:d96aa62afc5b 1170 {
Kojto 39:d96aa62afc5b 1171 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 1172 break;
Kojto 39:d96aa62afc5b 1173
Kojto 39:d96aa62afc5b 1174 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 1175 RZA_IO_RegWrite_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 1176 1,
Kojto 39:d96aa62afc5b 1177 USB_PIPEnCTR_1_5_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1178 USB_PIPEnCTR_1_5_ACLRM);
Kojto 39:d96aa62afc5b 1179 break;
Kojto 39:d96aa62afc5b 1180
Kojto 39:d96aa62afc5b 1181 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 1182 RZA_IO_RegWrite_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 1183 1,
Kojto 39:d96aa62afc5b 1184 USB_PIPEnCTR_1_5_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1185 USB_PIPEnCTR_1_5_ACLRM);
Kojto 39:d96aa62afc5b 1186 break;
Kojto 39:d96aa62afc5b 1187
Kojto 39:d96aa62afc5b 1188 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 1189 RZA_IO_RegWrite_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 1190 1,
Kojto 39:d96aa62afc5b 1191 USB_PIPEnCTR_1_5_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1192 USB_PIPEnCTR_1_5_ACLRM);
Kojto 39:d96aa62afc5b 1193 break;
Kojto 39:d96aa62afc5b 1194
Kojto 39:d96aa62afc5b 1195 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 1196 RZA_IO_RegWrite_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 1197 1,
Kojto 39:d96aa62afc5b 1198 USB_PIPEnCTR_1_5_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1199 USB_PIPEnCTR_1_5_ACLRM);
Kojto 39:d96aa62afc5b 1200 break;
Kojto 39:d96aa62afc5b 1201
Kojto 39:d96aa62afc5b 1202 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 1203 RZA_IO_RegWrite_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 1204 1,
Kojto 39:d96aa62afc5b 1205 USB_PIPEnCTR_1_5_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1206 USB_PIPEnCTR_1_5_ACLRM);
Kojto 39:d96aa62afc5b 1207 break;
Kojto 39:d96aa62afc5b 1208
Kojto 39:d96aa62afc5b 1209 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 1210 RZA_IO_RegWrite_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 1211 1,
Kojto 39:d96aa62afc5b 1212 USB_PIPEnCTR_6_8_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1213 USB_PIPEnCTR_6_8_ACLRM);
Kojto 39:d96aa62afc5b 1214 break;
Kojto 39:d96aa62afc5b 1215
Kojto 39:d96aa62afc5b 1216 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 1217 RZA_IO_RegWrite_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 1218 1,
Kojto 39:d96aa62afc5b 1219 USB_PIPEnCTR_6_8_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1220 USB_PIPEnCTR_6_8_ACLRM);
Kojto 39:d96aa62afc5b 1221 break;
Kojto 39:d96aa62afc5b 1222
Kojto 39:d96aa62afc5b 1223 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 1224 RZA_IO_RegWrite_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 1225 1,
Kojto 39:d96aa62afc5b 1226 USB_PIPEnCTR_6_8_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1227 USB_PIPEnCTR_6_8_ACLRM);
Kojto 39:d96aa62afc5b 1228 break;
Kojto 39:d96aa62afc5b 1229
Kojto 39:d96aa62afc5b 1230 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 1231 RZA_IO_RegWrite_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 1232 1,
Kojto 39:d96aa62afc5b 1233 USB_PIPEnCTR_9_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1234 USB_PIPEnCTR_9_ACLRM);
Kojto 39:d96aa62afc5b 1235 break;
Kojto 39:d96aa62afc5b 1236
Kojto 39:d96aa62afc5b 1237 default:
Kojto 39:d96aa62afc5b 1238 break;
Kojto 39:d96aa62afc5b 1239 }
Kojto 39:d96aa62afc5b 1240 }
Kojto 39:d96aa62afc5b 1241
Kojto 39:d96aa62afc5b 1242 /*******************************************************************************
Kojto 39:d96aa62afc5b 1243 * Function Name: usb0_host_clr_aclrm
Kojto 39:d96aa62afc5b 1244 * Description : The auto buffer clear mode of specified pipe is enabled
Kojto 39:d96aa62afc5b 1245 * Arguments : uint16_t pipe : Pipe
Kojto 39:d96aa62afc5b 1246 * Return Value : none
Kojto 39:d96aa62afc5b 1247 *******************************************************************************/
Kojto 39:d96aa62afc5b 1248 void usb0_host_clr_aclrm (uint16_t pipe)
Kojto 39:d96aa62afc5b 1249 {
Kojto 39:d96aa62afc5b 1250 switch (pipe)
Kojto 39:d96aa62afc5b 1251 {
Kojto 39:d96aa62afc5b 1252 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 1253 break;
Kojto 39:d96aa62afc5b 1254
Kojto 39:d96aa62afc5b 1255 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 1256 RZA_IO_RegWrite_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 1257 0,
Kojto 39:d96aa62afc5b 1258 USB_PIPEnCTR_1_5_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1259 USB_PIPEnCTR_1_5_ACLRM);
Kojto 39:d96aa62afc5b 1260 break;
Kojto 39:d96aa62afc5b 1261
Kojto 39:d96aa62afc5b 1262 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 1263 RZA_IO_RegWrite_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 1264 0,
Kojto 39:d96aa62afc5b 1265 USB_PIPEnCTR_1_5_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1266 USB_PIPEnCTR_1_5_ACLRM);
Kojto 39:d96aa62afc5b 1267 break;
Kojto 39:d96aa62afc5b 1268
Kojto 39:d96aa62afc5b 1269 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 1270 RZA_IO_RegWrite_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 1271 0,
Kojto 39:d96aa62afc5b 1272 USB_PIPEnCTR_1_5_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1273 USB_PIPEnCTR_1_5_ACLRM);
Kojto 39:d96aa62afc5b 1274 break;
Kojto 39:d96aa62afc5b 1275
Kojto 39:d96aa62afc5b 1276 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 1277 RZA_IO_RegWrite_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 1278 0,
Kojto 39:d96aa62afc5b 1279 USB_PIPEnCTR_1_5_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1280 USB_PIPEnCTR_1_5_ACLRM);
Kojto 39:d96aa62afc5b 1281 break;
Kojto 39:d96aa62afc5b 1282
Kojto 39:d96aa62afc5b 1283 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 1284 RZA_IO_RegWrite_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 1285 0,
Kojto 39:d96aa62afc5b 1286 USB_PIPEnCTR_1_5_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1287 USB_PIPEnCTR_1_5_ACLRM);
Kojto 39:d96aa62afc5b 1288 break;
Kojto 39:d96aa62afc5b 1289
Kojto 39:d96aa62afc5b 1290 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 1291 RZA_IO_RegWrite_16(&USB200.PIPE6CTR,
Kojto 39:d96aa62afc5b 1292 0,
Kojto 39:d96aa62afc5b 1293 USB_PIPEnCTR_6_8_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1294 USB_PIPEnCTR_6_8_ACLRM);
Kojto 39:d96aa62afc5b 1295 break;
Kojto 39:d96aa62afc5b 1296
Kojto 39:d96aa62afc5b 1297 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 1298 RZA_IO_RegWrite_16(&USB200.PIPE7CTR,
Kojto 39:d96aa62afc5b 1299 0,
Kojto 39:d96aa62afc5b 1300 USB_PIPEnCTR_6_8_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1301 USB_PIPEnCTR_6_8_ACLRM);
Kojto 39:d96aa62afc5b 1302 break;
Kojto 39:d96aa62afc5b 1303
Kojto 39:d96aa62afc5b 1304 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 1305 RZA_IO_RegWrite_16(&USB200.PIPE8CTR,
Kojto 39:d96aa62afc5b 1306 0,
Kojto 39:d96aa62afc5b 1307 USB_PIPEnCTR_6_8_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1308 USB_PIPEnCTR_6_8_ACLRM);
Kojto 39:d96aa62afc5b 1309 break;
Kojto 39:d96aa62afc5b 1310
Kojto 39:d96aa62afc5b 1311 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 1312 RZA_IO_RegWrite_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 1313 0,
Kojto 39:d96aa62afc5b 1314 USB_PIPEnCTR_9_ACLRM_SHIFT,
Kojto 39:d96aa62afc5b 1315 USB_PIPEnCTR_9_ACLRM);
Kojto 39:d96aa62afc5b 1316 break;
Kojto 39:d96aa62afc5b 1317
Kojto 39:d96aa62afc5b 1318 default:
Kojto 39:d96aa62afc5b 1319 break;
Kojto 39:d96aa62afc5b 1320 }
Kojto 39:d96aa62afc5b 1321 }
Kojto 39:d96aa62afc5b 1322
Kojto 39:d96aa62afc5b 1323 /*******************************************************************************
Kojto 39:d96aa62afc5b 1324 * Function Name: usb0_host_get_inbuf
Kojto 39:d96aa62afc5b 1325 * Description : Returns INBUFM of the pipe specified by the argument.
Kojto 39:d96aa62afc5b 1326 * Arguments : uint16_t pipe ; Pipe Number
Kojto 39:d96aa62afc5b 1327 * Return Value : inbuf
Kojto 39:d96aa62afc5b 1328 *******************************************************************************/
Kojto 39:d96aa62afc5b 1329 uint16_t usb0_host_get_inbuf (uint16_t pipe)
Kojto 39:d96aa62afc5b 1330 {
Kojto 39:d96aa62afc5b 1331 uint16_t inbuf;
Kojto 39:d96aa62afc5b 1332
Kojto 39:d96aa62afc5b 1333 switch (pipe)
Kojto 39:d96aa62afc5b 1334 {
Kojto 39:d96aa62afc5b 1335 case USB_HOST_PIPE0:
Kojto 39:d96aa62afc5b 1336 inbuf = 0;
Kojto 39:d96aa62afc5b 1337 break;
Kojto 39:d96aa62afc5b 1338
Kojto 39:d96aa62afc5b 1339 case USB_HOST_PIPE1:
Kojto 39:d96aa62afc5b 1340 inbuf = RZA_IO_RegRead_16(&USB200.PIPE1CTR,
Kojto 39:d96aa62afc5b 1341 USB_PIPEnCTR_1_5_INBUFM_SHIFT,
Kojto 39:d96aa62afc5b 1342 USB_PIPEnCTR_1_5_INBUFM);
Kojto 39:d96aa62afc5b 1343 break;
Kojto 39:d96aa62afc5b 1344
Kojto 39:d96aa62afc5b 1345 case USB_HOST_PIPE2:
Kojto 39:d96aa62afc5b 1346 inbuf = RZA_IO_RegRead_16(&USB200.PIPE2CTR,
Kojto 39:d96aa62afc5b 1347 USB_PIPEnCTR_1_5_INBUFM_SHIFT,
Kojto 39:d96aa62afc5b 1348 USB_PIPEnCTR_1_5_INBUFM);
Kojto 39:d96aa62afc5b 1349 break;
Kojto 39:d96aa62afc5b 1350
Kojto 39:d96aa62afc5b 1351 case USB_HOST_PIPE3:
Kojto 39:d96aa62afc5b 1352 inbuf = RZA_IO_RegRead_16(&USB200.PIPE3CTR,
Kojto 39:d96aa62afc5b 1353 USB_PIPEnCTR_1_5_INBUFM_SHIFT,
Kojto 39:d96aa62afc5b 1354 USB_PIPEnCTR_1_5_INBUFM);
Kojto 39:d96aa62afc5b 1355 break;
Kojto 39:d96aa62afc5b 1356
Kojto 39:d96aa62afc5b 1357 case USB_HOST_PIPE4:
Kojto 39:d96aa62afc5b 1358 inbuf = RZA_IO_RegRead_16(&USB200.PIPE4CTR,
Kojto 39:d96aa62afc5b 1359 USB_PIPEnCTR_1_5_INBUFM_SHIFT,
Kojto 39:d96aa62afc5b 1360 USB_PIPEnCTR_1_5_INBUFM);
Kojto 39:d96aa62afc5b 1361 break;
Kojto 39:d96aa62afc5b 1362
Kojto 39:d96aa62afc5b 1363 case USB_HOST_PIPE5:
Kojto 39:d96aa62afc5b 1364 inbuf = RZA_IO_RegRead_16(&USB200.PIPE5CTR,
Kojto 39:d96aa62afc5b 1365 USB_PIPEnCTR_1_5_INBUFM_SHIFT,
Kojto 39:d96aa62afc5b 1366 USB_PIPEnCTR_1_5_INBUFM);
Kojto 39:d96aa62afc5b 1367 break;
Kojto 39:d96aa62afc5b 1368
Kojto 39:d96aa62afc5b 1369 case USB_HOST_PIPE6:
Kojto 39:d96aa62afc5b 1370 inbuf = 0;
Kojto 39:d96aa62afc5b 1371 break;
Kojto 39:d96aa62afc5b 1372
Kojto 39:d96aa62afc5b 1373 case USB_HOST_PIPE7:
Kojto 39:d96aa62afc5b 1374 inbuf = 0;
Kojto 39:d96aa62afc5b 1375 break;
Kojto 39:d96aa62afc5b 1376
Kojto 39:d96aa62afc5b 1377 case USB_HOST_PIPE8:
Kojto 39:d96aa62afc5b 1378 inbuf = 0;
Kojto 39:d96aa62afc5b 1379 break;
Kojto 39:d96aa62afc5b 1380
Kojto 39:d96aa62afc5b 1381 case USB_HOST_PIPE9:
Kojto 39:d96aa62afc5b 1382 inbuf = RZA_IO_RegRead_16(&USB200.PIPE9CTR,
Kojto 39:d96aa62afc5b 1383 USB_PIPEnCTR_9_INBUFM_SHIFT,
Kojto 39:d96aa62afc5b 1384 USB_PIPEnCTR_9_INBUFM);
Kojto 39:d96aa62afc5b 1385 break;
Kojto 39:d96aa62afc5b 1386
Kojto 39:d96aa62afc5b 1387 default:
Kojto 39:d96aa62afc5b 1388 inbuf = 0;
Kojto 39:d96aa62afc5b 1389 break;
Kojto 39:d96aa62afc5b 1390 }
Kojto 39:d96aa62afc5b 1391
Kojto 39:d96aa62afc5b 1392 return inbuf;
Kojto 39:d96aa62afc5b 1393 }
Kojto 39:d96aa62afc5b 1394
Kojto 39:d96aa62afc5b 1395 /*******************************************************************************
Kojto 39:d96aa62afc5b 1396 * Function Name: usb0_host_setting_interrupt
Kojto 39:d96aa62afc5b 1397 * Description : Sets the USB module interrupt level.
Kojto 39:d96aa62afc5b 1398 * Arguments : uint8_t level ; interrupt level
Kojto 39:d96aa62afc5b 1399 * Return Value : none
Kojto 39:d96aa62afc5b 1400 *******************************************************************************/
Kojto 39:d96aa62afc5b 1401 void usb0_host_setting_interrupt (uint8_t level)
Kojto 39:d96aa62afc5b 1402 {
Kojto 39:d96aa62afc5b 1403 #if(1) /* ohci_wrapp */
Kojto 39:d96aa62afc5b 1404 IRQn_Type d0fifo_dmaintid;
Kojto 39:d96aa62afc5b 1405 IRQn_Type d1fifo_dmaintid;
Kojto 39:d96aa62afc5b 1406
Kojto 39:d96aa62afc5b 1407 InterruptHandlerRegister(USBI0_IRQn, usb0_host_interrupt);
Kojto 39:d96aa62afc5b 1408 GIC_SetPriority(USBI0_IRQn, level);
Kojto 39:d96aa62afc5b 1409 GIC_EnableIRQ(USBI0_IRQn);
Kojto 39:d96aa62afc5b 1410
Kojto 39:d96aa62afc5b 1411 d0fifo_dmaintid = (IRQn_Type)Userdef_USB_usb0_host_d0fifo_dmaintid();
Kojto 39:d96aa62afc5b 1412
Kojto 39:d96aa62afc5b 1413 if (d0fifo_dmaintid != 0xFFFF)
Kojto 39:d96aa62afc5b 1414 {
Kojto 39:d96aa62afc5b 1415 InterruptHandlerRegister(d0fifo_dmaintid, usb0_host_dma_interrupt_d0fifo);
Kojto 39:d96aa62afc5b 1416 GIC_SetPriority(d0fifo_dmaintid, level);
Kojto 39:d96aa62afc5b 1417 GIC_EnableIRQ(d0fifo_dmaintid);
Kojto 39:d96aa62afc5b 1418 }
Kojto 39:d96aa62afc5b 1419
Kojto 39:d96aa62afc5b 1420 d1fifo_dmaintid = (IRQn_Type)Userdef_USB_usb0_host_d1fifo_dmaintid();
Kojto 39:d96aa62afc5b 1421
Kojto 39:d96aa62afc5b 1422 if (d1fifo_dmaintid != 0xFFFF)
Kojto 39:d96aa62afc5b 1423 {
Kojto 39:d96aa62afc5b 1424 InterruptHandlerRegister(d1fifo_dmaintid, usb0_host_dma_interrupt_d1fifo);
Kojto 39:d96aa62afc5b 1425 GIC_SetPriority(d1fifo_dmaintid, level);
Kojto 39:d96aa62afc5b 1426 GIC_EnableIRQ(d1fifo_dmaintid);
Kojto 39:d96aa62afc5b 1427 }
Kojto 39:d96aa62afc5b 1428 #else
Kojto 39:d96aa62afc5b 1429 uint16_t d0fifo_dmaintid;
Kojto 39:d96aa62afc5b 1430 uint16_t d1fifo_dmaintid;
Kojto 39:d96aa62afc5b 1431
Kojto 39:d96aa62afc5b 1432 R_INTC_RegistIntFunc(INTC_ID_USBI0, usb0_host_interrupt);
Kojto 39:d96aa62afc5b 1433 R_INTC_SetPriority(INTC_ID_USBI0, level);
Kojto 39:d96aa62afc5b 1434 R_INTC_Enable(INTC_ID_USBI0);
Kojto 39:d96aa62afc5b 1435
Kojto 39:d96aa62afc5b 1436 d0fifo_dmaintid = Userdef_USB_usb0_host_d0fifo_dmaintid();
Kojto 39:d96aa62afc5b 1437
Kojto 39:d96aa62afc5b 1438 if (d0fifo_dmaintid != 0xFFFF)
Kojto 39:d96aa62afc5b 1439 {
Kojto 39:d96aa62afc5b 1440 R_INTC_RegistIntFunc(d0fifo_dmaintid, usb0_host_dma_interrupt_d0fifo);
Kojto 39:d96aa62afc5b 1441 R_INTC_SetPriority(d0fifo_dmaintid, level);
Kojto 39:d96aa62afc5b 1442 R_INTC_Enable(d0fifo_dmaintid);
Kojto 39:d96aa62afc5b 1443 }
Kojto 39:d96aa62afc5b 1444
Kojto 39:d96aa62afc5b 1445 d1fifo_dmaintid = Userdef_USB_usb0_host_d1fifo_dmaintid();
Kojto 39:d96aa62afc5b 1446
Kojto 39:d96aa62afc5b 1447 if (d1fifo_dmaintid != 0xFFFF)
Kojto 39:d96aa62afc5b 1448 {
Kojto 39:d96aa62afc5b 1449 R_INTC_RegistIntFunc(d1fifo_dmaintid, usb0_host_dma_interrupt_d1fifo);
Kojto 39:d96aa62afc5b 1450 R_INTC_SetPriority(d1fifo_dmaintid, level);
Kojto 39:d96aa62afc5b 1451 R_INTC_Enable(d1fifo_dmaintid);
Kojto 39:d96aa62afc5b 1452 }
Kojto 39:d96aa62afc5b 1453 #endif
Kojto 39:d96aa62afc5b 1454 }
Kojto 39:d96aa62afc5b 1455
Kojto 39:d96aa62afc5b 1456 /*******************************************************************************
Kojto 39:d96aa62afc5b 1457 * Function Name: usb0_host_reset_module
Kojto 39:d96aa62afc5b 1458 * Description : Initializes the USB module.
Kojto 39:d96aa62afc5b 1459 * : Enables providing clock to the USB module.
Kojto 39:d96aa62afc5b 1460 * : Sets USB bus wait register.
Kojto 39:d96aa62afc5b 1461 * Arguments : uint16_t clockmode ; 48MHz ; USBHCLOCK_X1_48MHZ
Kojto 39:d96aa62afc5b 1462 * : ; 12MHz ; USBHCLOCK_EXTAL_12MHZ
Kojto 39:d96aa62afc5b 1463 * Return Value : none
Kojto 39:d96aa62afc5b 1464 *******************************************************************************/
Kojto 39:d96aa62afc5b 1465 void usb0_host_reset_module (uint16_t clockmode)
Kojto 39:d96aa62afc5b 1466 {
Kojto 39:d96aa62afc5b 1467 if (RZA_IO_RegRead_16(&USB200.SYSCFG0,
Kojto 39:d96aa62afc5b 1468 USB_SYSCFG_UPLLE_SHIFT,
Kojto 39:d96aa62afc5b 1469 USB_SYSCFG_UPLLE) == 1)
Kojto 39:d96aa62afc5b 1470 {
Kojto 39:d96aa62afc5b 1471 if ((USB200.SYSCFG0 & USB_HOST_BITUCKSEL) != clockmode)
Kojto 39:d96aa62afc5b 1472 {
Kojto 39:d96aa62afc5b 1473 RZA_IO_RegWrite_16(&USB200.SUSPMODE,
Kojto 39:d96aa62afc5b 1474 0,
Kojto 39:d96aa62afc5b 1475 USB_SUSPMODE_SUSPM_SHIFT,
Kojto 39:d96aa62afc5b 1476 USB_SUSPMODE_SUSPM);
Kojto 39:d96aa62afc5b 1477 USB200.SYSCFG0 = 0;
Kojto 39:d96aa62afc5b 1478 USB200.SYSCFG0 = (USB_HOST_BITUPLLE | clockmode);
Kojto 39:d96aa62afc5b 1479 Userdef_USB_usb0_host_delay_xms(1);
Kojto 39:d96aa62afc5b 1480 RZA_IO_RegWrite_16(&USB200.SUSPMODE,
Kojto 39:d96aa62afc5b 1481 1,
Kojto 39:d96aa62afc5b 1482 USB_SUSPMODE_SUSPM_SHIFT,
Kojto 39:d96aa62afc5b 1483 USB_SUSPMODE_SUSPM);
Kojto 39:d96aa62afc5b 1484 }
Kojto 39:d96aa62afc5b 1485 else
Kojto 39:d96aa62afc5b 1486 {
Kojto 39:d96aa62afc5b 1487 RZA_IO_RegWrite_16(&USB200.SUSPMODE,
Kojto 39:d96aa62afc5b 1488 0,
Kojto 39:d96aa62afc5b 1489 USB_SUSPMODE_SUSPM_SHIFT,
Kojto 39:d96aa62afc5b 1490 USB_SUSPMODE_SUSPM);
Kojto 39:d96aa62afc5b 1491 Userdef_USB_usb0_host_delay_xms(1);
Kojto 39:d96aa62afc5b 1492 RZA_IO_RegWrite_16(&USB200.SUSPMODE,
Kojto 39:d96aa62afc5b 1493 1,
Kojto 39:d96aa62afc5b 1494 USB_SUSPMODE_SUSPM_SHIFT,
Kojto 39:d96aa62afc5b 1495 USB_SUSPMODE_SUSPM);
Kojto 39:d96aa62afc5b 1496 }
Kojto 39:d96aa62afc5b 1497 }
Kojto 39:d96aa62afc5b 1498 else
Kojto 39:d96aa62afc5b 1499 {
Kojto 39:d96aa62afc5b 1500 RZA_IO_RegWrite_16(&USB200.SUSPMODE,
Kojto 39:d96aa62afc5b 1501 0,
Kojto 39:d96aa62afc5b 1502 USB_SUSPMODE_SUSPM_SHIFT,
Kojto 39:d96aa62afc5b 1503 USB_SUSPMODE_SUSPM);
Kojto 39:d96aa62afc5b 1504 USB200.SYSCFG0 = 0;
Kojto 39:d96aa62afc5b 1505 USB200.SYSCFG0 = (USB_HOST_BITUPLLE | clockmode);
Kojto 39:d96aa62afc5b 1506 Userdef_USB_usb0_host_delay_xms(1);
Kojto 39:d96aa62afc5b 1507 RZA_IO_RegWrite_16(&USB200.SUSPMODE,
Kojto 39:d96aa62afc5b 1508 1,
Kojto 39:d96aa62afc5b 1509 USB_SUSPMODE_SUSPM_SHIFT,
Kojto 39:d96aa62afc5b 1510 USB_SUSPMODE_SUSPM);
Kojto 39:d96aa62afc5b 1511 }
Kojto 39:d96aa62afc5b 1512
Kojto 39:d96aa62afc5b 1513 USB200.BUSWAIT = (uint16_t)(USB_HOST_BUSWAIT_05 & USB_HOST_BITBWAIT);
Kojto 39:d96aa62afc5b 1514 }
Kojto 39:d96aa62afc5b 1515
Kojto 39:d96aa62afc5b 1516 /*******************************************************************************
Kojto 39:d96aa62afc5b 1517 * Function Name: usb0_host_get_buf_size
Kojto 39:d96aa62afc5b 1518 * Description : Obtains pipe buffer size specified by the argument and
Kojto 39:d96aa62afc5b 1519 * : maximum packet size of the USB device in use.
Kojto 39:d96aa62afc5b 1520 * : When USB_HOST_PIPE0 is specified by the argument, obtains the maximum
Kojto 39:d96aa62afc5b 1521 * : packet size of the USB device using the corresponding pipe.
Kojto 39:d96aa62afc5b 1522 * : For the case that USB_HOST_PIPE0 is not assigned by the argument, when the
Kojto 39:d96aa62afc5b 1523 * : corresponding pipe is in continuous transfer mode,
Kojto 39:d96aa62afc5b 1524 * : obtains the buffer size allocated in the corresponcing pipe,
Kojto 39:d96aa62afc5b 1525 * : when incontinuous transfer, obtains maximum packet size.
Kojto 39:d96aa62afc5b 1526 * Arguments : uint16_t ; pipe Number
Kojto 39:d96aa62afc5b 1527 * Return Value : Maximum packet size or buffer size
Kojto 39:d96aa62afc5b 1528 *******************************************************************************/
Kojto 39:d96aa62afc5b 1529 uint16_t usb0_host_get_buf_size (uint16_t pipe)
Kojto 39:d96aa62afc5b 1530 {
Kojto 39:d96aa62afc5b 1531 uint16_t size;
Kojto 39:d96aa62afc5b 1532 uint16_t bufsize;
Kojto 39:d96aa62afc5b 1533
Kojto 39:d96aa62afc5b 1534 if (pipe == USB_HOST_PIPE0)
Kojto 39:d96aa62afc5b 1535 {
Kojto 39:d96aa62afc5b 1536 size = RZA_IO_RegRead_16(&USB200.DCPMAXP,
Kojto 39:d96aa62afc5b 1537 USB_DCPMAXP_MXPS_SHIFT,
Kojto 39:d96aa62afc5b 1538 USB_DCPMAXP_MXPS);
Kojto 39:d96aa62afc5b 1539 }
Kojto 39:d96aa62afc5b 1540 else
Kojto 39:d96aa62afc5b 1541 {
Kojto 39:d96aa62afc5b 1542 if (RZA_IO_RegRead_16(&g_usb0_host_pipecfg[pipe], USB_PIPECFG_CNTMD_SHIFT, USB_PIPECFG_CNTMD) == 1)
Kojto 39:d96aa62afc5b 1543 {
Kojto 39:d96aa62afc5b 1544 bufsize = RZA_IO_RegRead_16(&g_usb0_host_pipebuf[pipe], USB_PIPEBUF_BUFSIZE_SHIFT, USB_PIPEBUF_BUFSIZE);
Kojto 39:d96aa62afc5b 1545 size = (uint16_t)((bufsize + 1) * USB_HOST_PIPExBUF);
Kojto 39:d96aa62afc5b 1546 }
Kojto 39:d96aa62afc5b 1547 else
Kojto 39:d96aa62afc5b 1548 {
Kojto 39:d96aa62afc5b 1549 size = RZA_IO_RegRead_16(&g_usb0_host_pipemaxp[pipe], USB_PIPEMAXP_MXPS_SHIFT, USB_PIPEMAXP_MXPS);
Kojto 39:d96aa62afc5b 1550 }
Kojto 39:d96aa62afc5b 1551 }
Kojto 39:d96aa62afc5b 1552 return size;
Kojto 39:d96aa62afc5b 1553 }
Kojto 39:d96aa62afc5b 1554
Kojto 39:d96aa62afc5b 1555 /*******************************************************************************
Kojto 39:d96aa62afc5b 1556 * Function Name: usb0_host_get_mxps
Kojto 39:d96aa62afc5b 1557 * Description : Obtains maximum packet size of the USB device using the pipe
Kojto 39:d96aa62afc5b 1558 * : specified by the argument.
Kojto 39:d96aa62afc5b 1559 * Arguments : uint16_t ; Pipe Number
Kojto 39:d96aa62afc5b 1560 * Return Value : Max Packet Size
Kojto 39:d96aa62afc5b 1561 *******************************************************************************/
Kojto 39:d96aa62afc5b 1562 uint16_t usb0_host_get_mxps (uint16_t pipe)
Kojto 39:d96aa62afc5b 1563 {
Kojto 39:d96aa62afc5b 1564 uint16_t size;
Kojto 39:d96aa62afc5b 1565
Kojto 39:d96aa62afc5b 1566 if (pipe == USB_HOST_PIPE0)
Kojto 39:d96aa62afc5b 1567 {
Kojto 39:d96aa62afc5b 1568 size = RZA_IO_RegRead_16(&USB200.DCPMAXP,
Kojto 39:d96aa62afc5b 1569 USB_DCPMAXP_MXPS_SHIFT,
Kojto 39:d96aa62afc5b 1570 USB_DCPMAXP_MXPS);
Kojto 39:d96aa62afc5b 1571 }
Kojto 39:d96aa62afc5b 1572 else
Kojto 39:d96aa62afc5b 1573 {
Kojto 39:d96aa62afc5b 1574 size = RZA_IO_RegRead_16(&g_usb0_host_pipemaxp[pipe], USB_PIPEMAXP_MXPS_SHIFT, USB_PIPEMAXP_MXPS);
Kojto 39:d96aa62afc5b 1575 }
Kojto 39:d96aa62afc5b 1576
Kojto 39:d96aa62afc5b 1577 return size;
Kojto 39:d96aa62afc5b 1578 }
Kojto 39:d96aa62afc5b 1579
Kojto 39:d96aa62afc5b 1580 /* End of File */