Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of F401RE-USBHost by
USBHALHost_F401RE.h
00001 #pragma once 00002 #include "mbed.h" 00003 #include "USBHostTypes.h" 00004 #include "USBEndpoint.h" 00005 00006 class HC { 00007 static const uint8_t DIR_IN = 1; 00008 static const uint8_t DIR_OUT = 0; 00009 00010 public: 00011 HC(); 00012 HC(int ch); 00013 ~HC(); 00014 HAL_StatusTypeDef Init(uint8_t epnum, uint8_t dev_address, uint8_t speed, uint8_t ep_type, uint16_t mps); 00015 HAL_StatusTypeDef SubmitRequest(uint8_t* pbuff, uint16_t length, bool setup = false); 00016 HCD_URBStateTypeDef GetURBState(); 00017 HCD_HCStateTypeDef GetState(); 00018 uint32_t GetXferCount(); 00019 void SetToggle(uint8_t toggle); 00020 00021 static uint8_t slot; 00022 00023 private: 00024 int _ch; 00025 uint8_t _ep_addr; 00026 uint8_t _ep_type; 00027 }; 00028 00029 class USBHALHost { 00030 public: 00031 uint8_t LastStatus; 00032 uint8_t prev_LastStatus; 00033 00034 protected: 00035 USBHALHost(); 00036 void init(); 00037 virtual bool addDevice(USBDeviceConnected* parent, int port, bool lowSpeed) = 0; 00038 int token_setup(USBEndpoint* ep, SETUP_PACKET* setup, uint16_t wLength = 0); 00039 int token_iso_in(USBEndpoint* ep, uint8_t* data, int size); 00040 int multi_token_in(USBEndpoint* ep, uint8_t* data = NULL, size_t total = 0, bool block = true); 00041 int multi_token_out(USBEndpoint* ep, const uint8_t* data = NULL, size_t total = 0); 00042 void multi_token_inNB(USBEndpoint* ep, uint8_t* data, int size); 00043 USB_TYPE multi_token_inNB_result(USBEndpoint* ep); 00044 void setToggle(USBEndpoint* ep, uint8_t toggle); 00045 00046 private: 00047 int token_in(USBEndpoint* ep, uint8_t* data = NULL, int size = 0, int retryLimit = 10); 00048 int token_out(USBEndpoint* ep, const uint8_t* data = NULL, int size = 0, int retryLimit = 10); 00049 int token_ctl_in(USBEndpoint* ep, uint8_t* data, int size, int retryLimit); 00050 int token_int_in(USBEndpoint* ep, uint8_t* data, int size); 00051 int token_blk_in(USBEndpoint* ep, uint8_t* data, int size, int retryLimit); 00052 int token_ctl_out(USBEndpoint* ep, const uint8_t* data, int size, int retryLimit); 00053 int token_int_out(USBEndpoint* ep, const uint8_t* data, int size); 00054 int token_blk_out(USBEndpoint* ep, const uint8_t* data, int size, int retryLimit); 00055 bool wait_attach(); 00056 static USBHALHost * instHost; 00057 }; 00058
Generated on Tue Jul 12 2022 21:43:28 by
1.7.2
