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
targets/TARGET_STM/USBHALHost_STM.cpp@8:3e7a33f81048, 2020-01-04 (annotated)
- Committer:
- kenjiArai
- Date:
- Sat Jan 04 23:30:59 2020 +0000
- Revision:
- 8:3e7a33f81048
updated for STM32F4xx
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kenjiArai | 8:3e7a33f81048 | 1 | /* mbed USBHost Library |
kenjiArai | 8:3e7a33f81048 | 2 | * Copyright (c) 2006-2013 ARM Limited |
kenjiArai | 8:3e7a33f81048 | 3 | * |
kenjiArai | 8:3e7a33f81048 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kenjiArai | 8:3e7a33f81048 | 5 | * you may not use this file except in compliance with the License. |
kenjiArai | 8:3e7a33f81048 | 6 | * You may obtain a copy of the License at |
kenjiArai | 8:3e7a33f81048 | 7 | * |
kenjiArai | 8:3e7a33f81048 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
kenjiArai | 8:3e7a33f81048 | 9 | * |
kenjiArai | 8:3e7a33f81048 | 10 | * Unless required by applicable law or agreed to in writing, software |
kenjiArai | 8:3e7a33f81048 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
kenjiArai | 8:3e7a33f81048 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kenjiArai | 8:3e7a33f81048 | 13 | * See the License for the specific language governing permissions and |
kenjiArai | 8:3e7a33f81048 | 14 | * limitations under the License. |
kenjiArai | 8:3e7a33f81048 | 15 | */ |
kenjiArai | 8:3e7a33f81048 | 16 | |
kenjiArai | 8:3e7a33f81048 | 17 | #ifdef TARGET_STM |
kenjiArai | 8:3e7a33f81048 | 18 | #include "mbed.h" |
kenjiArai | 8:3e7a33f81048 | 19 | #include "USBHALHost.h" |
kenjiArai | 8:3e7a33f81048 | 20 | #include "dbg.h" |
kenjiArai | 8:3e7a33f81048 | 21 | #include "pinmap.h" |
kenjiArai | 8:3e7a33f81048 | 22 | |
kenjiArai | 8:3e7a33f81048 | 23 | #include "USBHALHost_STM.h" |
kenjiArai | 8:3e7a33f81048 | 24 | |
kenjiArai | 8:3e7a33f81048 | 25 | void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd) |
kenjiArai | 8:3e7a33f81048 | 26 | { |
kenjiArai | 8:3e7a33f81048 | 27 | USBHALHost_Private_t *priv = (USBHALHost_Private_t *)(hhcd->pData); |
kenjiArai | 8:3e7a33f81048 | 28 | USBHALHost *obj = priv->inst; |
kenjiArai | 8:3e7a33f81048 | 29 | void (USBHALHost::*func)(int hub, int port, bool lowSpeed, USBHostHub * hub_parent) = priv->deviceConnected; |
kenjiArai | 8:3e7a33f81048 | 30 | (obj->*func)(0, 1, 0, NULL); |
kenjiArai | 8:3e7a33f81048 | 31 | } |
kenjiArai | 8:3e7a33f81048 | 32 | void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) |
kenjiArai | 8:3e7a33f81048 | 33 | { |
kenjiArai | 8:3e7a33f81048 | 34 | USBHALHost_Private_t *priv = (USBHALHost_Private_t *)(hhcd->pData); |
kenjiArai | 8:3e7a33f81048 | 35 | USBHALHost *obj = priv->inst; |
kenjiArai | 8:3e7a33f81048 | 36 | void (USBHALHost::*func1)(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr) = priv->deviceDisconnected; |
kenjiArai | 8:3e7a33f81048 | 37 | (obj->*func1)(0, 1, (USBHostHub *)NULL, 0); |
kenjiArai | 8:3e7a33f81048 | 38 | } |
kenjiArai | 8:3e7a33f81048 | 39 | int HAL_HCD_HC_GetDirection(HCD_HandleTypeDef *hhcd, uint8_t chnum) |
kenjiArai | 8:3e7a33f81048 | 40 | { |
kenjiArai | 8:3e7a33f81048 | 41 | /* useful for transmission */ |
kenjiArai | 8:3e7a33f81048 | 42 | return hhcd->hc[chnum].ep_is_in; |
kenjiArai | 8:3e7a33f81048 | 43 | } |
kenjiArai | 8:3e7a33f81048 | 44 | |
kenjiArai | 8:3e7a33f81048 | 45 | uint32_t HAL_HCD_HC_GetMaxPacket(HCD_HandleTypeDef *hhcd, uint8_t chnum) |
kenjiArai | 8:3e7a33f81048 | 46 | { |
kenjiArai | 8:3e7a33f81048 | 47 | /* useful for transmission */ |
kenjiArai | 8:3e7a33f81048 | 48 | return hhcd->hc[chnum].max_packet; |
kenjiArai | 8:3e7a33f81048 | 49 | } |
kenjiArai | 8:3e7a33f81048 | 50 | |
kenjiArai | 8:3e7a33f81048 | 51 | void HAL_HCD_EnableInt(HCD_HandleTypeDef *hhcd, uint8_t chnum) |
kenjiArai | 8:3e7a33f81048 | 52 | { |
kenjiArai | 8:3e7a33f81048 | 53 | USB_OTG_GlobalTypeDef *USBx = hhcd->Instance; |
kenjiArai | 8:3e7a33f81048 | 54 | USBx_HOST->HAINTMSK |= (1 << chnum); |
kenjiArai | 8:3e7a33f81048 | 55 | } |
kenjiArai | 8:3e7a33f81048 | 56 | |
kenjiArai | 8:3e7a33f81048 | 57 | |
kenjiArai | 8:3e7a33f81048 | 58 | void HAL_HCD_DisableInt(HCD_HandleTypeDef *hhcd, uint8_t chnum) |
kenjiArai | 8:3e7a33f81048 | 59 | { |
kenjiArai | 8:3e7a33f81048 | 60 | USB_OTG_GlobalTypeDef *USBx = hhcd->Instance; |
kenjiArai | 8:3e7a33f81048 | 61 | USBx_HOST->HAINTMSK &= ~(1 << chnum); |
kenjiArai | 8:3e7a33f81048 | 62 | } |
kenjiArai | 8:3e7a33f81048 | 63 | uint32_t HAL_HCD_HC_GetType(HCD_HandleTypeDef *hhcd, uint8_t chnum) |
kenjiArai | 8:3e7a33f81048 | 64 | { |
kenjiArai | 8:3e7a33f81048 | 65 | /* useful for transmission */ |
kenjiArai | 8:3e7a33f81048 | 66 | return hhcd->hc[chnum].ep_type; |
kenjiArai | 8:3e7a33f81048 | 67 | } |
kenjiArai | 8:3e7a33f81048 | 68 | |
kenjiArai | 8:3e7a33f81048 | 69 | void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) |
kenjiArai | 8:3e7a33f81048 | 70 | { |
kenjiArai | 8:3e7a33f81048 | 71 | USBHALHost_Private_t *priv = (USBHALHost_Private_t *)(hhcd->pData); |
kenjiArai | 8:3e7a33f81048 | 72 | USBHALHost *obj = priv->inst; |
kenjiArai | 8:3e7a33f81048 | 73 | void (USBHALHost::*func)(volatile uint32_t addr) = priv->transferCompleted; |
kenjiArai | 8:3e7a33f81048 | 74 | |
kenjiArai | 8:3e7a33f81048 | 75 | uint32_t addr = priv->addr[chnum]; |
kenjiArai | 8:3e7a33f81048 | 76 | uint32_t max_size = HAL_HCD_HC_GetMaxPacket(hhcd, chnum); |
kenjiArai | 8:3e7a33f81048 | 77 | uint32_t type = HAL_HCD_HC_GetType(hhcd, chnum); |
kenjiArai | 8:3e7a33f81048 | 78 | uint32_t dir = HAL_HCD_HC_GetDirection(hhcd, chnum); |
kenjiArai | 8:3e7a33f81048 | 79 | uint32_t length; |
kenjiArai | 8:3e7a33f81048 | 80 | if ((addr != 0)) { |
kenjiArai | 8:3e7a33f81048 | 81 | HCTD *td = (HCTD *)addr; |
kenjiArai | 8:3e7a33f81048 | 82 | |
kenjiArai | 8:3e7a33f81048 | 83 | if ((type == EP_TYPE_BULK) || (type == EP_TYPE_CTRL)) { |
kenjiArai | 8:3e7a33f81048 | 84 | switch (urb_state) { |
kenjiArai | 8:3e7a33f81048 | 85 | case URB_DONE: |
kenjiArai | 8:3e7a33f81048 | 86 | #if defined(MAX_NYET_RETRY) |
kenjiArai | 8:3e7a33f81048 | 87 | td->retry = 0; |
kenjiArai | 8:3e7a33f81048 | 88 | #endif |
kenjiArai | 8:3e7a33f81048 | 89 | if (td->size > max_size) { |
kenjiArai | 8:3e7a33f81048 | 90 | /* enqueue another request */ |
kenjiArai | 8:3e7a33f81048 | 91 | td->currBufPtr += max_size; |
kenjiArai | 8:3e7a33f81048 | 92 | td->size -= max_size; |
kenjiArai | 8:3e7a33f81048 | 93 | length = td->size <= max_size ? td->size : max_size; |
kenjiArai | 8:3e7a33f81048 | 94 | MBED_ASSERT(HAL_HCD_HC_SubmitRequest(hhcd, chnum, dir, type, !td->setup, (uint8_t *) td->currBufPtr, length, 0) == HAL_OK); |
kenjiArai | 8:3e7a33f81048 | 95 | HAL_HCD_EnableInt(hhcd, chnum); |
kenjiArai | 8:3e7a33f81048 | 96 | return; |
kenjiArai | 8:3e7a33f81048 | 97 | } |
kenjiArai | 8:3e7a33f81048 | 98 | break; |
kenjiArai | 8:3e7a33f81048 | 99 | case URB_NOTREADY: |
kenjiArai | 8:3e7a33f81048 | 100 | /* try again */ |
kenjiArai | 8:3e7a33f81048 | 101 | /* abritary limit , to avoid dead lock if other error than |
kenjiArai | 8:3e7a33f81048 | 102 | * slow response is */ |
kenjiArai | 8:3e7a33f81048 | 103 | #if defined(MAX_NYET_RETRY) |
kenjiArai | 8:3e7a33f81048 | 104 | if (td->retry < MAX_NYET_RETRY) { |
kenjiArai | 8:3e7a33f81048 | 105 | /* increment retry counter */ |
kenjiArai | 8:3e7a33f81048 | 106 | td->retry++; |
kenjiArai | 8:3e7a33f81048 | 107 | #endif |
kenjiArai | 8:3e7a33f81048 | 108 | length = td->size <= max_size ? td->size : max_size; |
kenjiArai | 8:3e7a33f81048 | 109 | MBED_ASSERT(HAL_HCD_HC_SubmitRequest(hhcd, chnum, dir, type, !td->setup, (uint8_t *) td->currBufPtr, length, 0) == HAL_OK); |
kenjiArai | 8:3e7a33f81048 | 110 | HAL_HCD_EnableInt(hhcd, chnum); |
kenjiArai | 8:3e7a33f81048 | 111 | return; |
kenjiArai | 8:3e7a33f81048 | 112 | #if defined(MAX_NYET_RETRY) |
kenjiArai | 8:3e7a33f81048 | 113 | } else { |
kenjiArai | 8:3e7a33f81048 | 114 | USB_ERR("urb_state != URB_NOTREADY"); |
kenjiArai | 8:3e7a33f81048 | 115 | } |
kenjiArai | 8:3e7a33f81048 | 116 | #endif |
kenjiArai | 8:3e7a33f81048 | 117 | break; |
kenjiArai | 8:3e7a33f81048 | 118 | } |
kenjiArai | 8:3e7a33f81048 | 119 | } |
kenjiArai | 8:3e7a33f81048 | 120 | if ((type == EP_TYPE_INTR)) { |
kenjiArai | 8:3e7a33f81048 | 121 | /* reply a packet of length NULL, this will be analyse in call back |
kenjiArai | 8:3e7a33f81048 | 122 | * for mouse or hub */ |
kenjiArai | 8:3e7a33f81048 | 123 | td->state = USB_TYPE_IDLE ; |
kenjiArai | 8:3e7a33f81048 | 124 | HAL_HCD_DisableInt(hhcd, chnum); |
kenjiArai | 8:3e7a33f81048 | 125 | |
kenjiArai | 8:3e7a33f81048 | 126 | } else { |
kenjiArai | 8:3e7a33f81048 | 127 | td->state = (urb_state == URB_DONE) ? USB_TYPE_IDLE : USB_TYPE_ERROR; |
kenjiArai | 8:3e7a33f81048 | 128 | } |
kenjiArai | 8:3e7a33f81048 | 129 | td->currBufPtr += HAL_HCD_HC_GetXferCount(hhcd, chnum); |
kenjiArai | 8:3e7a33f81048 | 130 | (obj->*func)(addr); |
kenjiArai | 8:3e7a33f81048 | 131 | } else { |
kenjiArai | 8:3e7a33f81048 | 132 | if (urb_state != 0) { |
kenjiArai | 8:3e7a33f81048 | 133 | USB_DBG_EVENT("spurious %d %d", chnum, urb_state); |
kenjiArai | 8:3e7a33f81048 | 134 | } |
kenjiArai | 8:3e7a33f81048 | 135 | } |
kenjiArai | 8:3e7a33f81048 | 136 | } |
kenjiArai | 8:3e7a33f81048 | 137 | |
kenjiArai | 8:3e7a33f81048 | 138 | USBHALHost *USBHALHost::instHost; |
kenjiArai | 8:3e7a33f81048 | 139 | |
kenjiArai | 8:3e7a33f81048 | 140 | |
kenjiArai | 8:3e7a33f81048 | 141 | void USBHALHost::init() |
kenjiArai | 8:3e7a33f81048 | 142 | { |
kenjiArai | 8:3e7a33f81048 | 143 | |
kenjiArai | 8:3e7a33f81048 | 144 | NVIC_DisableIRQ(USBHAL_IRQn); |
kenjiArai | 8:3e7a33f81048 | 145 | NVIC_SetVector(USBHAL_IRQn, (uint32_t)(_usbisr)); |
kenjiArai | 8:3e7a33f81048 | 146 | HAL_HCD_Init((HCD_HandleTypeDef *) usb_hcca); |
kenjiArai | 8:3e7a33f81048 | 147 | NVIC_EnableIRQ(USBHAL_IRQn); |
kenjiArai | 8:3e7a33f81048 | 148 | control_disable = 0; |
kenjiArai | 8:3e7a33f81048 | 149 | HAL_HCD_Start((HCD_HandleTypeDef *) usb_hcca); |
kenjiArai | 8:3e7a33f81048 | 150 | usb_vbus(1); |
kenjiArai | 8:3e7a33f81048 | 151 | } |
kenjiArai | 8:3e7a33f81048 | 152 | |
kenjiArai | 8:3e7a33f81048 | 153 | uint32_t USBHALHost::controlHeadED() |
kenjiArai | 8:3e7a33f81048 | 154 | { |
kenjiArai | 8:3e7a33f81048 | 155 | return 0xffffffff; |
kenjiArai | 8:3e7a33f81048 | 156 | } |
kenjiArai | 8:3e7a33f81048 | 157 | |
kenjiArai | 8:3e7a33f81048 | 158 | uint32_t USBHALHost::bulkHeadED() |
kenjiArai | 8:3e7a33f81048 | 159 | { |
kenjiArai | 8:3e7a33f81048 | 160 | return 0xffffffff; |
kenjiArai | 8:3e7a33f81048 | 161 | } |
kenjiArai | 8:3e7a33f81048 | 162 | |
kenjiArai | 8:3e7a33f81048 | 163 | uint32_t USBHALHost::interruptHeadED() |
kenjiArai | 8:3e7a33f81048 | 164 | { |
kenjiArai | 8:3e7a33f81048 | 165 | return 0xffffffff; |
kenjiArai | 8:3e7a33f81048 | 166 | } |
kenjiArai | 8:3e7a33f81048 | 167 | |
kenjiArai | 8:3e7a33f81048 | 168 | void USBHALHost::updateBulkHeadED(uint32_t addr) |
kenjiArai | 8:3e7a33f81048 | 169 | { |
kenjiArai | 8:3e7a33f81048 | 170 | } |
kenjiArai | 8:3e7a33f81048 | 171 | |
kenjiArai | 8:3e7a33f81048 | 172 | |
kenjiArai | 8:3e7a33f81048 | 173 | void USBHALHost::updateControlHeadED(uint32_t addr) |
kenjiArai | 8:3e7a33f81048 | 174 | { |
kenjiArai | 8:3e7a33f81048 | 175 | } |
kenjiArai | 8:3e7a33f81048 | 176 | |
kenjiArai | 8:3e7a33f81048 | 177 | void USBHALHost::updateInterruptHeadED(uint32_t addr) |
kenjiArai | 8:3e7a33f81048 | 178 | { |
kenjiArai | 8:3e7a33f81048 | 179 | } |
kenjiArai | 8:3e7a33f81048 | 180 | |
kenjiArai | 8:3e7a33f81048 | 181 | |
kenjiArai | 8:3e7a33f81048 | 182 | void USBHALHost::enableList(ENDPOINT_TYPE type) |
kenjiArai | 8:3e7a33f81048 | 183 | { |
kenjiArai | 8:3e7a33f81048 | 184 | /* react when the 3 lists are requested to be disabled */ |
kenjiArai | 8:3e7a33f81048 | 185 | if (type == CONTROL_ENDPOINT) { |
kenjiArai | 8:3e7a33f81048 | 186 | control_disable--; |
kenjiArai | 8:3e7a33f81048 | 187 | if (control_disable == 0) { |
kenjiArai | 8:3e7a33f81048 | 188 | NVIC_EnableIRQ(USBHAL_IRQn); |
kenjiArai | 8:3e7a33f81048 | 189 | } else { |
kenjiArai | 8:3e7a33f81048 | 190 | printf("reent\n"); |
kenjiArai | 8:3e7a33f81048 | 191 | } |
kenjiArai | 8:3e7a33f81048 | 192 | } |
kenjiArai | 8:3e7a33f81048 | 193 | } |
kenjiArai | 8:3e7a33f81048 | 194 | |
kenjiArai | 8:3e7a33f81048 | 195 | |
kenjiArai | 8:3e7a33f81048 | 196 | bool USBHALHost::disableList(ENDPOINT_TYPE type) |
kenjiArai | 8:3e7a33f81048 | 197 | { |
kenjiArai | 8:3e7a33f81048 | 198 | if (type == CONTROL_ENDPOINT) { |
kenjiArai | 8:3e7a33f81048 | 199 | NVIC_DisableIRQ(USBHAL_IRQn); |
kenjiArai | 8:3e7a33f81048 | 200 | control_disable++; |
kenjiArai | 8:3e7a33f81048 | 201 | if (control_disable > 1) { |
kenjiArai | 8:3e7a33f81048 | 202 | printf("disable reentrance !!!\n"); |
kenjiArai | 8:3e7a33f81048 | 203 | } |
kenjiArai | 8:3e7a33f81048 | 204 | return true; |
kenjiArai | 8:3e7a33f81048 | 205 | } |
kenjiArai | 8:3e7a33f81048 | 206 | return false; |
kenjiArai | 8:3e7a33f81048 | 207 | } |
kenjiArai | 8:3e7a33f81048 | 208 | |
kenjiArai | 8:3e7a33f81048 | 209 | |
kenjiArai | 8:3e7a33f81048 | 210 | void USBHALHost::memInit() |
kenjiArai | 8:3e7a33f81048 | 211 | { |
kenjiArai | 8:3e7a33f81048 | 212 | usb_hcca = (volatile HCD_HandleTypeDef *)usb_buf; |
kenjiArai | 8:3e7a33f81048 | 213 | usb_edBuf = usb_buf + HCCA_SIZE; |
kenjiArai | 8:3e7a33f81048 | 214 | usb_tdBuf = usb_buf + HCCA_SIZE + (MAX_ENDPOINT * ED_SIZE); |
kenjiArai | 8:3e7a33f81048 | 215 | /* init channel */ |
kenjiArai | 8:3e7a33f81048 | 216 | memset((void *)usb_buf, 0, TOTAL_SIZE); |
kenjiArai | 8:3e7a33f81048 | 217 | for (int i = 0; i < MAX_ENDPOINT; i++) { |
kenjiArai | 8:3e7a33f81048 | 218 | HCED *hced = (HCED *)(usb_edBuf + i * ED_SIZE); |
kenjiArai | 8:3e7a33f81048 | 219 | hced->ch_num = i; |
kenjiArai | 8:3e7a33f81048 | 220 | hced->hhcd = (HCCA *) usb_hcca; |
kenjiArai | 8:3e7a33f81048 | 221 | } |
kenjiArai | 8:3e7a33f81048 | 222 | } |
kenjiArai | 8:3e7a33f81048 | 223 | |
kenjiArai | 8:3e7a33f81048 | 224 | volatile uint8_t *USBHALHost::getED() |
kenjiArai | 8:3e7a33f81048 | 225 | { |
kenjiArai | 8:3e7a33f81048 | 226 | for (int i = 0; i < MAX_ENDPOINT; i++) { |
kenjiArai | 8:3e7a33f81048 | 227 | if (!edBufAlloc[i]) { |
kenjiArai | 8:3e7a33f81048 | 228 | edBufAlloc[i] = true; |
kenjiArai | 8:3e7a33f81048 | 229 | return (volatile uint8_t *)(usb_edBuf + i * ED_SIZE); |
kenjiArai | 8:3e7a33f81048 | 230 | } |
kenjiArai | 8:3e7a33f81048 | 231 | } |
kenjiArai | 8:3e7a33f81048 | 232 | perror("Could not allocate ED\r\n"); |
kenjiArai | 8:3e7a33f81048 | 233 | return NULL; //Could not alloc ED |
kenjiArai | 8:3e7a33f81048 | 234 | } |
kenjiArai | 8:3e7a33f81048 | 235 | |
kenjiArai | 8:3e7a33f81048 | 236 | volatile uint8_t *USBHALHost::getTD() |
kenjiArai | 8:3e7a33f81048 | 237 | { |
kenjiArai | 8:3e7a33f81048 | 238 | int i; |
kenjiArai | 8:3e7a33f81048 | 239 | for (i = 0; i < MAX_TD; i++) { |
kenjiArai | 8:3e7a33f81048 | 240 | if (!tdBufAlloc[i]) { |
kenjiArai | 8:3e7a33f81048 | 241 | tdBufAlloc[i] = true; |
kenjiArai | 8:3e7a33f81048 | 242 | return (volatile uint8_t *)(usb_tdBuf + i * TD_SIZE); |
kenjiArai | 8:3e7a33f81048 | 243 | } |
kenjiArai | 8:3e7a33f81048 | 244 | } |
kenjiArai | 8:3e7a33f81048 | 245 | perror("Could not allocate TD\r\n"); |
kenjiArai | 8:3e7a33f81048 | 246 | return NULL; //Could not alloc TD |
kenjiArai | 8:3e7a33f81048 | 247 | } |
kenjiArai | 8:3e7a33f81048 | 248 | |
kenjiArai | 8:3e7a33f81048 | 249 | |
kenjiArai | 8:3e7a33f81048 | 250 | void USBHALHost::freeED(volatile uint8_t *ed) |
kenjiArai | 8:3e7a33f81048 | 251 | { |
kenjiArai | 8:3e7a33f81048 | 252 | int i; |
kenjiArai | 8:3e7a33f81048 | 253 | i = (ed - usb_edBuf) / ED_SIZE; |
kenjiArai | 8:3e7a33f81048 | 254 | edBufAlloc[i] = false; |
kenjiArai | 8:3e7a33f81048 | 255 | } |
kenjiArai | 8:3e7a33f81048 | 256 | |
kenjiArai | 8:3e7a33f81048 | 257 | void USBHALHost::freeTD(volatile uint8_t *td) |
kenjiArai | 8:3e7a33f81048 | 258 | { |
kenjiArai | 8:3e7a33f81048 | 259 | int i; |
kenjiArai | 8:3e7a33f81048 | 260 | i = (td - usb_tdBuf) / TD_SIZE; |
kenjiArai | 8:3e7a33f81048 | 261 | tdBufAlloc[i] = false; |
kenjiArai | 8:3e7a33f81048 | 262 | } |
kenjiArai | 8:3e7a33f81048 | 263 | |
kenjiArai | 8:3e7a33f81048 | 264 | |
kenjiArai | 8:3e7a33f81048 | 265 | void USBHALHost::resetRootHub() |
kenjiArai | 8:3e7a33f81048 | 266 | { |
kenjiArai | 8:3e7a33f81048 | 267 | // Initiate port reset |
kenjiArai | 8:3e7a33f81048 | 268 | wait(0.2); |
kenjiArai | 8:3e7a33f81048 | 269 | HAL_HCD_ResetPort((HCD_HandleTypeDef *)usb_hcca); |
kenjiArai | 8:3e7a33f81048 | 270 | } |
kenjiArai | 8:3e7a33f81048 | 271 | |
kenjiArai | 8:3e7a33f81048 | 272 | |
kenjiArai | 8:3e7a33f81048 | 273 | void USBHALHost::_usbisr(void) |
kenjiArai | 8:3e7a33f81048 | 274 | { |
kenjiArai | 8:3e7a33f81048 | 275 | if (instHost) { |
kenjiArai | 8:3e7a33f81048 | 276 | instHost->UsbIrqhandler(); |
kenjiArai | 8:3e7a33f81048 | 277 | } |
kenjiArai | 8:3e7a33f81048 | 278 | } |
kenjiArai | 8:3e7a33f81048 | 279 | |
kenjiArai | 8:3e7a33f81048 | 280 | void USBHALHost::UsbIrqhandler() |
kenjiArai | 8:3e7a33f81048 | 281 | { |
kenjiArai | 8:3e7a33f81048 | 282 | HAL_HCD_IRQHandler((HCD_HandleTypeDef *)usb_hcca); |
kenjiArai | 8:3e7a33f81048 | 283 | } |
kenjiArai | 8:3e7a33f81048 | 284 | #endif |