00001
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef _USB_HOST_HUB_H_
00042 #define _USB_HOST_HUB_H_
00043
00044
00045
00046
00047 #include "modules/usb/usb_task.h"
00048
00049
00050
00051
00052
00053
00054
00055 #ifndef HUB_CLASS
00056 #define HUB_CLASS 0x09
00057 #endif
00058
00059
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