google ADK bt test on MQX
[adk-bluetooth-test.git] / adk-stack / transport / usb / usb_host / host / source / host / host_shut.c
blob6fe469631e02294892dc4ab46d3161379a227b4c
1 /**HEADER********************************************************************
2 *
3 * Copyright (c) 2008 Freescale Semiconductor;
4 * All Rights Reserved
6 * Copyright (c) 1989-2008 ARC International;
7 * All Rights Reserved
9 ***************************************************************************
11 * THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
12 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
13 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
14 * IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
15 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
16 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
17 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
19 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
20 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
21 * THE POSSIBILITY OF SUCH DAMAGE.
23 **************************************************************************
25 * $FileName: host_shut.c$
26 * $Version : 3.8.9.0$
27 * $Date : Jun-7-2012$
29 * Comments:
31 * This file contains the USB Host API specific function to shutdown
32 * the host
34 *END************************************************************************/
35 #include <mqx.h>
37 #include "usb.h"
38 #include "usb_prv.h"
40 #include "host_cnfg.h"
41 #include "hostapi.h"
42 #include "host_main.h"
43 #include "host_shut.h"
45 /*FUNCTION*-------------------------------------------------------------
47 * Function Name : _usb_host_shutdown
48 * Returned Value : USB_OK or error code
49 * Comments :
50 * Shutdown an initialized USB Host
52 *END*-----------------------------------------------------------------*/
53 void _usb_host_shutdown
55 /* [IN] the USB_host handle */
56 _usb_host_handle handle
58 { /* Body */
59 USB_STATUS status;
60 USB_HOST_STATE_STRUCT_PTR usb_host_ptr;
61 usb_host_ptr = (USB_HOST_STATE_STRUCT_PTR)handle;
62 #ifdef _HOST_DEBUG_
63 DEBUG_LOG_TRACE("_usb_host_shutdown");
64 #endif
67 /* De-initialize and disconnect the host hardware from the bus */
68 status = _usb_host_shutdown_call_interface (handle);
70 if (status != USB_OK)
72 #ifdef _HOST_DEBUG_
73 DEBUG_LOG_TRACE("_usb_host_shutdown FAILED");
74 #endif
77 /* Free all Pipe Descriptors */
78 USB_mem_free((pointer)usb_host_ptr->PIPE_DESCRIPTOR_BASE_PTR);
80 /* Free the USB state structure */
81 USB_mem_free(handle);
82 #ifdef _HOST_DEBUG_
83 DEBUG_LOG_TRACE("_usb_host_shutdown SUCCESSFUL");
84 #endif
87 } /* EndBody */
89 /*FUNCTION*-------------------------------------------------------------
91 * Function Name : _usb_host_bus_control
92 * Returned Value : None
93 * Comments :
94 * _usb_host_bus_control controls the bus operations such as asserting and
95 * deasserting the bus reset, asserting and deasserting resume,
96 * suspending and resuming the SOF generation
98 *END*-----------------------------------------------------------------*/
100 void _usb_host_bus_control
102 /* [IN] the USB Host state structure */
103 _usb_host_handle handle,
105 /* The operation to be performed on the bus */
106 uint_8 bcontrol
108 { /* Body */
110 USB_STATUS status;
111 USB_HOST_STATE_STRUCT_PTR usb_host_ptr;
113 #ifdef _HOST_DEBUG_
114 DEBUG_LOG_TRACE("_usb_host_bus_control");
115 #endif
117 usb_host_ptr = (USB_HOST_STATE_STRUCT_PTR)handle;
119 status = _usb_host_bus_control_data_call_interface (handle, bcontrol);
121 if (status != USB_OK)
123 #ifdef _HOST_DEBUG_
124 DEBUG_LOG_TRACE("_usb_host_bus_control FAILED");
125 #endif
128 #ifdef _HOST_DEBUG_
129 DEBUG_LOG_TRACE("_usb_host_bus_control SUCCESSFUL");
130 #endif
132 } /* Endbody */
134 /* EOF */