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 ST

Committer:
frq08711@LMECWL0871.LME.ST.COM
Date:
Fri Feb 17 12:40:57 2017 +0100
Revision:
3:1c76b46ad779
Parent:
1:ab240722d7ef
Child:
5:fc157e6bd5a5
fixes for USBMSD

Who changed what in which revision?

UserRevisionLine numberNew 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 #ifdef TARGET_STM
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 18 #include "mbed.h"
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 19 #include "USBHALHost.h"
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 20 #include "dbg.h"
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 21 #include "pinmap.h"
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 22
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 23 #include "USBHALHost_STM_TARGET.h"
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 24
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 25 void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd)
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 26 {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 27 USBHALHost_Private_t *priv=(USBHALHost_Private_t *)(hhcd->pData);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 28 USBHALHost *obj= priv->inst;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 29 int i;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 30 void (USBHALHost::*func)(int hub, int port, bool lowSpeed, USBHostHub * hub_parent ) = priv->deviceConnected;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 31 for (i=0; i<MAX_ENDPOINT; i++)
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 32 if (priv->addr[i]==(uint32_t)-1)priv->addr[i]=0;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 33 (obj->*func)(0,1,1,NULL);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 34 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 35 void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd)
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 36 {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 37 USBHALHost_Private_t *priv=(USBHALHost_Private_t *)(hhcd->pData);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 38 USBHALHost *obj= priv->inst;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 39 void (USBHALHost::*func1)(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr)= priv->deviceDisconnected;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 40 void (USBHALHost::*func2)(volatile uint32_t addr)= priv->transferCompleted;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 41 int i;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 42 (obj->*func1)(0,1,(USBHostHub *)NULL,0);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 43
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 44 /* fix me call with same frame number */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 45 /* all on going transaction must end and any new one must be rejected */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 46 for (i=0; i<MAX_ENDPOINT; i++) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 47 uint32_t addr = priv->addr[i];
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 48 priv->addr[i]=(uint32_t)-1;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 49 if ((addr!=(uint32_t)-1)&& (addr!=0)){
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 50 HCTD *td = (HCTD *)addr;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 51 td->currBufPtr +=HAL_HCD_HC_GetXferCount(hhcd, i);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 52 td->state = USB_TYPE_DISCONNECTED;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 53 (obj->*func2)(addr);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 54 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 55 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 56 for (i=1; i< MAX_ENDPOINT;i++)HAL_HCD_HC_Halt(hhcd,i);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 57 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 58 int HAL_HCD_HC_GetDirection(HCD_HandleTypeDef *hhcd,uint8_t chnum)
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 59 {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 60 /* useful for transmission */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 61 return hhcd->hc[chnum].ep_is_in;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 62 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 63
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 64 uint32_t HAL_HCD_HC_GetMaxPacket(HCD_HandleTypeDef *hhcd,uint8_t chnum)
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 65 {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 66 /* useful for transmission */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 67 return hhcd->hc[chnum].max_packet;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 68 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 69
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 70
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 71 uint32_t HAL_HCD_HC_GetType(HCD_HandleTypeDef *hhcd,uint8_t chnum)
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 72 {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 73 /* useful for transmission */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 74 return hhcd->hc[chnum].ep_type;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 75 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 76
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 77 void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd,uint8_t chnum, HCD_URBStateTypeDef urb_state)
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 78 {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 79 USBHALHost_Private_t *priv=(USBHALHost_Private_t *)(hhcd->pData);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 80 USBHALHost *obj= priv->inst;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 81 void (USBHALHost::*func)(volatile uint32_t addr)= priv->transferCompleted;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 82 uint32_t addr = priv->addr[chnum];
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 83 uint32_t max_size = HAL_HCD_HC_GetMaxPacket(hhcd, chnum);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 84 uint32_t type = HAL_HCD_HC_GetType(hhcd, chnum);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 85 uint32_t dir = HAL_HCD_HC_GetDirection(hhcd,chnum);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 86 uint32_t length;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 87 if ((addr!=(uint32_t)-1) && (addr!=0)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 88 HCTD *td = (HCTD *)addr;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 89 /* put the state */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 90 if ((urb_state == URB_IDLE) && (type == EP_TYPE_INTR) ) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 91 length = td->size;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 92 MBED_ASSERT(HAL_HCD_HC_SubmitRequest(hhcd, chnum, dir ,type , 1,(uint8_t*) td->currBufPtr, length, 0)==HAL_OK);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 93 return;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 94 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 95 td->state = (urb_state == URB_DONE) ? USB_TYPE_IDLE : USB_TYPE_ERROR;
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 96 /* move buffer pointer , for size */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 97 if ((type != EP_TYPE_BULK) && (type != EP_TYPE_CTRL )) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 98 /* in packet */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 99 } else {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 100 if (urb_state == URB_DONE) {
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 101 /* reset retry counter */
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 102 td->retry = 0;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 103 if (td->size > max_size) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 104 /* enqueue another request */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 105 td->currBufPtr += max_size;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 106 td->size -= max_size;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 107 length = td->size <= max_size ? td->size : max_size;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 108 MBED_ASSERT(HAL_HCD_HC_SubmitRequest(hhcd, chnum, dir ,type , 1,(uint8_t*) td->currBufPtr, length, 0)==HAL_OK);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 109 return;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 110 }
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 111 }else if (urb_state == URB_NOTREADY) {
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 112 /* try again */
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 113 /* abritary limit , to avoid dead lock if other error than
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 114 * slow response is */
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 115 if (td->retry < 1000) {
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 116 /* increment retry counter */
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 117 td->retry++;
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 118 length = td->size <= max_size ? td->size : max_size;
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 119 MBED_ASSERT(HAL_HCD_HC_SubmitRequest(hhcd, chnum, dir ,type , 1,(uint8_t*) td->currBufPtr, length, 0)==HAL_OK);
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 120 return;
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 121 }else USB_ERR("urb_state != URB_NOTREADY");
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 122
frq08711@LMECWL0871.LME.ST.COM 3:1c76b46ad779 123
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 124 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 125 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 126 td->state = (urb_state == URB_DONE) ? USB_TYPE_IDLE : USB_TYPE_ERROR;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 127 td->currBufPtr +=HAL_HCD_HC_GetXferCount(hhcd, chnum);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 128 priv->addr[chnum]=0;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 129 (obj->*func)(addr);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 130 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 131 else
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 132 {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 133 USB_DBG_EVENT("spurious %d %d",chnum, urb_state);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 134 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 135 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 136 USBHALHost * USBHALHost::instHost;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 137
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 138
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 139 void USBHALHost::init() {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 140
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 141 NVIC_DisableIRQ(USBHAL_IRQn);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 142 NVIC_SetVector(USBHAL_IRQn, (uint32_t)(_usbisr));
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 143 HAL_HCD_Init((HCD_HandleTypeDef *) usb_hcca);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 144 NVIC_EnableIRQ(USBHAL_IRQn);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 145 HAL_HCD_Start((HCD_HandleTypeDef *) usb_hcca);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 146 usb_vbus(1);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 147 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 148
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 149 uint32_t USBHALHost::controlHeadED() {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 150 return 0xffffffff;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 151 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 152
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 153 uint32_t USBHALHost::bulkHeadED() {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 154 return 0xffffffff;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 155 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 156
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 157 uint32_t USBHALHost::interruptHeadED() {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 158 return 0xffffffff;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 159 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 160
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 161 void USBHALHost::updateBulkHeadED(uint32_t addr) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 162 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 163
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 164
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 165 void USBHALHost::updateControlHeadED(uint32_t addr) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 166 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 167
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 168 void USBHALHost::updateInterruptHeadED(uint32_t addr) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 169 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 170
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 171
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 172 void USBHALHost::enableList(ENDPOINT_TYPE type) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 173 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 174
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 175
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 176 bool USBHALHost::disableList(ENDPOINT_TYPE type) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 177 return true;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 178 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 179
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 180
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 181 void USBHALHost::memInit() {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 182 usb_hcca = (volatile HCD_HandleTypeDef *)usb_buf;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 183 usb_edBuf = usb_buf + HCCA_SIZE;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 184 usb_tdBuf = usb_buf + HCCA_SIZE +(MAX_ENDPOINT*ED_SIZE);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 185 /* init channel */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 186 for (int i=0; i < MAX_ENDPOINT; i++) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 187 HCED *hced = (HCED*)(usb_edBuf + i*ED_SIZE);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 188 hced->ch_num = i;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 189 hced->hhcd = (HCCA *) usb_hcca;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 190 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 191 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 192
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 193 volatile uint8_t * USBHALHost::getED() {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 194 for (int i = 0; i < MAX_ENDPOINT; i++) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 195 if ( !edBufAlloc[i] ) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 196 edBufAlloc[i] = true;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 197 return (volatile uint8_t *)(usb_edBuf + i*ED_SIZE);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 198 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 199 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 200 perror("Could not allocate ED\r\n");
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 201 return NULL; //Could not alloc ED
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 202 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 203
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 204 volatile uint8_t * USBHALHost::getTD() {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 205 int i;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 206 for (i = 0; i < MAX_TD; i++) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 207 if ( !tdBufAlloc[i] ) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 208 tdBufAlloc[i] = true;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 209 return (volatile uint8_t *)(usb_tdBuf + i*TD_SIZE);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 210 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 211 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 212 perror("Could not allocate TD\r\n");
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 213 return NULL; //Could not alloc TD
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 214 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 215
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 216
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 217 void USBHALHost::freeED(volatile uint8_t * ed) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 218 int i;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 219 i = (ed - usb_edBuf) / ED_SIZE;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 220 edBufAlloc[i] = false;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 221 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 222
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 223 void USBHALHost::freeTD(volatile uint8_t * td) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 224 int i;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 225 i = (td - usb_tdBuf) / TD_SIZE;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 226 tdBufAlloc[i] = false;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 227 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 228
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 229
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 230 void USBHALHost::resetRootHub() {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 231 // Initiate port reset
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 232 wait(0.2);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 233 HAL_HCD_ResetPort((HCD_HandleTypeDef *)usb_hcca);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 234 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 235
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 236
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 237 void USBHALHost::_usbisr(void) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 238 if (instHost) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 239 instHost->UsbIrqhandler();
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 240 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 241 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 242
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 243 void USBHALHost::UsbIrqhandler() {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 244 HAL_HCD_IRQHandler((HCD_HandleTypeDef *)usb_hcca);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 245 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 246 #endif