usb_host_hub.h

Go to the documentation of this file.
00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
00013 
00014 /* Copyright (c) 2007, Atmel Corporation All rights reserved.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions are met:
00018  *
00019  * 1. Redistributions of source code must retain the above copyright notice,
00020  * this list of conditions and the following disclaimer.
00021  *
00022  * 2. Redistributions in binary form must reproduce the above copyright notice,
00023  * this list of conditions and the following disclaimer in the documentation
00024  * and/or other materials provided with the distribution.
00025  *
00026  * 3. The name of ATMEL may not be used to endorse or promote products derived
00027  * from this software without specific prior written permission.
00028  *
00029  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
00030  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00031  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00032  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00033  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00034  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00035  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00036  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00038  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  */
00040 
00041 #ifndef _USB_HOST_HUB_H_
00042 #define _USB_HOST_HUB_H_
00043 
00044 //_____ I N C L U D E S ____________________________________________________
00045 
00046 
00047 #include "modules/usb/usb_task.h"
00048 
00049 //_____ M A C R O S ________________________________________________________
00050 
00051 
00052 //_____ S T A N D A R D    D E F I N I T I O N S ___________________________
00053 
00054 
00055 #ifndef HUB_CLASS
00056    #define HUB_CLASS 0x09
00057 #endif
00058 
00059 //Hub class features selectors
00060 #define C_HUB_LOCAL_POWER     0
00061 #define C_HUB_OVER_CURRENT    1
00062 #define PORT_CONNECTION       0
00063 #define PORT_ENABLE           1
00064 #define PORT_SUSPEND          2
00065 #define PORT_OVER_CURRENT     3
00066 #define PORT_RESET            4
00067 #define PORT_POWER            8
00068 #define PORT_LOW_SPEED        9
00069 #define C_PORT_CONNECTION     16
00070 #define C_PORT_ENABLE         17
00071 #define C_PORT_SUSPEND        18
00072 #define C_PORT_OVER_CURRENT   19
00073 #define C_PORT_RESET          20
00074 #define PORT_TEST             21
00075 #define PORT_INDICATOR        22
00076 
00077 
00078 #define NB_PORT_OFFSET        2
00079 
00080 
00081 #define HUB_DEVICE_POWERED           2
00082 #define HUB_DEVICE_CONNECT           3
00083 #define HUB_DEVICE_WAIT_RST_1        4
00084 #define HUB_DEVICE_WAIT_RST_2        5
00085 #define HUB_DEVICE_READY             6
00086 
00087 
00088 #define HUB_PORT_CONNECTION          0
00089 #define HUB_PORT_RESET               1
00090 #define HUB_PORT_DISCONNECT          2
00091 
00092 #if (USB_HUB_SUPPORT==ENABLE)
00093 
00094 extern  U8 f_hub_port_disconnect;
00095 extern  U8 hub_device_address[USB_MAX_HUB_NUMBER];
00096 extern  U8 hub_port_state[USB_MAX_HUB_NUMBER][HUB_MAX_NB_PORT];
00097 extern  U8 nb_hub_present;
00098 
00099 
00100 U32 get_port_status(U8 port_number);
00101 void hub_manage_port_change_status(U8 port_change_status, U8 hub_number);
00102 void enumerate_hub_port_device(U8 hub_port, U8 port_ev, U8 hub_number);
00103 void hub_init(U8 hub_number);
00104 
00114 #define Clear_hub_feature(feature_selector)        (usb_request.bmRequestType = USB_SETUP_SET_CLASS_DEVICE,\
00115                                            usb_request.bRequest      = SETUP_CLEAR_FEATURE,\
00116                                            usb_request.wValue        = (U16)feature_selector,\
00117                                            usb_request.wIndex        = 0,\
00118                                            usb_request.wLength       = 0,\
00119                                            usb_request.uncomplete_read = FALSE,\
00120                                            host_send_control(data_stage))
00121 
00132 #define Clear_port_feature(feature_selector,port)        (usb_request.bmRequestType = USB_SETUP_SET_CLASS_OTHER,\
00133                                            usb_request.bRequest      = SETUP_CLEAR_FEATURE,\
00134                                            usb_request.wValue        = (U16)feature_selector,\
00135                                            usb_request.wIndex        = port,\
00136                                            usb_request.wLength       = 0,\
00137                                            usb_request.uncomplete_read = FALSE,\
00138                                            host_send_control(data_stage))
00139 
00147 #define Get_hub_descriptor()              (usb_request.bmRequestType = USB_SETUP_GET_CLASS_DEVICE,\
00148                                            usb_request.bRequest      = SETUP_GET_DESCRIPTOR,\
00149                                            usb_request.wValue        = 0x2900,\
00150                                            usb_request.wIndex        = 0,\
00151                                            usb_request.wLength       = 0xFF,\
00152                                            usb_request.uncomplete_read = FALSE,\
00153                                            host_send_control(data_stage))
00154 
00162 #define Get_hub_status()              (usb_request.bmRequestType = USB_SETUP_GET_CLASS_DEVICE,\
00163                                            usb_request.bRequest      = SETUP_GET_STATUS,\
00164                                            usb_request.wValue        = 0,\
00165                                            usb_request.wIndex        = 0,\
00166                                            usb_request.wLength       = 4,\
00167                                            usb_request.uncomplete_read = FALSE,\
00168                                            host_send_control(data_stage))
00169 
00178 #define Get_port_status(port)              (usb_request.bmRequestType = USB_SETUP_GET_CLASS_OTHER,\
00179                                            usb_request.bRequest      = SETUP_GET_STATUS,\
00180                                            usb_request.wValue        = 0,\
00181                                            usb_request.wIndex        = port,\
00182                                            usb_request.wLength       = 4,\
00183                                            usb_request.uncomplete_read = FALSE,\
00184                                            host_send_control(data_stage))
00185 
00186 
00196 #define Set_hub_feature(feature)              (usb_request.bmRequestType = USB_SETUP_SET_CLASS_DEVICE,\
00197                                            usb_request.bRequest      = SETUP_SET_FEATURE,\
00198                                            usb_request.wValue        = (U16)feature,\
00199                                            usb_request.wIndex        = 0,\
00200                                            usb_request.wLength       = 0,\
00201                                            usb_request.uncomplete_read = FALSE,\
00202                                            host_send_control(data_stage))
00203 
00204 
00215 #define Set_port_feature(feature,port)              (usb_request.bmRequestType = USB_SETUP_SET_CLASS_OTHER,\
00216                                            usb_request.bRequest      = SETUP_SET_FEATURE,\
00217                                            usb_request.wValue        = (U16)feature,\
00218                                            usb_request.wIndex        = port,\
00219                                            usb_request.wLength       = 0,\
00220                                            usb_request.uncomplete_read = FALSE,\
00221                                            host_send_control(data_stage))
00222 
00223 
00224 
00225 #define Set_port_indicator_green(i)             Set_port_feature(PORT_INDICATOR,0x0200+i)
00226 #define Set_port_indicator_amber(i)             Set_port_feature(PORT_INDICATOR,0x0100+i)
00227 #define Set_port_indicator_auto(i)              Set_port_feature(PORT_INDICATOR,0x0300+i)
00228 #define Set_port_indicator_off(i)               Set_port_feature(PORT_INDICATOR,0x0000+i)
00229 
00230 #define Set_port_reset(i)                       Set_port_feature(PORT_RESET,i)
00231 #define Set_port_suspend(i)                     Set_port_feature(PORT_SUSPEND,i)
00232 #define Clear_port_suspend(i)                   Clear_port_feature(PORT_SUSPEND,i)
00233 
00234 #define Set_port_power(i)                       Set_port_feature(PORT_POWER,i);
00235 #define Clear_port_power(i)                     Clear_port_feature(PORT_POWER,i);
00236 
00237 
00238 
00240 
00242 extern U8 hub_device_address[USB_MAX_HUB_NUMBER];
00243 
00245 extern U8 nb_hub_present;
00246 
00247 #endif
00248 
00249 #endif  // _USB_HOST_HUB_H_
00250 

Generated on Fri May 15 15:41:36 2009 for ATMEL by  doxygen 1.5.3