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 USBHost_DISCO-F746NG by
USBHost/TARGET_STM32F7/USBHALHost_F746NG.h@24:5396b6a93262, 2016-06-13 (annotated)
- Committer:
- DieterGraef
- Date:
- Mon Jun 13 17:21:07 2016 +0000
- Revision:
- 24:5396b6a93262
- Child:
- 25:7d6d9fc471bf
USB Host for STM32F746 DISCO Board. At the moment you can only use either the High Speed Port or the Fast Speed Port.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DieterGraef | 24:5396b6a93262 | 1 | |
DieterGraef | 24:5396b6a93262 | 2 | #pragma once |
DieterGraef | 24:5396b6a93262 | 3 | #include "mbed.h" |
DieterGraef | 24:5396b6a93262 | 4 | #include "USBHostTypes.h" |
DieterGraef | 24:5396b6a93262 | 5 | #include "USBEndpoint.h" |
DieterGraef | 24:5396b6a93262 | 6 | #define USB_FastSpeed 0 |
DieterGraef | 24:5396b6a93262 | 7 | #define USB_HighSpeed 1 |
DieterGraef | 24:5396b6a93262 | 8 | |
DieterGraef | 24:5396b6a93262 | 9 | class HC { |
DieterGraef | 24:5396b6a93262 | 10 | static const uint8_t DIR_IN = 1; |
DieterGraef | 24:5396b6a93262 | 11 | static const uint8_t DIR_OUT = 0; |
DieterGraef | 24:5396b6a93262 | 12 | |
DieterGraef | 24:5396b6a93262 | 13 | public: |
DieterGraef | 24:5396b6a93262 | 14 | HC(HCD_HandleTypeDef* hhcd_USB); |
DieterGraef | 24:5396b6a93262 | 15 | HC(HCD_HandleTypeDef* hhcd_USB,int ch); |
DieterGraef | 24:5396b6a93262 | 16 | ~HC(); |
DieterGraef | 24:5396b6a93262 | 17 | HAL_StatusTypeDef Init(int IF_N,uint8_t epnum, uint8_t dev_address, uint8_t speed, uint8_t ep_type, uint16_t mps); |
DieterGraef | 24:5396b6a93262 | 18 | HAL_StatusTypeDef SubmitRequest(int IF_N,uint8_t* pbuff, uint16_t length, bool setup = false); |
DieterGraef | 24:5396b6a93262 | 19 | HCD_URBStateTypeDef GetURBState(); |
DieterGraef | 24:5396b6a93262 | 20 | HCD_HCStateTypeDef GetState(); |
DieterGraef | 24:5396b6a93262 | 21 | uint32_t GetXferCount(); |
DieterGraef | 24:5396b6a93262 | 22 | void SetToggle(uint8_t toggle); |
DieterGraef | 24:5396b6a93262 | 23 | |
DieterGraef | 24:5396b6a93262 | 24 | static uint8_t slot; |
DieterGraef | 24:5396b6a93262 | 25 | HCD_HandleTypeDef* hc_USB; |
DieterGraef | 24:5396b6a93262 | 26 | private: |
DieterGraef | 24:5396b6a93262 | 27 | int _ch; |
DieterGraef | 24:5396b6a93262 | 28 | uint8_t _ep_addr; |
DieterGraef | 24:5396b6a93262 | 29 | uint8_t _ep_type; |
DieterGraef | 24:5396b6a93262 | 30 | }; |
DieterGraef | 24:5396b6a93262 | 31 | |
DieterGraef | 24:5396b6a93262 | 32 | class USBHALHost { |
DieterGraef | 24:5396b6a93262 | 33 | public: |
DieterGraef | 24:5396b6a93262 | 34 | uint8_t LastStatus; |
DieterGraef | 24:5396b6a93262 | 35 | uint8_t prev_LastStatus; |
DieterGraef | 24:5396b6a93262 | 36 | int IF_N; |
DieterGraef | 24:5396b6a93262 | 37 | HCD_HandleTypeDef hhcd_USB; |
DieterGraef | 24:5396b6a93262 | 38 | |
DieterGraef | 24:5396b6a93262 | 39 | protected: |
DieterGraef | 24:5396b6a93262 | 40 | USBHALHost(int InterfaceNumber); |
DieterGraef | 24:5396b6a93262 | 41 | void init(); |
DieterGraef | 24:5396b6a93262 | 42 | virtual bool addDevice(USBDeviceConnected* parent, int port, bool lowSpeed) = 0; |
DieterGraef | 24:5396b6a93262 | 43 | int token_setup(USBEndpoint* ep, SETUP_PACKET* setup, uint16_t wLength = 0); |
DieterGraef | 24:5396b6a93262 | 44 | int token_iso_in(USBEndpoint* ep, uint8_t* data, int size); |
DieterGraef | 24:5396b6a93262 | 45 | int multi_token_in(USBEndpoint* ep, uint8_t* data = NULL, size_t total = 0, bool block = true); |
DieterGraef | 24:5396b6a93262 | 46 | int multi_token_out(USBEndpoint* ep, const uint8_t* data = NULL, size_t total = 0); |
DieterGraef | 24:5396b6a93262 | 47 | void multi_token_inNB(USBEndpoint* ep, uint8_t* data, int size); |
DieterGraef | 24:5396b6a93262 | 48 | USB_TYPE multi_token_inNB_result(USBEndpoint* ep); |
DieterGraef | 24:5396b6a93262 | 49 | void setToggle(USBEndpoint* ep, uint8_t toggle); |
DieterGraef | 24:5396b6a93262 | 50 | int epint_setup(USBEndpoint* ep); |
DieterGraef | 24:5396b6a93262 | 51 | |
DieterGraef | 24:5396b6a93262 | 52 | |
DieterGraef | 24:5396b6a93262 | 53 | private: |
DieterGraef | 24:5396b6a93262 | 54 | |
DieterGraef | 24:5396b6a93262 | 55 | int token_in(USBEndpoint* ep, uint8_t* data = NULL, int size = 0, int retryLimit = 10); |
DieterGraef | 24:5396b6a93262 | 56 | int token_out(USBEndpoint* ep, const uint8_t* data = NULL, int size = 0, int retryLimit = 10); |
DieterGraef | 24:5396b6a93262 | 57 | int token_ctl_in(USBEndpoint* ep, uint8_t* data, int size, int retryLimit); |
DieterGraef | 24:5396b6a93262 | 58 | int token_int_in(USBEndpoint* ep, uint8_t* data, int size); |
DieterGraef | 24:5396b6a93262 | 59 | int token_blk_in(USBEndpoint* ep, uint8_t* data, int size, int retryLimit); |
DieterGraef | 24:5396b6a93262 | 60 | int token_ctl_out(USBEndpoint* ep, const uint8_t* data, int size, int retryLimit); |
DieterGraef | 24:5396b6a93262 | 61 | int token_int_out(USBEndpoint* ep, const uint8_t* data, int size); |
DieterGraef | 24:5396b6a93262 | 62 | int token_blk_out(USBEndpoint* ep, const uint8_t* data, int size, int retryLimit); |
DieterGraef | 24:5396b6a93262 | 63 | bool wait_attach(); |
DieterGraef | 24:5396b6a93262 | 64 | static USBHALHost * instHost; |
DieterGraef | 24:5396b6a93262 | 65 | HCD_HandleTypeDef* hhcd; |
DieterGraef | 24:5396b6a93262 | 66 | void usbisr(void); |
DieterGraef | 24:5396b6a93262 | 67 | static void _usbisr(void); |
DieterGraef | 24:5396b6a93262 | 68 | }; |
DieterGraef | 24:5396b6a93262 | 69 | |
DieterGraef | 24:5396b6a93262 | 70 |