Added TARGET_DISCO_F469NI in USBHOST\USBHost\TARGET_STM\USBHALHost_STM_TARGET.h
Dependents: DISCO-F469NI_USB_Disk STM32F4xx_USB_Memory
Fork of USBHOST by
USBHost/USBHALHost.h@8:3e7a33f81048, 2020-01-04 (annotated)
- Committer:
- kenjiArai
- Date:
- Sat Jan 04 23:30:59 2020 +0000
- Revision:
- 8:3e7a33f81048
- Parent:
- 5:fc157e6bd5a5
updated for STM32F4xx
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1 | /* mbed USBHost Library |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2 | * Copyright (c) 2006-2013 ARM Limited |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 3 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 5 | * you may not use this file except in compliance with the License. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 6 | * You may obtain a copy of the License at |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 7 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 9 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 10 | * Unless required by applicable law or agreed to in writing, software |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 13 | * See the License for the specific language governing permissions and |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 14 | * limitations under the License. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 15 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 16 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 17 | #ifndef USBHALHOST_H |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 18 | #define USBHALHOST_H |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 19 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 20 | #include "USBHostTypes.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 21 | #include "USBHostConf.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 22 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 23 | class USBHostHub; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 24 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 25 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 26 | * USBHALHost class |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 27 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 28 | class USBHALHost { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 29 | protected: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 30 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 31 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 32 | * Constructor |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 33 | * init variables and memory where will be stored HCCA, ED and TD |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 34 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 35 | USBHALHost(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 36 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 37 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 38 | * Initialize host controller. Enable USB interrupts. This part is not in the constructor because, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 39 | * this function calls a virtual method if a device is already connected |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 40 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 41 | void init(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 42 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 43 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 44 | * reset the root hub |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 45 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 46 | void resetRootHub(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 47 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 48 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 49 | * return the value contained in the control HEAD ED register |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 50 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 51 | * @returns address of the control Head ED |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 52 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 53 | uint32_t controlHeadED(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 54 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 55 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 56 | * return the value contained in the bulk HEAD ED register |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 57 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 58 | * @returns address of the bulk head ED |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 59 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 60 | uint32_t bulkHeadED(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 61 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 62 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 63 | * return the value of the head interrupt ED contained in the HCCA |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 64 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 65 | * @returns address of the head interrupt ED contained in the HCCA |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 66 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 67 | uint32_t interruptHeadED(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 68 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 69 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 70 | * Update the head ED for control transfers |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 71 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 72 | void updateControlHeadED(uint32_t addr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 73 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 74 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 75 | * Update the head ED for bulk transfers |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 76 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 77 | void updateBulkHeadED(uint32_t addr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 78 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 79 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 80 | * Update the head ED for interrupt transfers |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 81 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 82 | void updateInterruptHeadED(uint32_t addr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 83 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 84 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 85 | * Enable List for the specified endpoint type |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 86 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 87 | * @param type enable the list of ENDPOINT_TYPE type |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 88 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 89 | void enableList(ENDPOINT_TYPE type); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 90 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 91 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 92 | * Disable List for the specified endpoint type |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 93 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 94 | * @param type disable the list of ENDPOINT_TYPE type |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 95 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 96 | bool disableList(ENDPOINT_TYPE type); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 97 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 98 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 99 | * Virtual method called when a device has been connected |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 100 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 101 | * @param hub hub number of the device |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 102 | * @param port port number of the device |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 103 | * @param lowSpeed 1 if low speed, 0 otherwise |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 104 | * @param hub_parent reference to the hub where the device is connected (NULL if the hub parent is the root hub) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 105 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 106 | virtual void deviceConnected(int hub, int port, bool lowSpeed, USBHostHub * hub_parent = NULL) = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 107 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 108 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 109 | * Virtual method called when a device has been disconnected |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 110 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 111 | * @param hub hub number of the device |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 112 | * @param port port number of the device |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 113 | * @param hub_parent reference to the hub where the device is connected (NULL if the hub parent is the root hub) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 114 | * @param addr list of the TDs which have been completed to dequeue freed TDs |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 115 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 116 | virtual void deviceDisconnected(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr) = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 117 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 118 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 119 | * Virtual method called when a transfer has been completed |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 120 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 121 | * @param addr list of the TDs which have been completed |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 122 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 123 | virtual void transferCompleted(volatile uint32_t addr) = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 124 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 125 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 126 | * Find a memory section for a new ED |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 127 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 128 | * @returns the address of the new ED |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 129 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 130 | volatile uint8_t * getED(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 131 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 132 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 133 | * Find a memory section for a new TD |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 134 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 135 | * @returns the address of the new TD |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 136 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 137 | volatile uint8_t * getTD(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 138 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 139 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 140 | * Release a previous memory section reserved for an ED |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 141 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 142 | * @param ed address of the ED |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 143 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 144 | void freeED(volatile uint8_t * ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 145 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 146 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 147 | * Release a previous memory section reserved for an TD |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 148 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 149 | * @param td address of the TD |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 150 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 151 | void freeTD(volatile uint8_t * td); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 152 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 153 | private: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 154 | static void _usbisr(void); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 155 | void UsbIrqhandler(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 156 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 157 | void memInit(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 158 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 159 | HCCA volatile * usb_hcca; //256 bytes aligned |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 160 | uint8_t volatile * usb_edBuf; //4 bytes aligned |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 161 | uint8_t volatile * usb_tdBuf; //4 bytes aligned |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 162 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 163 | static USBHALHost * instHost; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 164 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 165 | bool volatile edBufAlloc[MAX_ENDPOINT]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 166 | bool volatile tdBufAlloc[MAX_TD]; |
frq08711@LMECWL0871.LME.ST.COM | 5:fc157e6bd5a5 | 167 | #ifdef USBHOST_OTHER |
frq08711@LMECWL0871.LME.ST.COM | 5:fc157e6bd5a5 | 168 | int control_disable; |
frq08711@LMECWL0871.LME.ST.COM | 5:fc157e6bd5a5 | 169 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 5:fc157e6bd5a5 | 170 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 171 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 172 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 173 | #endif |