SDG+USBHost(Mouse) Sample

Dependencies:   Sound_Generator USBHost_custom

Fork of SDG_Mouse_Sample by GR-PEACH_producer_meeting

Information

Japanese version is available in lower part of this page.
このページの後半に日本語版が用意されています.

What is this?

This program is a demonstration that sounds the sound by mouse operation by using USBHost(Mouse) and Sound Generator.

Settings

Close JP3 of GR-PEACH.
/media/uploads/RyoheiHagimoto/sdg-mouse.jpg

Operation

operationeffect
Right clickSounds
Left clickReset to base tone (C)
Moves the mouse to the rightLower the sound
Moves the mouse to the leftHigher the sound
Center cursorAdjust the sensitivity.
Reset the reference value in the click.

Others

The default setting of serial communication (baud rate etc.) in mbed is shown the following link.
Please refer to the link and change the settings of your PC terminal software.
The default value of baud rate in mbed is 9600, and this application uses baud rate 9600.
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication


概要

このプログラムは、USBHost(Mouse) + Sound Generatorで、マウス操作による擬似笛デモです。

設定

GR-PEACHのJP3をショートする必要があります。
/media/uploads/RyoheiHagimoto/sdg-mouse.jpg

操作方法

操作内容
右クリック音出力開始
左クリック基準音(ド)にリセット
マウス右移動高音になります
マウス左移動低音になります
センターカーソル音高低の変化量調整(クリックで基準値にリセット)

Others

mbedのシリアル通信(ボーレート等)のデフォルト設定は以下のリンクに示しています。
リンクを参考に、お使いのPCターミナルソフトの設定を変更して下さい。
mbedでのボーレートのデフォルト値は9600で、このサンプルではボーレート9600を使います。
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication

Committer:
mbed_official
Date:
Mon Jan 19 14:30:37 2015 +0000
Revision:
27:4206883f4cb7
Synchronized with git revision 0ab8d2e6b3d884137dcb5c62d29a07abe132bac7

Full URL: https://github.com/mbedmicro/mbed/commit/0ab8d2e6b3d884137dcb5c62d29a07abe132bac7/

RZ_A1H - Implement some USB functions and fix some bugs about USBHost common codes.

Who changed what in which revision?

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