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_usbint.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 "ohci_wrapp_RZ_A1_local.h"
mbed_official 27:4206883f4cb7 43 #endif
mbed_official 27:4206883f4cb7 44
mbed_official 27:4206883f4cb7 45
mbed_official 27:4206883f4cb7 46 /*******************************************************************************
mbed_official 27:4206883f4cb7 47 Typedef definitions
mbed_official 27:4206883f4cb7 48 *******************************************************************************/
mbed_official 27:4206883f4cb7 49
mbed_official 27:4206883f4cb7 50
mbed_official 27:4206883f4cb7 51 /*******************************************************************************
mbed_official 27:4206883f4cb7 52 Macro definitions
mbed_official 27:4206883f4cb7 53 *******************************************************************************/
mbed_official 27:4206883f4cb7 54
mbed_official 27:4206883f4cb7 55
mbed_official 27:4206883f4cb7 56 /*******************************************************************************
mbed_official 27:4206883f4cb7 57 Imported global variables and functions (from other files)
mbed_official 27:4206883f4cb7 58 *******************************************************************************/
mbed_official 27:4206883f4cb7 59
mbed_official 27:4206883f4cb7 60
mbed_official 27:4206883f4cb7 61 /*******************************************************************************
mbed_official 27:4206883f4cb7 62 Exported global variables and functions (to be accessed by other files)
mbed_official 27:4206883f4cb7 63 *******************************************************************************/
mbed_official 27:4206883f4cb7 64 static void usb0_host_interrupt1(void);
mbed_official 27:4206883f4cb7 65 static void usb0_host_BRDYInterrupt(uint16_t Status, uint16_t Int_enbl);
mbed_official 27:4206883f4cb7 66 static void usb0_host_NRDYInterrupt(uint16_t Status, uint16_t Int_enbl);
mbed_official 27:4206883f4cb7 67 static void usb0_host_BEMPInterrupt(uint16_t Status, uint16_t Int_enbl);
mbed_official 27:4206883f4cb7 68
mbed_official 27:4206883f4cb7 69
mbed_official 27:4206883f4cb7 70 /*******************************************************************************
mbed_official 27:4206883f4cb7 71 Private global variables and functions
mbed_official 27:4206883f4cb7 72 *******************************************************************************/
mbed_official 27:4206883f4cb7 73
mbed_official 27:4206883f4cb7 74
mbed_official 27:4206883f4cb7 75 /*******************************************************************************
mbed_official 27:4206883f4cb7 76 * Function Name: usb0_host_interrupt
mbed_official 27:4206883f4cb7 77 * Description : Executes USB interrupt.
mbed_official 27:4206883f4cb7 78 * : Register this function in the USB interrupt handler.
mbed_official 27:4206883f4cb7 79 * : Set CFIF0 in the pipe set before the interrupt after executing
mbed_official 27:4206883f4cb7 80 * : this function.
mbed_official 27:4206883f4cb7 81 * Arguments : uint32_t int_sense ; Interrupts detection mode
mbed_official 27:4206883f4cb7 82 * : ; INTC_LEVEL_SENSITIVE : Level sense
mbed_official 27:4206883f4cb7 83 * : ; INTC_EDGE_TRIGGER : Edge trigger
mbed_official 27:4206883f4cb7 84 * Return Value : none
mbed_official 27:4206883f4cb7 85 *******************************************************************************/
mbed_official 27:4206883f4cb7 86 void usb0_host_interrupt (uint32_t int_sense)
mbed_official 27:4206883f4cb7 87 {
mbed_official 27:4206883f4cb7 88 uint16_t savepipe1;
mbed_official 27:4206883f4cb7 89 uint16_t savepipe2;
mbed_official 27:4206883f4cb7 90 uint16_t buffer;
mbed_official 27:4206883f4cb7 91
mbed_official 27:4206883f4cb7 92 savepipe1 = USB200.CFIFOSEL;
mbed_official 27:4206883f4cb7 93 savepipe2 = USB200.PIPESEL;
mbed_official 27:4206883f4cb7 94 usb0_host_interrupt1();
mbed_official 27:4206883f4cb7 95
mbed_official 27:4206883f4cb7 96 /* Control transmission changes ISEL within interruption processing. */
mbed_official 27:4206883f4cb7 97 /* For this reason, write return of ISEL cannot be performed. */
mbed_official 27:4206883f4cb7 98 buffer = USB200.CFIFOSEL;
mbed_official 27:4206883f4cb7 99 buffer &= (uint16_t)~(USB_HOST_BITCURPIPE);
mbed_official 27:4206883f4cb7 100 buffer |= (uint16_t)(savepipe1 & USB_HOST_BITCURPIPE);
mbed_official 27:4206883f4cb7 101 USB200.CFIFOSEL = buffer;
mbed_official 27:4206883f4cb7 102 USB200.PIPESEL = savepipe2;
mbed_official 27:4206883f4cb7 103 }
mbed_official 27:4206883f4cb7 104
mbed_official 27:4206883f4cb7 105 /*******************************************************************************
mbed_official 27:4206883f4cb7 106 * Function Name: usb0_host_interrupt1
mbed_official 27:4206883f4cb7 107 * Description : Execue the USB interrupt.
mbed_official 27:4206883f4cb7 108 * Arguments : none
mbed_official 27:4206883f4cb7 109 * Return Value : none
mbed_official 27:4206883f4cb7 110 *******************************************************************************/
mbed_official 27:4206883f4cb7 111 void usb0_host_interrupt1 (void)
mbed_official 27:4206883f4cb7 112 {
mbed_official 27:4206883f4cb7 113 uint16_t intsts0;
mbed_official 27:4206883f4cb7 114 uint16_t intsts1;
mbed_official 27:4206883f4cb7 115 uint16_t intenb0;
mbed_official 27:4206883f4cb7 116 uint16_t intenb1;
mbed_official 27:4206883f4cb7 117 uint16_t brdysts;
mbed_official 27:4206883f4cb7 118 uint16_t nrdysts;
mbed_official 27:4206883f4cb7 119 uint16_t bempsts;
mbed_official 27:4206883f4cb7 120 uint16_t brdyenb;
mbed_official 27:4206883f4cb7 121 uint16_t nrdyenb;
mbed_official 27:4206883f4cb7 122 uint16_t bempenb;
mbed_official 27:4206883f4cb7 123 volatile uint16_t dumy_sts;
mbed_official 27:4206883f4cb7 124
mbed_official 27:4206883f4cb7 125 intsts0 = USB200.INTSTS0;
mbed_official 27:4206883f4cb7 126 intsts1 = USB200.INTSTS1;
mbed_official 27:4206883f4cb7 127 intenb0 = USB200.INTENB0;
mbed_official 27:4206883f4cb7 128 intenb1 = USB200.INTENB1;
mbed_official 27:4206883f4cb7 129
mbed_official 27:4206883f4cb7 130 if ((intsts1 & USB_HOST_BITBCHG) && (intenb1 & USB_HOST_BITBCHGE))
mbed_official 27:4206883f4cb7 131 {
mbed_official 27:4206883f4cb7 132 USB200.INTSTS1 = (uint16_t)~USB_HOST_BITBCHG;
mbed_official 27:4206883f4cb7 133 RZA_IO_RegWrite_16(&USB200.INTENB1,
mbed_official 27:4206883f4cb7 134 0,
mbed_official 27:4206883f4cb7 135 USB_INTENB1_BCHGE_SHIFT,
mbed_official 27:4206883f4cb7 136 USB_INTENB1_BCHGE);
mbed_official 27:4206883f4cb7 137 g_usb0_host_bchg_flag = USB_HOST_YES;
mbed_official 27:4206883f4cb7 138 }
mbed_official 27:4206883f4cb7 139 else if ((intsts1 & USB_HOST_BITSACK) && (intenb1 & USB_HOST_BITSACKE))
mbed_official 27:4206883f4cb7 140 {
mbed_official 27:4206883f4cb7 141 USB200.INTSTS1 = (uint16_t)~USB_HOST_BITSACK;
mbed_official 27:4206883f4cb7 142 #if(1) /* ohci_wrapp */
mbed_official 27:4206883f4cb7 143 ohciwrapp_loc_TransEnd(USB_HOST_PIPE0, TD_CC_NOERROR);
mbed_official 27:4206883f4cb7 144 #else
mbed_official 27:4206883f4cb7 145 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 146 g_usb0_host_CmdStage |= USB_HOST_CMD_DONE;
mbed_official 27:4206883f4cb7 147 #endif
mbed_official 27:4206883f4cb7 148 }
mbed_official 27:4206883f4cb7 149 else if ((intsts1 & USB_HOST_BITSIGN) && (intenb1 & USB_HOST_BITSIGNE))
mbed_official 27:4206883f4cb7 150 {
mbed_official 27:4206883f4cb7 151 USB200.INTSTS1 = (uint16_t)~USB_HOST_BITSIGN;
mbed_official 27:4206883f4cb7 152 #if(1) /* ohci_wrapp */
mbed_official 27:4206883f4cb7 153 g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_NORES; /* exit NORES */
mbed_official 27:4206883f4cb7 154 ohciwrapp_loc_TransEnd(USB_HOST_PIPE0, TD_CC_STALL);
mbed_official 27:4206883f4cb7 155 #else
mbed_official 27:4206883f4cb7 156 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 157 g_usb0_host_CmdStage |= USB_HOST_CMD_NORES;
mbed_official 27:4206883f4cb7 158 #endif
mbed_official 27:4206883f4cb7 159 }
mbed_official 27:4206883f4cb7 160 else if (((intsts1 & USB_HOST_BITDTCH) == USB_HOST_BITDTCH)
mbed_official 27:4206883f4cb7 161 && ((intenb1 & USB_HOST_BITDTCHE) == USB_HOST_BITDTCHE))
mbed_official 27:4206883f4cb7 162 {
mbed_official 27:4206883f4cb7 163 USB200.INTSTS1 = (uint16_t)~USB_HOST_BITDTCH;
mbed_official 27:4206883f4cb7 164 RZA_IO_RegWrite_16(&USB200.INTENB1,
mbed_official 27:4206883f4cb7 165 0,
mbed_official 27:4206883f4cb7 166 USB_INTENB1_DTCHE_SHIFT,
mbed_official 27:4206883f4cb7 167 USB_INTENB1_DTCHE);
mbed_official 27:4206883f4cb7 168 g_usb0_host_detach_flag = USB_HOST_YES;
mbed_official 27:4206883f4cb7 169
mbed_official 27:4206883f4cb7 170 Userdef_USB_usb0_host_detach();
mbed_official 27:4206883f4cb7 171
mbed_official 27:4206883f4cb7 172 usb0_host_UsbDetach2();
mbed_official 27:4206883f4cb7 173 }
mbed_official 27:4206883f4cb7 174 else if (((intsts1 & USB_HOST_BITATTCH) == USB_HOST_BITATTCH)
mbed_official 27:4206883f4cb7 175 && ((intenb1 & USB_HOST_BITATTCHE) == USB_HOST_BITATTCHE))
mbed_official 27:4206883f4cb7 176 {
mbed_official 27:4206883f4cb7 177 USB200.INTSTS1 = (uint16_t)~USB_HOST_BITATTCH;
mbed_official 27:4206883f4cb7 178 RZA_IO_RegWrite_16(&USB200.INTENB1,
mbed_official 27:4206883f4cb7 179 0,
mbed_official 27:4206883f4cb7 180 USB_INTENB1_ATTCHE_SHIFT,
mbed_official 27:4206883f4cb7 181 USB_INTENB1_ATTCHE);
mbed_official 27:4206883f4cb7 182 g_usb0_host_attach_flag = USB_HOST_YES;
mbed_official 27:4206883f4cb7 183
mbed_official 27:4206883f4cb7 184 Userdef_USB_usb0_host_attach();
mbed_official 27:4206883f4cb7 185
mbed_official 27:4206883f4cb7 186 usb0_host_UsbAttach();
mbed_official 27:4206883f4cb7 187 }
mbed_official 27:4206883f4cb7 188 else if ((intsts0 & intenb0 & (USB_HOST_BITBEMP | USB_HOST_BITNRDY | USB_HOST_BITBRDY)))
mbed_official 27:4206883f4cb7 189 {
mbed_official 27:4206883f4cb7 190 brdysts = USB200.BRDYSTS;
mbed_official 27:4206883f4cb7 191 nrdysts = USB200.NRDYSTS;
mbed_official 27:4206883f4cb7 192 bempsts = USB200.BEMPSTS;
mbed_official 27:4206883f4cb7 193 brdyenb = USB200.BRDYENB;
mbed_official 27:4206883f4cb7 194 nrdyenb = USB200.NRDYENB;
mbed_official 27:4206883f4cb7 195 bempenb = USB200.BEMPENB;
mbed_official 27:4206883f4cb7 196
mbed_official 27:4206883f4cb7 197 if ((intsts0 & USB_HOST_BITBRDY) && (intenb0 & USB_HOST_BITBRDYE) && (brdysts & brdyenb))
mbed_official 27:4206883f4cb7 198 {
mbed_official 27:4206883f4cb7 199 usb0_host_BRDYInterrupt(brdysts, brdyenb);
mbed_official 27:4206883f4cb7 200 }
mbed_official 27:4206883f4cb7 201 else if ((intsts0 & USB_HOST_BITBEMP) && (intenb0 & USB_HOST_BITBEMPE) && (bempsts & bempenb))
mbed_official 27:4206883f4cb7 202 {
mbed_official 27:4206883f4cb7 203 usb0_host_BEMPInterrupt(bempsts, bempenb);
mbed_official 27:4206883f4cb7 204 }
mbed_official 27:4206883f4cb7 205 else if ((intsts0 & USB_HOST_BITNRDY) && (intenb0 & USB_HOST_BITNRDYE) && (nrdysts & nrdyenb))
mbed_official 27:4206883f4cb7 206 {
mbed_official 27:4206883f4cb7 207 usb0_host_NRDYInterrupt(nrdysts, nrdyenb);
mbed_official 27:4206883f4cb7 208 }
mbed_official 27:4206883f4cb7 209 else
mbed_official 27:4206883f4cb7 210 {
mbed_official 27:4206883f4cb7 211 /* Do Nothing */
mbed_official 27:4206883f4cb7 212 }
mbed_official 27:4206883f4cb7 213 }
mbed_official 27:4206883f4cb7 214 else
mbed_official 27:4206883f4cb7 215 {
mbed_official 27:4206883f4cb7 216 /* Do Nothing */
mbed_official 27:4206883f4cb7 217 }
mbed_official 27:4206883f4cb7 218
mbed_official 27:4206883f4cb7 219 /* Three dummy read for clearing interrupt requests */
mbed_official 27:4206883f4cb7 220 dumy_sts = USB200.INTSTS0;
mbed_official 27:4206883f4cb7 221 dumy_sts = USB200.INTSTS1;
mbed_official 27:4206883f4cb7 222
mbed_official 27:4206883f4cb7 223 }
mbed_official 27:4206883f4cb7 224
mbed_official 27:4206883f4cb7 225 /*******************************************************************************
mbed_official 27:4206883f4cb7 226 * Function Name: usb0_host_BRDYInterrupt
mbed_official 27:4206883f4cb7 227 * Description : Executes USB BRDY interrupt.
mbed_official 27:4206883f4cb7 228 * Arguments : uint16_t Status ; BRDYSTS Register Value
mbed_official 27:4206883f4cb7 229 * : uint16_t Int_enbl ; BRDYENB Register Value
mbed_official 27:4206883f4cb7 230 * Return Value : none
mbed_official 27:4206883f4cb7 231 *******************************************************************************/
mbed_official 27:4206883f4cb7 232 void usb0_host_BRDYInterrupt (uint16_t Status, uint16_t Int_enbl)
mbed_official 27:4206883f4cb7 233 {
mbed_official 27:4206883f4cb7 234 uint16_t buffer;
mbed_official 27:4206883f4cb7 235 volatile uint16_t dumy_sts;
mbed_official 27:4206883f4cb7 236
mbed_official 27:4206883f4cb7 237 if ((Status & g_usb0_host_bit_set[USB_HOST_PIPE0]) && (Int_enbl & g_usb0_host_bit_set[USB_HOST_PIPE0]))
mbed_official 27:4206883f4cb7 238 {
mbed_official 27:4206883f4cb7 239 USB200.BRDYSTS = (uint16_t)~g_usb0_host_bit_set[USB_HOST_PIPE0];
mbed_official 27:4206883f4cb7 240
mbed_official 27:4206883f4cb7 241 #if(1) /* ohci_wrapp */
mbed_official 27:4206883f4cb7 242 switch ((g_usb0_host_CmdStage & (USB_HOST_STAGE_FIELD | USB_HOST_CMD_FIELD)))
mbed_official 27:4206883f4cb7 243 {
mbed_official 27:4206883f4cb7 244 case (USB_HOST_STAGE_STATUS | USB_HOST_CMD_DOING):
mbed_official 27:4206883f4cb7 245 buffer = usb0_host_read_buffer_c(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 246 usb0_host_disable_brdy_int(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 247 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 248 g_usb0_host_CmdStage |= USB_HOST_CMD_DONE;
mbed_official 27:4206883f4cb7 249 ohciwrapp_loc_TransEnd(USB_HOST_PIPE0, TD_CC_NOERROR);
mbed_official 27:4206883f4cb7 250 break;
mbed_official 27:4206883f4cb7 251
mbed_official 27:4206883f4cb7 252 case (USB_HOST_STAGE_DATA | USB_HOST_CMD_DOING):
mbed_official 27:4206883f4cb7 253 buffer = usb0_host_read_buffer_c(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 254 switch (buffer)
mbed_official 27:4206883f4cb7 255 {
mbed_official 27:4206883f4cb7 256 case USB_HOST_READING: /* Continue of data read */
mbed_official 27:4206883f4cb7 257 break;
mbed_official 27:4206883f4cb7 258
mbed_official 27:4206883f4cb7 259 case USB_HOST_READEND: /* End of data read */
mbed_official 27:4206883f4cb7 260 case USB_HOST_READSHRT: /* End of data read */
mbed_official 27:4206883f4cb7 261 usb0_host_disable_brdy_int(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 262 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 263 g_usb0_host_CmdStage |= USB_HOST_CMD_DONE;
mbed_official 27:4206883f4cb7 264 ohciwrapp_loc_TransEnd(USB_HOST_PIPE0, TD_CC_NOERROR);
mbed_official 27:4206883f4cb7 265 break;
mbed_official 27:4206883f4cb7 266
mbed_official 27:4206883f4cb7 267 case USB_HOST_READOVER: /* buffer over */
mbed_official 27:4206883f4cb7 268 USB200.CFIFOCTR = USB_HOST_BITBCLR;
mbed_official 27:4206883f4cb7 269 usb0_host_disable_brdy_int(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 270 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 271 g_usb0_host_CmdStage |= USB_HOST_CMD_DONE;
mbed_official 27:4206883f4cb7 272 ohciwrapp_loc_TransEnd(USB_HOST_PIPE0, TD_CC_NOERROR);
mbed_official 27:4206883f4cb7 273 break;
mbed_official 27:4206883f4cb7 274
mbed_official 27:4206883f4cb7 275 case USB_HOST_FIFOERROR: /* FIFO access error */
mbed_official 27:4206883f4cb7 276 default:
mbed_official 27:4206883f4cb7 277 break;
mbed_official 27:4206883f4cb7 278 }
mbed_official 27:4206883f4cb7 279 break;
mbed_official 27:4206883f4cb7 280
mbed_official 27:4206883f4cb7 281 default:
mbed_official 27:4206883f4cb7 282 break;
mbed_official 27:4206883f4cb7 283 }
mbed_official 27:4206883f4cb7 284 #else
mbed_official 27:4206883f4cb7 285 switch ((g_usb0_host_CmdStage & (USB_HOST_MODE_FIELD | USB_HOST_STAGE_FIELD | USB_HOST_CMD_FIELD)))
mbed_official 27:4206883f4cb7 286 {
mbed_official 27:4206883f4cb7 287 case (USB_HOST_MODE_WRITE | USB_HOST_STAGE_STATUS | USB_HOST_CMD_DOING):
mbed_official 27:4206883f4cb7 288 case (USB_HOST_MODE_NO_DATA | USB_HOST_STAGE_STATUS | USB_HOST_CMD_DOING):
mbed_official 27:4206883f4cb7 289 buffer = usb0_host_read_buffer_c(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 290 usb0_host_disable_brdy_int(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 291 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 292 g_usb0_host_CmdStage |= USB_HOST_CMD_DONE;
mbed_official 27:4206883f4cb7 293 break;
mbed_official 27:4206883f4cb7 294
mbed_official 27:4206883f4cb7 295 case (USB_HOST_MODE_READ | USB_HOST_STAGE_DATA | USB_HOST_CMD_DOING):
mbed_official 27:4206883f4cb7 296 buffer = usb0_host_read_buffer_c(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 297
mbed_official 27:4206883f4cb7 298 switch (buffer)
mbed_official 27:4206883f4cb7 299 {
mbed_official 27:4206883f4cb7 300 case USB_HOST_READING: /* Continue of data read */
mbed_official 27:4206883f4cb7 301 break;
mbed_official 27:4206883f4cb7 302
mbed_official 27:4206883f4cb7 303 case USB_HOST_READEND: /* End of data read */
mbed_official 27:4206883f4cb7 304 case USB_HOST_READSHRT: /* End of data read */
mbed_official 27:4206883f4cb7 305 usb0_host_disable_brdy_int(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 306 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 307 g_usb0_host_CmdStage |= USB_HOST_CMD_DONE;
mbed_official 27:4206883f4cb7 308 break;
mbed_official 27:4206883f4cb7 309
mbed_official 27:4206883f4cb7 310 case USB_HOST_READOVER: /* buffer over */
mbed_official 27:4206883f4cb7 311 USB200.CFIFOCTR = USB_HOST_BITBCLR;
mbed_official 27:4206883f4cb7 312 usb0_host_disable_brdy_int(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 313 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 314 g_usb0_host_CmdStage |= USB_HOST_CMD_DONE;
mbed_official 27:4206883f4cb7 315 break;
mbed_official 27:4206883f4cb7 316
mbed_official 27:4206883f4cb7 317 case USB_HOST_FIFOERROR: /* FIFO access error */
mbed_official 27:4206883f4cb7 318 default:
mbed_official 27:4206883f4cb7 319 break;
mbed_official 27:4206883f4cb7 320 }
mbed_official 27:4206883f4cb7 321 break;
mbed_official 27:4206883f4cb7 322
mbed_official 27:4206883f4cb7 323 default:
mbed_official 27:4206883f4cb7 324 break;
mbed_official 27:4206883f4cb7 325 }
mbed_official 27:4206883f4cb7 326 #endif
mbed_official 27:4206883f4cb7 327 }
mbed_official 27:4206883f4cb7 328 else
mbed_official 27:4206883f4cb7 329 {
mbed_official 27:4206883f4cb7 330 usb0_host_brdy_int(Status, Int_enbl);
mbed_official 27:4206883f4cb7 331 }
mbed_official 27:4206883f4cb7 332
mbed_official 27:4206883f4cb7 333 /* Three dummy reads for clearing interrupt requests */
mbed_official 27:4206883f4cb7 334 dumy_sts = USB200.BRDYSTS;
mbed_official 27:4206883f4cb7 335 }
mbed_official 27:4206883f4cb7 336
mbed_official 27:4206883f4cb7 337 /*******************************************************************************
mbed_official 27:4206883f4cb7 338 * Function Name: usb0_host_NRDYInterrupt
mbed_official 27:4206883f4cb7 339 * Description : Executes USB NRDY interrupt.
mbed_official 27:4206883f4cb7 340 * Arguments : uint16_t Status ; NRDYSTS Register Value
mbed_official 27:4206883f4cb7 341 * : uint16_t Int_enbl ; NRDYENB Register Value
mbed_official 27:4206883f4cb7 342 * Return Value : none
mbed_official 27:4206883f4cb7 343 *******************************************************************************/
mbed_official 27:4206883f4cb7 344 void usb0_host_NRDYInterrupt (uint16_t Status, uint16_t Int_enbl)
mbed_official 27:4206883f4cb7 345 {
mbed_official 27:4206883f4cb7 346 uint16_t pid;
mbed_official 27:4206883f4cb7 347 volatile uint16_t dumy_sts;
mbed_official 27:4206883f4cb7 348
mbed_official 27:4206883f4cb7 349 if ((Status & g_usb0_host_bit_set[USB_HOST_PIPE0]) && (Int_enbl & g_usb0_host_bit_set[USB_HOST_PIPE0]))
mbed_official 27:4206883f4cb7 350 {
mbed_official 27:4206883f4cb7 351 USB200.NRDYSTS = (uint16_t)~g_usb0_host_bit_set[USB_HOST_PIPE0];
mbed_official 27:4206883f4cb7 352 pid = usb0_host_get_pid(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 353
mbed_official 27:4206883f4cb7 354 if ((pid == USB_HOST_PID_STALL) || (pid == USB_HOST_PID_STALL2))
mbed_official 27:4206883f4cb7 355 {
mbed_official 27:4206883f4cb7 356 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 357 g_usb0_host_CmdStage |= USB_HOST_CMD_STALL;
mbed_official 27:4206883f4cb7 358 #if(1) /* ohci_wrapp */
mbed_official 27:4206883f4cb7 359 g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_STALL;
mbed_official 27:4206883f4cb7 360 ohciwrapp_loc_TransEnd(USB_HOST_PIPE0, TD_CC_STALL);
mbed_official 27:4206883f4cb7 361 #endif
mbed_official 27:4206883f4cb7 362 }
mbed_official 27:4206883f4cb7 363 else if (pid == USB_HOST_PID_NAK)
mbed_official 27:4206883f4cb7 364 {
mbed_official 27:4206883f4cb7 365 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 366 g_usb0_host_CmdStage |= USB_HOST_CMD_NORES;
mbed_official 27:4206883f4cb7 367 #if(1) /* ohci_wrapp */
mbed_official 27:4206883f4cb7 368 g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_NORES;
mbed_official 27:4206883f4cb7 369 ohciwrapp_loc_TransEnd(USB_HOST_PIPE0, TD_CC_STALL);
mbed_official 27:4206883f4cb7 370 #endif
mbed_official 27:4206883f4cb7 371 }
mbed_official 27:4206883f4cb7 372 else
mbed_official 27:4206883f4cb7 373 {
mbed_official 27:4206883f4cb7 374 /* Do Nothing */
mbed_official 27:4206883f4cb7 375 }
mbed_official 27:4206883f4cb7 376 }
mbed_official 27:4206883f4cb7 377 else
mbed_official 27:4206883f4cb7 378 {
mbed_official 27:4206883f4cb7 379 usb0_host_nrdy_int(Status, Int_enbl);
mbed_official 27:4206883f4cb7 380 }
mbed_official 27:4206883f4cb7 381
mbed_official 27:4206883f4cb7 382 /* Three dummy reads for clearing interrupt requests */
mbed_official 27:4206883f4cb7 383 dumy_sts = USB200.NRDYSTS;
mbed_official 27:4206883f4cb7 384 }
mbed_official 27:4206883f4cb7 385
mbed_official 27:4206883f4cb7 386 /*******************************************************************************
mbed_official 27:4206883f4cb7 387 * Function Name: usb0_host_BEMPInterrupt
mbed_official 27:4206883f4cb7 388 * Description : Executes USB BEMP interrupt.
mbed_official 27:4206883f4cb7 389 * Arguments : uint16_t Status ; BEMPSTS Register Value
mbed_official 27:4206883f4cb7 390 * : uint16_t Int_enbl ; BEMPENB Register Value
mbed_official 27:4206883f4cb7 391 * Return Value : none
mbed_official 27:4206883f4cb7 392 *******************************************************************************/
mbed_official 27:4206883f4cb7 393 void usb0_host_BEMPInterrupt (uint16_t Status, uint16_t Int_enbl)
mbed_official 27:4206883f4cb7 394 {
mbed_official 27:4206883f4cb7 395 uint16_t buffer;
mbed_official 27:4206883f4cb7 396 uint16_t pid;
mbed_official 27:4206883f4cb7 397 volatile uint16_t dumy_sts;
mbed_official 27:4206883f4cb7 398
mbed_official 27:4206883f4cb7 399 if ((Status & g_usb0_host_bit_set[USB_HOST_PIPE0]) && (Int_enbl & g_usb0_host_bit_set[USB_HOST_PIPE0]))
mbed_official 27:4206883f4cb7 400 {
mbed_official 27:4206883f4cb7 401 USB200.BEMPSTS = (uint16_t)~g_usb0_host_bit_set[USB_HOST_PIPE0];
mbed_official 27:4206883f4cb7 402 pid = usb0_host_get_pid(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 403
mbed_official 27:4206883f4cb7 404 if ((pid == USB_HOST_PID_STALL) || (pid == USB_HOST_PID_STALL2))
mbed_official 27:4206883f4cb7 405 {
mbed_official 27:4206883f4cb7 406 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 407 g_usb0_host_CmdStage |= USB_HOST_CMD_STALL;
mbed_official 27:4206883f4cb7 408 #if(1) /* ohci_wrapp */
mbed_official 27:4206883f4cb7 409 g_usb0_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_STALL; /* exit STALL */
mbed_official 27:4206883f4cb7 410 ohciwrapp_loc_TransEnd(USB_HOST_PIPE0, TD_CC_STALL);
mbed_official 27:4206883f4cb7 411 #endif
mbed_official 27:4206883f4cb7 412 }
mbed_official 27:4206883f4cb7 413 else
mbed_official 27:4206883f4cb7 414 {
mbed_official 27:4206883f4cb7 415 #if(1) /* ohci_wrapp */
mbed_official 27:4206883f4cb7 416 switch ((g_usb0_host_CmdStage & (USB_HOST_STAGE_FIELD | USB_HOST_CMD_FIELD)))
mbed_official 27:4206883f4cb7 417 {
mbed_official 27:4206883f4cb7 418 case (USB_HOST_STAGE_STATUS | USB_HOST_CMD_DOING):
mbed_official 27:4206883f4cb7 419 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 420 g_usb0_host_CmdStage |= USB_HOST_CMD_DONE;
mbed_official 27:4206883f4cb7 421 ohciwrapp_loc_TransEnd(USB_HOST_PIPE0, TD_CC_NOERROR);
mbed_official 27:4206883f4cb7 422 break;
mbed_official 27:4206883f4cb7 423
mbed_official 27:4206883f4cb7 424 case (USB_HOST_STAGE_DATA | USB_HOST_CMD_DOING):
mbed_official 27:4206883f4cb7 425 buffer = usb0_host_write_buffer(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 426 switch (buffer)
mbed_official 27:4206883f4cb7 427 {
mbed_official 27:4206883f4cb7 428 case USB_HOST_WRITING: /* Continue of data write */
mbed_official 27:4206883f4cb7 429 case USB_HOST_WRITEEND: /* End of data write (zero-length) */
mbed_official 27:4206883f4cb7 430 break;
mbed_official 27:4206883f4cb7 431
mbed_official 27:4206883f4cb7 432 case USB_HOST_WRITESHRT: /* End of data write */
mbed_official 27:4206883f4cb7 433 g_usb0_host_CmdStage &= (~USB_HOST_STAGE_FIELD);
mbed_official 27:4206883f4cb7 434 g_usb0_host_CmdStage |= USB_HOST_STAGE_STATUS;
mbed_official 27:4206883f4cb7 435 ohciwrapp_loc_TransEnd(USB_HOST_PIPE0, TD_CC_NOERROR);
mbed_official 27:4206883f4cb7 436 break;
mbed_official 27:4206883f4cb7 437
mbed_official 27:4206883f4cb7 438 case USB_HOST_FIFOERROR: /* FIFO access error */
mbed_official 27:4206883f4cb7 439 default:
mbed_official 27:4206883f4cb7 440 break;
mbed_official 27:4206883f4cb7 441 }
mbed_official 27:4206883f4cb7 442 break;
mbed_official 27:4206883f4cb7 443
mbed_official 27:4206883f4cb7 444 default:
mbed_official 27:4206883f4cb7 445 /* do nothing */
mbed_official 27:4206883f4cb7 446 break;
mbed_official 27:4206883f4cb7 447 }
mbed_official 27:4206883f4cb7 448 #else
mbed_official 27:4206883f4cb7 449 switch ((g_usb0_host_CmdStage & (USB_HOST_MODE_FIELD | USB_HOST_STAGE_FIELD | USB_HOST_CMD_FIELD)))
mbed_official 27:4206883f4cb7 450 {
mbed_official 27:4206883f4cb7 451 case (USB_HOST_MODE_READ | USB_HOST_STAGE_STATUS | USB_HOST_CMD_DOING):
mbed_official 27:4206883f4cb7 452 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 453 g_usb0_host_CmdStage |= USB_HOST_CMD_DONE;
mbed_official 27:4206883f4cb7 454 break;
mbed_official 27:4206883f4cb7 455
mbed_official 27:4206883f4cb7 456 case (USB_HOST_MODE_WRITE | USB_HOST_STAGE_DATA | USB_HOST_CMD_DOING):
mbed_official 27:4206883f4cb7 457 buffer = usb0_host_write_buffer(USB_HOST_PIPE0);
mbed_official 27:4206883f4cb7 458 switch (buffer)
mbed_official 27:4206883f4cb7 459 {
mbed_official 27:4206883f4cb7 460 case USB_HOST_WRITING: /* Continue of data write */
mbed_official 27:4206883f4cb7 461 case USB_HOST_WRITEEND: /* End of data write (zero-length) */
mbed_official 27:4206883f4cb7 462 break;
mbed_official 27:4206883f4cb7 463
mbed_official 27:4206883f4cb7 464 case USB_HOST_WRITESHRT: /* End of data write */
mbed_official 27:4206883f4cb7 465 g_usb0_host_CmdStage &= (~USB_HOST_STAGE_FIELD);
mbed_official 27:4206883f4cb7 466 g_usb0_host_CmdStage |= USB_HOST_STAGE_STATUS;
mbed_official 27:4206883f4cb7 467 break;
mbed_official 27:4206883f4cb7 468
mbed_official 27:4206883f4cb7 469 case USB_HOST_FIFOERROR: /* FIFO access error */
mbed_official 27:4206883f4cb7 470 default:
mbed_official 27:4206883f4cb7 471 break;
mbed_official 27:4206883f4cb7 472 }
mbed_official 27:4206883f4cb7 473 break;
mbed_official 27:4206883f4cb7 474
mbed_official 27:4206883f4cb7 475 case (USB_HOST_MODE_WRITE | USB_HOST_STAGE_STATUS | USB_HOST_CMD_DOING):
mbed_official 27:4206883f4cb7 476 g_usb0_host_CmdStage &= (~USB_HOST_CMD_FIELD);
mbed_official 27:4206883f4cb7 477 g_usb0_host_CmdStage |= USB_HOST_CMD_IDLE;
mbed_official 27:4206883f4cb7 478 break;
mbed_official 27:4206883f4cb7 479
mbed_official 27:4206883f4cb7 480 default:
mbed_official 27:4206883f4cb7 481 /* do nothing */
mbed_official 27:4206883f4cb7 482 break;
mbed_official 27:4206883f4cb7 483 }
mbed_official 27:4206883f4cb7 484 #endif
mbed_official 27:4206883f4cb7 485 }
mbed_official 27:4206883f4cb7 486 }
mbed_official 27:4206883f4cb7 487 else
mbed_official 27:4206883f4cb7 488 {
mbed_official 27:4206883f4cb7 489 usb0_host_bemp_int(Status, Int_enbl);
mbed_official 27:4206883f4cb7 490 }
mbed_official 27:4206883f4cb7 491
mbed_official 27:4206883f4cb7 492 /* Three dummy reads for clearing interrupt requests */
mbed_official 27:4206883f4cb7 493 dumy_sts = USB200.BEMPSTS;
mbed_official 27:4206883f4cb7 494 }
mbed_official 27:4206883f4cb7 495
mbed_official 27:4206883f4cb7 496 /* End of File */