├── App ├── CDC │ ├── app_usbh_cdc_acm.c │ ├── app_usbh_cdc_acm.h │ ├── app_usbh_cdc_ecm.c │ └── app_usbh_cdc_ecm.h ├── FTDI │ ├── app_usbh_ftdi.c │ └── app_usbh_ftdi.h ├── HID │ ├── app_usbh_hid.c │ ├── app_usbh_hid.h │ ├── app_usbh_keyboard.c │ ├── app_usbh_keyboard.h │ ├── app_usbh_mouse.c │ └── app_usbh_mouse.h ├── MSC │ └── uC-FS-V4 │ │ ├── app_usbh_msc.c │ │ └── app_usbh_msc.h ├── Test │ ├── app_usbh_msc_stress.c │ └── app_usbh_msc_stress.h ├── app_usbh.c └── app_usbh.h ├── Cfg └── Template │ ├── usbh_cfg.h │ ├── usbh_hc_cfg.c │ └── usbh_hc_cfg.h ├── Class ├── CDC │ ├── ACM │ │ ├── usbh_acm.c │ │ └── usbh_acm.h │ ├── ECM │ │ ├── usbh_ecm.c │ │ └── usbh_ecm.h │ ├── usbh_cdc.c │ └── usbh_cdc.h ├── FTDI │ ├── usbh_ftdi.c │ └── usbh_ftdi.h ├── HID │ ├── usbh_hid.c │ ├── usbh_hid.h │ ├── usbh_hidparser.c │ └── usbh_hidparser.h └── MSC │ ├── usbh_msc.c │ └── usbh_msc.h ├── HCD ├── ATSAMx │ ├── usbh_hcd_atsamx.c │ └── usbh_hcd_atsamx.h ├── DWC_OTG_HS │ ├── usbh_hcd_dwc_otg_hs.c │ └── usbh_hcd_dwc_otg_hs.h ├── EHCI │ ├── usbh_hcd_ehci.c │ └── usbh_hcd_ehci.h ├── OHCI │ ├── usbh_hcd_ohci.c │ └── usbh_hcd_ohci.h ├── RX600 │ ├── usbh_hcd_rx600.c │ └── usbh_hcd_rx600.h ├── Renesas_USBHS │ ├── usbh_hcd_renesas_usbhs.c │ └── usbh_hcd_renesas_usbhs.h ├── STM32F_FS │ ├── usbh_hcd_stm32fx_fs.c │ └── usbh_hcd_stm32fx_fs.h └── Template │ ├── bsp_usbh_template.c │ ├── bsp_usbh_template.h │ ├── usbh_hcd_template.c │ └── usbh_hcd_template.h ├── LICENSE ├── NOTICE ├── OS ├── Template │ └── usbh_os.c ├── uCOS-II │ └── usbh_os.c └── uCOS-III │ └── usbh_os.c ├── README.rst └── Source ├── usbh_class.c ├── usbh_class.h ├── usbh_core.c ├── usbh_core.h ├── usbh_err.h ├── usbh_hub.c ├── usbh_hub.h └── usbh_os.h /App/CDC/app_usbh_cdc_acm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST CDC ACM TEST APPLICATION 19 | * 20 | * TEMPLATE 21 | * 22 | * Filename : app_usbh_cdc_acm.c 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | #ifndef APP_USBH_CDC_ACM_H 28 | #define APP_USBH_CDC_ACM_H 29 | 30 | 31 | /* 32 | ************************************************************************************************************** 33 | * INCLUDE FILES 34 | ************************************************************************************************************** 35 | */ 36 | 37 | #include 38 | 39 | 40 | /* 41 | ************************************************************************************************************** 42 | * EXTERNS 43 | ************************************************************************************************************** 44 | */ 45 | 46 | #ifdef APP_USBH_CDC_ACM_MODULE 47 | #define APP_USBH_CDC_ACM_EXT 48 | #else 49 | #define APP_USBH_CDC_ACM_EXT extern 50 | #endif 51 | 52 | /* 53 | ************************************************************************************************************** 54 | * DEFINES 55 | ************************************************************************************************************** 56 | */ 57 | 58 | 59 | /* 60 | ************************************************************************************************************** 61 | * DATA TYPES 62 | ************************************************************************************************************** 63 | */ 64 | 65 | 66 | /* 67 | ************************************************************************************************************** 68 | * GLOBAL VARIABLES 69 | ************************************************************************************************************** 70 | */ 71 | 72 | 73 | /* 74 | ************************************************************************************************************** 75 | * MACRO'S 76 | ************************************************************************************************************** 77 | */ 78 | 79 | 80 | /* 81 | ************************************************************************************************************** 82 | * FUNCTION PROTOTYPES 83 | ************************************************************************************************************** 84 | */ 85 | 86 | USBH_ERR App_USBH_CDC_ACM_Init (void); 87 | 88 | 89 | /* 90 | ************************************************************************************************************** 91 | * CONFIGURATION ERRORS 92 | ************************************************************************************************************** 93 | */ 94 | 95 | 96 | #endif 97 | 98 | /* 99 | ************************************************************************************************************** 100 | * END 101 | ************************************************************************************************************** 102 | */ 103 | -------------------------------------------------------------------------------- /App/CDC/app_usbh_cdc_ecm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST CDC ECM TEST APPLICATION 19 | * 20 | * TEMPLATE 21 | * 22 | * Filename : app_usbh_cdc_ecm.c 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | #ifndef APP_USBH_CDC_ECM_H 28 | #define APP_USBH_CDC_ECM_H 29 | 30 | 31 | /* 32 | ************************************************************************************************************** 33 | * INCLUDE FILES 34 | ************************************************************************************************************** 35 | */ 36 | 37 | #include 38 | 39 | 40 | /* 41 | ************************************************************************************************************** 42 | * EXTERNS 43 | ************************************************************************************************************** 44 | */ 45 | 46 | #ifdef APP_USBH_CDC_ECM_MODULE 47 | #define APP_USBH_CDC_ECM_EXT 48 | #else 49 | #define APP_USBH_CDC_ECM_EXT extern 50 | #endif 51 | 52 | /* 53 | ************************************************************************************************************** 54 | * DEFINES 55 | ************************************************************************************************************** 56 | */ 57 | 58 | 59 | /* 60 | ************************************************************************************************************** 61 | * DATA TYPES 62 | ************************************************************************************************************** 63 | */ 64 | 65 | 66 | /* 67 | ************************************************************************************************************** 68 | * GLOBAL VARIABLES 69 | ************************************************************************************************************** 70 | */ 71 | 72 | 73 | /* 74 | ************************************************************************************************************** 75 | * MACRO'S 76 | ************************************************************************************************************** 77 | */ 78 | 79 | 80 | /* 81 | ************************************************************************************************************** 82 | * FUNCTION PROTOTYPES 83 | ************************************************************************************************************** 84 | */ 85 | 86 | USBH_ERR App_USBH_CDC_ECM_Init (void); 87 | 88 | 89 | /* 90 | ************************************************************************************************************** 91 | * CONFIGURATION ERRORS 92 | ************************************************************************************************************** 93 | */ 94 | 95 | 96 | #endif 97 | 98 | /* 99 | ************************************************************************************************************** 100 | * END 101 | ************************************************************************************************************** 102 | */ 103 | -------------------------------------------------------------------------------- /App/FTDI/app_usbh_ftdi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST FTDI TEST APPLICATION 19 | * 20 | * TEMPLATE 21 | * 22 | * Filename : app_usbh_ftdi.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #ifndef APP_USBH_FTDI_MODULE_PRESENT 34 | #define APP_USBH_FTDI_MODULE_PRESENT 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | #include 44 | 45 | 46 | /* 47 | ********************************************************************************************************* 48 | * EXTERNS 49 | ********************************************************************************************************* 50 | */ 51 | 52 | #ifdef APP_USBH_FTDI_MODULE 53 | #define APP_USBH_FTDI_EXT 54 | #else 55 | #define APP_USBH_FTDI_EXT extern 56 | #endif 57 | 58 | 59 | /* 60 | ********************************************************************************************************* 61 | * DEFINES 62 | ********************************************************************************************************* 63 | */ 64 | 65 | 66 | /* 67 | ********************************************************************************************************* 68 | * DATA TYPES 69 | ********************************************************************************************************* 70 | */ 71 | 72 | 73 | /* 74 | ********************************************************************************************************* 75 | * GLOBAL VARIABLES 76 | ********************************************************************************************************* 77 | */ 78 | 79 | 80 | /* 81 | ********************************************************************************************************* 82 | * MACROS 83 | ********************************************************************************************************* 84 | */ 85 | 86 | 87 | /* 88 | ********************************************************************************************************* 89 | * FUNCTION PROTOTYPES 90 | ********************************************************************************************************* 91 | */ 92 | 93 | void App_USBH_FTDI_Init(USBH_ERR *p_err); 94 | 95 | 96 | /* 97 | ********************************************************************************************************* 98 | * CONFIGURATION ERRORS 99 | ********************************************************************************************************* 100 | */ 101 | 102 | 103 | /* 104 | ********************************************************************************************************* 105 | * MODULE END 106 | ********************************************************************************************************* 107 | */ 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /App/HID/app_usbh_hid.c: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST HID TEST APPLICATION 19 | * 20 | * TEMPLATE 21 | * 22 | * Filename : app_usbh_hid_demo.c 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * INCLUDE FILES 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #define APP_USBH_HID_MODULE 34 | #include 35 | #include "app_usbh_hid.h" 36 | 37 | 38 | /* 39 | ********************************************************************************************************* 40 | * LOCAL DEFINES 41 | ********************************************************************************************************* 42 | */ 43 | 44 | #define USBH_HID_APP_USAGE_MOUSE 0x00000002u 45 | #define USBH_HID_APP_USAGE_KBD 0x00000006u 46 | 47 | 48 | /* 49 | ********************************************************************************************************* 50 | * LOCAL CONSTANTS 51 | ********************************************************************************************************* 52 | */ 53 | 54 | 55 | /* 56 | ********************************************************************************************************* 57 | * LOCAL DATA TYPES 58 | ********************************************************************************************************* 59 | */ 60 | 61 | 62 | /* 63 | ********************************************************************************************************* 64 | * LOCAL TABLES 65 | ********************************************************************************************************* 66 | */ 67 | 68 | 69 | /* 70 | ********************************************************************************************************* 71 | * LOCAL GLOBAL VARIABLES 72 | ********************************************************************************************************* 73 | */ 74 | 75 | 76 | /* 77 | ********************************************************************************************************* 78 | * LOCAL FUNCTION PROTOTYPES 79 | ********************************************************************************************************* 80 | */ 81 | 82 | static void App_USBH_HID_ClassDevNotify(void *p_hid_dev, 83 | CPU_INT08U state, 84 | void *p_ctx); 85 | 86 | static void App_USBH_HID_DevConn (USBH_HID_DEV *p_hid_dev); 87 | 88 | static void App_USBH_HID_DevDisconn (USBH_HID_DEV *p_hid_dev); 89 | 90 | 91 | /* 92 | ********************************************************************************************************* 93 | * LOCAL CONFIGURATION ERRORS 94 | ********************************************************************************************************* 95 | */ 96 | 97 | 98 | /* 99 | ********************************************************************************************************* 100 | ********************************************************************************************************* 101 | * GLOBAL FUNCTIONS 102 | ********************************************************************************************************* 103 | ********************************************************************************************************* 104 | */ 105 | 106 | 107 | 108 | /* 109 | ********************************************************************************************************* 110 | * App_USBH_HID_Init() 111 | * 112 | * Description : Register HID notify callback. 113 | * 114 | * Argument(s) : None. 115 | * 116 | * Return(s) : USBH_ERR_NONE, if the demo is initialized. 117 | * Specific error code, otherwise. 118 | * 119 | * Note(s) : None. 120 | ********************************************************************************************************* 121 | */ 122 | 123 | USBH_ERR App_USBH_HID_Init (void) 124 | { 125 | USBH_ERR host_err; 126 | 127 | /* ----------- REGISTER DRV & NOTIFICATION ------------ */ 128 | host_err = USBH_ClassDrvReg( &USBH_HID_ClassDrv, 129 | App_USBH_HID_ClassDevNotify, 130 | (void *)0); 131 | return (host_err); 132 | } 133 | 134 | 135 | /* 136 | ********************************************************************************************************* 137 | ********************************************************************************************************* 138 | * LOCAL FUNCTIONS 139 | ********************************************************************************************************* 140 | ********************************************************************************************************* 141 | */ 142 | 143 | 144 | /* 145 | ********************************************************************************************************* 146 | * App_USBH_HID_ClassDevNotify() 147 | * 148 | * Description : Handle device state change notification for HID devices. 149 | * 150 | * Argument(s) : p_class_dev Pointer to class device. 151 | * 152 | * state State. 153 | * 154 | * pctx Pointer to context. 155 | * 156 | * Return(s) : None. 157 | * 158 | * Note(s) : None. 159 | ********************************************************************************************************* 160 | */ 161 | 162 | static void App_USBH_HID_ClassDevNotify (void *p_class_dev, 163 | CPU_INT08U state, 164 | void *p_ctx) 165 | { 166 | USBH_HID_DEV *p_hid_dev; 167 | 168 | 169 | (void)p_ctx; 170 | p_hid_dev = (USBH_HID_DEV *)p_class_dev; 171 | 172 | switch (state) { 173 | case USBH_CLASS_DEV_STATE_CONN: /* ---------------- HID DEVICE CONN'D ----------------- */ 174 | APP_TRACE_INFO(("HID Demo: Device Connected\r\n")); 175 | App_USBH_HID_DevConn(p_hid_dev); 176 | break; 177 | 178 | case USBH_CLASS_DEV_STATE_DISCONN: /* ---------------- HID DEVICE REMOVED ---------------- */ 179 | APP_TRACE_INFO(("HID Demo: Device Removed\r\n")); 180 | App_USBH_HID_DevDisconn(p_hid_dev); 181 | break; 182 | 183 | default: 184 | break; 185 | } 186 | } 187 | 188 | 189 | /* 190 | ********************************************************************************************************* 191 | * App_USBH_HID_DevConn() 192 | * 193 | * Description : This function is called when HID device is connected. 194 | * 195 | * Argument(s) : p_hid_dev Pointer to HID device. 196 | * 197 | * Return(s) : None. 198 | * 199 | * Note(s) : None. 200 | ********************************************************************************************************* 201 | */ 202 | 203 | static void App_USBH_HID_DevConn (USBH_HID_DEV *p_hid_dev) 204 | { 205 | CPU_INT08U nbr_report_id; 206 | CPU_INT08U report_id_cnt; 207 | USBH_HID_REPORT_ID *p_report_id_array; 208 | USBH_HID_REPORT_ID *p_report_id; 209 | USBH_ERR err; 210 | 211 | 212 | err = USBH_HID_RefAdd(p_hid_dev); /* Add ref */ 213 | if (err != USBH_ERR_NONE) { 214 | APP_TRACE_INFO(("Error in App_USBH_HID_DevConn(): %d\r\n", err)); 215 | return; 216 | } 217 | 218 | err = USBH_HID_IdleSet(p_hid_dev, 0u, 0u); /* Set Idle Time. */ 219 | if (err == USBH_ERR_EP_STALL) { 220 | APP_TRACE_INFO(("Error in App_USBH_HID_DevConn(): %d\r\n", err)); 221 | } else if (err != USBH_ERR_NONE) { 222 | APP_TRACE_INFO(("Error in App_USBH_HID_DevConn(): %d\r\n", err)); 223 | return; 224 | } 225 | 226 | err = USBH_HID_Init(p_hid_dev); /* Initialize HID */ 227 | if (err != USBH_ERR_NONE) { 228 | APP_TRACE_INFO(("Error in App_USBH_HID_DevConn(): %d\r\n", err)); 229 | return; 230 | } 231 | 232 | err = USBH_HID_GetReportIDArray(p_hid_dev, 233 | &p_report_id_array, 234 | &nbr_report_id); 235 | if (err != USBH_ERR_NONE) { 236 | APP_TRACE_INFO(("Error in App_USBH_HID_DevConn(): %d\r\n", err)); 237 | return; 238 | } 239 | 240 | for (report_id_cnt = 0u; report_id_cnt < nbr_report_id; report_id_cnt++) { 241 | p_report_id = &p_report_id_array[report_id_cnt]; 242 | 243 | if (p_report_id->Type != 0x08u) { /* Validate report is of INPUT type. */ 244 | continue; 245 | } 246 | 247 | if (p_hid_dev->Usage == USBH_HID_APP_USAGE_KBD) { 248 | 249 | APP_TRACE_INFO(("HID Demo: Keyboard Connected\r\n")); 250 | 251 | err = USBH_HID_RegRxCB( p_hid_dev, 252 | p_report_id->ReportID, 253 | (USBH_HID_RXCB_FNCT)App_USBH_KBD_CallBack, 254 | (void *)p_hid_dev); 255 | 256 | } else if (p_hid_dev->Usage == USBH_HID_APP_USAGE_MOUSE) { 257 | 258 | APP_TRACE_INFO(("HID Demo: Mouse Connected\r\n")); 259 | 260 | err = USBH_HID_RegRxCB( p_hid_dev, 261 | p_report_id->ReportID, 262 | (USBH_HID_RXCB_FNCT)App_USBH_MouseCallBack, 263 | (void *)p_hid_dev); 264 | } 265 | } 266 | 267 | if (err != USBH_ERR_NONE) { 268 | APP_TRACE_INFO(("Error in App_USBH_HID_DevConn(): %d\r\n", err)); 269 | } 270 | } 271 | 272 | /* 273 | ********************************************************************************************************* 274 | * App_USBH_HID_DevDisconn() 275 | * 276 | * Description : This function is called when HID device is disconnected. 277 | * 278 | * Argument(s) : phid_dev Pointer to HID device. 279 | * 280 | * Return(s) : None. 281 | * 282 | * Note(s) : None. 283 | ********************************************************************************************************* 284 | */ 285 | 286 | static void App_USBH_HID_DevDisconn (USBH_HID_DEV *p_hid_dev) 287 | { 288 | USBH_HID_RefRel(p_hid_dev); /* Rel ref. */ 289 | } 290 | 291 | /* 292 | ********************************************************************************************************* 293 | * END 294 | ********************************************************************************************************* 295 | */ 296 | -------------------------------------------------------------------------------- /App/HID/app_usbh_hid.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST HID TEST APPLICATION 19 | * 20 | * TEMPLATE 21 | * 22 | * Filename : app_usbh_hid.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #ifndef APP_USBH_HID_MODULE_PRESENT 34 | #define APP_USBH_HID_MODULE_PRESENT 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | #include 44 | #include 45 | #include "app_usbh_keyboard.h" 46 | #include "app_usbh_mouse.h" 47 | 48 | 49 | /* 50 | ********************************************************************************************************* 51 | * EXTERNS 52 | ********************************************************************************************************* 53 | */ 54 | 55 | #ifdef APP_USBH_HID_MODULE 56 | #define APP_USBH_HID_EXT 57 | #else 58 | #define APP_USBH_HID_EXT extern 59 | #endif 60 | 61 | 62 | /* 63 | ********************************************************************************************************* 64 | * DEFINES 65 | ********************************************************************************************************* 66 | */ 67 | 68 | 69 | /* 70 | ********************************************************************************************************* 71 | * DATA TYPES 72 | ********************************************************************************************************* 73 | */ 74 | 75 | 76 | /* 77 | ********************************************************************************************************* 78 | * GLOBAL VARIABLES 79 | ********************************************************************************************************* 80 | */ 81 | 82 | 83 | /* 84 | ********************************************************************************************************* 85 | * MACROS 86 | ********************************************************************************************************* 87 | */ 88 | 89 | 90 | /* 91 | ********************************************************************************************************* 92 | * FUNCTION PROTOTYPES 93 | ********************************************************************************************************* 94 | */ 95 | 96 | USBH_ERR App_USBH_HID_Init(void); 97 | 98 | 99 | /* 100 | ********************************************************************************************************* 101 | * CONFIGURATION ERRORS 102 | ********************************************************************************************************* 103 | */ 104 | 105 | 106 | /* 107 | ********************************************************************************************************* 108 | * MODULE END 109 | ********************************************************************************************************* 110 | */ 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /App/HID/app_usbh_keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST HID KEYBOARD TEST APPLICATION 19 | * 20 | * TEMPLATE 21 | * 22 | * Filename : app_usbh_keyboard.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #ifndef APP_USBH_KEYBOARD_MODULE_PRESENT 34 | #define APP_USBH_KEYBOARD_MODULE_PRESENT 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | #include "app_usbh_hid.h" 44 | 45 | 46 | /* 47 | ********************************************************************************************************* 48 | * EXTERNS 49 | ********************************************************************************************************* 50 | */ 51 | 52 | #ifdef APP_USBH_KEYBOARD_MODULE 53 | #define APP_USBH_KEYBOARD_EXT 54 | #else 55 | #define APP_USBH_KEYBOARD_EXT extern 56 | #endif 57 | 58 | 59 | /* 60 | ********************************************************************************************************* 61 | * DEFAULT CONFIGURATION 62 | ********************************************************************************************************* 63 | */ 64 | 65 | 66 | /* 67 | ********************************************************************************************************* 68 | * DEFINES 69 | ********************************************************************************************************* 70 | */ 71 | 72 | 73 | /* 74 | ********************************************************************************************************* 75 | * DATA TYPES 76 | ********************************************************************************************************* 77 | */ 78 | 79 | 80 | /* 81 | ********************************************************************************************************* 82 | * GLOBAL VARIABLES 83 | ********************************************************************************************************* 84 | */ 85 | 86 | 87 | /* 88 | ********************************************************************************************************* 89 | * MACROS 90 | ********************************************************************************************************* 91 | */ 92 | 93 | 94 | /* 95 | ********************************************************************************************************* 96 | * FUNCTION PROTOTYPES 97 | ********************************************************************************************************* 98 | */ 99 | 100 | void App_USBH_KBD_CallBack (USBH_HID_DEV *p_hid_dev, 101 | void *p_buf, 102 | CPU_INT08U buf_len, 103 | USBH_ERR err); 104 | 105 | 106 | /* 107 | ********************************************************************************************************* 108 | * CONFIGURATION ERRORS 109 | ********************************************************************************************************* 110 | */ 111 | 112 | 113 | /* 114 | ********************************************************************************************************* 115 | * MODULE END 116 | ********************************************************************************************************* 117 | */ 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /App/HID/app_usbh_mouse.c: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST HID MOUSE TEST APPLICATION 19 | * 20 | * TEMPLATE 21 | * 22 | * Filename : app_usbh_mouse.c 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * INCLUDE FILES 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #define APP_USBH_MOUSE_MODULE 34 | #include "app_usbh_mouse.h" 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * LOCAL DEFINES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | #define MOUSE_BUTTON_1 0x01u 44 | #define MOUSE_BUTTON_2 0x02u 45 | #define MOUSE_BUTTON_3 0x04u 46 | 47 | 48 | /* 49 | ********************************************************************************************************* 50 | * LOCAL CONSTANTS 51 | ********************************************************************************************************* 52 | */ 53 | 54 | 55 | /* 56 | ********************************************************************************************************* 57 | * LOCAL DATA TYPES 58 | ********************************************************************************************************* 59 | */ 60 | 61 | 62 | /* 63 | ********************************************************************************************************* 64 | * LOCAL TABLES 65 | ********************************************************************************************************* 66 | */ 67 | 68 | 69 | /* 70 | ********************************************************************************************************* 71 | * LOCAL GLOBAL VARIABLES 72 | ********************************************************************************************************* 73 | */ 74 | 75 | static CPU_INT08U App_USBH_MouseStatePrev = 0u; 76 | static CPU_INT32S App_USBH_MousePosX = 0u; 77 | static CPU_INT32S App_USBH_MousePosY = 0u; 78 | 79 | 80 | /* 81 | ********************************************************************************************************* 82 | * LOCAL FUNCTION PROTOTYPES 83 | ********************************************************************************************************* 84 | */ 85 | 86 | static void App_USBH_MouseDisplayData (CPU_INT08S *p_buf); 87 | 88 | 89 | /* 90 | ********************************************************************************************************* 91 | * LOCAL CONFIGURATION ERRORS 92 | ********************************************************************************************************* 93 | */ 94 | 95 | 96 | /* 97 | ********************************************************************************************************* 98 | ********************************************************************************************************* 99 | * GLOBAL FUNCTIONS 100 | ********************************************************************************************************* 101 | ********************************************************************************************************* 102 | */ 103 | 104 | 105 | /* 106 | ********************************************************************************************************* 107 | * App_USBH_MouseCallBack() 108 | * 109 | * Description : Callback function for mouse events. 110 | * 111 | * Argument(s) : p_hid_dev Pointer to the HID class device. 112 | * 113 | * p_buf Pointer to the data sent by the keyboard. 114 | * 115 | * buf_len Buffer length. 116 | * 117 | * err Status of the callback. 118 | * 119 | * Return(s) : None. 120 | * 121 | * Note(s) : None. 122 | ********************************************************************************************************* 123 | */ 124 | 125 | void App_USBH_MouseCallBack (USBH_HID_DEV *p_hid_dev, 126 | void *p_buf, 127 | CPU_INT08U buf_len, 128 | USBH_ERR err) 129 | { 130 | (void)p_hid_dev; 131 | 132 | if ((err == USBH_ERR_NONE) && 133 | (buf_len >= 3u)) { 134 | App_USBH_MouseDisplayData(p_buf); 135 | } 136 | } 137 | 138 | 139 | /* 140 | ********************************************************************************************************* 141 | ********************************************************************************************************* 142 | * LOCAL FUNCTIONS 143 | ********************************************************************************************************* 144 | ********************************************************************************************************* 145 | */ 146 | 147 | 148 | /* 149 | ********************************************************************************************************* 150 | * App_USBH_MouseDisplayData() 151 | * 152 | * Description : Print buttons pressed & pointer location. 153 | * 154 | * Argument(s) : pbuf Buffer pointer. 155 | * 156 | * Return(s) : None. 157 | * 158 | * Note(s) : This function parses the report buffer of a simple/basic mouse. It might require to be 159 | * modified when used with a complex mouse 160 | ********************************************************************************************************* 161 | */ 162 | 163 | static void App_USBH_MouseDisplayData (CPU_INT08S *p_buf) 164 | { 165 | CPU_INT08U state; 166 | CPU_BOOLEAN pressed_prev; 167 | CPU_BOOLEAN pressed; 168 | 169 | 170 | state = (CPU_INT08U)p_buf[0]; 171 | pressed = (state & MOUSE_BUTTON_1) == MOUSE_BUTTON_1 ? DEF_TRUE : DEF_FALSE; 172 | pressed_prev = (App_USBH_MouseStatePrev & MOUSE_BUTTON_1) == MOUSE_BUTTON_1 ? DEF_TRUE : DEF_FALSE; 173 | 174 | if ((pressed == DEF_TRUE) && 175 | (pressed_prev == DEF_FALSE)) { 176 | APP_TRACE_INFO(("Left button pressed\r\n")); 177 | } 178 | if ((pressed == DEF_FALSE) && 179 | (pressed_prev == DEF_TRUE)) { 180 | APP_TRACE_INFO(("Left button released\r\n")); 181 | } 182 | 183 | pressed = (state & MOUSE_BUTTON_3) == MOUSE_BUTTON_3 ? DEF_TRUE : DEF_FALSE; 184 | pressed_prev = (App_USBH_MouseStatePrev & MOUSE_BUTTON_3) == MOUSE_BUTTON_3 ? DEF_TRUE : DEF_FALSE; 185 | 186 | if ((pressed == DEF_TRUE) && 187 | (pressed_prev == DEF_FALSE)) { 188 | APP_TRACE_INFO(("Middle button pressed\r\n")); 189 | } 190 | if ((pressed == DEF_FALSE) && 191 | (pressed_prev == DEF_TRUE)) { 192 | APP_TRACE_INFO(("Middle button released\r\n")); 193 | } 194 | 195 | pressed = (state & MOUSE_BUTTON_2) == MOUSE_BUTTON_2 ? DEF_TRUE : DEF_FALSE; 196 | pressed_prev = (App_USBH_MouseStatePrev & MOUSE_BUTTON_2) == MOUSE_BUTTON_2 ? DEF_TRUE : DEF_FALSE; 197 | 198 | if ((pressed == DEF_TRUE) && 199 | (pressed_prev == DEF_FALSE)) { 200 | APP_TRACE_INFO(("Right button pressed\r\n")); 201 | } 202 | if ((pressed == DEF_FALSE) && 203 | (pressed_prev == DEF_TRUE)) { 204 | APP_TRACE_INFO(("Right button released\r\n")); 205 | } 206 | 207 | App_USBH_MouseStatePrev = state; 208 | 209 | if ((p_buf[1u] != 0u) || 210 | (p_buf[2u] != 0u)) { 211 | App_USBH_MousePosX += p_buf[1u]; 212 | App_USBH_MousePosY += p_buf[2u]; 213 | 214 | APP_TRACE_INFO(("Pointer at (x, y) = (%d, %d)\r\n", 215 | App_USBH_MousePosX, 216 | App_USBH_MousePosY)); 217 | } 218 | } 219 | 220 | /* 221 | ********************************************************************************************************* 222 | * END 223 | ********************************************************************************************************* 224 | */ 225 | -------------------------------------------------------------------------------- /App/HID/app_usbh_mouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST HID MOUSE TEST APPLICATION 19 | * 20 | * TEMPLATE 21 | * 22 | * Filename : app_usbh_mouse.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #ifndef APP_USBH_MOUSE_MODULE_PRESENT 34 | #define APP_USBH_MOUSE_MODULE_PRESENT 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | #include "app_usbh_hid.h" 44 | 45 | 46 | /* 47 | ********************************************************************************************************* 48 | * EXTERNS 49 | ********************************************************************************************************* 50 | */ 51 | 52 | #ifdef APP_USBH_MOUSE_MODULE 53 | #define APP_USBH_MOUSE_EXT 54 | #else 55 | #define APP_USBH_MOUSE_EXT extern 56 | #endif 57 | 58 | 59 | /* 60 | ********************************************************************************************************* 61 | * DEFAULT CONFIGURATION 62 | ********************************************************************************************************* 63 | */ 64 | 65 | 66 | /* 67 | ********************************************************************************************************* 68 | * DEFINES 69 | ********************************************************************************************************* 70 | */ 71 | 72 | 73 | /* 74 | ********************************************************************************************************* 75 | * DATA TYPES 76 | ********************************************************************************************************* 77 | */ 78 | 79 | 80 | /* 81 | ********************************************************************************************************* 82 | * GLOBAL VARIABLES 83 | ********************************************************************************************************* 84 | */ 85 | 86 | 87 | /* 88 | ********************************************************************************************************* 89 | * MACROS 90 | ********************************************************************************************************* 91 | */ 92 | 93 | 94 | /* 95 | ********************************************************************************************************* 96 | * FUNCTION PROTOTYPES 97 | ********************************************************************************************************* 98 | */ 99 | 100 | void App_USBH_MouseCallBack (USBH_HID_DEV *p_hid_dev, 101 | void *p_buf, 102 | CPU_INT08U buf_len, 103 | USBH_ERR err); 104 | 105 | 106 | /* 107 | ********************************************************************************************************* 108 | * CONFIGURATION ERRORS 109 | ********************************************************************************************************* 110 | */ 111 | 112 | 113 | /* 114 | ********************************************************************************************************* 115 | * MODULE END 116 | ********************************************************************************************************* 117 | */ 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /App/MSC/uC-FS-V4/app_usbh_msc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST MSC TEST APPLICATION 19 | * 20 | * TEMPLATE 21 | * 22 | * Filename : app_usbh_msc.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #ifndef APP_USBH_MSC_MODULE_PRESENT 34 | #define APP_USBH_MSC_MODULE_PRESENT 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | 52 | /* 53 | ********************************************************************************************************* 54 | * EXTERNS 55 | ********************************************************************************************************* 56 | */ 57 | 58 | #ifdef APP_USBH_MSC_MODULE 59 | #define APP_USBH_MSC_EXT 60 | #else 61 | #define APP_USBH_MSC_EXT extern 62 | #endif 63 | 64 | /* 65 | ********************************************************************************************************* 66 | * DEFAULT CONFIGURATION 67 | ********************************************************************************************************* 68 | */ 69 | 70 | 71 | /* 72 | ********************************************************************************************************* 73 | * DEFINES 74 | ********************************************************************************************************* 75 | */ 76 | 77 | 78 | /* 79 | ********************************************************************************************************* 80 | * DATA TYPES 81 | ********************************************************************************************************* 82 | */ 83 | 84 | 85 | /* 86 | ********************************************************************************************************* 87 | * GLOBAL VARIABLES 88 | ********************************************************************************************************* 89 | */ 90 | 91 | 92 | /* 93 | ********************************************************************************************************* 94 | * MACROS 95 | ********************************************************************************************************* 96 | */ 97 | 98 | 99 | /* 100 | ********************************************************************************************************* 101 | * FUNCTION PROTOTYPES 102 | ********************************************************************************************************* 103 | */ 104 | 105 | USBH_ERR App_USBH_MSC_Init(void); 106 | 107 | 108 | /* 109 | ********************************************************************************************************* 110 | * CONFIGURATION ERRORS 111 | ********************************************************************************************************* 112 | */ 113 | 114 | 115 | /* 116 | ********************************************************************************************************* 117 | * MODULE END 118 | ********************************************************************************************************* 119 | */ 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /App/Test/app_usbh_msc_stress.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST MSC TEST APPLICATION 19 | * 20 | * TEMPLATE 21 | * 22 | * Filename : app_usbh_msc.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #ifndef APP_USBH_MSC_MODULE_PRESENT 34 | #define APP_USBH_MSC_MODULE_PRESENT 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | 52 | /* 53 | ********************************************************************************************************* 54 | * EXTERNS 55 | ********************************************************************************************************* 56 | */ 57 | 58 | #ifdef APP_USBH_MSC_MODULE 59 | #define APP_USBH_MSC_EXT 60 | #else 61 | #define APP_USBH_MSC_EXT extern 62 | #endif 63 | 64 | /* 65 | ********************************************************************************************************* 66 | * DEFAULT CONFIGURATION 67 | ********************************************************************************************************* 68 | */ 69 | 70 | 71 | /* 72 | ********************************************************************************************************* 73 | * DEFINES 74 | ********************************************************************************************************* 75 | */ 76 | 77 | 78 | /* 79 | ********************************************************************************************************* 80 | * DATA TYPES 81 | ********************************************************************************************************* 82 | */ 83 | 84 | 85 | /* 86 | ********************************************************************************************************* 87 | * GLOBAL VARIABLES 88 | ********************************************************************************************************* 89 | */ 90 | 91 | 92 | /* 93 | ********************************************************************************************************* 94 | * MACROS 95 | ********************************************************************************************************* 96 | */ 97 | 98 | 99 | /* 100 | ********************************************************************************************************* 101 | * FUNCTION PROTOTYPES 102 | ********************************************************************************************************* 103 | */ 104 | 105 | USBH_ERR App_USBH_MSC_Init(void); 106 | 107 | 108 | /* 109 | ********************************************************************************************************* 110 | * CONFIGURATION ERRORS 111 | ********************************************************************************************************* 112 | */ 113 | 114 | 115 | /* 116 | ********************************************************************************************************* 117 | * MODULE END 118 | ********************************************************************************************************* 119 | */ 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /App/app_usbh.c: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB HOST APPLICATION INITIALIZATION 19 | * 20 | * 21 | * Filename : app_usbh.c 22 | * Version : V3.42.01 23 | ********************************************************************************************************* 24 | */ 25 | 26 | /* 27 | ********************************************************************************************************* 28 | * INCLUDE FILES 29 | ********************************************************************************************************* 30 | */ 31 | 32 | #define APP_USBH_MODULE 33 | 34 | #include "app_usbh.h" 35 | #include 36 | #include 37 | 38 | #if (APP_CFG_USBH_EN == DEF_ENABLED) 39 | 40 | /* 41 | ********************************************************************************************************* 42 | * LOCAL DEFINES 43 | ********************************************************************************************************* 44 | */ 45 | 46 | 47 | /* 48 | ********************************************************************************************************* 49 | * LOCAL GLOBAL VARIABLES 50 | ********************************************************************************************************* 51 | */ 52 | 53 | /* 54 | ********************************************************************************************************* 55 | * USB HOST STACK INTERNAL TASK'S STACKS 56 | ********************************************************************************************************* 57 | */ 58 | 59 | static USBH_STK App_USBH_AsyncTaskStk[USBH_OS_CFG_ASYNC_TASK_STK_SIZE]; 60 | static USBH_STK App_USBH_HubTaskStk[USBH_OS_CFG_HUB_TASK_STK_SIZE]; 61 | 62 | 63 | /* 64 | ********************************************************************************************************* 65 | * LOCAL CONSTANTS 66 | ********************************************************************************************************* 67 | */ 68 | 69 | USBH_KERNEL_TASK_INFO AsyncTaskInfo = { /* ---------------- INFO ON ASYNC TASK ---------------- */ 70 | USBH_OS_CFG_ASYNC_TASK_PRIO, /* Async task priority. */ 71 | App_USBH_AsyncTaskStk, /* Ptr to async task stack. */ 72 | USBH_OS_CFG_ASYNC_TASK_STK_SIZE /* Size of async task stack. */ 73 | }; 74 | 75 | USBH_KERNEL_TASK_INFO HubTaskInfo = { /* ----------------- INFO ON HUB TASK ----------------- */ 76 | USBH_OS_CFG_HUB_TASK_PRIO, /* Hub task priority. */ 77 | App_USBH_HubTaskStk, /* Ptr to hub task stack. */ 78 | USBH_OS_CFG_HUB_TASK_STK_SIZE /* Size of hub task stack. */ 79 | }; 80 | 81 | 82 | /* 83 | ********************************************************************************************************* 84 | * LOCAL FUNCTION PROTOTYPES 85 | ********************************************************************************************************* 86 | */ 87 | 88 | 89 | /* 90 | ********************************************************************************************************* 91 | * LOCAL CONFIGURATION ERRORS 92 | ********************************************************************************************************* 93 | */ 94 | 95 | 96 | /* 97 | ********************************************************************************************************* 98 | * App_USBH_Init() 99 | * 100 | * Description : Initialize USB Host Stack and additional demos. 101 | * 102 | * Argument(s) : None. 103 | * 104 | * Return(s) : DEF_OK if successfull. 105 | * DEF_FAIL otherwise. 106 | * 107 | * Note(s) : None. 108 | ********************************************************************************************************* 109 | */ 110 | 111 | CPU_BOOLEAN App_USBH_Init (void) 112 | { 113 | USBH_ERR err; 114 | CPU_INT08U hc_nbr; 115 | 116 | 117 | APP_TRACE_INFO(("\r\n")); 118 | APP_TRACE_INFO(("=============================\r\n")); 119 | APP_TRACE_INFO(("= USB HOST INITIALIZATION =\r\n")); 120 | APP_TRACE_INFO(("=============================\r\n")); 121 | 122 | err = USBH_Init(&AsyncTaskInfo, 123 | &HubTaskInfo); 124 | if (err != USBH_ERR_NONE) { 125 | APP_TRACE_DBG(("...could not initialize USB HOST Stack w/err = %d\r\n\r\n", err)); 126 | return (DEF_FAIL); 127 | } 128 | 129 | #if (APP_CFG_USBH_MSC_EN == DEF_ENABLED) 130 | APP_TRACE_INFO(("... Initiliazing HOST Mass Storage class ...\r\n")); 131 | err = App_USBH_MSC_Init(); 132 | 133 | if (err != USBH_ERR_NONE) { 134 | APP_TRACE_DBG(("...could not initialize HOST Mass Storage Class w/err = %d\r\n\r\n", err)); 135 | return (DEF_FAIL); 136 | } 137 | #endif 138 | 139 | #if (APP_CFG_USBH_HID_EN == DEF_ENABLED) 140 | APP_TRACE_INFO(("... Initiliazing HOST Human Interface Device class ...\r\n")); 141 | err = App_USBH_HID_Init(); 142 | 143 | if (err != USBH_ERR_NONE) { 144 | APP_TRACE_DBG(("...could not initialize HID class w/err = %d\r\n\r\n", err)); 145 | return (DEF_FAIL); 146 | } 147 | #endif 148 | 149 | #if (APP_CFG_USBH_CDC_ACM_EN == DEF_ENABLED) 150 | APP_TRACE_INFO(("... Initiliazing HOST Communication Device Class ...\r\n")); 151 | err = App_USBH_CDC_ACM_Init(); 152 | 153 | if (err != USBH_ERR_NONE) { 154 | APP_TRACE_DBG(("...could not initialize CDC ACM w/err = %d\r\n\r\n", err)); 155 | return (DEF_FAIL); 156 | } 157 | #endif 158 | 159 | #if (APP_CFG_USBH_CDC_ECM_EN == DEF_ENABLED) 160 | APP_TRACE_INFO(("... Initiliazing HOST Communication Device Class ...\r\n")); 161 | err = App_USBH_CDC_ECM_Init(); 162 | 163 | if (err != USBH_ERR_NONE) { 164 | APP_TRACE_DBG(("...could not initialize CDC ECM w/err = %d\r\n\r\n", err)); 165 | return (DEF_FAIL); 166 | } 167 | #endif 168 | 169 | #if (APP_CFG_USBH_FTDI_EN == DEF_ENABLED) 170 | APP_TRACE_INFO(("... Initiliazing HOST FUTURE TECHNOLOGY DEVICES INTL. Class ...\r\n")); 171 | App_USBH_FTDI_Init(&err); 172 | 173 | if (err != USBH_ERR_NONE) { 174 | APP_TRACE_DBG(("...could not initialize FTDI w/err = %d\r\n\r\n", err)); 175 | return (DEF_FAIL); 176 | } 177 | #endif 178 | 179 | hc_nbr = USBH_HC_Add(&USBH_HC_TemplateCfg, 180 | &USBH_TemplateHCD_DrvAPI, 181 | &USBH_TemplateHCD_RH_API, 182 | &USBH_DrvBSP_Template, 183 | &err); 184 | if (err != USBH_ERR_NONE) { 185 | APP_TRACE_DBG(("...could not add host controller w/err = %d\r\n\r\n", err)); 186 | return (DEF_FAIL); 187 | } 188 | 189 | err = USBH_HC_Start(hc_nbr); 190 | if (err != USBH_ERR_NONE) { 191 | APP_TRACE_DBG(("...could not start host controller w/err = %d\r\n\r\n", err)); 192 | return (DEF_FAIL); 193 | } 194 | 195 | return (DEF_OK); 196 | } 197 | #endif 198 | -------------------------------------------------------------------------------- /App/app_usbh.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * EXAMPLE CODE 4 | * 5 | * This file is provided as an example on how to use Micrium products. 6 | * 7 | * Please feel free to use any application code labeled as 'EXAMPLE CODE' in 8 | * your application products. Example code may be used as is, in whole or in 9 | * part, or may be used as a reference only. This file can be modified as 10 | * required to meet the end-product requirements. 11 | * 12 | ********************************************************************************************************* 13 | */ 14 | 15 | /* 16 | ********************************************************************************************************* 17 | * 18 | * USB APPLICATION INITIALIZATION 19 | * 20 | * 21 | * Filename : app_usbh.h 22 | * Version : V3.42.01 23 | ********************************************************************************************************* 24 | */ 25 | 26 | #ifndef APP_USBH_MODULE_PRESENT 27 | #define APP_USBH_MODULE_PRESENT 28 | 29 | 30 | /* 31 | ********************************************************************************************************* 32 | * INCLUDE FILES 33 | ********************************************************************************************************* 34 | */ 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | 41 | /* 42 | ********************************************************************************************************* 43 | * EXTERNS 44 | ********************************************************************************************************* 45 | */ 46 | 47 | #ifdef APP_USBH_MODULE 48 | #define APP_USBH_MODULE_EXT 49 | #else 50 | #define APP_USBH_MODULE_EXT extern 51 | #endif 52 | 53 | 54 | /* 55 | ********************************************************************************************************* 56 | * DEFINES 57 | ********************************************************************************************************* 58 | */ 59 | 60 | /* 61 | ********************************************************************************************************* 62 | * DEFAULT USB HOST CONFIGURATION 63 | ********************************************************************************************************* 64 | */ 65 | 66 | #ifndef APP_CFG_USBH_MSC_EN 67 | #define APP_CFG_USBH_MSC_EN DEF_DISABLED 68 | #endif 69 | 70 | #ifndef APP_CFG_USBH_HID_EN 71 | #define APP_CFG_USBH_HID_EN DEF_DISABLED 72 | #endif 73 | 74 | #ifndef APP_CFG_USBH_CDC_ACM_EN 75 | #define APP_CFG_USBH_CDC_ACM_EN DEF_DISABLED 76 | #endif 77 | 78 | #ifndef APP_CFG_USBH_CDC_ECM_EN 79 | #define APP_CFG_USBH_CDC_ECM_EN DEF_DISABLED 80 | #endif 81 | 82 | #ifndef APP_CFG_USBH_FTDI_EN 83 | #define APP_CFG_USBH_FTDI_EN DEF_DISABLED 84 | #endif 85 | 86 | 87 | /* 88 | ********************************************************************************************************* 89 | * CONDITIONAL INCLUDE FILES 90 | ********************************************************************************************************* 91 | */ 92 | 93 | #if (APP_CFG_USBH_EN == DEF_ENABLED) 94 | 95 | #if (APP_CFG_USBH_HID_EN == DEF_ENABLED) 96 | #include "HID/app_usbh_hid.h" 97 | #endif 98 | 99 | #if (APP_CFG_USBH_CDC_ACM_EN == DEF_ENABLED) 100 | #include "CDC/app_usbh_cdc_acm.h" 101 | #endif 102 | 103 | #if (APP_CFG_USBH_CDC_ECM_EN == DEF_ENABLED) 104 | #include "CDC/app_usbh_cdc_ecm.h" 105 | #endif 106 | 107 | #if (APP_CFG_USBH_MSC_EN == DEF_ENABLED) 108 | #include "MSC/uC-FS-V4/app_usbh_msc.h" 109 | #endif 110 | 111 | #if (APP_CFG_USBH_FTDI_EN == DEF_ENABLED) 112 | #include 113 | #endif 114 | 115 | #endif 116 | 117 | 118 | /* 119 | ********************************************************************************************************* 120 | * DATA TYPES 121 | ********************************************************************************************************* 122 | */ 123 | 124 | typedef CPU_STK USBH_STK; /* Task's stack data type. */ 125 | 126 | 127 | /* 128 | ********************************************************************************************************* 129 | * GLOBAL VARIABLES 130 | ********************************************************************************************************* 131 | */ 132 | 133 | 134 | /* 135 | ********************************************************************************************************* 136 | * MACRO'S 137 | ********************************************************************************************************* 138 | */ 139 | 140 | 141 | /* 142 | ********************************************************************************************************* 143 | * FUNCTION PROTOTYPES 144 | ********************************************************************************************************* 145 | */ 146 | 147 | #if (APP_CFG_USBH_EN == DEF_ENABLED) 148 | CPU_BOOLEAN App_USBH_Init (void); 149 | #endif 150 | 151 | 152 | /* 153 | ********************************************************************************************************* 154 | * CONFIGURATION ERRORS 155 | ********************************************************************************************************* 156 | */ 157 | 158 | #ifndef APP_CFG_USBH_EN 159 | #error "APP_CFG_USBH_EN not #defined in 'app_cfg.h' " 160 | #error " [MUST be DEF_ENABLED ] " 161 | #error " [ || DEF_DISABLED] " 162 | 163 | #elif ((APP_CFG_USBH_EN != DEF_ENABLED) && \ 164 | (APP_CFG_USBH_EN != DEF_DISABLED)) 165 | #error "APP_CFG_USBH_EN illegally #defined in 'app_cfg.h' " 166 | #error " [MUST be DEF_ENABLED ] " 167 | #error " [ || DEF_DISABLED] " 168 | 169 | #elif ((APP_CFG_USBH_EN == DEF_ENABLED ) && \ 170 | (!defined(USBH_OS_CFG_ASYNC_TASK_PRIO))) 171 | #error "USBH_OS_CFG_ASYNC_TASK_PRIO not #defined in 'app_cfg.h' " 172 | #error " [MUST be > 0u ] " 173 | 174 | #elif ((APP_CFG_USBH_EN == DEF_ENABLED ) && \ 175 | (!defined(USBH_OS_CFG_ASYNC_TASK_STK_SIZE))) 176 | #error "USBH_OS_CFG_ASYNC_TASK_STK_SIZE not #defined in 'app_cfg.h' " 177 | #error " [MUST be > 0u ] " 178 | 179 | #elif ((APP_CFG_USBH_EN == DEF_ENABLED ) && \ 180 | (!defined(USBH_OS_CFG_HUB_TASK_PRIO))) 181 | #error "USBH_OS_CFG_HUB_TASK_PRIO not #defined in 'app_cfg.h' " 182 | #error " [MUST be > 0u ] " 183 | 184 | #elif ((APP_CFG_USBH_EN == DEF_ENABLED ) && \ 185 | (!defined(USBH_OS_CFG_HUB_TASK_STK_SIZE))) 186 | #error "USBH_OS_CFG_HUB_TASK_STK_SIZE not #defined in 'app_cfg.h' " 187 | #error " [MUST be > 0u ] " 188 | 189 | #elif ((APP_CFG_USBH_EN == DEF_ENABLED ) && \ 190 | (APP_CFG_USBH_MSC_EN == DEF_ENABLED ) && \ 191 | (APP_CFG_FS_EN == DEF_DISABLED)) 192 | #error "Host MSC demo chosen: APP_CFG_FS_EN MUST be DEF_ENABLED in app_cfg.h. " 193 | #endif 194 | 195 | 196 | /* 197 | ********************************************************************************************************* 198 | * MODULE END 199 | ********************************************************************************************************* 200 | */ 201 | 202 | #endif 203 | -------------------------------------------------------------------------------- /Cfg/Template/usbh_hc_cfg.c: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * USB HOST CONTROLLER CONFIGURATION FILE 21 | * 22 | * TEMPLATE 23 | * 24 | * Filename : usbh_hc_cfg.c 25 | * Version : V3.42.01 26 | ********************************************************************************************************* 27 | */ 28 | 29 | /* 30 | ********************************************************************************************************* 31 | * INCLUDE FILES 32 | ********************************************************************************************************* 33 | */ 34 | 35 | #define USBH_HC_CFG_MODULE 36 | #define MICRIUM_SOURCE 37 | #include "usbh_hc_cfg.h" 38 | 39 | 40 | /* 41 | ********************************************************************************************************* 42 | * LOCAL DEFINES 43 | ********************************************************************************************************* 44 | */ 45 | 46 | 47 | /* 48 | ********************************************************************************************************* 49 | * LOCAL CONSTANTS 50 | ********************************************************************************************************* 51 | */ 52 | 53 | 54 | /* 55 | ********************************************************************************************************* 56 | * LOCAL DATA TYPES 57 | ********************************************************************************************************* 58 | */ 59 | 60 | 61 | /* 62 | ********************************************************************************************************* 63 | * LOCAL TABLES 64 | ********************************************************************************************************* 65 | */ 66 | 67 | /* 68 | ********************************************************************************************************* 69 | * LOCAL GLOBAL VARIABLES 70 | ********************************************************************************************************* 71 | */ 72 | 73 | USBH_HC_CFG USBH_HC_TemplateCfg = { 74 | (CPU_ADDR)0x00000000u, /* Base addr of host controller hw registers. */ 75 | (CPU_ADDR)0x00000000u, /* Base addr of host controller dedicated mem. */ 76 | 0u, /* Size of host controller dedicated mem. */ 77 | DEF_ENABLED, /* Does HC can access sys mem? */ 78 | 1024u, /* Data buf max len. */ 79 | 2u, /* Max nbr opened bulk EP. */ 80 | 2u, /* Max nbr opened intr EP. */ 81 | 2u /* Max nbr opened isoc EP. */ 82 | }; 83 | 84 | 85 | /* 86 | ********************************************************************************************************* 87 | * LOCAL FUNCTION PROTOTYPES 88 | ********************************************************************************************************* 89 | */ 90 | 91 | 92 | /* 93 | ********************************************************************************************************* 94 | * LOCAL CONFIGURATION ERRORS 95 | ********************************************************************************************************* 96 | */ 97 | 98 | 99 | /* 100 | ********************************************************************************************************* 101 | * MODULE END 102 | ********************************************************************************************************* 103 | */ 104 | -------------------------------------------------------------------------------- /Cfg/Template/usbh_hc_cfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * USB HOST CONTROLLER CONFIGURATION FILE 21 | * 22 | * TEMPLATE 23 | * 24 | * Filename : usbh_hc_cfg.h 25 | * Version : V3.42.01 26 | ********************************************************************************************************* 27 | */ 28 | 29 | #ifndef USBH_HC_CFG_MODULE_PRESENT 30 | #define USBH_HC_CFG_MODULE_PRESENT 31 | 32 | 33 | /* 34 | ********************************************************************************************************* 35 | * INCLUDE FILES 36 | ********************************************************************************************************* 37 | */ 38 | 39 | #include 40 | 41 | 42 | /* 43 | ********************************************************************************************************* 44 | * EXTERNS 45 | ********************************************************************************************************* 46 | */ 47 | 48 | #ifdef USBH_HC_CFG_MODULE 49 | #define USBH_HC_CFG_MODULE_EXT 50 | #else 51 | #define USBH_HC_CFG_MODULE_EXT extern 52 | #endif 53 | 54 | 55 | /* 56 | ********************************************************************************************************* 57 | * DEFINES 58 | ********************************************************************************************************* 59 | */ 60 | 61 | 62 | /* 63 | ********************************************************************************************************* 64 | * DATA TYPES 65 | ********************************************************************************************************* 66 | */ 67 | 68 | 69 | /* 70 | ********************************************************************************************************* 71 | * GLOBAL VARIABLES 72 | ********************************************************************************************************* 73 | */ 74 | 75 | /* 76 | ********************************************************************************************************* 77 | * USB HOST CONTROLLER CONFIGURATION 78 | ********************************************************************************************************* 79 | */ 80 | 81 | USBH_HC_CFG_MODULE_EXT USBH_HC_CFG USBH_HC_TemplateCfg; 82 | 83 | 84 | /* 85 | ********************************************************************************************************* 86 | * MACRO'S 87 | ********************************************************************************************************* 88 | */ 89 | 90 | 91 | /* 92 | ********************************************************************************************************* 93 | * FUNCTION PROTOTYPES 94 | ********************************************************************************************************* 95 | */ 96 | 97 | 98 | /* 99 | ********************************************************************************************************* 100 | * CONFIGURATION ERRORS 101 | ********************************************************************************************************* 102 | */ 103 | 104 | 105 | /* 106 | ********************************************************************************************************* 107 | * MODULE END 108 | ********************************************************************************************************* 109 | */ 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /Class/CDC/ECM/usbh_ecm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * COMMUNICATIONS DEVICE CLASS (CDC) 21 | * ETHERNET CONTROL MODEL (ECM) 22 | * 23 | * Filename : usbh_ecm.h 24 | * Version : V3.42.01 25 | ********************************************************************************************************* 26 | */ 27 | 28 | /* 29 | ********************************************************************************************************* 30 | * MODULE 31 | ********************************************************************************************************* 32 | */ 33 | 34 | #ifndef USBH_CDC_ECM_MODULE_PRESENT 35 | #define USBH_CDC_ECM_MODULE_PRESENT 36 | 37 | 38 | /* 39 | ********************************************************************************************************* 40 | * INCLUDE FILES 41 | ********************************************************************************************************* 42 | */ 43 | 44 | #include "../usbh_cdc.h" 45 | 46 | 47 | /* 48 | ********************************************************************************************************* 49 | * EXTERNS 50 | ********************************************************************************************************* 51 | */ 52 | 53 | #ifdef USBH_CDC_ECM_MODULE 54 | #define USBH_CDC_ECM_EXT 55 | #else 56 | #define USBH_CDC_ECM_EXT extern 57 | #endif 58 | 59 | 60 | /* 61 | ********************************************************************************************************* 62 | * DEFINES 63 | ********************************************************************************************************* 64 | */ 65 | 66 | #define USBH_CDC_ECM_MAC_LEN 13u /* Length of the MAC address. */ 67 | 68 | 69 | /* 70 | ********************************************************************************************************* 71 | * DATA TYPES 72 | ********************************************************************************************************* 73 | */ 74 | 75 | typedef enum usbh_cdc_ecm_event { 76 | USBH_CDC_ECM_EVENT_NETWORK_CONNECTION, /* Event for USBH_CDC_NOTIFICATION_NET_CONN */ 77 | USBH_CDC_ECM_EVENT_RESPONSE_AVAILABLE, /* Event for USBH_CDC_NOTIFICATION_RESP_AVAIL */ 78 | USBH_CDC_ECM_EVENT_CONNECTION_SPEED_CHANGE /* Event for USBH_CDC_NOTIFICATION_CONN_SPEED_CHNG */ 79 | } USBH_CDC_ECM_EVENT; 80 | 81 | typedef struct usbh_cdc_ecm_state { 82 | USBH_CDC_ECM_EVENT Event; /* Event that occurred. */ 83 | union { 84 | CPU_BOOLEAN ConnectionStatus; /* Status of the network connection. */ 85 | struct { 86 | CPU_INT32U DownlinkSpeed; /* Downlink speed in bits per second. */ 87 | CPU_INT32U UplinkSpeed; /* Uplink speed in bits per second. */ 88 | } ConnectionSpeed; 89 | } EventData; /* Event data. */ 90 | } USBH_CDC_ECM_STATE; 91 | 92 | typedef struct usbh_cdc_ecm_parameters { 93 | CPU_INT32U EthernetStatistics; /* Bitmap of supported statistics. */ 94 | CPU_INT16U MaxSegmentSize; /* Maximum segment size, typically 1514. */ 95 | CPU_INT16U NumberMCFilters; /* Number of multicast filters supported. */ 96 | CPU_INT08U NumberPowerFilters; /* Number of power filters supported. */ 97 | } USBH_CDC_ECM_PARAMETERS; 98 | 99 | typedef void (*USBH_CDC_ECM_EVENT_NOTIFY) (void *p_arg, 100 | USBH_CDC_ECM_STATE ecm_state); 101 | 102 | typedef struct usbh_cdc_ecm_dev { 103 | USBH_CDC_DEV *CDC_DevPtr; 104 | USBH_CDC_ECM_EVENT_NOTIFY EventNotifyPtr; 105 | void *EventNotifyArgPtr; 106 | CPU_INT16U MAC_Addr[USBH_CDC_ECM_MAC_LEN]; /* MAC address of the device, ECM120 5.4 */ 107 | USBH_CDC_ECM_PARAMETERS Parameters; 108 | } USBH_CDC_ECM_DEV; 109 | 110 | 111 | /* 112 | ********************************************************************************************************* 113 | * GLOBAL VARIABLES 114 | ********************************************************************************************************* 115 | */ 116 | 117 | 118 | /* 119 | ********************************************************************************************************* 120 | * MACRO'S 121 | ********************************************************************************************************* 122 | */ 123 | 124 | /* 125 | ********************************************************************************************************* 126 | * FUNCTION PROTOTYPES 127 | * 128 | * Note(s) : (1) USBH_CDC_ECM does not define DataTx, DataRx, DataTxAsync, DataRxAsync or CmdTx functions 129 | * these can be accessed through the CDC layer (via USBH_CDC_DEV) 130 | ********************************************************************************************************* 131 | */ 132 | 133 | USBH_ERR USBH_CDC_ECM_GlobalInit (void); 134 | 135 | USBH_ERR USBH_CDC_ECM_EventRxAsync(USBH_CDC_ECM_DEV *p_cdc_ecm_dev, 136 | USBH_CDC_ECM_EVENT_NOTIFY p_ecm_event_notify, 137 | void *p_arg); 138 | 139 | CPU_INT32U USBH_CDC_ECM_DataTx (USBH_CDC_ECM_DEV *p_cdc_ecm_dev, 140 | CPU_INT08U *p_buf, 141 | CPU_INT32U buf_len, 142 | CPU_INT32U timeout_ms, 143 | USBH_ERR *p_err); 144 | 145 | USBH_CDC_ECM_DEV *USBH_CDC_ECM_Add (USBH_CDC_DEV *p_cdc_dev, 146 | USBH_ERR *p_err); 147 | 148 | USBH_ERR USBH_CDC_ECM_Remove (USBH_CDC_ECM_DEV *p_cdc_ecm_dev); 149 | 150 | 151 | /* 152 | ********************************************************************************************************* 153 | * CONFIGURATION ERRORS 154 | ********************************************************************************************************* 155 | */ 156 | 157 | 158 | /* 159 | ********************************************************************************************************* 160 | * END 161 | ********************************************************************************************************* 162 | */ 163 | 164 | #endif 165 | -------------------------------------------------------------------------------- /Class/HID/usbh_hidparser.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * HUMAN INTERFACE DEVICE CLASS PARSER 21 | * 22 | * Filename : usbh_hidparser.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #ifndef USBH_HIDPARSER_MODULE_PRESENT 34 | #define USBH_HIDPARSER_MODULE_PRESENT 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | 44 | /* 45 | ********************************************************************************************************* 46 | * EXTERNS 47 | ********************************************************************************************************* 48 | */ 49 | 50 | #ifdef USBH_HIDPARSER_MODULE 51 | #define USBH_HIDPARSER_EXT 52 | #else 53 | #define USBH_HIDPARSER_EXT extern 54 | #endif 55 | 56 | 57 | /* 58 | ********************************************************************************************************* 59 | * DEFINES 60 | ********************************************************************************************************* 61 | */ 62 | 63 | 64 | /* 65 | ********************************************************************************************************* 66 | * DATA TYPES 67 | ********************************************************************************************************* 68 | */ 69 | 70 | 71 | /* 72 | ********************************************************************************************************* 73 | * GLOBAL VARIABLES 74 | ********************************************************************************************************* 75 | */ 76 | 77 | 78 | /* 79 | ********************************************************************************************************* 80 | * MACROS 81 | ********************************************************************************************************* 82 | */ 83 | 84 | 85 | /* 86 | ********************************************************************************************************* 87 | * FUNCTION PROTOTYPES 88 | ********************************************************************************************************* 89 | */ 90 | 91 | USBH_ERR USBH_HID_ParserGlobalInit(void); 92 | 93 | USBH_ERR USBH_HID_ItemParser (USBH_HID_DEV *p_hid_dev, 94 | CPU_INT08U *p_report_desc, 95 | CPU_INT32U desc_len); 96 | 97 | USBH_ERR USBH_HID_CreateReportID (USBH_HID_DEV *p_hid_dev); 98 | 99 | USBH_HID_REPORT_ID *USBH_HID_MaxReport (USBH_HID_DEV *p_hid_dev, 100 | CPU_INT08U type); 101 | 102 | 103 | /* 104 | ********************************************************************************************************* 105 | * CONFIGURATION ERRORS 106 | ********************************************************************************************************* 107 | */ 108 | 109 | 110 | /* 111 | ********************************************************************************************************* 112 | * MODULE END 113 | ********************************************************************************************************* 114 | */ 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /Class/MSC/usbh_msc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * MASS STORAGE CLASS (MSC) 21 | * 22 | * Filename : usbh_msc.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #ifndef USBH_MSC_MODULE_PRESENT 34 | #define USBH_MSC_MODULE_PRESENT 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | #include "../../Source/usbh_os.h" 44 | #include "../../Source/usbh_class.h" 45 | 46 | 47 | /* 48 | ********************************************************************************************************* 49 | * EXTERNS 50 | ********************************************************************************************************* 51 | */ 52 | 53 | #ifdef USBH_MSC_MODULE 54 | #define USBH_MSC_EXT 55 | #else 56 | #define USBH_MSC_EXT extern 57 | #endif 58 | 59 | 60 | /* 61 | ********************************************************************************************************* 62 | * DEFINES 63 | ********************************************************************************************************* 64 | */ 65 | 66 | #define USBH_MSC_TIMEOUT 10000u 67 | 68 | #define USBH_MSC_DEV_NOT_IN_USE 0u 69 | #define USBH_MSC_DEV_IN_USE 1u 70 | 71 | #define USBH_MSC_DATA_DIR_IN 0x80u 72 | #define USBH_MSC_DATA_DIR_OUT 0x00u 73 | #define USBH_MSC_DATA_DIR_NONE 0x01u 74 | 75 | 76 | /* 77 | ********************************************************************************************************* 78 | * DATA TYPES 79 | ********************************************************************************************************* 80 | */ 81 | 82 | typedef CPU_INT08U USBH_MSC_DATA_DIR; 83 | 84 | /* -------------------- MSC DEVICE -------------------- */ 85 | typedef struct usbh_msc_dev { 86 | USBH_EP BulkInEP; /* Bulk IN endpoint. */ 87 | USBH_EP BulkOutEP; /* Bulk OUT endpoint. */ 88 | USBH_DEV *DevPtr; /* Pointer to USB device. */ 89 | USBH_IF *IF_Ptr; /* Pointer to interface. */ 90 | CPU_INT08U State; /* State of MSC device. */ 91 | CPU_INT08U RefCnt; /* Cnt of app ref on this dev. */ 92 | USBH_HMUTEX HMutex; 93 | } USBH_MSC_DEV; 94 | 95 | typedef struct msc_inquiry_info { 96 | CPU_INT08U DevType; 97 | CPU_INT08U IsRemovable; 98 | CPU_INT08U Vendor_ID[8]; 99 | CPU_INT08U Product_ID[16]; 100 | CPU_INT32U ProductRevisionLevel; 101 | } USBH_MSC_INQUIRY_INFO; 102 | 103 | 104 | /* 105 | ********************************************************************************************************* 106 | * GLOBAL VARIABLES 107 | ********************************************************************************************************* 108 | */ 109 | 110 | USBH_MSC_EXT USBH_CLASS_DRV USBH_MSC_ClassDrv; 111 | 112 | 113 | /* 114 | ********************************************************************************************************* 115 | * MACROS 116 | ********************************************************************************************************* 117 | */ 118 | 119 | 120 | /* 121 | ********************************************************************************************************* 122 | * FUNCTION PROTOTYPES 123 | ********************************************************************************************************* 124 | */ 125 | 126 | USBH_ERR USBH_MSC_Init (USBH_MSC_DEV *p_msc_dev, 127 | CPU_INT08U lun); 128 | 129 | CPU_INT08U USBH_MSC_MaxLUN_Get (USBH_MSC_DEV *p_msc_dev, 130 | USBH_ERR *p_err); 131 | 132 | CPU_BOOLEAN USBH_MSC_UnitRdyTest(USBH_MSC_DEV *p_msc_dev, 133 | CPU_INT08U lun, 134 | USBH_ERR *p_err); 135 | 136 | USBH_ERR USBH_MSC_CapacityRd (USBH_MSC_DEV *p_msc_dev, 137 | CPU_INT08U lun, 138 | CPU_INT32U *p_nbr_blks, 139 | CPU_INT32U *p_blk_size); 140 | 141 | USBH_ERR USBH_MSC_StdInquiry (USBH_MSC_DEV *p_msc_dev, 142 | USBH_MSC_INQUIRY_INFO *p_msc_inquiry_info, 143 | CPU_INT08U lun); 144 | 145 | USBH_ERR USBH_MSC_RefAdd (USBH_MSC_DEV *p_msc_dev); 146 | 147 | USBH_ERR USBH_MSC_RefRel (USBH_MSC_DEV *p_msc_dev); 148 | 149 | CPU_INT32U USBH_MSC_Rd (USBH_MSC_DEV *p_msc_dev, 150 | CPU_INT08U lun, 151 | CPU_INT32U blk_addr, 152 | CPU_INT16U nbr_blks, 153 | CPU_INT32U blk_size, 154 | void *p_arg, 155 | USBH_ERR *p_err); 156 | 157 | CPU_INT32U USBH_MSC_Wr (USBH_MSC_DEV *p_msc_dev, 158 | CPU_INT08U lun, 159 | CPU_INT32U blk_addr, 160 | CPU_INT16U nbr_blks, 161 | CPU_INT32U blk_size, 162 | const void *p_arg, 163 | USBH_ERR *p_err); 164 | 165 | 166 | /* 167 | ********************************************************************************************************* 168 | * CONFIGURATION ERRORS 169 | ********************************************************************************************************* 170 | */ 171 | 172 | 173 | /* 174 | ********************************************************************************************************* 175 | * MODULE END 176 | ********************************************************************************************************* 177 | */ 178 | 179 | #endif 180 | -------------------------------------------------------------------------------- /HCD/ATSAMx/usbh_hcd_atsamx.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * ATSAMX HOST CONTROLLER DRIVER 21 | * 22 | * Filename : usbh_hcd_atsamx.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | #ifndef USBH_HCD_ATSAMX_H 28 | #define USBH_HCD_ATSAMX_H 29 | 30 | 31 | /* 32 | ********************************************************************************************************* 33 | * INCLUDE FILES 34 | ********************************************************************************************************* 35 | */ 36 | 37 | #include "../../Source/usbh_core.h" 38 | 39 | 40 | /* 41 | ********************************************************************************************************* 42 | * EXTERNS 43 | ********************************************************************************************************* 44 | */ 45 | 46 | #ifdef USBH_HCD_ATSAMX_MODULE 47 | #define USBH_HCD_ATSAMX_EXT 48 | #else 49 | #define USBH_HCD_ATSAMX_EXT extern 50 | #endif 51 | 52 | 53 | /* 54 | ********************************************************************************************************* 55 | * DEFINES 56 | ********************************************************************************************************* 57 | */ 58 | 59 | 60 | /* 61 | ********************************************************************************************************* 62 | * DATA TYPES 63 | ********************************************************************************************************* 64 | */ 65 | 66 | 67 | /* 68 | ********************************************************************************************************* 69 | * GLOBAL VARIABLES 70 | * 71 | * Note(s) : (1) The following MCUs are supported by USBH_ATSAMX_HCD_DrvAPI: 72 | * Microchip ATSAM D5x/E5x 73 | * 74 | * (2) Due to hardware limitations, the ATSAM D5x/E5x host controller does not support a 75 | * combination of Full-Speed HUB + Low-Speed device 76 | ********************************************************************************************************* 77 | */ 78 | 79 | USBH_HCD_ATSAMX_EXT USBH_HC_DRV_API USBH_ATSAMX_HCD_DrvAPI; /* See note 2. */ 80 | USBH_HCD_ATSAMX_EXT USBH_HC_RH_API USBH_ATSAMX_HCD_RH_API; 81 | 82 | 83 | /* 84 | ********************************************************************************************************* 85 | * MACROS 86 | ********************************************************************************************************* 87 | */ 88 | 89 | 90 | /* 91 | ********************************************************************************************************* 92 | * FUNCTION PROTOTYPES 93 | ********************************************************************************************************* 94 | */ 95 | 96 | 97 | /* 98 | ********************************************************************************************************* 99 | * CONFIGURATION ERRORS 100 | ********************************************************************************************************* 101 | */ 102 | 103 | 104 | /* 105 | ********************************************************************************************************* 106 | * MODULE END 107 | ********************************************************************************************************* 108 | */ 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /HCD/DWC_OTG_HS/usbh_hcd_dwc_otg_hs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * HOST CONTROLLER DRIVER 21 | * SYNOPSYS DESIGNWARE CORE USB 2.0 OTG (HS) 22 | * 23 | * File : usbh_hcd_dwc_otg_hs.h 24 | * Version : V3.42.01 25 | ********************************************************************************************************* 26 | */ 27 | 28 | 29 | #ifndef USBH_HCD_DWC_OTG_HS_H 30 | #define USBH_HCD_DWC_OTG_HS_H 31 | 32 | 33 | /* 34 | ********************************************************************************************************* 35 | * INCLUDE FILES 36 | ********************************************************************************************************* 37 | */ 38 | 39 | #include "../../Source/usbh_core.h" 40 | 41 | 42 | /* 43 | ********************************************************************************************************* 44 | * EXTERNS 45 | ********************************************************************************************************* 46 | */ 47 | 48 | #ifdef USBH_HCD_DWC_OTG_HS_MODULE 49 | #define USBH_HCD_DWC_OTG_HS_EXT 50 | #else 51 | #define USBH_HCD_DWC_OTG_HS_EXT extern 52 | #endif 53 | 54 | 55 | /* 56 | ********************************************************************************************************* 57 | * DEFINES 58 | ********************************************************************************************************* 59 | */ 60 | 61 | 62 | /* 63 | ********************************************************************************************************* 64 | * DATA TYPES 65 | ********************************************************************************************************* 66 | */ 67 | 68 | 69 | /* 70 | ********************************************************************************************************* 71 | * GLOBAL VARIABLES 72 | * 73 | * Note(s) : (1) The following MCUs are supported by USBH_STM32FX_FS_HCD_DrvAPI: 74 | * 75 | * 76 | * (2) The following MCUs are supported by USBH_STM32FX_OTG_HS_HCD_DrvAPI: 77 | * 78 | * STMicroelectronics STM32F20xx series. 79 | * STMicroelectronics STM32F21xx series. 80 | * STMicroelectronics STM32F4xxx series. 81 | * STMicroelectronics STM32F74xx series. 82 | * STMicroelectronics STM32F75xx series. 83 | * 84 | ********************************************************************************************************* 85 | */ 86 | 87 | USBH_HCD_DWC_OTG_HS_EXT USBH_HC_DRV_API USBH_STM32FX_OTG_HS_HCD_DrvAPI; 88 | 89 | USBH_HCD_DWC_OTG_HS_EXT USBH_HC_RH_API USBH_DWCOTGHS_HCD_RH_API; 90 | 91 | 92 | /* 93 | ********************************************************************************************************* 94 | * MACROS 95 | ********************************************************************************************************* 96 | */ 97 | 98 | 99 | /* 100 | ********************************************************************************************************* 101 | * FUNCTION PROTOTYPES 102 | ********************************************************************************************************* 103 | */ 104 | 105 | 106 | /* 107 | ********************************************************************************************************* 108 | * CONFIGURATION ERRORS 109 | ********************************************************************************************************* 110 | */ 111 | 112 | 113 | /* 114 | ********************************************************************************************************* 115 | * MODULE END 116 | ********************************************************************************************************* 117 | */ 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /HCD/EHCI/usbh_hcd_ehci.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * GENERIC EHCI DRIVER 21 | * 22 | * Filename : usbh_ehci.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | #ifndef USBH_EHCI_H 28 | #define USBH_EHCI_H 29 | 30 | 31 | /* 32 | ********************************************************************************************************* 33 | * INCLUDE HEADER FILES 34 | ********************************************************************************************************* 35 | */ 36 | 37 | #include "../../Source/usbh_core.h" 38 | 39 | 40 | /* 41 | ********************************************************************************************************* 42 | * CONSTANTS 43 | ********************************************************************************************************* 44 | */ 45 | 46 | #define EHCI_MAX_ITD 10u /* Max nbr of iTD per EP for HS isoc xfer */ 47 | #define EHCI_MAX_SITD 10u /* Max nbr of siTD per EP for FS isoc xfer */ 48 | 49 | 50 | #define EHCI_MAX_PERIODIC_BW 90u 51 | #define EHCI_PORT_POWERED_ALWAYS 0u 52 | #define EHCI_PORT_POWERED_INDIVIDUAL 1u 53 | #define EHCI_MAX_PERIODIC_LIST_SIZE (256u * 2u) 54 | 55 | 56 | #define EHCI_TIMESTAMP_MICROSEC 1u 57 | #define EHCI_TIMESTAMP_MILLISEC 2u 58 | 59 | /* ----------- EHCI QH LIST NUMBER DEFINES ------------ */ 60 | #define EHCI_QH_LIST_256MS 0u 61 | #define EHCI_QH_LIST_128MS 256u 62 | #define EHCI_QH_LIST_64MS 384u 63 | #define EHCI_QH_LIST_32MS 448u 64 | #define EHCI_QH_LIST_16MS 480u 65 | #define EHCI_QH_LIST_08MS 496u 66 | #define EHCI_QH_LIST_04MS 504u 67 | #define EHCI_QH_LIST_02MS 508u 68 | #define EHCI_QH_LIST_01MS 510u 69 | #define EHCI_INTR_QH_LIST_SIZE (EHCI_QH_LIST_01MS + 1u) 70 | 71 | #define EHCI_MAX_BW_PER_MICRO_FRAME 3072u 72 | 73 | #define EHCI_BW_FLAG_CONSUME 1u 74 | #define EHCI_BW_FLAG_PRODUCE 2u 75 | 76 | 77 | /* 78 | ********************************************************************************************************* 79 | * LOCAL DEFINES 80 | ********************************************************************************************************* 81 | */ 82 | 83 | 84 | /* 85 | ********************************************************************************************************* 86 | * LOCAL DATA TYPES 87 | ********************************************************************************************************* 88 | */ 89 | 90 | 91 | /* 92 | ********************************************************************************************************* 93 | * LOCAL GLOBAL VARIABLES 94 | ********************************************************************************************************* 95 | */ 96 | /* 97 | ********************************************************************************************************* 98 | * MACROS 99 | ********************************************************************************************************* 100 | */ 101 | 102 | 103 | #ifndef EHCI_CFG_ONRESET_EN /* En callback to setup auxiliary registers on reset. */ 104 | #define EHCI_CFG_ONRESET_EN DEF_DISABLED 105 | #endif 106 | 107 | #define USBH_EHCI_CFG_PERIODIC_EN DEF_ENABLED 108 | 109 | 110 | /* 111 | ********************************************************************************************************* 112 | * MAXIMUM PACKET SIZES 113 | ********************************************************************************************************* 114 | */ 115 | 116 | #define MPS_HS 1024u /* Maximum Packet Size for High Speed device */ 117 | #define MPS_FS 1023u /* Maximum Packet Size for Full Speed device */ 118 | #define MPS_LS 64u /* Maximum Packet Size for Low Speed device */ 119 | 120 | 121 | /* 122 | ********************************************************************************************************* 123 | * TYPE DEFINITIONS 124 | ********************************************************************************************************* 125 | */ 126 | 127 | typedef struct ehci_isoc_ep_desc EHCI_ISOC_EP_DESC; 128 | typedef struct ehci_isoc_ep_urb EHCI_ISOC_EP_URB; 129 | typedef struct ehci_intr_info EHCI_INTR_INFO; 130 | 131 | 132 | typedef struct ehci_qh { 133 | CPU_REG32 QHHorLinkPtr; 134 | CPU_REG32 QHEpCapChar[2]; 135 | CPU_REG32 QHCurQTDPtr; 136 | CPU_REG32 QHNxtQTDPtr; 137 | CPU_REG32 QHAltNxtQTDPtr; 138 | CPU_REG32 QHToken; 139 | CPU_REG32 QHBufPagePtrList[5]; 140 | /* Fields not part of qH struct defined in EHCI spec */ 141 | USBH_EP *EPPtr; 142 | CPU_INT32U QTDHead; 143 | CPU_INT08U SMask; 144 | CPU_INT08U BWStartFrame; 145 | CPU_INT16U FrameInterval; 146 | CPU_INT08U Rsvd[4]; /* Padding to align the struct on a 32-byte boundary */ 147 | } EHCI_QH; 148 | 149 | 150 | typedef struct ehci_qtd { 151 | CPU_REG32 QTDNxtPtr; 152 | CPU_REG32 QTDAltNxtPtr; 153 | CPU_REG32 QTDToken; 154 | CPU_REG32 QTDBufPagePtrList[5]; 155 | } EHCI_QTD; 156 | 157 | 158 | typedef struct ehci_sitd { 159 | CPU_REG32 SITDNxtLinkPtr; 160 | CPU_REG32 SITDEpCapChar[2]; 161 | CPU_REG32 SITDStsCtrl; 162 | CPU_REG32 SITDBufPagePtrList[2]; 163 | CPU_REG32 SITDBackLinkPtr; 164 | } EHCI_SITD; 165 | 166 | 167 | typedef struct ehci_itd { 168 | CPU_REG32 ITDNxtLinkPtr; 169 | CPU_REG32 ITDStsAndCntrl[8]; 170 | CPU_REG32 ITDBufPagePtrList[7]; 171 | } EHCI_ITD; 172 | 173 | 174 | struct ehci_isoc_ep_desc { 175 | void *TDTailPtr; 176 | USBH_EP *EPPtr; 177 | CPU_INT08U SMask; 178 | CPU_INT08U CMask; 179 | CPU_INT08U TCnt; 180 | CPU_INT08U AppStartFrame; 181 | CPU_INT08U NbrFrame; 182 | CPU_INT16U FrameInterval; 183 | EHCI_ISOC_EP_DESC *NxtEPDesc; 184 | }; 185 | 186 | struct ehci_isoc_ep_urb { 187 | CPU_INT32U iTD_Addr; 188 | CPU_INT08U AppStartFrame; 189 | CPU_INT08U NbrFrame; 190 | }; 191 | 192 | 193 | typedef struct ehci_cap { 194 | CPU_INT08U CapLen; 195 | CPU_INT16U HCIVersion; 196 | CPU_INT32U HCSParams; 197 | CPU_INT32U HCCParams; 198 | CPU_INT08U HCSPPortRoute[15]; 199 | } EHCI_CAP; 200 | 201 | 202 | typedef struct ehci_cap_reg { 203 | CPU_REG32 CapLen_HCIVersion; 204 | CPU_REG32 HCSParams; 205 | CPU_REG32 HCCParams; 206 | CPU_REG08 HCSPPortRoute[15]; 207 | } EHCI_CAP_REG; 208 | 209 | 210 | typedef struct ehci_oper_reg { 211 | CPU_REG32 USBCmd; 212 | CPU_REG32 USBSts; 213 | CPU_REG32 USBIntr; 214 | CPU_REG32 FrameIx; 215 | CPU_REG32 CtrlDSSeg; 216 | CPU_REG32 PeriodicListBase; 217 | CPU_REG32 AsyncListAddr; 218 | CPU_REG32 Rsvd[9]; 219 | CPU_REG32 CfgFlag; 220 | CPU_REG32 PortSC[1]; 221 | } EHCI_OPER_REG; 222 | 223 | 224 | typedef struct ehci_dma { 225 | EHCI_QTD *QTDPtr; /* DMA memory CTRL,BULK and INTR QTD */ 226 | EHCI_QH *QHPtr; /* DMA memory for Queue Head (QH) */ 227 | EHCI_ITD *ITDPtr; 228 | CPU_INT08U *BufPtr; 229 | } EHCI_DMA; 230 | 231 | 232 | #if (USBH_EHCI_CFG_PERIODIC_EN == DEF_ENABLED) 233 | struct ehci_intr_info { 234 | CPU_INT08U IntrPlaceholderIx; /* Index of Intr placeholder in QHLists array. */ 235 | CPU_INT16U FrameInterval; 236 | USBH_EP *EpPtr; 237 | EHCI_INTR_INFO *NxtIntrInfo; 238 | }; 239 | #endif 240 | 241 | 242 | typedef struct ehci_dev { /* -------------------- EHCI Device ------------------- */ 243 | EHCI_CAP HcCap; /* Pointer to Capability structure */ 244 | EHCI_DMA DMA_EHCI; 245 | CPU_INT08U EHCI_HubBuf[sizeof(USBH_HUB_DESC)]; 246 | EHCI_QH *AsyncQHHead; /* Asynchronous list head */ 247 | CPU_INT08U NbrPorts; /* Number of Ports in RootHub */ 248 | 249 | MEM_POOL HC_QHPool; /* Memory pool for allocating HC QHs */ 250 | MEM_POOL HC_QTDPool; /* Memory pool for allocating HC QTDs */ 251 | MEM_POOL BufPool; 252 | 253 | CPU_INT32U PortResetChng; /* Port Reset Change status variable */ 254 | EHCI_CAP_REG *HcCapReg; /* Pointer to Host Controller Capability Registers */ 255 | EHCI_OPER_REG *HcOperReg; /* Pointer to Host Controller Operational Registers */ 256 | 257 | #if (USBH_EHCI_CFG_PERIODIC_EN == DEF_ENABLED) 258 | CPU_INT32U *PeriodicListBase; 259 | 260 | EHCI_QH *QHLists[EHCI_INTR_QH_LIST_SIZE]; /* HCD qH placeholder array for Intr ep. */ 261 | 262 | MEM_POOL HC_ITDPool; /* Memory pool for allocating HC iTDs */ 263 | 264 | MEM_POOL IntrInfoPool; /* Memory pool for allocating Intr info struct. */ 265 | MEM_POOL HC_Isoc_EP_DescPool; /* Memory pool for allocating HCD Isoc EP struct */ 266 | MEM_POOL HC_Isoc_EP_URBPool; 267 | 268 | CPU_INT16U MaxPeriodicBWArr[256][8]; /* Maximum Periodic Bandwidth */ 269 | EHCI_ISOC_EP_DESC *HeadIsocEPDesc; /* Isochronous list head pointer */ 270 | EHCI_INTR_INFO *HeadIntrInfo; /* Intr info list head pointer. */ 271 | #endif 272 | 273 | CPU_INT32U FNOCnt; /* Counter for Frame List Rollover */ 274 | CPU_BOOLEAN HC_Started; /* Indicate if EHCI HC is started. */ 275 | CPU_INT08U DrvType; /* Indicate which EHCI drv type. */ 276 | } EHCI_DEV; 277 | 278 | 279 | /* 280 | ********************************************************************************************************* 281 | * GLOBAL VARIABLES 282 | ********************************************************************************************************* 283 | */ 284 | 285 | #ifdef USBH_EHCI_MODULE 286 | #define USBH_EHCI_EXT 287 | #else 288 | #define USBH_EHCI_EXT extern 289 | #endif 290 | 291 | USBH_EHCI_EXT USBH_HC_DRV_API EHCI_DrvAPI; 292 | USBH_EHCI_EXT USBH_HC_DRV_API EHCI_DrvAPI_Synopsys; 293 | USBH_EHCI_EXT USBH_HC_RH_API EHCI_RH_API; 294 | 295 | 296 | /* 297 | ********************************************************************************************************* 298 | * FUNCTION PROTOTYPES 299 | ********************************************************************************************************* 300 | */ 301 | 302 | 303 | /* 304 | ********************************************************************************************************* 305 | * CONFIGURATION ERRORS 306 | ********************************************************************************************************* 307 | */ 308 | 309 | 310 | /* 311 | ********************************************************************************************************* 312 | * MODULE END 313 | ********************************************************************************************************* 314 | */ 315 | 316 | #endif 317 | -------------------------------------------------------------------------------- /HCD/OHCI/usbh_hcd_ohci.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * STANDARD OHCI DRIVER 21 | * 22 | * Filename : usbh_ohci.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | #ifndef USBH_OHCI_MODULE_PRESENT 28 | #define USBH_OHCI_MODULE_PRESENT 29 | 30 | 31 | /* 32 | ********************************************************************************************************* 33 | * INCLUDE FILES 34 | ********************************************************************************************************* 35 | */ 36 | 37 | #include "../../Source/usbh_core.h" 38 | 39 | 40 | /* 41 | ********************************************************************************************************* 42 | * EXTERNS 43 | ********************************************************************************************************* 44 | */ 45 | 46 | #ifdef USBH_OHCI_MODULE 47 | #define USBH_OHCI_EXT 48 | #else 49 | #define USBH_OHCI_EXT extern 50 | #endif 51 | 52 | 53 | /* 54 | ********************************************************************************************************* 55 | * DEFINES 56 | ********************************************************************************************************* 57 | */ 58 | 59 | /* ----------- OHCI ED LIST NUMBER DEFINES ------------ */ 60 | #define OHCI_ED_LIST_32MS 0u 61 | #define OHCI_ED_LIST_16MS 32u 62 | #define OHCI_ED_LIST_08MS 48u 63 | #define OHCI_ED_LIST_04MS 56u 64 | #define OHCI_ED_LIST_02MS 60u 65 | #define OHCI_ED_LIST_01MS 62u 66 | #define OHCI_ED_LIST_CTRL 63u 67 | #define OHCI_ED_LIST_BULK 64u 68 | #define OHCI_ED_LIST_SIZE (OHCI_ED_LIST_BULK + 1u) 69 | 70 | #define OHCI_MAX_PERIODIC_BW 90u 71 | 72 | 73 | /* 74 | ********************************************************************************************************* 75 | * DATA TYPES 76 | ********************************************************************************************************* 77 | */ 78 | 79 | typedef struct ohci_hcd_td OHCI_HCD_TD; 80 | typedef struct ohci_hcd_ed OHCI_HCD_ED; 81 | 82 | typedef struct ohci_oper_reg { 83 | CPU_REG32 Revision; 84 | CPU_REG32 Control; 85 | CPU_REG32 CommandStatus; 86 | CPU_REG32 InterruptStatus; 87 | CPU_REG32 InterruptEnable; 88 | CPU_REG32 InterruptDisable; 89 | CPU_REG32 HCCA; 90 | CPU_REG32 PeriodCurrentED; 91 | CPU_REG32 ControlHeadED; 92 | CPU_REG32 ControlCurrentED; 93 | CPU_REG32 BulkHeadED; 94 | CPU_REG32 BulkCurrentED; 95 | CPU_REG32 DoneHead; 96 | CPU_REG32 FmInterval; 97 | CPU_REG32 FmRemaining; 98 | CPU_REG32 FmNumber; 99 | CPU_REG32 PeriodicStart; 100 | CPU_REG32 LSThreshold; 101 | CPU_REG32 RhDescriptorA; 102 | CPU_REG32 RhDescriptorB; 103 | CPU_REG32 RhStatus; 104 | CPU_REG32 RhPortStatus[1]; 105 | } OHCI_OPER_REG; 106 | /* --- HOST CONTROLLER COMMUNICATION AREA DATA TYPE --- */ 107 | typedef struct ohci_hcca { 108 | CPU_REG32 IntTbl[32]; /* Interrupt Table */ 109 | CPU_REG32 FrameNbr; /* Frame Number */ 110 | CPU_REG32 DoneHead; /* Done Head */ 111 | CPU_REG08 Rsvd[116]; /* Reserved for future use */ 112 | CPU_REG08 Unknown[4]; /* Unused */ 113 | } OHCI_HCCA; 114 | 115 | /* --- HOST CONTROLLER ENDPOINT DESCRIPTOR DATA TYPE -- */ 116 | typedef struct ohci_hc_ed { 117 | CPU_REG32 Ctrl; /* Endpoint descriptor control */ 118 | CPU_REG32 TailTD; /* Physical address of tail in Transfer descriptor list */ 119 | CPU_REG32 HeadTD; /* Physcial address of head in Transfer descriptor list */ 120 | CPU_REG32 Next; /* Physical address of next Endpoint descriptor */ 121 | } OHCI_HC_ED; 122 | 123 | /* --- HOST CONTROLLER TRANSFER DESCRIPTOR DATA TYPE -- */ 124 | typedef struct ohci_hc_td { 125 | CPU_REG32 Ctrl; /* Transfer descriptor control */ 126 | CPU_REG32 CurBuf; /* Physical address of current buffer pointer */ 127 | CPU_REG32 Next; /* Physical pointer to next Transfer Descriptor */ 128 | CPU_REG32 BufEnd; /* Physical address of end of buffer */ 129 | CPU_REG32 Offsets[4]; /* Isochronous offsets */ 130 | } OHCI_HC_TD; 131 | 132 | /* --- HOST CONTROLLER ENDPOINT TRANSFER DESCRIPTOR --- */ 133 | struct ohci_hcd_ed { 134 | OHCI_HC_ED *HC_EDPtr; 135 | CPU_INT32U DMA_HC_ED; 136 | OHCI_HCD_TD *Head_HCD_TDPtr; 137 | OHCI_HCD_TD *Tail_HCD_TDPtr; 138 | OHCI_HCD_ED *NextPtr; 139 | CPU_INT32U ListInterval; 140 | CPU_INT32U BW; 141 | CPU_BOOLEAN IsHalt; 142 | }; 143 | 144 | /* HOST CONTROLLER DRIVER TRANSFER DESCRIPTOR DATA TYPE */ 145 | struct ohci_hcd_td { 146 | OHCI_HC_TD *HC_TdPtr; 147 | CPU_INT32U DMA_HC_TD; 148 | OHCI_HCD_TD *NextPtr; 149 | USBH_URB *URBPtr; /* URB associated with this TD */ 150 | CPU_REG08 State; 151 | }; 152 | 153 | /* -------------- OHCI DMA Structure ------------------ */ 154 | typedef struct ohci_dma { 155 | OHCI_HCCA *HCCAPtr; /* DMA memory HCCA descriptor */ 156 | OHCI_HC_TD *TDPtr; /* DMA memory CTRL,BULK and INTR endpoint TD */ 157 | OHCI_HC_ED *EDPtr; /* DMA memory for Endpoint Descriptors (ED) */ 158 | CPU_INT08U *BufPtr; 159 | } OHCI_DMA; 160 | 161 | /* -------------- OHCI DEVICE DATA TYPE --------------- */ 162 | typedef struct ohci_dev { 163 | OHCI_DMA DMA_OHCI; 164 | CPU_INT08U OHCI_HubBuf[sizeof(USBH_HUB_DESC)]; 165 | OHCI_HCD_ED *EDLists[OHCI_ED_LIST_SIZE]; /* OHCI EndPoint Descriptor Lists */ 166 | CPU_INT08U CanWakeUp; /* Port Power */ 167 | CPU_INT08U NbrPorts; /* Number of Ports in RootHub */ 168 | CPU_INT32U TotBW; /* Periodic list parameters */ 169 | CPU_INT32U Branch[32]; /* Bandwidth of branches */ 170 | MEM_POOL HC_EDPool; /* Memory pool for allocating DMA ednpoint descriptor */ 171 | MEM_POOL HC_TDPool; /* Memory pool for allocating DMA general TDs */ 172 | OHCI_HCD_ED *HCD_ED; 173 | MEM_POOL HCD_EDPool; /* Memory pool for allocating OHCI driver EDs */ 174 | OHCI_HCD_TD *HCD_TD; 175 | MEM_POOL HCD_TDPool; /* Memory pool for allocating OHCI driver TDs */ 176 | MEM_POOL BufPool; 177 | CPU_INT32U FrameNbr; 178 | OHCI_HCD_TD **OHCI_Lookup; 179 | } OHCI_DEV; 180 | 181 | 182 | /* 183 | ********************************************************************************************************* 184 | * GLOBAL VARIABLES 185 | ********************************************************************************************************* 186 | */ 187 | 188 | USBH_OHCI_EXT USBH_HC_DRV_API OHCI_DrvAPI; 189 | USBH_OHCI_EXT USBH_HC_RH_API OHCI_RH_API; 190 | 191 | 192 | /* 193 | ********************************************************************************************************* 194 | * MACROS 195 | ********************************************************************************************************* 196 | */ 197 | 198 | 199 | /* 200 | ********************************************************************************************************* 201 | * FUNCTION PROTOTYPES 202 | ********************************************************************************************************* 203 | */ 204 | 205 | 206 | /* 207 | ********************************************************************************************************* 208 | * CONFIGURATION ERRORS 209 | ********************************************************************************************************* 210 | */ 211 | 212 | 213 | /* 214 | ********************************************************************************************************* 215 | * MODULE END 216 | ********************************************************************************************************* 217 | */ 218 | 219 | #endif 220 | -------------------------------------------------------------------------------- /HCD/RX600/usbh_hcd_rx600.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * USB HOST DRIVER 21 | * RENESAS RX600 (FS) 22 | * 23 | * Filename : usbh_rx600.h 24 | * Version : V3.42.01 25 | ********************************************************************************************************* 26 | */ 27 | 28 | #ifndef USBH_RX600_H 29 | #define USBH_RX600_H 30 | 31 | 32 | /* 33 | ************************************************************************************************************** 34 | * INCLUDE FILES 35 | ************************************************************************************************************** 36 | */ 37 | 38 | #include "../../Source/usbh_core.h" 39 | 40 | 41 | /* 42 | ************************************************************************************************************** 43 | * EXTERNS 44 | ************************************************************************************************************** 45 | */ 46 | 47 | #ifdef USBH_RX600_MODULE 48 | #define USBH_RX600_EXT 49 | #else 50 | #define USBH_RX600_EXT extern 51 | #endif 52 | 53 | /* 54 | ************************************************************************************************************** 55 | * DEFINES 56 | ************************************************************************************************************** 57 | */ 58 | 59 | 60 | 61 | /* 62 | ************************************************************************************************************** 63 | * DATA TYPES 64 | ************************************************************************************************************** 65 | */ 66 | 67 | 68 | /* 69 | ************************************************************************************************************** 70 | * GLOBAL VARIABLES 71 | ************************************************************************************************************** 72 | */ 73 | 74 | USBH_RX600_EXT USBH_HC_DRV_API USBH_RX600_DrvAPI; 75 | USBH_RX600_EXT USBH_HC_RH_API USBH_RX600_RH_API; 76 | 77 | 78 | /* 79 | ************************************************************************************************************** 80 | * MACRO'S 81 | ************************************************************************************************************** 82 | */ 83 | 84 | 85 | /* 86 | ************************************************************************************************************** 87 | * FUNCTION PROTOTYPES 88 | ************************************************************************************************************** 89 | */ 90 | 91 | 92 | /* 93 | ************************************************************************************************************** 94 | * CONFIGURATION ERRORS 95 | ************************************************************************************************************** 96 | */ 97 | 98 | 99 | /* 100 | ************************************************************************************************************** 101 | * END 102 | ************************************************************************************************************** 103 | */ 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /HCD/Renesas_USBHS/usbh_hcd_renesas_usbhs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * HOST CONTROLLER DRIVER 21 | * 22 | * RENESAS USB HIGH-SPEED 23 | * 24 | * Filename : usbh_hcd_renesas_usbhs.h 25 | * Version : V3.42.01 26 | ********************************************************************************************************* 27 | * Note(s) : (1) With an appropriate BSP, this host controller driver driver will support the USB 28 | * module on the Renesas RZ. 29 | ********************************************************************************************************* 30 | */ 31 | 32 | #ifndef USBH_HCD_RENESAS_USBHS_H 33 | #define USBH_HCD_RENESAS_USBHS_H 34 | 35 | 36 | /* 37 | ********************************************************************************************************* 38 | * INCLUDE FILES 39 | ********************************************************************************************************* 40 | */ 41 | 42 | #include "../../Source/usbh_core.h" 43 | 44 | 45 | /* 46 | ********************************************************************************************************* 47 | * EXTERNS 48 | ********************************************************************************************************* 49 | */ 50 | 51 | #ifdef USBH_HCD_RENESAS_USBHS_MODULE 52 | #define USBH_HCD_RENESAS_USBHS_EXT 53 | #else 54 | #define USBH_HCD_RENESAS_USBHS_EXT extern 55 | #endif 56 | 57 | 58 | /* 59 | ********************************************************************************************************* 60 | * DEFINES 61 | ********************************************************************************************************* 62 | */ 63 | 64 | /* 65 | ********************************************************************************************************* 66 | * PIPE INFORMATION TABLE DEFINES 67 | ********************************************************************************************************* 68 | */ 69 | 70 | /* -------------- PIPE TYPE BIT DEFINES --------------- */ 71 | #define USBH_HCD_PIPE_DESC_TYPE_CTRL DEF_BIT_00 72 | #define USBH_HCD_PIPE_DESC_TYPE_ISOC DEF_BIT_01 73 | #define USBH_HCD_PIPE_DESC_TYPE_BULK DEF_BIT_02 74 | #define USBH_HCD_PIPE_DESC_TYPE_INTR DEF_BIT_03 75 | 76 | /* ------------ PIPE DIRECTION BIT DEFINES ------------ */ 77 | #define USBH_HCD_PIPE_DESC_DIR_OUT DEF_BIT_04 78 | #define USBH_HCD_PIPE_DESC_DIR_IN DEF_BIT_05 79 | 80 | #define USBH_HCD_PIPE_DESC_DIR_BOTH (USBH_HCD_PIPE_DESC_DIR_OUT | USBH_HCD_PIPE_DESC_DIR_IN) 81 | 82 | 83 | /* 84 | ********************************************************************************************************* 85 | * DATA TYPES 86 | ********************************************************************************************************* 87 | */ 88 | 89 | /* 90 | ********************************************************************************************************* 91 | * ENDPOINT INFORMATION DATA TYPE 92 | * 93 | * Note(s) : (1) The endpoint information data type provides information about the USB host controller 94 | * physical EPs (or pipes). 95 | * 96 | * (a) The 'Attrib' bit-field defines the EP attributes. The EP attributes is combination 97 | * of the following flags: 98 | * 99 | * USBH_HCD_PIPE_DESC_TYPE_CTRL Indicate control type capable. 100 | * USBH_HCD_PIPE_DESC_TYPE_ISOC Indicate isochronous type capable. 101 | * USBH_HCD_PIPE_DESC_TYPE_BULK Indicate bulk type capable. 102 | * USBH_HCD_PIPE_DESC_TYPE_INTR Indicate interrupt type capable. 103 | * USBH_HCD_PIPE_DESC_DIR_OUT Indicate OUT direction capable. 104 | * USBH_HCD_PIPE_DESC_DIR_IN Indicate IN direction capable. 105 | ********************************************************************************************************* 106 | */ 107 | 108 | typedef const struct usbh_hcd_renesas_usbhs_pipe_desc { 109 | CPU_INT08U Attrib; /* Endpoint attributes (see Note #1a). */ 110 | CPU_INT08U Nbr; /* Endpoint number. */ 111 | CPU_INT16U MaxPktSize; /* Endpoint maximum packet size. */ 112 | } USBH_HCD_RENESAS_USBHS_PIPE_DESC; 113 | 114 | 115 | /* 116 | ********************************************************************************************************* 117 | * GLOBAL VARIABLES 118 | ********************************************************************************************************* 119 | */ 120 | 121 | USBH_HCD_RENESAS_USBHS_EXT USBH_HC_DRV_API USBH_HCD_API_RenesasRZ_FIFO; 122 | USBH_HCD_RENESAS_USBHS_EXT USBH_HC_DRV_API USBH_HCD_API_RenesasRZ_DMA; 123 | 124 | USBH_HCD_RENESAS_USBHS_EXT USBH_HC_DRV_API USBH_HCD_API_RenesasRX64M_FIFO; 125 | USBH_HCD_RENESAS_USBHS_EXT USBH_HC_DRV_API USBH_HCD_API_RenesasRX64M_DMA; 126 | 127 | USBH_HCD_RENESAS_USBHS_EXT USBH_HC_DRV_API USBH_HCD_API_RenesasRX71M_FIFO; 128 | USBH_HCD_RENESAS_USBHS_EXT USBH_HC_DRV_API USBH_HCD_API_RenesasRX71M_DMA; 129 | 130 | USBH_HCD_RENESAS_USBHS_EXT USBH_HC_RH_API USBH_HCD_RH_API_RenesasUSBHS; 131 | 132 | 133 | /* 134 | ********************************************************************************************************* 135 | * MACROS 136 | ********************************************************************************************************* 137 | */ 138 | 139 | 140 | /* 141 | ********************************************************************************************************* 142 | * FUNCTION PROTOTYPES 143 | ********************************************************************************************************* 144 | */ 145 | 146 | 147 | /* 148 | ********************************************************************************************************* 149 | * CONFIGURATION ERRORS 150 | ********************************************************************************************************* 151 | */ 152 | 153 | 154 | /* 155 | ********************************************************************************************************* 156 | * MODULE END 157 | ********************************************************************************************************* 158 | */ 159 | 160 | #endif 161 | -------------------------------------------------------------------------------- /HCD/STM32F_FS/usbh_hcd_stm32fx_fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * STM32FX_FS HOST CONTROLLER DRIVER 21 | * 22 | * Filename : usbh_hcd_stm32fx_fs.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | #ifndef USBH_HCD_STM32FX_FS_H 28 | #define USBH_HCD_STM32FX_FS_H 29 | 30 | 31 | /* 32 | ********************************************************************************************************* 33 | * INCLUDE FILES 34 | ********************************************************************************************************* 35 | */ 36 | 37 | #include "Source/usbh_core.h" 38 | 39 | 40 | /* 41 | ********************************************************************************************************* 42 | * EXTERNS 43 | ********************************************************************************************************* 44 | */ 45 | 46 | #ifdef USBH_HCD_STM32FX_FS_MODULE 47 | #define USBH_HCD_STM32FX_FS_EXT 48 | #else 49 | #define USBH_HCD_STM32FX_FS_EXT extern 50 | #endif 51 | 52 | 53 | /* 54 | ********************************************************************************************************* 55 | * DEFINES 56 | ********************************************************************************************************* 57 | */ 58 | 59 | 60 | /* 61 | ********************************************************************************************************* 62 | * DATA TYPES 63 | ********************************************************************************************************* 64 | */ 65 | 66 | 67 | /* 68 | ********************************************************************************************************* 69 | * GLOBAL VARIABLES 70 | * 71 | * Note(s) : (1) The following MCUs are supported by USBH_STM32FX_FS_HCD_DrvAPI: 72 | * 73 | * STMicroelectronics STM32F105xx series. 74 | * STMicroelectronics STM32F107xx series. 75 | * STMicroelectronics STM32F205xx series. 76 | * STMicroelectronics STM32F207xx series. 77 | * STMicroelectronics STM32F215xx series. 78 | * STMicroelectronics STM32F217xx series. 79 | * STMicroelectronics STM32F405xx series. 80 | * STMicroelectronics STM32F407xx series. 81 | * STMicroelectronics STM32F415xx series. 82 | * STMicroelectronics STM32F417xx series. 83 | * 84 | * (2) The following MCUs are supported by USBH_STM32FX_OTG_FS_HCD_DrvAPI: 85 | * 86 | * STMicroelectronics STM32F74xx series. 87 | * STMicroelectronics STM32F75xx series. 88 | * 89 | * (3) The following MCUs are support by USBD_DrvAPI_EFM32_OTG_FS API: 90 | * 91 | * Silicon Labs EFM32 Giant Gecko series. 92 | * Silicon Labs EFM32 Wonder Gecko series. 93 | * Silicon Labs EFM32 Leopard Gecko series. 94 | * 95 | ********************************************************************************************************* 96 | */ 97 | 98 | USBH_HCD_STM32FX_FS_EXT USBH_HC_DRV_API USBH_STM32FX_FS_HCD_DrvAPI; 99 | USBH_HCD_STM32FX_FS_EXT USBH_HC_DRV_API USBH_STM32FX_OTG_FS_HCD_DrvAPI; 100 | USBH_HCD_STM32FX_FS_EXT USBH_HC_DRV_API USBH_EFM32_OTG_FS_HCD_DrvAPI; 101 | 102 | USBH_HCD_STM32FX_FS_EXT USBH_HC_RH_API USBH_STM32FX_FS_HCD_RH_API; 103 | 104 | 105 | /* 106 | ********************************************************************************************************* 107 | * MACROS 108 | ********************************************************************************************************* 109 | */ 110 | 111 | 112 | /* 113 | ********************************************************************************************************* 114 | * FUNCTION PROTOTYPES 115 | ********************************************************************************************************* 116 | */ 117 | 118 | 119 | /* 120 | ********************************************************************************************************* 121 | * CONFIGURATION ERRORS 122 | ********************************************************************************************************* 123 | */ 124 | 125 | 126 | /* 127 | ********************************************************************************************************* 128 | * MODULE END 129 | ********************************************************************************************************* 130 | */ 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /HCD/Template/bsp_usbh_template.c: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * USB HOST DRIVER BOARD SUPPORT PACKAGE (BSP) FUNCTIONS 21 | * 22 | * TEMPLATE 23 | * 24 | * Filename : bsp_usbh_template.c 25 | * Version : V3.42.01 26 | ********************************************************************************************************* 27 | */ 28 | 29 | /* 30 | ************************************************************************************************************** 31 | * INCLUDE FILES 32 | ************************************************************************************************************** 33 | */ 34 | 35 | #include 36 | #include 37 | #include 38 | #include "bsp_usbh_template.h" 39 | 40 | 41 | /* 42 | ************************************************************************************************************** 43 | * LOCAL DEFINES 44 | ************************************************************************************************************** 45 | */ 46 | 47 | 48 | /* 49 | ************************************************************************************************************** 50 | * LOCAL CONSTANTS 51 | ************************************************************************************************************** 52 | */ 53 | 54 | 55 | /* 56 | ************************************************************************************************************** 57 | * LOCAL DATA TYPES 58 | ************************************************************************************************************** 59 | */ 60 | 61 | 62 | /* 63 | ************************************************************************************************************** 64 | * LOCAL TABLES 65 | ************************************************************************************************************** 66 | */ 67 | 68 | 69 | /* 70 | ************************************************************************************************************** 71 | * LOCAL GLOBAL VARIABLES 72 | ************************************************************************************************************** 73 | */ 74 | 75 | static USBH_HC_DRV *USBH_HC_Template_DrvPtr; 76 | 77 | static CPU_FNCT_PTR BSP_USBH_Template_ISR_Ptr; 78 | 79 | 80 | /* 81 | ************************************************************************************************************** 82 | * LOCAL FUNCTION PROTOTYPES 83 | ************************************************************************************************************** 84 | */ 85 | 86 | static void BSP_USBH_Template_Init (USBH_HC_DRV *p_drv, 87 | USBH_ERR *p_err); 88 | 89 | static void BSP_USBH_Template_ISR_Register (CPU_FNCT_PTR isr_fnct, 90 | USBH_ERR *p_err); 91 | 92 | static void BSP_USBH_Template_ISR_Unregister(USBH_ERR *p_err); 93 | 94 | static void BSP_USBH_Template_IntHandler (void); 95 | 96 | 97 | /* 98 | ********************************************************************************************************* 99 | * USB HOST DRIVER BSP INTERFACE 100 | ********************************************************************************************************* 101 | */ 102 | 103 | USBH_HC_BSP_API USBH_DrvBSP_Template = { 104 | BSP_USBH_Template_Init, 105 | BSP_USBH_Template_ISR_Register, 106 | BSP_USBH_Template_ISR_Unregister 107 | }; 108 | 109 | 110 | /* 111 | ************************************************************************************************************** 112 | * LOCAL CONFIGURATION ERRORS 113 | ************************************************************************************************************** 114 | */ 115 | 116 | 117 | /* 118 | ************************************************************************************************************** 119 | ************************************************************************************************************** 120 | * LOCAL FUNCTION 121 | ************************************************************************************************************** 122 | ************************************************************************************************************** 123 | */ 124 | 125 | /* 126 | ********************************************************************************************************* 127 | * BSP_USBH_Template_Init() 128 | * 129 | * Description : This function performs board specific initialization of USB host controller. 130 | * 131 | * Argument(s) : p_drv Pointer to host controller driver structure. 132 | * 133 | * p_err Pointer to variable that will receive the return error code from this function 134 | * 135 | * USBH_ERR_NONE BSP init successfull. 136 | * 137 | * Return(s) : none. 138 | * 139 | * Note(s) : none. 140 | ********************************************************************************************************* 141 | */ 142 | 143 | static void BSP_USBH_Template_Init (USBH_HC_DRV *p_drv, 144 | USBH_ERR *p_err) 145 | { 146 | USBH_HC_Template_DrvPtr = p_drv; 147 | 148 | /* $$$$ This function performs all operations that the host controller cannot do. Typical operations are: */ 149 | 150 | /* $$$$ Enable host control registers and bus clock [mandatory]. */ 151 | /* $$$$ Configure main USB host interrupt(s) in interrupt controller (e.g. registering BSP ISR) [mandatory]. */ 152 | /* $$$$ Configure I/O pins [if necessary]. */ 153 | 154 | *p_err = USBH_ERR_NONE; 155 | } 156 | 157 | 158 | /* 159 | ********************************************************************************************************* 160 | * BSP_USBH_Template_ISR_Register() 161 | * 162 | * Description : Registers Interrupt Service Routine. 163 | * 164 | * Argument(s) : isr_fnct Host controller ISR address. 165 | * 166 | * p_err Pointer to variable that will receive the return error code from this function 167 | * 168 | * USBH_ERR_NONE ISR registered successfully. 169 | * 170 | * Return(s) : none. 171 | * 172 | * Note(s) : none. 173 | ********************************************************************************************************* 174 | */ 175 | 176 | static void BSP_USBH_Template_ISR_Register (CPU_FNCT_PTR isr_fnct, 177 | USBH_ERR *p_err) 178 | { 179 | BSP_USBH_Template_ISR_Ptr = isr_fnct; 180 | 181 | *p_err = USBH_ERR_NONE; 182 | } 183 | 184 | 185 | /* 186 | ********************************************************************************************************* 187 | * BSP_USBH_Template_ISR_Unregister() 188 | * 189 | * Description : Unregisters Interrupt Service Routine. 190 | * 191 | * Argument(s) : p_err Pointer to variable that will receive the return error code from this function 192 | * 193 | * USBH_ERR_NONE ISR unregistered successfully. 194 | * 195 | * Return(s) : none. 196 | * 197 | * Note(s) : none. 198 | ********************************************************************************************************* 199 | */ 200 | 201 | static void BSP_USBH_Template_ISR_Unregister (USBH_ERR *p_err) 202 | { 203 | BSP_USBH_Template_ISR_Ptr = (CPU_FNCT_PTR)0; 204 | 205 | *p_err = USBH_ERR_NONE; 206 | } 207 | 208 | 209 | /* 210 | ********************************************************************************************************* 211 | * BSP_USBH_Template_IntHandler() 212 | * 213 | * Description : USB host interrupt handler. 214 | * 215 | * Argument(s) : none. 216 | * 217 | * Return(s) : none. 218 | * 219 | * Note(s) : none. 220 | ********************************************************************************************************* 221 | */ 222 | 223 | static void BSP_USBH_Template_IntHandler (void) 224 | { 225 | if (BSP_USBH_Template_ISR_Ptr != (CPU_FNCT_PTR)0) { 226 | BSP_USBH_Template_ISR_Ptr((void *)USBH_HC_Template_DrvPtr); 227 | } 228 | } 229 | 230 | 231 | /* 232 | ************************************************************************************************************** 233 | * END 234 | ************************************************************************************************************** 235 | */ 236 | -------------------------------------------------------------------------------- /HCD/Template/bsp_usbh_template.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * USB HOST DRIVER BOARD SUPPORT PACKAGE (BSP) FUNCTIONS 21 | * 22 | * TEMPLATE 23 | * 24 | * Filename : bsp_usbh_template.h 25 | * Version : V3.42.01 26 | ********************************************************************************************************* 27 | */ 28 | 29 | /* 30 | ********************************************************************************************************* 31 | * MODULE 32 | * 33 | * Note(s) : (1) This USB host driver board-specific function header file is protected from multiple 34 | * pre-processor inclusion through use of the USB host configuration module present pre- 35 | * processor macro definition. 36 | ********************************************************************************************************* 37 | */ 38 | 39 | #ifndef BSP_USBH_PRESENT /* See Note #1. */ 40 | #define BSP_USBH_PRESENT 41 | 42 | 43 | /* 44 | ********************************************************************************************************* 45 | * INCLUDE FILES 46 | ********************************************************************************************************* 47 | */ 48 | 49 | #include "usbh_hcd_template.h" 50 | #include "../../Source/usbh_core.h" 51 | 52 | 53 | /* 54 | ********************************************************************************************************* 55 | * EXTERNAL C LANGUAGE LINKAGE 56 | * 57 | * Note(s) : (1) C++ compilers MUST 'extern'ally declare ALL C function prototypes & variable/object 58 | * declarations for correct C language linkage. 59 | ********************************************************************************************************* 60 | */ 61 | 62 | #ifdef __cplusplus 63 | extern "C" { /* See Note #1. */ 64 | #endif 65 | 66 | 67 | /* 68 | ********************************************************************************************************* 69 | * GLOBAL VARIABLES 70 | ********************************************************************************************************* 71 | */ 72 | 73 | extern USBH_HC_BSP_API USBH_DrvBSP_Template; 74 | 75 | 76 | /* 77 | ********************************************************************************************************* 78 | * EXTERNAL C LANGUAGE LINKAGE END 79 | ********************************************************************************************************* 80 | */ 81 | 82 | #ifdef __cplusplus 83 | } /* End of 'extern'al C lang linkage. */ 84 | #endif 85 | 86 | 87 | /* 88 | ********************************************************************************************************* 89 | * MODULE END 90 | ********************************************************************************************************* 91 | */ 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /HCD/Template/usbh_hcd_template.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * TEMPLATE HOST CONTROLLER DRIVER 21 | * 22 | * Filename : usbh_hcd_template.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | #ifndef USBH_HCD_TEMPLATE_H 28 | #define USBH_HCD_TEMPLATE_H 29 | 30 | 31 | /* 32 | ********************************************************************************************************* 33 | * INCLUDE FILES 34 | ********************************************************************************************************* 35 | */ 36 | 37 | #include "../../Source/usbh_core.h" 38 | 39 | 40 | /* 41 | ********************************************************************************************************* 42 | * EXTERNS 43 | ********************************************************************************************************* 44 | */ 45 | 46 | #ifdef USBH_HCD_TEMPLATE_MODULE 47 | #define USBH_HCD_TEMPLATE_EXT 48 | #else 49 | #define USBH_HCD_TEMPLATE_EXT extern 50 | #endif 51 | 52 | 53 | /* 54 | ********************************************************************************************************* 55 | * DEFINES 56 | ********************************************************************************************************* 57 | */ 58 | 59 | 60 | /* 61 | ********************************************************************************************************* 62 | * DATA TYPES 63 | ********************************************************************************************************* 64 | */ 65 | 66 | 67 | /* 68 | ********************************************************************************************************* 69 | * GLOBAL VARIABLES 70 | ********************************************************************************************************* 71 | */ 72 | 73 | USBH_HCD_TEMPLATE_EXT USBH_HC_DRV_API USBH_TemplateHCD_DrvAPI; 74 | USBH_HCD_TEMPLATE_EXT USBH_HC_RH_API USBH_TemplateHCD_RH_API; 75 | 76 | 77 | /* 78 | ********************************************************************************************************* 79 | * MACROS 80 | ********************************************************************************************************* 81 | */ 82 | 83 | 84 | /* 85 | ********************************************************************************************************* 86 | * FUNCTION PROTOTYPES 87 | ********************************************************************************************************* 88 | */ 89 | 90 | 91 | /* 92 | ********************************************************************************************************* 93 | * CONFIGURATION ERRORS 94 | ********************************************************************************************************* 95 | */ 96 | 97 | 98 | /* 99 | ********************************************************************************************************* 100 | * MODULE END 101 | ********************************************************************************************************* 102 | */ 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | ATTENTION ALL USERS OF THIS REPOSITORY: 2 | 3 | The original work found in this repository is provided by Silicon Labs under the 4 | Apache License, Version 2.0. 5 | 6 | Any third party may contribute derivative works to the original work in which 7 | modifications are clearly identified as being licensed under: 8 | 9 | (1) the Apache License, Version 2.0 or a compatible open source license; or 10 | (2) under a proprietary license with a copy of such license deposited. 11 | 12 | All posted derivative works must clearly identify which license choice has been 13 | elected. 14 | 15 | No such posted derivative works will be considered to be a “Contribution” under 16 | the Apache License, Version 2.0. 17 | 18 | SILICON LABS MAKES NO WARRANTY WITH RESPECT TO ALL POSTED THIRD PARTY CONTENT 19 | AND DISCLAIMS ALL OTHER WARRANTIES OR LIABILITIES, INCLUDING ALL WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, OWNERSHIP, 21 | NON-INFRINGEMENT, AND NON-MISAPPROPRIATION. 22 | 23 | In the event a derivative work is desired to be submitted to Silicon Labs as a 24 | “Contribution” under the Apache License, Version 2.0, a “Contributor” must give 25 | written email notice to micrium@weston-embedded.com. Unless an email response in 26 | the affirmative to accept the derivative work as a “Contribution”, such email 27 | submission should be considered to have not been incorporated into the original 28 | work. 29 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | .. raw:: html 2 | 3 | 4 |

5 | 6 |

7 |
8 | 9 | µC/OS is a full-featured embedded operating system originally developed by Micriµm™. In addition to the two highly popular kernels, µC/OS features support for TCP/IP, USB-Device, USB-Host, and Modbus, as well as a robust File System. 10 | 11 | Since its founding in 1999 as a private company, Micriµm and its team of engineers have offered world-class embedded software components for the most critical and demanding real-time applications. Recognized as having some of the cleanest code in the industry, with easy-to-understand documentation, the Micrium real-time kernels, and software components have successfully been deployed in thousands of products worldwide across a broad range of industries. Micrium’s µC/OS-II™ kernel has been certified for use in safety-critical applications and remains a respected favorite in the medical, aerospace, and industrial markets. µC/OS continues to be the RTOS of choice for engineers requiring the most reliable and trusted solution for their mission-critical applications. 12 | 13 | ---------- 14 | 15 | .. raw:: HTML 16 | 17 | 18 |

19 | 20 |

21 |
22 | 23 | Founded by a team of former Micrium employees, Weston Embedded Solutions is the official custodian for the µC/OS RTOS and Stacks software repository to ensure it remains the trusted choice for embedded engineers around the world. 24 | 25 | ---------- 26 | 27 | Product Documentation and Release Notes 28 | *************** 29 | https://micrium.atlassian.net/ 30 | 31 | Technical Support 32 | ***************** 33 | https://weston-embedded.com/micrium-support 34 | 35 | Example Projects 36 | ********* 37 | https://weston-embedded.com/micrium-examples 38 | 39 | Commercial Licensing Option 40 | ********* 41 | https://weston-embedded.com/products/cesium 42 | 43 | Who to Contact 44 | ********* 45 | https://weston-embedded.com/company/contact -------------------------------------------------------------------------------- /Source/usbh_class.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * USB HOST CLASS OPERATIONS 21 | * 22 | * Filename : usbh_class.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #ifndef USBH_CLASS_MODULE_PRESENT 34 | #define USBH_CLASS_MODULE_PRESENT 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | #include "usbh_core.h" 44 | 45 | 46 | /* 47 | ********************************************************************************************************* 48 | * EXTERNS 49 | ********************************************************************************************************* 50 | */ 51 | 52 | #ifdef USBH_CLASS_MODULE 53 | #define USBH_CLASS_EXT 54 | #else 55 | #define USBH_CLASS_EXT extern 56 | #endif 57 | 58 | 59 | /* 60 | ********************************************************************************************************* 61 | * DEFINES 62 | ********************************************************************************************************* 63 | */ 64 | 65 | /* 66 | ********************************************************************************************************* 67 | * CLASS DEVICE STATE 68 | ********************************************************************************************************* 69 | */ 70 | 71 | #define USBH_CLASS_DEV_STATE_NONE 0u 72 | #define USBH_CLASS_DEV_STATE_CONN 1u 73 | #define USBH_CLASS_DEV_STATE_DISCONN 2u 74 | #define USBH_CLASS_DEV_STATE_SUSPEND 3u 75 | 76 | 77 | /* 78 | ********************************************************************************************************* 79 | * CLASS DRIVER TYPE 80 | ********************************************************************************************************* 81 | */ 82 | 83 | #define USBH_CLASS_DRV_TYPE_NONE 0u 84 | #define USBH_CLASS_DRV_TYPE_IF_CLASS_DRV 1u 85 | #define USBH_CLASS_DRV_TYPE_DEV_CLASS_DRV 2u 86 | 87 | 88 | /* 89 | ********************************************************************************************************* 90 | * DATA TYPES 91 | ********************************************************************************************************* 92 | */ 93 | 94 | /* 95 | ********************************************************************************************************* 96 | * CLASS DRIVER API DATA TYPE 97 | ********************************************************************************************************* 98 | */ 99 | 100 | struct usbh_class_drv { 101 | CPU_INT08U *NamePtr; /* Name of the class driver. */ 102 | 103 | void (*GlobalInit) (USBH_ERR *p_err); /* Global initialization function. */ 104 | 105 | void *(*ProbeDev ) (USBH_DEV *p_dev, /* Probe device descriptor. */ 106 | USBH_ERR *p_err); 107 | 108 | void *(*ProbeIF ) (USBH_DEV *p_dev, /* Probe interface descriptor. */ 109 | USBH_IF *p_if, 110 | USBH_ERR *p_err); 111 | 112 | void (*Suspend ) (void *p_class_dev); /* Called when bus suspends. */ 113 | 114 | void (*Resume ) (void *p_class_dev); /* Called when bus resumes. */ 115 | 116 | void (*Disconn ) (void *p_class_dev); /* Called when device is removed. */ 117 | }; 118 | 119 | 120 | /* 121 | ********************************************************************************************************* 122 | * CLASS DRIVER NOTIFICATION DATA TYPE 123 | ********************************************************************************************************* 124 | */ 125 | 126 | typedef void (*USBH_CLASS_NOTIFY_FNCT)(void *p_class_dev, 127 | CPU_INT08U is_conn, 128 | void *p_ctx); 129 | 130 | 131 | /* 132 | ********************************************************************************************************* 133 | * CLASS DRIVER REGISTRATION DATA TYPE 134 | ********************************************************************************************************* 135 | */ 136 | 137 | struct usbh_class_drv_reg { 138 | USBH_CLASS_DRV *ClassDrvPtr; /* Class driver structure */ 139 | USBH_CLASS_NOTIFY_FNCT NotifyFnctPtr; /* Called when device connection status changes */ 140 | void *NotifyArgPtr; /* Context of the notification funtion */ 141 | CPU_INT08U InUse; 142 | }; 143 | 144 | 145 | /* 146 | ********************************************************************************************************* 147 | * GLOBAL VARIABLES 148 | ********************************************************************************************************* 149 | */ 150 | 151 | /* 152 | ********************************************************************************************************* 153 | * REGISTERED USB CLASS DRIVERS LIST 154 | ********************************************************************************************************* 155 | */ 156 | 157 | USBH_CLASS_EXT USBH_CLASS_DRV_REG USBH_ClassDrvList[USBH_CFG_MAX_NBR_CLASS_DRVS]; 158 | 159 | 160 | /* 161 | ********************************************************************************************************* 162 | * MACROS 163 | ********************************************************************************************************* 164 | */ 165 | 166 | 167 | /* 168 | ********************************************************************************************************* 169 | * FUNCTION PROTOTYPES 170 | ********************************************************************************************************* 171 | */ 172 | 173 | USBH_ERR USBH_ClassDrvReg (USBH_CLASS_DRV *p_class_drv, 174 | USBH_CLASS_NOTIFY_FNCT class_notify_fnct, 175 | void *p_class_notify_ctx); 176 | 177 | USBH_ERR USBH_ClassDrvUnreg (USBH_CLASS_DRV *p_class_drv); 178 | 179 | void USBH_ClassSuspend (USBH_DEV *p_dev); 180 | 181 | void USBH_ClassResume (USBH_DEV *p_dev); 182 | 183 | USBH_ERR USBH_ClassDrvConn (USBH_DEV *p_dev); 184 | 185 | void USBH_ClassDrvDisconn(USBH_DEV *p_dev); 186 | 187 | 188 | /* 189 | ********************************************************************************************************* 190 | * CONFIGURATION ERRORS 191 | ********************************************************************************************************* 192 | */ 193 | 194 | 195 | /* 196 | ********************************************************************************************************* 197 | * MODULE END 198 | ********************************************************************************************************* 199 | */ 200 | 201 | #endif 202 | -------------------------------------------------------------------------------- /Source/usbh_hub.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * USB HOST HUB OPERATIONS 21 | * 22 | * Filename : usbh_hub.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | #ifndef USBH_HUB_MODULE_PRESENT 34 | #define USBH_HUB_MODULE_PRESENT 35 | 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | #include "usbh_core.h" 44 | 45 | 46 | /* 47 | ********************************************************************************************************* 48 | * EXTERNS 49 | ********************************************************************************************************* 50 | */ 51 | 52 | #ifdef USBH_HUB_MODULE 53 | #define USBH_HUB_EXT 54 | #else 55 | #define USBH_HUB_EXT extern 56 | #endif 57 | 58 | 59 | /* 60 | ********************************************************************************************************* 61 | * DEFINES 62 | ********************************************************************************************************* 63 | */ 64 | 65 | 66 | /* 67 | ********************************************************************************************************* 68 | * DATA TYPES 69 | ********************************************************************************************************* 70 | */ 71 | 72 | 73 | /* 74 | ********************************************************************************************************* 75 | * GLOBAL VARIABLES 76 | ********************************************************************************************************* 77 | */ 78 | 79 | extern USBH_CLASS_DRV USBH_HUB_Drv; 80 | 81 | 82 | /* 83 | ********************************************************************************************************* 84 | * MACROS 85 | ********************************************************************************************************* 86 | */ 87 | 88 | 89 | /* 90 | ********************************************************************************************************* 91 | * FUNCTION PROTOTYPES 92 | ********************************************************************************************************* 93 | */ 94 | 95 | USBH_ERR USBH_HUB_PortEn (USBH_HUB_DEV *p_hub_dev, 96 | CPU_INT16U port_nbr); 97 | 98 | USBH_ERR USBH_HUB_PortDis (USBH_HUB_DEV *p_hub_dev, 99 | CPU_INT16U port_nbr); 100 | 101 | USBH_ERR USBH_HUB_PortSuspendSet(USBH_HUB_DEV *p_hub_dev, 102 | CPU_INT16U port_nbr); 103 | 104 | void USBH_HUB_ClassNotify (void *p_class_dev, 105 | CPU_INT08U state, 106 | void *p_ctx); 107 | 108 | CPU_INT32U USBH_HUB_RH_CtrlReq (USBH_HC *p_hc, 109 | CPU_INT08U b_req, 110 | CPU_INT08U bm_req_type, 111 | CPU_INT16U w_val, 112 | CPU_INT16U w_ix, 113 | void *p_buf, 114 | CPU_INT32U buf_len, 115 | USBH_ERR *p_err); 116 | 117 | void USBH_HUB_RH_Event (USBH_DEV *p_dev); 118 | 119 | void USBH_HUB_ParseHubDesc (USBH_HUB_DESC *p_hub_desc, 120 | void *p_buf_src); 121 | 122 | void USBH_HUB_FmtHubDesc (USBH_HUB_DESC *p_hub_desc, 123 | void *p_buf_dest); 124 | 125 | void USBH_HUB_EventTask (void *p_arg); 126 | 127 | 128 | /* 129 | ********************************************************************************************************* 130 | * CONFIGURATION ERRORS 131 | ********************************************************************************************************* 132 | */ 133 | 134 | 135 | /* 136 | ********************************************************************************************************* 137 | * MODULE END 138 | ********************************************************************************************************* 139 | */ 140 | 141 | #endif 142 | -------------------------------------------------------------------------------- /Source/usbh_os.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/USB-Host 4 | * The Embedded USB Host Stack 5 | * 6 | * Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com 7 | * 8 | * SPDX-License-Identifier: APACHE-2.0 9 | * 10 | * This software is subject to an open source license and is distributed by 11 | * Silicon Laboratories Inc. pursuant to the terms of the Apache License, 12 | * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. 13 | * 14 | ********************************************************************************************************* 15 | */ 16 | 17 | /* 18 | ********************************************************************************************************* 19 | * 20 | * USB HOST OS OPERATIONS 21 | * 22 | * Filename : usb_os.h 23 | * Version : V3.42.01 24 | ********************************************************************************************************* 25 | */ 26 | 27 | /* 28 | ********************************************************************************************************* 29 | * MODULE 30 | ********************************************************************************************************* 31 | */ 32 | 33 | 34 | #ifndef USBH_OS_H 35 | #define USBH_OS_H 36 | 37 | /* 38 | ********************************************************************************************************* 39 | * INCLUDE FILES 40 | ********************************************************************************************************* 41 | */ 42 | 43 | 44 | #include 45 | #include 46 | #include 47 | #include "usbh_err.h" 48 | 49 | 50 | /* 51 | ********************************************************************************************************* 52 | * EXTERNS 53 | ********************************************************************************************************* 54 | */ 55 | 56 | 57 | #ifdef USBH_OS_MODULE 58 | #define USBH_OS_EXT 59 | #else 60 | #define USBH_OS_EXT extern 61 | #endif 62 | 63 | /* 64 | ********************************************************************************************************* 65 | * DEFINES 66 | ********************************************************************************************************* 67 | */ 68 | 69 | 70 | /* 71 | ********************************************************************************************************* 72 | * DATA TYPES 73 | ********************************************************************************************************* 74 | */ 75 | 76 | typedef CPU_INT32U USBH_HSEM; /* Handle on semaphores. */ 77 | typedef CPU_INT32U USBH_HMUTEX; /* Handle on mutex. */ 78 | typedef CPU_INT32U USBH_HTASK; /* Handle on tasks. */ 79 | typedef CPU_INT32U USBH_HQUEUE; /* Handle on queues. */ 80 | typedef CPU_INT32U USBH_HTMR; /* Handle on timers. */ 81 | 82 | typedef void (*USBH_TASK_FNCT)(void *data); /* Task function. */ 83 | 84 | /* 85 | ********************************************************************************************************* 86 | * GLOBAL VARIABLES 87 | ********************************************************************************************************* 88 | */ 89 | 90 | 91 | /* 92 | ********************************************************************************************************* 93 | * MACRO'S 94 | ********************************************************************************************************* 95 | */ 96 | 97 | 98 | /* 99 | ********************************************************************************************************* 100 | * FUNCTION PROTOTYPES 101 | ********************************************************************************************************* 102 | */ 103 | 104 | USBH_ERR USBH_OS_LayerInit (void); 105 | /* --------------- DELAY TASK FUNCTIONS --------------- */ 106 | void USBH_OS_DlyMS (CPU_INT32U dly); 107 | 108 | void USBH_OS_DlyUS (CPU_INT32U dly); 109 | 110 | /* ----------------- MUTEX FUNCTIONS ------------------ */ 111 | USBH_ERR USBH_OS_MutexCreate (USBH_HMUTEX *p_mutex); 112 | 113 | USBH_ERR USBH_OS_MutexLock (USBH_HMUTEX mutex); 114 | 115 | USBH_ERR USBH_OS_MutexUnlock (USBH_HMUTEX mutex); 116 | 117 | USBH_ERR USBH_OS_MutexDestroy (USBH_HMUTEX mutex); 118 | 119 | /* --------------- SEMAPHORE FUNCTIONS ---------------- */ 120 | USBH_ERR USBH_OS_SemCreate (USBH_HSEM *p_sem, 121 | CPU_INT32U cnt); 122 | 123 | USBH_ERR USBH_OS_SemWait (USBH_HSEM sem, 124 | CPU_INT32U timeout); 125 | 126 | USBH_ERR USBH_OS_SemWaitAbort (USBH_HSEM sem); 127 | 128 | USBH_ERR USBH_OS_SemPost (USBH_HSEM sem); 129 | 130 | USBH_ERR USBH_OS_SemDestroy (USBH_HSEM sem); 131 | 132 | /* ------------------ TASK FUNCTIONS ------------------ */ 133 | USBH_ERR USBH_OS_TaskCreate (CPU_CHAR *p_name, 134 | CPU_INT32U prio, 135 | USBH_TASK_FNCT task_fnct, 136 | void *p_data, 137 | CPU_INT32U *p_stk, 138 | CPU_INT32U stk_size, 139 | USBH_HTASK *p_task); 140 | 141 | /* --------------- MSG QUEUE FUNCTIONS ---------------- */ 142 | USBH_HQUEUE USBH_OS_MsgQueueCreate (void **p_start, 143 | CPU_INT16U size, 144 | USBH_ERR *p_err); 145 | 146 | USBH_ERR USBH_OS_MsgQueuePut (USBH_HQUEUE msg_q, 147 | void *p_msg); 148 | 149 | void *USBH_OS_MsgQueueGet (USBH_HQUEUE msg_q, 150 | CPU_INT32U timeout, 151 | USBH_ERR *p_err); 152 | 153 | /* ----------- INTERNAL USE TIMER FUNCTIONS ----------- */ 154 | USBH_HTMR USBH_OS_TmrCreate (CPU_CHAR *p_name, 155 | CPU_INT32U interval_ms, 156 | void (*p_callback)(void *p_tmr, void *p_arg), 157 | void *p_callback_arg, 158 | USBH_ERR *p_err); 159 | 160 | USBH_ERR USBH_OS_TmrStart (USBH_HTMR tmr); 161 | 162 | USBH_ERR USBH_OS_TmrDel (USBH_HTMR tmr); 163 | 164 | /* ------------------- MISCELLANEOUS ------------------ */ 165 | void *USBH_OS_VirToBus (void *x); 166 | 167 | void *USBH_OS_BusToVir (void *x); 168 | 169 | 170 | /* 171 | ********************************************************************************************************* 172 | * CONFIGURATION ERRORS 173 | ********************************************************************************************************* 174 | */ 175 | 176 | 177 | /* 178 | ********************************************************************************************************* 179 | * MODULE END 180 | ********************************************************************************************************* 181 | */ 182 | #endif 183 | --------------------------------------------------------------------------------