USBHost library. NOTE: This library is only officially supported on the LPC1768 platform. For more information, please see the handbook page.
Dependencies: FATFileSystem mbed-rtos
Dependents: BTstack WallbotWii SD to Flash Data Transfer USBHost-MSD_HelloWorld ... more
Legacy Warning
This is an mbed 2 library. To learn more about mbed OS 5, visit the docs.
Pull requests against this repository are no longer supported. Please raise against mbed OS 5 as documented above.
USBHost/TARGET_RENESAS/TARGET_RZ_A1H/src/host/usb0_host_usbsig.c@27:4206883f4cb7, 2015-01-19 (annotated)
- 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?
User | Revision | Line number | New 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_usbsig.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 | #include "dev_drv.h" |
mbed_official | 27:4206883f4cb7 | 42 | |
mbed_official | 27:4206883f4cb7 | 43 | |
mbed_official | 27:4206883f4cb7 | 44 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 45 | Typedef definitions |
mbed_official | 27:4206883f4cb7 | 46 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 47 | |
mbed_official | 27:4206883f4cb7 | 48 | |
mbed_official | 27:4206883f4cb7 | 49 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 50 | Macro definitions |
mbed_official | 27:4206883f4cb7 | 51 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 52 | |
mbed_official | 27:4206883f4cb7 | 53 | |
mbed_official | 27:4206883f4cb7 | 54 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 55 | Imported global variables and functions (from other files) |
mbed_official | 27:4206883f4cb7 | 56 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 57 | |
mbed_official | 27:4206883f4cb7 | 58 | |
mbed_official | 27:4206883f4cb7 | 59 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 60 | Exported global variables and functions (to be accessed by other files) |
mbed_official | 27:4206883f4cb7 | 61 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 62 | static void usb0_host_EnableINT_Module(void); |
mbed_official | 27:4206883f4cb7 | 63 | static void usb0_host_Enable_AttachINT(void); |
mbed_official | 27:4206883f4cb7 | 64 | static void usb0_host_Disable_AttachINT(void); |
mbed_official | 27:4206883f4cb7 | 65 | static void usb0_host_Disable_BchgINT(void); |
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_InitModule |
mbed_official | 27:4206883f4cb7 | 75 | * Description : Initializes the USB module in USB host module. |
mbed_official | 27:4206883f4cb7 | 76 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 77 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 78 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 79 | void usb0_host_InitModule (void) |
mbed_official | 27:4206883f4cb7 | 80 | { |
mbed_official | 27:4206883f4cb7 | 81 | uint16_t buf1; |
mbed_official | 27:4206883f4cb7 | 82 | uint16_t buf2; |
mbed_official | 27:4206883f4cb7 | 83 | uint16_t buf3; |
mbed_official | 27:4206883f4cb7 | 84 | |
mbed_official | 27:4206883f4cb7 | 85 | usb0_host_init_pipe_status(); |
mbed_official | 27:4206883f4cb7 | 86 | |
mbed_official | 27:4206883f4cb7 | 87 | RZA_IO_RegWrite_16(&USB200.SYSCFG0, |
mbed_official | 27:4206883f4cb7 | 88 | 1, |
mbed_official | 27:4206883f4cb7 | 89 | USB_SYSCFG_DCFM_SHIFT, |
mbed_official | 27:4206883f4cb7 | 90 | USB_SYSCFG_DCFM); /* HOST mode */ |
mbed_official | 27:4206883f4cb7 | 91 | RZA_IO_RegWrite_16(&USB200.SYSCFG0, |
mbed_official | 27:4206883f4cb7 | 92 | 1, |
mbed_official | 27:4206883f4cb7 | 93 | USB_SYSCFG_DRPD_SHIFT, |
mbed_official | 27:4206883f4cb7 | 94 | USB_SYSCFG_DRPD); /* PORT0 D+, D- setting */ |
mbed_official | 27:4206883f4cb7 | 95 | |
mbed_official | 27:4206883f4cb7 | 96 | do |
mbed_official | 27:4206883f4cb7 | 97 | { |
mbed_official | 27:4206883f4cb7 | 98 | buf1 = RZA_IO_RegRead_16(&USB200.SYSSTS0, |
mbed_official | 27:4206883f4cb7 | 99 | USB_SYSSTS0_LNST_SHIFT, |
mbed_official | 27:4206883f4cb7 | 100 | USB_SYSSTS0_LNST); |
mbed_official | 27:4206883f4cb7 | 101 | Userdef_USB_usb0_host_delay_xms(50); |
mbed_official | 27:4206883f4cb7 | 102 | buf2 = RZA_IO_RegRead_16(&USB200.SYSSTS0, |
mbed_official | 27:4206883f4cb7 | 103 | USB_SYSSTS0_LNST_SHIFT, |
mbed_official | 27:4206883f4cb7 | 104 | USB_SYSSTS0_LNST); |
mbed_official | 27:4206883f4cb7 | 105 | Userdef_USB_usb0_host_delay_xms(50); |
mbed_official | 27:4206883f4cb7 | 106 | buf3 = RZA_IO_RegRead_16(&USB200.SYSSTS0, |
mbed_official | 27:4206883f4cb7 | 107 | USB_SYSSTS0_LNST_SHIFT, |
mbed_official | 27:4206883f4cb7 | 108 | USB_SYSSTS0_LNST); |
mbed_official | 27:4206883f4cb7 | 109 | |
mbed_official | 27:4206883f4cb7 | 110 | } while ((buf1 != buf2) || (buf1 != buf3)); |
mbed_official | 27:4206883f4cb7 | 111 | |
mbed_official | 27:4206883f4cb7 | 112 | RZA_IO_RegWrite_16(&USB200.SYSCFG0, |
mbed_official | 27:4206883f4cb7 | 113 | 1, |
mbed_official | 27:4206883f4cb7 | 114 | USB_SYSCFG_USBE_SHIFT, |
mbed_official | 27:4206883f4cb7 | 115 | USB_SYSCFG_USBE); |
mbed_official | 27:4206883f4cb7 | 116 | |
mbed_official | 27:4206883f4cb7 | 117 | USB200.CFIFOSEL = (uint16_t)(USB_HOST_BITRCNT | USB_HOST_BITMBW_8 | USB_HOST_BITBYTE_LITTLE); |
mbed_official | 27:4206883f4cb7 | 118 | USB200.D0FIFOSEL = (uint16_t)( USB_HOST_BITMBW_8 | USB_HOST_BITBYTE_LITTLE); |
mbed_official | 27:4206883f4cb7 | 119 | USB200.D1FIFOSEL = (uint16_t)( USB_HOST_BITMBW_8 | USB_HOST_BITBYTE_LITTLE); |
mbed_official | 27:4206883f4cb7 | 120 | } |
mbed_official | 27:4206883f4cb7 | 121 | |
mbed_official | 27:4206883f4cb7 | 122 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 123 | * Function Name: usb0_host_CheckAttach |
mbed_official | 27:4206883f4cb7 | 124 | * Description : Returns the USB device connection state. |
mbed_official | 27:4206883f4cb7 | 125 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 126 | * Return Value : uint16_t ; USB_HOST_ATTACH : Attached |
mbed_official | 27:4206883f4cb7 | 127 | * : ; USB_HOST_DETACH : not Attached |
mbed_official | 27:4206883f4cb7 | 128 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 129 | uint16_t usb0_host_CheckAttach (void) |
mbed_official | 27:4206883f4cb7 | 130 | { |
mbed_official | 27:4206883f4cb7 | 131 | uint16_t buf1; |
mbed_official | 27:4206883f4cb7 | 132 | uint16_t buf2; |
mbed_official | 27:4206883f4cb7 | 133 | uint16_t buf3; |
mbed_official | 27:4206883f4cb7 | 134 | uint16_t rhst; |
mbed_official | 27:4206883f4cb7 | 135 | |
mbed_official | 27:4206883f4cb7 | 136 | do |
mbed_official | 27:4206883f4cb7 | 137 | { |
mbed_official | 27:4206883f4cb7 | 138 | buf1 = RZA_IO_RegRead_16(&USB200.SYSSTS0, |
mbed_official | 27:4206883f4cb7 | 139 | USB_SYSSTS0_LNST_SHIFT, |
mbed_official | 27:4206883f4cb7 | 140 | USB_SYSSTS0_LNST); |
mbed_official | 27:4206883f4cb7 | 141 | Userdef_USB_usb0_host_delay_xms(50); |
mbed_official | 27:4206883f4cb7 | 142 | buf2 = RZA_IO_RegRead_16(&USB200.SYSSTS0, |
mbed_official | 27:4206883f4cb7 | 143 | USB_SYSSTS0_LNST_SHIFT, |
mbed_official | 27:4206883f4cb7 | 144 | USB_SYSSTS0_LNST); |
mbed_official | 27:4206883f4cb7 | 145 | Userdef_USB_usb0_host_delay_xms(50); |
mbed_official | 27:4206883f4cb7 | 146 | buf3 = RZA_IO_RegRead_16(&USB200.SYSSTS0, |
mbed_official | 27:4206883f4cb7 | 147 | USB_SYSSTS0_LNST_SHIFT, |
mbed_official | 27:4206883f4cb7 | 148 | USB_SYSSTS0_LNST); |
mbed_official | 27:4206883f4cb7 | 149 | |
mbed_official | 27:4206883f4cb7 | 150 | } while ((buf1 != buf2) || (buf1 != buf3)); |
mbed_official | 27:4206883f4cb7 | 151 | |
mbed_official | 27:4206883f4cb7 | 152 | rhst = RZA_IO_RegRead_16(&USB200.DVSTCTR0, |
mbed_official | 27:4206883f4cb7 | 153 | USB_DVSTCTR0_RHST_SHIFT, |
mbed_official | 27:4206883f4cb7 | 154 | USB_DVSTCTR0_RHST); |
mbed_official | 27:4206883f4cb7 | 155 | if (rhst == USB_HOST_UNDECID) |
mbed_official | 27:4206883f4cb7 | 156 | { |
mbed_official | 27:4206883f4cb7 | 157 | if (buf1 == USB_HOST_FS_JSTS) |
mbed_official | 27:4206883f4cb7 | 158 | { |
mbed_official | 27:4206883f4cb7 | 159 | if (g_usb0_host_SupportUsbDeviceSpeed == USB_HOST_HIGH_SPEED) |
mbed_official | 27:4206883f4cb7 | 160 | { |
mbed_official | 27:4206883f4cb7 | 161 | RZA_IO_RegWrite_16(&USB200.SYSCFG0, |
mbed_official | 27:4206883f4cb7 | 162 | 1, |
mbed_official | 27:4206883f4cb7 | 163 | USB_SYSCFG_HSE_SHIFT, |
mbed_official | 27:4206883f4cb7 | 164 | USB_SYSCFG_HSE); |
mbed_official | 27:4206883f4cb7 | 165 | } |
mbed_official | 27:4206883f4cb7 | 166 | else |
mbed_official | 27:4206883f4cb7 | 167 | { |
mbed_official | 27:4206883f4cb7 | 168 | RZA_IO_RegWrite_16(&USB200.SYSCFG0, |
mbed_official | 27:4206883f4cb7 | 169 | 0, |
mbed_official | 27:4206883f4cb7 | 170 | USB_SYSCFG_HSE_SHIFT, |
mbed_official | 27:4206883f4cb7 | 171 | USB_SYSCFG_HSE); |
mbed_official | 27:4206883f4cb7 | 172 | } |
mbed_official | 27:4206883f4cb7 | 173 | return USB_HOST_ATTACH; |
mbed_official | 27:4206883f4cb7 | 174 | } |
mbed_official | 27:4206883f4cb7 | 175 | else if (buf1 == USB_HOST_LS_JSTS) |
mbed_official | 27:4206883f4cb7 | 176 | { |
mbed_official | 27:4206883f4cb7 | 177 | /* Low Speed Device */ |
mbed_official | 27:4206883f4cb7 | 178 | RZA_IO_RegWrite_16(&USB200.SYSCFG0, |
mbed_official | 27:4206883f4cb7 | 179 | 0, |
mbed_official | 27:4206883f4cb7 | 180 | USB_SYSCFG_HSE_SHIFT, |
mbed_official | 27:4206883f4cb7 | 181 | USB_SYSCFG_HSE); |
mbed_official | 27:4206883f4cb7 | 182 | return USB_HOST_ATTACH; |
mbed_official | 27:4206883f4cb7 | 183 | } |
mbed_official | 27:4206883f4cb7 | 184 | else |
mbed_official | 27:4206883f4cb7 | 185 | { |
mbed_official | 27:4206883f4cb7 | 186 | /* Do Nothing */ |
mbed_official | 27:4206883f4cb7 | 187 | } |
mbed_official | 27:4206883f4cb7 | 188 | } |
mbed_official | 27:4206883f4cb7 | 189 | else if ((rhst == USB_HOST_HSMODE) || (rhst == USB_HOST_FSMODE)) |
mbed_official | 27:4206883f4cb7 | 190 | { |
mbed_official | 27:4206883f4cb7 | 191 | return USB_HOST_ATTACH; |
mbed_official | 27:4206883f4cb7 | 192 | } |
mbed_official | 27:4206883f4cb7 | 193 | else if (rhst == USB_HOST_LSMODE) |
mbed_official | 27:4206883f4cb7 | 194 | { |
mbed_official | 27:4206883f4cb7 | 195 | return USB_HOST_ATTACH; |
mbed_official | 27:4206883f4cb7 | 196 | } |
mbed_official | 27:4206883f4cb7 | 197 | else |
mbed_official | 27:4206883f4cb7 | 198 | { |
mbed_official | 27:4206883f4cb7 | 199 | /* Do Nothing */ |
mbed_official | 27:4206883f4cb7 | 200 | } |
mbed_official | 27:4206883f4cb7 | 201 | |
mbed_official | 27:4206883f4cb7 | 202 | return USB_HOST_DETACH; |
mbed_official | 27:4206883f4cb7 | 203 | } |
mbed_official | 27:4206883f4cb7 | 204 | |
mbed_official | 27:4206883f4cb7 | 205 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 206 | * Function Name: usb0_host_UsbAttach |
mbed_official | 27:4206883f4cb7 | 207 | * Description : Connects the USB device. |
mbed_official | 27:4206883f4cb7 | 208 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 209 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 210 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 211 | void usb0_host_UsbAttach (void) |
mbed_official | 27:4206883f4cb7 | 212 | { |
mbed_official | 27:4206883f4cb7 | 213 | usb0_host_EnableINT_Module(); |
mbed_official | 27:4206883f4cb7 | 214 | usb0_host_Disable_BchgINT(); |
mbed_official | 27:4206883f4cb7 | 215 | usb0_host_Disable_AttachINT(); |
mbed_official | 27:4206883f4cb7 | 216 | usb0_host_Enable_DetachINT(); |
mbed_official | 27:4206883f4cb7 | 217 | } |
mbed_official | 27:4206883f4cb7 | 218 | |
mbed_official | 27:4206883f4cb7 | 219 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 220 | * Function Name: usb0_host_UsbDetach |
mbed_official | 27:4206883f4cb7 | 221 | * Description : Disconnects the USB device. |
mbed_official | 27:4206883f4cb7 | 222 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 223 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 224 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 225 | void usb0_host_UsbDetach (void) |
mbed_official | 27:4206883f4cb7 | 226 | { |
mbed_official | 27:4206883f4cb7 | 227 | uint16_t pipe; |
mbed_official | 27:4206883f4cb7 | 228 | uint16_t devadr; |
mbed_official | 27:4206883f4cb7 | 229 | |
mbed_official | 27:4206883f4cb7 | 230 | g_usb0_host_driver_state = USB_HOST_DRV_DETACHED; |
mbed_official | 27:4206883f4cb7 | 231 | |
mbed_official | 27:4206883f4cb7 | 232 | /* Terminate all the pipes in which communications on port */ |
mbed_official | 27:4206883f4cb7 | 233 | /* are currently carried out */ |
mbed_official | 27:4206883f4cb7 | 234 | for (pipe = 0; pipe < (USB_HOST_MAX_PIPE_NO + 1); ++pipe) |
mbed_official | 27:4206883f4cb7 | 235 | { |
mbed_official | 27:4206883f4cb7 | 236 | if (g_usb0_host_pipe_status[pipe] != USB_HOST_PIPE_IDLE) |
mbed_official | 27:4206883f4cb7 | 237 | { |
mbed_official | 27:4206883f4cb7 | 238 | if (pipe == USB_HOST_PIPE0) |
mbed_official | 27:4206883f4cb7 | 239 | { |
mbed_official | 27:4206883f4cb7 | 240 | devadr = RZA_IO_RegRead_16(&USB200.DCPMAXP, |
mbed_official | 27:4206883f4cb7 | 241 | USB_DCPMAXP_DEVSEL_SHIFT, |
mbed_official | 27:4206883f4cb7 | 242 | USB_DCPMAXP_DEVSEL); |
mbed_official | 27:4206883f4cb7 | 243 | } |
mbed_official | 27:4206883f4cb7 | 244 | else |
mbed_official | 27:4206883f4cb7 | 245 | { |
mbed_official | 27:4206883f4cb7 | 246 | devadr = RZA_IO_RegRead_16(&g_usb0_host_pipemaxp[pipe], USB_PIPEMAXP_DEVSEL_SHIFT, USB_PIPEMAXP_DEVSEL); |
mbed_official | 27:4206883f4cb7 | 247 | } |
mbed_official | 27:4206883f4cb7 | 248 | |
mbed_official | 27:4206883f4cb7 | 249 | if (devadr == g_usb0_host_UsbAddress) |
mbed_official | 27:4206883f4cb7 | 250 | { |
mbed_official | 27:4206883f4cb7 | 251 | usb0_host_stop_transfer(pipe); |
mbed_official | 27:4206883f4cb7 | 252 | } |
mbed_official | 27:4206883f4cb7 | 253 | |
mbed_official | 27:4206883f4cb7 | 254 | g_usb0_host_pipe_status[pipe] = USB_HOST_PIPE_IDLE; |
mbed_official | 27:4206883f4cb7 | 255 | } |
mbed_official | 27:4206883f4cb7 | 256 | } |
mbed_official | 27:4206883f4cb7 | 257 | |
mbed_official | 27:4206883f4cb7 | 258 | g_usb0_host_ConfigNum = 0; |
mbed_official | 27:4206883f4cb7 | 259 | g_usb0_host_UsbAddress = 0; |
mbed_official | 27:4206883f4cb7 | 260 | g_usb0_host_default_max_packet[USB_HOST_DEVICE_0] = 64; |
mbed_official | 27:4206883f4cb7 | 261 | |
mbed_official | 27:4206883f4cb7 | 262 | usb0_host_UsbDetach2(); |
mbed_official | 27:4206883f4cb7 | 263 | } |
mbed_official | 27:4206883f4cb7 | 264 | |
mbed_official | 27:4206883f4cb7 | 265 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 266 | * Function Name: usb0_host_UsbDetach2 |
mbed_official | 27:4206883f4cb7 | 267 | * Description : Disconnects the USB device. |
mbed_official | 27:4206883f4cb7 | 268 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 269 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 270 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 271 | void usb0_host_UsbDetach2 (void) |
mbed_official | 27:4206883f4cb7 | 272 | { |
mbed_official | 27:4206883f4cb7 | 273 | usb0_host_Disable_DetachINT(); |
mbed_official | 27:4206883f4cb7 | 274 | usb0_host_Disable_BchgINT(); |
mbed_official | 27:4206883f4cb7 | 275 | usb0_host_Enable_AttachINT(); |
mbed_official | 27:4206883f4cb7 | 276 | } |
mbed_official | 27:4206883f4cb7 | 277 | |
mbed_official | 27:4206883f4cb7 | 278 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 279 | * Function Name: usb0_host_UsbBusReset |
mbed_official | 27:4206883f4cb7 | 280 | * Description : Issues the USB bus reset signal. |
mbed_official | 27:4206883f4cb7 | 281 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 282 | * Return Value : uint16_t ; RHST |
mbed_official | 27:4206883f4cb7 | 283 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 284 | uint16_t usb0_host_UsbBusReset (void) |
mbed_official | 27:4206883f4cb7 | 285 | { |
mbed_official | 27:4206883f4cb7 | 286 | uint16_t buffer; |
mbed_official | 27:4206883f4cb7 | 287 | uint16_t loop; |
mbed_official | 27:4206883f4cb7 | 288 | |
mbed_official | 27:4206883f4cb7 | 289 | RZA_IO_RegWrite_16(&USB200.DVSTCTR0, |
mbed_official | 27:4206883f4cb7 | 290 | 1, |
mbed_official | 27:4206883f4cb7 | 291 | USB_DVSTCTR0_USBRST_SHIFT, |
mbed_official | 27:4206883f4cb7 | 292 | USB_DVSTCTR0_USBRST); |
mbed_official | 27:4206883f4cb7 | 293 | RZA_IO_RegWrite_16(&USB200.DVSTCTR0, |
mbed_official | 27:4206883f4cb7 | 294 | 0, |
mbed_official | 27:4206883f4cb7 | 295 | USB_DVSTCTR0_UACT_SHIFT, |
mbed_official | 27:4206883f4cb7 | 296 | USB_DVSTCTR0_UACT); |
mbed_official | 27:4206883f4cb7 | 297 | |
mbed_official | 27:4206883f4cb7 | 298 | Userdef_USB_usb0_host_delay_xms(50); |
mbed_official | 27:4206883f4cb7 | 299 | |
mbed_official | 27:4206883f4cb7 | 300 | buffer = USB200.DVSTCTR0; |
mbed_official | 27:4206883f4cb7 | 301 | buffer &= (uint16_t)(~(USB_HOST_BITRST)); |
mbed_official | 27:4206883f4cb7 | 302 | buffer |= USB_HOST_BITUACT; |
mbed_official | 27:4206883f4cb7 | 303 | USB200.DVSTCTR0 = buffer; |
mbed_official | 27:4206883f4cb7 | 304 | |
mbed_official | 27:4206883f4cb7 | 305 | Userdef_USB_usb0_host_delay_xms(20); |
mbed_official | 27:4206883f4cb7 | 306 | |
mbed_official | 27:4206883f4cb7 | 307 | for (loop = 0, buffer = USB_HOST_HSPROC; loop < 3; ++loop) |
mbed_official | 27:4206883f4cb7 | 308 | { |
mbed_official | 27:4206883f4cb7 | 309 | buffer = RZA_IO_RegRead_16(&USB200.DVSTCTR0, |
mbed_official | 27:4206883f4cb7 | 310 | USB_DVSTCTR0_RHST_SHIFT, |
mbed_official | 27:4206883f4cb7 | 311 | USB_DVSTCTR0_RHST); |
mbed_official | 27:4206883f4cb7 | 312 | if (buffer == USB_HOST_HSPROC) |
mbed_official | 27:4206883f4cb7 | 313 | { |
mbed_official | 27:4206883f4cb7 | 314 | Userdef_USB_usb0_host_delay_xms(10); |
mbed_official | 27:4206883f4cb7 | 315 | } |
mbed_official | 27:4206883f4cb7 | 316 | else |
mbed_official | 27:4206883f4cb7 | 317 | { |
mbed_official | 27:4206883f4cb7 | 318 | break; |
mbed_official | 27:4206883f4cb7 | 319 | } |
mbed_official | 27:4206883f4cb7 | 320 | } |
mbed_official | 27:4206883f4cb7 | 321 | |
mbed_official | 27:4206883f4cb7 | 322 | return buffer; |
mbed_official | 27:4206883f4cb7 | 323 | } |
mbed_official | 27:4206883f4cb7 | 324 | |
mbed_official | 27:4206883f4cb7 | 325 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 326 | * Function Name: usb0_host_UsbResume |
mbed_official | 27:4206883f4cb7 | 327 | * Description : Issues the USB resume signal. |
mbed_official | 27:4206883f4cb7 | 328 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 329 | * Return Value : int32_t ; DEVDRV_SUCCESS |
mbed_official | 27:4206883f4cb7 | 330 | * : ; DEVDRV_ERROR |
mbed_official | 27:4206883f4cb7 | 331 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 332 | int32_t usb0_host_UsbResume (void) |
mbed_official | 27:4206883f4cb7 | 333 | { |
mbed_official | 27:4206883f4cb7 | 334 | uint16_t buf; |
mbed_official | 27:4206883f4cb7 | 335 | |
mbed_official | 27:4206883f4cb7 | 336 | if ((g_usb0_host_driver_state & USB_HOST_DRV_SUSPEND) == 0) |
mbed_official | 27:4206883f4cb7 | 337 | { |
mbed_official | 27:4206883f4cb7 | 338 | /* not SUSPEND */ |
mbed_official | 27:4206883f4cb7 | 339 | return DEVDRV_ERROR; |
mbed_official | 27:4206883f4cb7 | 340 | } |
mbed_official | 27:4206883f4cb7 | 341 | |
mbed_official | 27:4206883f4cb7 | 342 | RZA_IO_RegWrite_16(&USB200.INTENB1, |
mbed_official | 27:4206883f4cb7 | 343 | 0, |
mbed_official | 27:4206883f4cb7 | 344 | USB_INTENB1_BCHGE_SHIFT, |
mbed_official | 27:4206883f4cb7 | 345 | USB_INTENB1_BCHGE); |
mbed_official | 27:4206883f4cb7 | 346 | RZA_IO_RegWrite_16(&USB200.DVSTCTR0, |
mbed_official | 27:4206883f4cb7 | 347 | 1, |
mbed_official | 27:4206883f4cb7 | 348 | USB_DVSTCTR0_RESUME_SHIFT, |
mbed_official | 27:4206883f4cb7 | 349 | USB_DVSTCTR0_RESUME); |
mbed_official | 27:4206883f4cb7 | 350 | Userdef_USB_usb0_host_delay_xms(20); |
mbed_official | 27:4206883f4cb7 | 351 | |
mbed_official | 27:4206883f4cb7 | 352 | buf = USB200.DVSTCTR0; |
mbed_official | 27:4206883f4cb7 | 353 | buf &= (uint16_t)(~(USB_HOST_BITRESUME)); |
mbed_official | 27:4206883f4cb7 | 354 | buf |= USB_HOST_BITUACT; |
mbed_official | 27:4206883f4cb7 | 355 | USB200.DVSTCTR0 = buf; |
mbed_official | 27:4206883f4cb7 | 356 | |
mbed_official | 27:4206883f4cb7 | 357 | g_usb0_host_driver_state &= (uint16_t)~USB_HOST_DRV_SUSPEND; |
mbed_official | 27:4206883f4cb7 | 358 | |
mbed_official | 27:4206883f4cb7 | 359 | return DEVDRV_SUCCESS; |
mbed_official | 27:4206883f4cb7 | 360 | } |
mbed_official | 27:4206883f4cb7 | 361 | |
mbed_official | 27:4206883f4cb7 | 362 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 363 | * Function Name: usb0_host_UsbSuspend |
mbed_official | 27:4206883f4cb7 | 364 | * Description : Issues the USB suspend signal. |
mbed_official | 27:4206883f4cb7 | 365 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 366 | * Return Value : int32_t ; DEVDRV_SUCCESS :not SUSPEND |
mbed_official | 27:4206883f4cb7 | 367 | * : ; DEVDRV_ERROR :SUSPEND |
mbed_official | 27:4206883f4cb7 | 368 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 369 | int32_t usb0_host_UsbSuspend (void) |
mbed_official | 27:4206883f4cb7 | 370 | { |
mbed_official | 27:4206883f4cb7 | 371 | uint16_t buf; |
mbed_official | 27:4206883f4cb7 | 372 | |
mbed_official | 27:4206883f4cb7 | 373 | if ((g_usb0_host_driver_state & USB_HOST_DRV_SUSPEND) != 0) |
mbed_official | 27:4206883f4cb7 | 374 | { |
mbed_official | 27:4206883f4cb7 | 375 | /* SUSPEND */ |
mbed_official | 27:4206883f4cb7 | 376 | return DEVDRV_ERROR; |
mbed_official | 27:4206883f4cb7 | 377 | } |
mbed_official | 27:4206883f4cb7 | 378 | |
mbed_official | 27:4206883f4cb7 | 379 | RZA_IO_RegWrite_16(&USB200.DVSTCTR0, |
mbed_official | 27:4206883f4cb7 | 380 | 0, |
mbed_official | 27:4206883f4cb7 | 381 | USB_DVSTCTR0_UACT_SHIFT, |
mbed_official | 27:4206883f4cb7 | 382 | USB_DVSTCTR0_UACT); |
mbed_official | 27:4206883f4cb7 | 383 | |
mbed_official | 27:4206883f4cb7 | 384 | Userdef_USB_usb0_host_delay_xms(5); |
mbed_official | 27:4206883f4cb7 | 385 | |
mbed_official | 27:4206883f4cb7 | 386 | buf = RZA_IO_RegRead_16(&USB200.SYSSTS0, |
mbed_official | 27:4206883f4cb7 | 387 | USB_SYSSTS0_LNST_SHIFT, |
mbed_official | 27:4206883f4cb7 | 388 | USB_SYSSTS0_LNST); |
mbed_official | 27:4206883f4cb7 | 389 | if ((buf != USB_HOST_FS_JSTS) && (buf != USB_HOST_LS_JSTS)) |
mbed_official | 27:4206883f4cb7 | 390 | { |
mbed_official | 27:4206883f4cb7 | 391 | usb0_host_UsbDetach(); |
mbed_official | 27:4206883f4cb7 | 392 | } |
mbed_official | 27:4206883f4cb7 | 393 | else |
mbed_official | 27:4206883f4cb7 | 394 | { |
mbed_official | 27:4206883f4cb7 | 395 | g_usb0_host_driver_state |= USB_HOST_DRV_SUSPEND; |
mbed_official | 27:4206883f4cb7 | 396 | } |
mbed_official | 27:4206883f4cb7 | 397 | |
mbed_official | 27:4206883f4cb7 | 398 | return DEVDRV_SUCCESS; |
mbed_official | 27:4206883f4cb7 | 399 | } |
mbed_official | 27:4206883f4cb7 | 400 | |
mbed_official | 27:4206883f4cb7 | 401 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 402 | * Function Name: usb0_host_Enable_DetachINT |
mbed_official | 27:4206883f4cb7 | 403 | * Description : Enables the USB disconnection interrupt. |
mbed_official | 27:4206883f4cb7 | 404 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 405 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 406 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 407 | void usb0_host_Enable_DetachINT (void) |
mbed_official | 27:4206883f4cb7 | 408 | { |
mbed_official | 27:4206883f4cb7 | 409 | USB200.INTSTS1 = (uint16_t)(~(USB_HOST_BITDTCH)); |
mbed_official | 27:4206883f4cb7 | 410 | RZA_IO_RegWrite_16(&USB200.INTENB1, |
mbed_official | 27:4206883f4cb7 | 411 | 1, |
mbed_official | 27:4206883f4cb7 | 412 | USB_INTENB1_DTCHE_SHIFT, |
mbed_official | 27:4206883f4cb7 | 413 | USB_INTENB1_DTCHE); |
mbed_official | 27:4206883f4cb7 | 414 | } |
mbed_official | 27:4206883f4cb7 | 415 | |
mbed_official | 27:4206883f4cb7 | 416 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 417 | * Function Name: usb0_host_Disable_DetachINT |
mbed_official | 27:4206883f4cb7 | 418 | * Description : Disables the USB disconnection interrupt. |
mbed_official | 27:4206883f4cb7 | 419 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 420 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 421 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 422 | void usb0_host_Disable_DetachINT (void) |
mbed_official | 27:4206883f4cb7 | 423 | { |
mbed_official | 27:4206883f4cb7 | 424 | USB200.INTSTS1 = (uint16_t)(~(USB_HOST_BITDTCH)); |
mbed_official | 27:4206883f4cb7 | 425 | RZA_IO_RegWrite_16(&USB200.INTENB1, |
mbed_official | 27:4206883f4cb7 | 426 | 0, |
mbed_official | 27:4206883f4cb7 | 427 | USB_INTENB1_DTCHE_SHIFT, |
mbed_official | 27:4206883f4cb7 | 428 | USB_INTENB1_DTCHE); |
mbed_official | 27:4206883f4cb7 | 429 | } |
mbed_official | 27:4206883f4cb7 | 430 | |
mbed_official | 27:4206883f4cb7 | 431 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 432 | * Function Name: usb0_host_Enable_AttachINT |
mbed_official | 27:4206883f4cb7 | 433 | * Description : Enables the USB connection detection interrupt. |
mbed_official | 27:4206883f4cb7 | 434 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 435 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 436 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 437 | void usb0_host_Enable_AttachINT (void) |
mbed_official | 27:4206883f4cb7 | 438 | { |
mbed_official | 27:4206883f4cb7 | 439 | USB200.INTSTS1 = (uint16_t)(~(USB_HOST_BITATTCH)); |
mbed_official | 27:4206883f4cb7 | 440 | RZA_IO_RegWrite_16(&USB200.INTENB1, |
mbed_official | 27:4206883f4cb7 | 441 | 1, |
mbed_official | 27:4206883f4cb7 | 442 | USB_INTENB1_ATTCHE_SHIFT, |
mbed_official | 27:4206883f4cb7 | 443 | USB_INTENB1_ATTCHE); |
mbed_official | 27:4206883f4cb7 | 444 | } |
mbed_official | 27:4206883f4cb7 | 445 | |
mbed_official | 27:4206883f4cb7 | 446 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 447 | * Function Name: usb0_host_Disable_AttachINT |
mbed_official | 27:4206883f4cb7 | 448 | * Description : Disables the USB connection detection interrupt. |
mbed_official | 27:4206883f4cb7 | 449 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 450 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 451 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 452 | void usb0_host_Disable_AttachINT (void) |
mbed_official | 27:4206883f4cb7 | 453 | { |
mbed_official | 27:4206883f4cb7 | 454 | USB200.INTSTS1 = (uint16_t)(~(USB_HOST_BITATTCH)); |
mbed_official | 27:4206883f4cb7 | 455 | RZA_IO_RegWrite_16(&USB200.INTENB1, |
mbed_official | 27:4206883f4cb7 | 456 | 0, |
mbed_official | 27:4206883f4cb7 | 457 | USB_INTENB1_ATTCHE_SHIFT, |
mbed_official | 27:4206883f4cb7 | 458 | USB_INTENB1_ATTCHE); |
mbed_official | 27:4206883f4cb7 | 459 | } |
mbed_official | 27:4206883f4cb7 | 460 | |
mbed_official | 27:4206883f4cb7 | 461 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 462 | * Function Name: usb0_host_Disable_BchgINT |
mbed_official | 27:4206883f4cb7 | 463 | * Description : Disables the USB bus change detection interrupt. |
mbed_official | 27:4206883f4cb7 | 464 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 465 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 466 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 467 | void usb0_host_Disable_BchgINT (void) |
mbed_official | 27:4206883f4cb7 | 468 | { |
mbed_official | 27:4206883f4cb7 | 469 | USB200.INTSTS1 = (uint16_t)(~(USB_HOST_BITBCHG)); |
mbed_official | 27:4206883f4cb7 | 470 | RZA_IO_RegWrite_16(&USB200.INTENB1, |
mbed_official | 27:4206883f4cb7 | 471 | 0, |
mbed_official | 27:4206883f4cb7 | 472 | USB_INTENB1_BCHGE_SHIFT, |
mbed_official | 27:4206883f4cb7 | 473 | USB_INTENB1_BCHGE); |
mbed_official | 27:4206883f4cb7 | 474 | } |
mbed_official | 27:4206883f4cb7 | 475 | |
mbed_official | 27:4206883f4cb7 | 476 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 477 | * Function Name: usb0_host_set_devadd |
mbed_official | 27:4206883f4cb7 | 478 | * Description : DEVADDn register is set by specified value |
mbed_official | 27:4206883f4cb7 | 479 | * Arguments : uint16_t addr : Device address |
mbed_official | 27:4206883f4cb7 | 480 | * : uint16_t *devadd : Set value |
mbed_official | 27:4206883f4cb7 | 481 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 482 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 483 | void usb0_host_set_devadd (uint16_t addr, uint16_t * devadd) |
mbed_official | 27:4206883f4cb7 | 484 | { |
mbed_official | 27:4206883f4cb7 | 485 | uint16_t * ptr; |
mbed_official | 27:4206883f4cb7 | 486 | uint16_t ret_flag = DEVDRV_FLAG_ON; // avoid warning. |
mbed_official | 27:4206883f4cb7 | 487 | |
mbed_official | 27:4206883f4cb7 | 488 | switch (addr) |
mbed_official | 27:4206883f4cb7 | 489 | { |
mbed_official | 27:4206883f4cb7 | 490 | case USB_HOST_DEVICE_0: |
mbed_official | 27:4206883f4cb7 | 491 | ptr = (uint16_t *)&USB200.DEVADD0; |
mbed_official | 27:4206883f4cb7 | 492 | break; |
mbed_official | 27:4206883f4cb7 | 493 | |
mbed_official | 27:4206883f4cb7 | 494 | case USB_HOST_DEVICE_1: |
mbed_official | 27:4206883f4cb7 | 495 | ptr = (uint16_t *)&USB200.DEVADD1; |
mbed_official | 27:4206883f4cb7 | 496 | break; |
mbed_official | 27:4206883f4cb7 | 497 | |
mbed_official | 27:4206883f4cb7 | 498 | case USB_HOST_DEVICE_2: |
mbed_official | 27:4206883f4cb7 | 499 | ptr = (uint16_t *)&USB200.DEVADD2; |
mbed_official | 27:4206883f4cb7 | 500 | break; |
mbed_official | 27:4206883f4cb7 | 501 | |
mbed_official | 27:4206883f4cb7 | 502 | case USB_HOST_DEVICE_3: |
mbed_official | 27:4206883f4cb7 | 503 | ptr = (uint16_t *)&USB200.DEVADD3; |
mbed_official | 27:4206883f4cb7 | 504 | break; |
mbed_official | 27:4206883f4cb7 | 505 | |
mbed_official | 27:4206883f4cb7 | 506 | case USB_HOST_DEVICE_4: |
mbed_official | 27:4206883f4cb7 | 507 | ptr = (uint16_t *)&USB200.DEVADD4; |
mbed_official | 27:4206883f4cb7 | 508 | break; |
mbed_official | 27:4206883f4cb7 | 509 | |
mbed_official | 27:4206883f4cb7 | 510 | case USB_HOST_DEVICE_5: |
mbed_official | 27:4206883f4cb7 | 511 | ptr = (uint16_t *)&USB200.DEVADD5; |
mbed_official | 27:4206883f4cb7 | 512 | break; |
mbed_official | 27:4206883f4cb7 | 513 | |
mbed_official | 27:4206883f4cb7 | 514 | case USB_HOST_DEVICE_6: |
mbed_official | 27:4206883f4cb7 | 515 | ptr = (uint16_t *)&USB200.DEVADD6; |
mbed_official | 27:4206883f4cb7 | 516 | break; |
mbed_official | 27:4206883f4cb7 | 517 | |
mbed_official | 27:4206883f4cb7 | 518 | case USB_HOST_DEVICE_7: |
mbed_official | 27:4206883f4cb7 | 519 | ptr = (uint16_t *)&USB200.DEVADD7; |
mbed_official | 27:4206883f4cb7 | 520 | break; |
mbed_official | 27:4206883f4cb7 | 521 | |
mbed_official | 27:4206883f4cb7 | 522 | case USB_HOST_DEVICE_8: |
mbed_official | 27:4206883f4cb7 | 523 | ptr = (uint16_t *)&USB200.DEVADD8; |
mbed_official | 27:4206883f4cb7 | 524 | break; |
mbed_official | 27:4206883f4cb7 | 525 | |
mbed_official | 27:4206883f4cb7 | 526 | case USB_HOST_DEVICE_9: |
mbed_official | 27:4206883f4cb7 | 527 | ptr = (uint16_t *)&USB200.DEVADD9; |
mbed_official | 27:4206883f4cb7 | 528 | break; |
mbed_official | 27:4206883f4cb7 | 529 | |
mbed_official | 27:4206883f4cb7 | 530 | case USB_HOST_DEVICE_10: |
mbed_official | 27:4206883f4cb7 | 531 | ptr = (uint16_t *)&USB200.DEVADDA; |
mbed_official | 27:4206883f4cb7 | 532 | break; |
mbed_official | 27:4206883f4cb7 | 533 | |
mbed_official | 27:4206883f4cb7 | 534 | default: |
mbed_official | 27:4206883f4cb7 | 535 | ret_flag = DEVDRV_FLAG_OFF; |
mbed_official | 27:4206883f4cb7 | 536 | break; |
mbed_official | 27:4206883f4cb7 | 537 | } |
mbed_official | 27:4206883f4cb7 | 538 | |
mbed_official | 27:4206883f4cb7 | 539 | if (ret_flag == DEVDRV_FLAG_ON) |
mbed_official | 27:4206883f4cb7 | 540 | { |
mbed_official | 27:4206883f4cb7 | 541 | *ptr = (uint16_t)(*devadd & USB_HOST_DEVADD_MASK); |
mbed_official | 27:4206883f4cb7 | 542 | } |
mbed_official | 27:4206883f4cb7 | 543 | } |
mbed_official | 27:4206883f4cb7 | 544 | |
mbed_official | 27:4206883f4cb7 | 545 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 546 | * Function Name: usb0_host_get_devadd |
mbed_official | 27:4206883f4cb7 | 547 | * Description : DEVADDn register is obtained |
mbed_official | 27:4206883f4cb7 | 548 | * Arguments : uint16_t addr : Device address |
mbed_official | 27:4206883f4cb7 | 549 | * : uint16_t *devadd : USB_HOST_DEVADD register value |
mbed_official | 27:4206883f4cb7 | 550 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 551 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 552 | void usb0_host_get_devadd (uint16_t addr, uint16_t * devadd) |
mbed_official | 27:4206883f4cb7 | 553 | { |
mbed_official | 27:4206883f4cb7 | 554 | uint16_t * ptr; |
mbed_official | 27:4206883f4cb7 | 555 | uint16_t ret_flag = DEVDRV_FLAG_ON; // avoid warning. |
mbed_official | 27:4206883f4cb7 | 556 | |
mbed_official | 27:4206883f4cb7 | 557 | switch (addr) |
mbed_official | 27:4206883f4cb7 | 558 | { |
mbed_official | 27:4206883f4cb7 | 559 | case USB_HOST_DEVICE_0: |
mbed_official | 27:4206883f4cb7 | 560 | ptr = (uint16_t *)&USB200.DEVADD0; |
mbed_official | 27:4206883f4cb7 | 561 | break; |
mbed_official | 27:4206883f4cb7 | 562 | |
mbed_official | 27:4206883f4cb7 | 563 | case USB_HOST_DEVICE_1: |
mbed_official | 27:4206883f4cb7 | 564 | ptr = (uint16_t *)&USB200.DEVADD1; |
mbed_official | 27:4206883f4cb7 | 565 | break; |
mbed_official | 27:4206883f4cb7 | 566 | |
mbed_official | 27:4206883f4cb7 | 567 | case USB_HOST_DEVICE_2: |
mbed_official | 27:4206883f4cb7 | 568 | ptr = (uint16_t *)&USB200.DEVADD2; |
mbed_official | 27:4206883f4cb7 | 569 | break; |
mbed_official | 27:4206883f4cb7 | 570 | |
mbed_official | 27:4206883f4cb7 | 571 | case USB_HOST_DEVICE_3: |
mbed_official | 27:4206883f4cb7 | 572 | ptr = (uint16_t *)&USB200.DEVADD3; |
mbed_official | 27:4206883f4cb7 | 573 | break; |
mbed_official | 27:4206883f4cb7 | 574 | |
mbed_official | 27:4206883f4cb7 | 575 | case USB_HOST_DEVICE_4: |
mbed_official | 27:4206883f4cb7 | 576 | ptr = (uint16_t *)&USB200.DEVADD4; |
mbed_official | 27:4206883f4cb7 | 577 | break; |
mbed_official | 27:4206883f4cb7 | 578 | |
mbed_official | 27:4206883f4cb7 | 579 | case USB_HOST_DEVICE_5: |
mbed_official | 27:4206883f4cb7 | 580 | ptr = (uint16_t *)&USB200.DEVADD5; |
mbed_official | 27:4206883f4cb7 | 581 | break; |
mbed_official | 27:4206883f4cb7 | 582 | |
mbed_official | 27:4206883f4cb7 | 583 | case USB_HOST_DEVICE_6: |
mbed_official | 27:4206883f4cb7 | 584 | ptr = (uint16_t *)&USB200.DEVADD6; |
mbed_official | 27:4206883f4cb7 | 585 | break; |
mbed_official | 27:4206883f4cb7 | 586 | |
mbed_official | 27:4206883f4cb7 | 587 | case USB_HOST_DEVICE_7: |
mbed_official | 27:4206883f4cb7 | 588 | ptr = (uint16_t *)&USB200.DEVADD7; |
mbed_official | 27:4206883f4cb7 | 589 | break; |
mbed_official | 27:4206883f4cb7 | 590 | |
mbed_official | 27:4206883f4cb7 | 591 | case USB_HOST_DEVICE_8: |
mbed_official | 27:4206883f4cb7 | 592 | ptr = (uint16_t *)&USB200.DEVADD8; |
mbed_official | 27:4206883f4cb7 | 593 | break; |
mbed_official | 27:4206883f4cb7 | 594 | |
mbed_official | 27:4206883f4cb7 | 595 | case USB_HOST_DEVICE_9: |
mbed_official | 27:4206883f4cb7 | 596 | ptr = (uint16_t *)&USB200.DEVADD9; |
mbed_official | 27:4206883f4cb7 | 597 | break; |
mbed_official | 27:4206883f4cb7 | 598 | |
mbed_official | 27:4206883f4cb7 | 599 | case USB_HOST_DEVICE_10: |
mbed_official | 27:4206883f4cb7 | 600 | ptr = (uint16_t *)&USB200.DEVADDA; |
mbed_official | 27:4206883f4cb7 | 601 | break; |
mbed_official | 27:4206883f4cb7 | 602 | |
mbed_official | 27:4206883f4cb7 | 603 | default: |
mbed_official | 27:4206883f4cb7 | 604 | ret_flag = DEVDRV_FLAG_OFF; |
mbed_official | 27:4206883f4cb7 | 605 | break; |
mbed_official | 27:4206883f4cb7 | 606 | } |
mbed_official | 27:4206883f4cb7 | 607 | |
mbed_official | 27:4206883f4cb7 | 608 | if (ret_flag == DEVDRV_FLAG_ON) |
mbed_official | 27:4206883f4cb7 | 609 | { |
mbed_official | 27:4206883f4cb7 | 610 | *devadd = *ptr; |
mbed_official | 27:4206883f4cb7 | 611 | } |
mbed_official | 27:4206883f4cb7 | 612 | } |
mbed_official | 27:4206883f4cb7 | 613 | |
mbed_official | 27:4206883f4cb7 | 614 | /******************************************************************************* |
mbed_official | 27:4206883f4cb7 | 615 | * Function Name: usb0_host_EnableINT_Module |
mbed_official | 27:4206883f4cb7 | 616 | * Description : Enables BEMP/NRDY/BRDY interrupt and SIGN/SACK interrupt. |
mbed_official | 27:4206883f4cb7 | 617 | * : Enables NRDY/BEMP interrupt in the pipe0. |
mbed_official | 27:4206883f4cb7 | 618 | * Arguments : none |
mbed_official | 27:4206883f4cb7 | 619 | * Return Value : none |
mbed_official | 27:4206883f4cb7 | 620 | *******************************************************************************/ |
mbed_official | 27:4206883f4cb7 | 621 | void usb0_host_EnableINT_Module (void) |
mbed_official | 27:4206883f4cb7 | 622 | { |
mbed_official | 27:4206883f4cb7 | 623 | uint16_t buf; |
mbed_official | 27:4206883f4cb7 | 624 | |
mbed_official | 27:4206883f4cb7 | 625 | buf = USB200.INTENB0; |
mbed_official | 27:4206883f4cb7 | 626 | buf |= (USB_HOST_BITBEMPE | USB_HOST_BITNRDYE | USB_HOST_BITBRDYE); |
mbed_official | 27:4206883f4cb7 | 627 | USB200.INTENB0 = buf; |
mbed_official | 27:4206883f4cb7 | 628 | |
mbed_official | 27:4206883f4cb7 | 629 | buf = USB200.INTENB1; |
mbed_official | 27:4206883f4cb7 | 630 | buf |= (USB_HOST_BITSIGNE | USB_HOST_BITSACKE); |
mbed_official | 27:4206883f4cb7 | 631 | USB200.INTENB1 = buf; |
mbed_official | 27:4206883f4cb7 | 632 | |
mbed_official | 27:4206883f4cb7 | 633 | usb0_host_enable_nrdy_int(USB_HOST_PIPE0); |
mbed_official | 27:4206883f4cb7 | 634 | usb0_host_enable_bemp_int(USB_HOST_PIPE0); |
mbed_official | 27:4206883f4cb7 | 635 | } |
mbed_official | 27:4206883f4cb7 | 636 | |
mbed_official | 27:4206883f4cb7 | 637 | /* End of File */ |