usb_hcd.c
Go to the documentation of this file.
1 
28 /* Includes ------------------------------------------------------------------*/
29 #include "usb_core.h"
30 #include "usb_hcd.h"
31 #include "usb_conf.h"
32 #include "usb_bsp.h"
33 
34 
97 uint32_t HCD_Init(USB_OTG_CORE_HANDLE *pdev ,
99 {
100  uint8_t i = 0;
101  pdev->host.ConnSts = 0;
102 
103  for (i= 0; i< USB_OTG_MAX_TX_FIFOS; i++)
104  {
105  pdev->host.ErrCnt[i] = 0;
106  pdev->host.XferCnt[i] = 0;
107  pdev->host.HC_Status[i] = HC_IDLE;
108  }
109  pdev->host.hc[0].max_packet = 8;
110 
111  USB_OTG_SelectCore(pdev, coreID);
112 #ifndef DUAL_ROLE_MODE_ENABLED
114  USB_OTG_CoreInit(pdev);
115 
116  /* Force Host Mode*/
118  USB_OTG_CoreInitHost(pdev);
120 #endif
121 
122  return 0;
123 }
124 
125 
134 {
135  USB_OTG_HPRT0_TypeDef HPRT0;
136  HPRT0.d32 = USB_OTG_READ_REG32(pdev->regs.HPRT0);
137 
138  return HPRT0.b.prtspd;
139 }
140 
148 {
149  /*
150  Before starting to drive a USB reset, the application waits for the OTG
151  interrupt triggered by the denounce done bit (DBCDNE bit in OTG_FS_GOTGINT),
152  which indicates that the bus is stable again after the electrical denounce
153  caused by the attachment of a pull-up resistor on DP (FS) or DM (LS).
154  */
155 
156  USB_OTG_ResetPort(pdev);
157  return 0;
158 }
159 
168 {
169  return (pdev->host.ConnSts);
170 }
171 
172 
181 {
182  return (pdev->host.PortEnabled);
183 }
184 
193 {
194  return (USB_OTG_READ_REG32(&pdev->regs.HREGS->HFNUM) & 0xFFFF) ;
195 }
196 
205 {
206  return pdev->host.URB_State[ch_num] ;
207 }
208 
216 uint32_t HCD_GetXferCnt (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num)
217 {
218  return pdev->host.XferCnt[ch_num] ;
219 }
220 
221 
222 
231 {
232  return pdev->host.HC_Status[ch_num] ;
233 }
234 
242 uint32_t HCD_HC_Init (USB_OTG_CORE_HANDLE *pdev , uint8_t hc_num)
243 {
244  return USB_OTG_HC_Init(pdev, hc_num);
245 }
246 
254 uint32_t HCD_SubmitRequest (USB_OTG_CORE_HANDLE *pdev , uint8_t hc_num)
255 {
256 
257  pdev->host.URB_State[hc_num] = URB_IDLE;
258  pdev->host.hc[hc_num].xfer_count = 0 ;
259  return USB_OTG_HC_StartXfer(pdev, hc_num);
260 }
261 
262 
275 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Specific api&#39;s relative to the used hardware platform.
USB_OTG_STS USB_OTG_SetCurrentMode(USB_OTG_CORE_HANDLE *pdev, uint8_t mode)
USB_OTG_SetCurrentMode : Set ID line.
Definition: usb_core.c:541
uint32_t HCD_IsDeviceConnected(USB_OTG_CORE_HANDLE *pdev)
HCD_IsDeviceConnected Check if the device is connected.
Definition: usb_hcd.c:167
Host layer Header file.
#define USB_OTG_MAX_TX_FIFOS
Definition: usb_regs.h:67
USB_OTG_STS USB_OTG_DisableGlobalInt(USB_OTG_CORE_HANDLE *pdev)
USB_OTG_DisableGlobalInt Enables the controller&#39;s Global Int in the AHB Config reg.
Definition: usb_core.c:464
uint32_t HCD_GetCurrentSpeed(USB_OTG_CORE_HANDLE *pdev)
HCD_GetCurrentSpeed Get Current device Speed.
Definition: usb_hcd.c:133
uint32_t HCD_Init(USB_OTG_CORE_HANDLE *pdev, USB_OTG_CORE_ID_TypeDef coreID)
HCD_Init Initialize the HOST portion of the driver.
Definition: usb_hcd.c:97
uint32_t HCD_SubmitRequest(USB_OTG_CORE_HANDLE *pdev, uint8_t hc_num)
HCD_SubmitRequest This function prepare a HC and start a transfer.
Definition: usb_hcd.c:254
USB_OTG_CORE_ID_TypeDef
Definition: usb_defines.h:190
HC_STATUS HCD_GetHCState(USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num)
HCD_GetHCState This function returns the HC Status.
Definition: usb_hcd.c:230
uint32_t HCD_GetXferCnt(USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num)
HCD_GetXferCnt This function returns the last URBstate.
Definition: usb_hcd.c:216
struct _USB_OTG_HPRT0_TypeDef::@88 b
uint32_t HCD_GetCurrentFrame(USB_OTG_CORE_HANDLE *pdev)
HCD_GetCurrentFrame This function returns the frame number for sof packet.
Definition: usb_hcd.c:192
#define USB_OTG_READ_REG32(reg)
Definition: usb_defines.h:225
USB_OTG_STS USB_OTG_SelectCore(USB_OTG_CORE_HANDLE *pdev, USB_OTG_CORE_ID_TypeDef coreID)
USB_OTG_SelectCore Initialize core registers address.
Definition: usb_core.c:222
Header of the Core Layer.
uint32_t HCD_HC_Init(USB_OTG_CORE_HANDLE *pdev, uint8_t hc_num)
HCD_HC_Init This function prepare a HC and start a transfer.
Definition: usb_hcd.c:242
__IO uint32_t HFNUM
Definition: usb_regs.h:188
uint32_t HCD_IsPortEnabled(USB_OTG_CORE_HANDLE *pdev)
HCD_IsPortEnabled This function checks if port is enabled.
Definition: usb_hcd.c:180
URB_STATE HCD_GetURB_State(USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num)
HCD_GetURB_State This function returns the last URBstate.
Definition: usb_hcd.c:204
URB_STATE
Definition: usb_core.h:96
USB_OTG_STS USB_OTG_EnableGlobalInt(USB_OTG_CORE_HANDLE *pdev)
USB_OTG_EnableGlobalInt Enables the controller&#39;s Global Int in the AHB Config reg.
Definition: usb_core.c:446
General low level driver configuration.
HC_STATUS
Definition: usb_core.h:84
USB_OTG_CORE_REGS regs
Definition: usb_core.h:290
uint32_t HCD_ResetPort(USB_OTG_CORE_HANDLE *pdev)
HCD_ResetPort Issues the reset command to device.
Definition: usb_hcd.c:147
__IO uint32_t * HPRT0
Definition: usb_regs.h:230
USB_OTG_HREGS * HREGS
Definition: usb_regs.h:226
USB_OTG_STS USB_OTG_CoreInit(USB_OTG_CORE_HANDLE *pdev)
USB_OTG_CoreInit Initializes the USB_OTG controller registers and prepares the core device mode or ho...
Definition: usb_core.c:329
#define HOST_MODE
Definition: usb_defines.h:111


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:26