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
00042
00043
00044 #ifndef _USB_HOST_HUB_H_
00045 #define _USB_HOST_HUB_H_
00046
00047
00048
00049
00050 #include "modules/usb/usb_task.h"
00051
00052
00053
00054
00055
00056
00057
00058 #ifndef HUB_CLASS
00059 #define HUB_CLASS 0x09
00060 #endif
00061
00062
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