usb_host_hub.h

Go to the documentation of this file.
00001 /*This file is prepared for Doxygen automatic documentation generation.*/
00013 
00014 /* Copyright (c) 2009 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  * 4. This software may only be redistributed and used in connection with an Atmel
00030  * AVR product.
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00033  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00034  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00035  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00036  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00037  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00038  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00039  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00040  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00041  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00042  */
00043 
00044 #ifndef _USB_HOST_HUB_H_
00045 #define _USB_HOST_HUB_H_
00046 
00047 //_____ I N C L U D E S ____________________________________________________
00048 
00049 
00050 #include "modules/usb/usb_task.h"
00051 
00052 //_____ M A C R O S ________________________________________________________
00053 
00054 
00055 //_____ S T A N D A R D    D E F I N I T I O N S ___________________________
00056 
00057 
00058 #ifndef HUB_CLASS
00059    #define HUB_CLASS 0x09
00060 #endif
00061 
00062 //Hub class features selectors
00063 #define C_HUB_LOCAL_POWER     0
00064 #define C_HUB_OVER_CURRENT    1
00065 #define PORT_CONNECTION       0
00066 #define PORT_ENABLE           1
00067 #define PORT_SUSPEND          2
00068 #define PORT_OVER_CURRENT     3
00069 #define PORT_RESET            4
00070 #define PORT_POWER            8
00071 #define PORT_LOW_SPEED        9
00072 #define C_PORT_CONNECTION     16
00073 #define C_PORT_ENABLE         17
00074 #define C_PORT_SUSPEND        18
00075 #define C_PORT_OVER_CURRENT   19
00076 #define C_PORT_RESET          20
00077 #define PORT_TEST             21
00078 #define PORT_INDICATOR        22
00079 
00080 
00081 #define NB_PORT_OFFSET        2
00082 
00083 
00084 #define HUB_DEVICE_POWERED           2
00085 #define HUB_DEVICE_CONNECT           3
00086 #define HUB_DEVICE_WAIT_RST_1        4
00087 #define HUB_DEVICE_WAIT_RST_2        5
00088 #define HUB_DEVICE_READY             6
00089 
00090 
00091 #define HUB_PORT_CONNECTION          0
00092 #define HUB_PORT_RESET               1
00093 #define HUB_PORT_DISCONNECT          2
00094 
00095 #if (USB_HUB_SUPPORT==ENABLE)
00096 
00097 extern  U8 f_hub_port_disconnect;
00098 extern  U8 hub_device_address[USB_MAX_HUB_NUMBER];
00099 extern  U8 hub_port_state[USB_MAX_HUB_NUMBER][HUB_MAX_NB_PORT];
00100 extern  U8 nb_hub_present;
00101 
00102 
00103 U32 get_port_status(U8 port_number);
00104 void hub_manage_port_change_status(U8 port_change_status, U8 hub_number);
00105 void enumerate_hub_port_device(U8 hub_port, U8 port_ev, U8 hub_number);
00106 void hub_init(U8 hub_number);
00107 
00117 #define Clear_hub_feature(feature_selector)        (usb_request.bmRequestType = USB_SETUP_SET_CLASS_DEVICE,\
00118                                            usb_request.bRequest      = SETUP_CLEAR_FEATURE,\
00119                                            usb_request.wValue        = (U16)feature_selector,\
00120                                            usb_request.wIndex        = 0,\
00121                                            usb_request.wLength       = 0,\
00122                                            usb_request.uncomplete_read = FALSE,\
00123                                            host_send_control(data_stage))
00124 
00135 #define Clear_port_feature(feature_selector,port)        (usb_request.bmRequestType = USB_SETUP_SET_CLASS_OTHER,\
00136                                            usb_request.bRequest      = SETUP_CLEAR_FEATURE,\
00137                                            usb_request.wValue        = (U16)feature_selector,\
00138                                            usb_request.wIndex        = port,\
00139                                            usb_request.wLength       = 0,\
00140                                            usb_request.uncomplete_read = FALSE,\
00141                                            host_send_control(data_stage))
00142 
00150 #define Get_hub_descriptor()              (usb_request.bmRequestType = USB_SETUP_GET_CLASS_DEVICE,\
00151                                            usb_request.bRequest      = SETUP_GET_DESCRIPTOR,\
00152                                            usb_request.wValue        = 0x2900,\
00153                                            usb_request.wIndex        = 0,\
00154                                            usb_request.wLength       = 0xFF,\
00155                                            usb_request.uncomplete_read = FALSE,\
00156                                            host_send_control(data_stage))
00157 
00165 #define Get_hub_status()              (usb_request.bmRequestType = USB_SETUP_GET_CLASS_DEVICE,\
00166                                            usb_request.bRequest      = SETUP_GET_STATUS,\
00167                                            usb_request.wValue        = 0,\
00168                                            usb_request.wIndex        = 0,\
00169                                            usb_request.wLength       = 4,\
00170                                            usb_request.uncomplete_read = FALSE,\
00171                                            host_send_control(data_stage))
00172 
00181 #define Get_port_status(port)              (usb_request.bmRequestType = USB_SETUP_GET_CLASS_OTHER,\
00182                                            usb_request.bRequest      = SETUP_GET_STATUS,\
00183                                            usb_request.wValue        = 0,\
00184                                            usb_request.wIndex        = port,\
00185                                            usb_request.wLength       = 4,\
00186                                            usb_request.uncomplete_read = FALSE,\
00187                                            host_send_control(data_stage))
00188 
00189 
00199 #define Set_hub_feature(feature)              (usb_request.bmRequestType = USB_SETUP_SET_CLASS_DEVICE,\
00200                                            usb_request.bRequest      = SETUP_SET_FEATURE,\
00201                                            usb_request.wValue        = (U16)feature,\
00202                                            usb_request.wIndex        = 0,\
00203                                            usb_request.wLength       = 0,\
00204                                            usb_request.uncomplete_read = FALSE,\
00205                                            host_send_control(data_stage))
00206 
00207 
00218 #define Set_port_feature(feature,port)              (usb_request.bmRequestType = USB_SETUP_SET_CLASS_OTHER,\
00219                                            usb_request.bRequest      = SETUP_SET_FEATURE,\
00220                                            usb_request.wValue        = (U16)feature,\
00221                                            usb_request.wIndex        = port,\
00222                                            usb_request.wLength       = 0,\
00223                                            usb_request.uncomplete_read = FALSE,\
00224                                            host_send_control(data_stage))
00225 
00226 
00227 
00228 #define Set_port_indicator_green(i)             Set_port_feature(PORT_INDICATOR,0x0200+i)
00229 #define Set_port_indicator_amber(i)             Set_port_feature(PORT_INDICATOR,0x0100+i)
00230 #define Set_port_indicator_auto(i)              Set_port_feature(PORT_INDICATOR,0x0300+i)
00231 #define Set_port_indicator_off(i)               Set_port_feature(PORT_INDICATOR,0x0000+i)
00232 
00233 #define Set_port_reset(i)                       Set_port_feature(PORT_RESET,i)
00234 #define Set_port_suspend(i)                     Set_port_feature(PORT_SUSPEND,i)
00235 #define Clear_port_suspend(i)                   Clear_port_feature(PORT_SUSPEND,i)
00236 
00237 #define Set_port_power(i)                       Set_port_feature(PORT_POWER,i);
00238 #define Clear_port_power(i)                     Clear_port_feature(PORT_POWER,i);
00239 
00240 
00241 
00243 
00245 extern U8 hub_device_address[USB_MAX_HUB_NUMBER];
00246 
00248 extern U8 nb_hub_present;
00249 
00250 #endif
00251 
00252 #endif  // _USB_HOST_HUB_H_
00253 

Generated on Wed Sep 23 09:17:03 2009 for ATMEL by  doxygen 1.5.3