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/TARGET_STM/USBHALHost_STM.cpp@1:ab240722d7ef, 2017-02-15 (annotated)
- Committer:
- frq08711@LMECWL0871.LME.ST.COM
- Date:
- Wed Feb 15 10:49:44 2017 +0100
- Revision:
- 1:ab240722d7ef
- Child:
- 3:1c76b46ad779
update to mbed 5.3.5
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 | #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 | 1:ab240722d7ef | 96 | if (urb_state == URB_NOTREADY) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 97 | USB_ERR("urb_state != URB_NOTREADY"); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 98 | /* move buffer pointer , for size */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 99 | if ((type != EP_TYPE_BULK) && (type != EP_TYPE_CTRL )) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 100 | /* in packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 101 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 102 | if (urb_state == URB_DONE) { |
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 | 1:ab240722d7ef | 111 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 112 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 113 | td->state = (urb_state == URB_DONE) ? USB_TYPE_IDLE : USB_TYPE_ERROR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 114 | td->currBufPtr +=HAL_HCD_HC_GetXferCount(hhcd, chnum); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 115 | priv->addr[chnum]=0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 116 | (obj->*func)(addr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 117 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 118 | else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 119 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 120 | USB_DBG_EVENT("spurious %d %d",chnum, urb_state); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 121 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 122 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 123 | USBHALHost * USBHALHost::instHost; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 124 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 125 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 126 | void USBHALHost::init() { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 127 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 128 | NVIC_DisableIRQ(USBHAL_IRQn); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 129 | NVIC_SetVector(USBHAL_IRQn, (uint32_t)(_usbisr)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 130 | HAL_HCD_Init((HCD_HandleTypeDef *) usb_hcca); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 131 | NVIC_EnableIRQ(USBHAL_IRQn); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 132 | HAL_HCD_Start((HCD_HandleTypeDef *) usb_hcca); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 133 | usb_vbus(1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 134 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 135 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 136 | uint32_t USBHALHost::controlHeadED() { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 137 | return 0xffffffff; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 138 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 139 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 140 | uint32_t USBHALHost::bulkHeadED() { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 141 | return 0xffffffff; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 142 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 143 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 144 | uint32_t USBHALHost::interruptHeadED() { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 145 | return 0xffffffff; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 146 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 147 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 148 | void USBHALHost::updateBulkHeadED(uint32_t addr) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 149 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 150 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 151 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 152 | void USBHALHost::updateControlHeadED(uint32_t addr) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 153 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 154 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 155 | void USBHALHost::updateInterruptHeadED(uint32_t addr) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 156 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 157 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 158 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 159 | void USBHALHost::enableList(ENDPOINT_TYPE type) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 160 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 161 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 162 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 163 | bool USBHALHost::disableList(ENDPOINT_TYPE type) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 164 | return true; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 165 | } |
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::memInit() { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 169 | usb_hcca = (volatile HCD_HandleTypeDef *)usb_buf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 170 | usb_edBuf = usb_buf + HCCA_SIZE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 171 | usb_tdBuf = usb_buf + HCCA_SIZE +(MAX_ENDPOINT*ED_SIZE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 172 | /* init channel */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 173 | for (int i=0; i < MAX_ENDPOINT; i++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 174 | HCED *hced = (HCED*)(usb_edBuf + i*ED_SIZE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 175 | hced->ch_num = i; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 176 | hced->hhcd = (HCCA *) usb_hcca; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 177 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 178 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 179 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 180 | volatile uint8_t * USBHALHost::getED() { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 181 | for (int i = 0; i < MAX_ENDPOINT; i++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 182 | if ( !edBufAlloc[i] ) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 183 | edBufAlloc[i] = true; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 184 | return (volatile uint8_t *)(usb_edBuf + i*ED_SIZE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 185 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 186 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 187 | perror("Could not allocate ED\r\n"); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 188 | return NULL; //Could not alloc ED |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 189 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 190 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 191 | volatile uint8_t * USBHALHost::getTD() { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 192 | int i; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 193 | for (i = 0; i < MAX_TD; i++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 194 | if ( !tdBufAlloc[i] ) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 195 | tdBufAlloc[i] = true; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 196 | return (volatile uint8_t *)(usb_tdBuf + i*TD_SIZE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 197 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 198 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 199 | perror("Could not allocate TD\r\n"); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 200 | return NULL; //Could not alloc TD |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 201 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 202 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 203 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 204 | void USBHALHost::freeED(volatile uint8_t * ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 205 | int i; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 206 | i = (ed - usb_edBuf) / ED_SIZE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 207 | edBufAlloc[i] = false; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 208 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 209 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 210 | void USBHALHost::freeTD(volatile uint8_t * td) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 211 | int i; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 212 | i = (td - usb_tdBuf) / TD_SIZE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 213 | tdBufAlloc[i] = false; |
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::resetRootHub() { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 218 | // Initiate port reset |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 219 | wait(0.2); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 220 | HAL_HCD_ResetPort((HCD_HandleTypeDef *)usb_hcca); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 221 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 222 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 223 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 224 | void USBHALHost::_usbisr(void) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 225 | if (instHost) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 226 | instHost->UsbIrqhandler(); |
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::UsbIrqhandler() { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 231 | HAL_HCD_IRQHandler((HCD_HandleTypeDef *)usb_hcca); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 232 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 233 | #endif |