hcd.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. // Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #pragma once
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #include <stdint.h>
  18. #include <stdbool.h>
  19. #include <sys/queue.h>
  20. #include "hal/usb_types.h"
  21. #include "hal/usbh_hal.h"
  22. #include "esp_err.h"
  23. // ------------------------------------------------- Macros & Types ----------------------------------------------------
  24. // ----------------------- States --------------------------
  25. /**
  26. * @brief States of the HCD port
  27. *
  28. * @note The port can be thought of as an abstraction of the Root Hub that contains
  29. * a single port.
  30. * @note These states roughly match the port states outlined in 11.5.1 of the
  31. * USB2.0 specification.
  32. */
  33. typedef enum {
  34. HCD_PORT_STATE_NOT_POWERED, /**< The port is not powered */
  35. HCD_PORT_STATE_DISCONNECTED, /**< The port is powered but no device is conencted */
  36. HCD_PORT_STATE_DISABLED, /**< A device has connected to the port but has not been reset. SOF/keep alive are not being sent */
  37. HCD_PORT_STATE_RESETTING, /**< The port is issuing a reset condition */
  38. HCD_PORT_STATE_SUSPENDED, /**< The port has been suspended. */
  39. HCD_PORT_STATE_RESUMING, /**< The port is issuing a resume condition */
  40. HCD_PORT_STATE_ENABLED, /**< The port has been enabled. SOF/keep alive are being sent */
  41. HCD_PORT_STATE_RECOVERY, /**< Port needs to be recovered from a fatal error (port error, overcurrent, or sudden disconnection) */
  42. } hcd_port_state_t;
  43. /**
  44. * @brief States of an HCD pipe
  45. *
  46. * Active:
  47. * - Pipe is able to transmit data. Transfer request can be enqueued.
  48. * - Event if pipe has no transfer requests enqueued, it can still be in the active state.
  49. * Halted:
  50. * - An error has occurred on the pipe. Transfer request will no longer be executed.
  51. * - Halt should be cleared using the clear command
  52. * Invalid:
  53. * - The underlying device that the pipe connects is not longer valid, thus making the pipe invalid.
  54. * - Pending transfer requests should be dequeued and the pipe should be freed.
  55. */
  56. typedef enum {
  57. HCD_PIPE_STATE_ACTIVE, /**< The pipe is active */
  58. HCD_PIPE_STATE_HALTED, /**< The pipe is halted */
  59. HCD_PIPE_STATE_INVALID, /**< The pipe no longer exists and should be freed */
  60. } hcd_pipe_state_t;
  61. // ----------------------- Events --------------------------
  62. /**
  63. * @brief HCD port events
  64. *
  65. * On receiving a port event, hcd_port_handle_event() should be called to handle that event
  66. */
  67. typedef enum {
  68. HCD_PORT_EVENT_NONE, /**< No event has ocurred. Or the previous event is no longer valid */
  69. HCD_PORT_EVENT_CONNECTION, /**< A device has been connected to the port */
  70. HCD_PORT_EVENT_DISCONNECTION, /**< A device disconnection has been detected */
  71. HCD_PORT_EVENT_ERROR, /**< A port error has been detected. Port is now HCD_PORT_STATE_RECOVERY */
  72. HCD_PORT_EVENT_OVERCURRENT, /**< Overcurrent detected on the port. Port is now HCD_PORT_STATE_RECOVERY */
  73. HCD_PORT_EVENT_SUDDEN_DISCONN, /**< The port has suddenly disconencted (i.e., there was an enabled device connected
  74. to the port when the disconnection occurred. Port is now HCD_PORT_STATE_RECOVERY. */
  75. } hcd_port_event_t;
  76. /**
  77. * @brief HCD pipe events
  78. *
  79. * @note Pipe error events will put the pipe into the HCD_PIPE_STATE_HALTED state
  80. * @note The HCD_PIPE_EVENT_INVALID will put the pipe in the HCD_PIPE_STATE_INVALID state
  81. */
  82. typedef enum {
  83. HCD_PIPE_EVENT_NONE, /**< The pipe has no events (used to indicate no events when polling) */
  84. HCD_PIPE_EVENT_XFER_REQ_DONE, /**< The pipe has completed a transfer request and can be dequeued */
  85. HCD_PIPE_EVENT_INVALID, /**< The pipe is invalid because */
  86. HCD_PIPE_EVENT_ERROR_XFER, /**< Excessive (three consecutive) transaction errors (e.g., no ACK, bad CRC etc) */
  87. HCD_PIPE_EVENT_ERROR_XFER_NOT_AVAIL, /**< Transfer request was not available */
  88. HCD_PIPE_EVENT_ERROR_OVERFLOW, /**< Received more data than requested. Usually a Packet babble error
  89. (i.e., an IN packet has exceeded the endpoint's MPS) */
  90. HCD_PIPE_EVENT_ERROR_STALL, /**< Pipe received a STALL response received */
  91. } hcd_pipe_event_t;
  92. // ---------------------- Commands -------------------------
  93. /**
  94. * @brief HCD port commands
  95. */
  96. typedef enum {
  97. HCD_PORT_CMD_POWER_ON, /**< Power ON the port */
  98. HCD_PORT_CMD_POWER_OFF, /**< Power OFF the port */
  99. HCD_PORT_CMD_RESET, /**< Issue a reset on the port */
  100. HCD_PORT_CMD_SUSPEND, /**< Suspend the port */
  101. HCD_PORT_CMD_RESUME, /**< Resume the port */
  102. HCD_PORT_CMD_DISABLE, /**< Disable the port (stops the SOFs or keep alive) */
  103. } hcd_port_cmd_t;
  104. /**
  105. * @brief HCD pipe commands
  106. *
  107. * The pipe commands represent the list of pipe manipulations outlined in 10.5.2.2. of USB2.0 specification.
  108. */
  109. typedef enum {
  110. HCD_PIPE_CMD_ABORT, /**< Retire all scheduled transfer requests. Pipe's state remains unchanged */
  111. HCD_PIPE_CMD_RESET, /**< Retire all scheduled transfer requests. Pipe's state moves to active */
  112. HCD_PIPE_CMD_CLEAR, /**< Pipe's state moves from halted to active */
  113. HCD_PIPE_CMD_HALT /**< Pipe's state moves to halted */
  114. } hcd_pipe_cmd_t;
  115. // -------------------- Object Types -----------------------
  116. /**
  117. * @brief Port handle type
  118. */
  119. typedef void * hcd_port_handle_t;
  120. /**
  121. * @brief Pipe handle type
  122. */
  123. typedef void * hcd_pipe_handle_t;
  124. /**
  125. * @brief HCD transfer request handle type
  126. */
  127. typedef void * hcd_xfer_req_handle_t;
  128. /**
  129. * @brief Port event callback type
  130. *
  131. * This callback is run when a port event occurs
  132. */
  133. typedef bool (*hcd_port_isr_callback_t)(hcd_port_handle_t port_hdl, hcd_port_event_t port_event, void *user_arg, bool in_isr);
  134. /**
  135. * @brief Pipe event callback
  136. *
  137. * This callback is run when a pipe event occurs
  138. */
  139. typedef bool (*hcd_pipe_isr_callback_t)(hcd_pipe_handle_t pipe_hdl, hcd_pipe_event_t pipe_event, void *user_arg, bool in_isr);
  140. /**
  141. * @brief HCD configuration structure
  142. */
  143. typedef struct {
  144. int intr_flags; /**< Interrupt flags for HCD interrupt */
  145. } hcd_config_t;
  146. /**
  147. * @brief Port configuration structure
  148. */
  149. typedef struct {
  150. hcd_port_isr_callback_t callback; /**< HCD port event callback */
  151. void *callback_arg; /**< User argument for HCD port callback */
  152. void *context;
  153. } hcd_port_config_t;
  154. /**
  155. * @brief Pipe configuration structure
  156. *
  157. * @note The callback can be set to NULL if no callback is required (e.g., using HCD in a polling manner).
  158. */
  159. typedef struct {
  160. hcd_pipe_isr_callback_t callback; /**< HCD pipe event ISR callback */
  161. void *callback_arg; /**< User argument for HCD pipe callback */
  162. void *context; /**< Context variable used to associate the pipe with upper layer object */
  163. usb_desc_ep_t *ep_desc; /**< Pointer to endpoint descriptor of the pipe */
  164. uint8_t dev_addr; /**< Device address of the pipe */
  165. usb_speed_t dev_speed; /**< Speed of the device */
  166. } hcd_pipe_config_t;
  167. // --------------------------------------------- Host Controller Driver ------------------------------------------------
  168. /**
  169. * @brief Installs the Host Controller Driver
  170. *
  171. * - Allocates memory and interrupt resources for the HCD and underlying ports
  172. * - Setups up HCD to use internal PHY
  173. *
  174. * @note This function must be called before any other HCD function is called
  175. *
  176. * @param config HCD configuration
  177. * @retval ESP_OK: HCD successfully installed
  178. * @retval ESP_ERR_NO_MEM: Insufficient memory
  179. * @retval ESP_ERR_INVALID_STATE: HCD is already installed
  180. * @retval ESP_ERR_NOT_FOUND: HCD could not allocate interrupt
  181. * @retval ESP_ERR_INVALID_ARG: Arguments are invalid
  182. */
  183. esp_err_t hcd_install(const hcd_config_t *config);
  184. /**
  185. * @brief Uninstalls the HCD
  186. *
  187. * Before uninstalling the HCD, the following conditions should be met:
  188. * - All ports must be uninitialized, all pipes freed
  189. *
  190. * @retval ESP_OK: HCD successfully uninstalled
  191. * @retval ESP_ERR_INVALID_STATE: HCD is not in the right condition to be uninstalled
  192. */
  193. esp_err_t hcd_uninstall(void);
  194. // ---------------------------------------------------- HCD Port -------------------------------------------------------
  195. /**
  196. * @brief Initialize a particular port of the HCD
  197. *
  198. * After a port is initialized, it will be put into the HCD_PORT_STATE_NOT_POWERED state.
  199. *
  200. * @note The host controller only has one port, thus the only valid port_number is 1
  201. *
  202. * @param[in] port_number Port number
  203. * @param[in] port_config Port configuration
  204. * @param[out] port_hdl Port handle
  205. * @retval ESP_OK: Port enabled
  206. * @retval ESP_ERR_NO_MEM: Insufficient memory
  207. * @retval ESP_ERR_INVALID_STATE: The port is already enabled
  208. * @retval ESP_ERR_NOT_FOUND: Port number not found
  209. * @retval ESP_ERR_INVALID_ARG: Arguments are invalid
  210. */
  211. esp_err_t hcd_port_init(int port_number, hcd_port_config_t *port_config, hcd_port_handle_t *port_hdl);
  212. /**
  213. * @brief Deinitialize a particular port
  214. *
  215. * The port must be placed in the HCD_PORT_STATE_NOT_POWERED or HCD_PORT_STATE_RECOVERY state before it can be
  216. * deinitialized.
  217. *
  218. * @param port_hdl Port handle
  219. * @retval ESP_OK: Port disabled
  220. * @retval ESP_ERR_INVALID_STATE: The port is not in a condition to be disabled (not unpowered)
  221. */
  222. esp_err_t hcd_port_deinit(hcd_port_handle_t port_hdl);
  223. /**
  224. * @brief Execute a port command
  225. *
  226. * Call this function to manipulate a port (e.g., powering it ON, sending a reset etc). The following conditions
  227. * must be met when calling this function:
  228. * - The port is in the correct state for the command (e.g., port must be suspend in order to use the resume command)
  229. * - The port does not have any pending events
  230. *
  231. * @note This function is internally protected by a mutex. If multiple threads call this function, this function will
  232. * can block.
  233. * @note For some of the commands that involve a blocking delay (e.g., reset and resume), if the port's state changes
  234. * unexpectedly (e.g., a disconnect during a resume), this function will return ESP_ERR_INVALID_RESPONSE.
  235. *
  236. * @param port_hdl Port handle
  237. * @param command Command for the HCD port
  238. * @retval ESP_OK: Command executed successfully
  239. * @retval ESP_ERR_INVALID_STATE: Conditions have not been met to call this function
  240. * @retval ESP_ERR_INVALID_RESPONSE: The command is no longer valid due to a change in the port's state
  241. */
  242. esp_err_t hcd_port_command(hcd_port_handle_t port_hdl, hcd_port_cmd_t command);
  243. /**
  244. * @brief Get the port's current state
  245. *
  246. * @param port_hdl Port handle
  247. * @return hcd_port_state_t Current port state
  248. */
  249. hcd_port_state_t hcd_port_get_state(hcd_port_handle_t port_hdl);
  250. /**
  251. * @brief Get the speed of the port
  252. *
  253. * The speed of the port is determined by the speed of the device connected to it.
  254. *
  255. * @note This function is only valid after a device directly to the port and has been reset
  256. *
  257. * @param[in port_hdl Port handle
  258. * @param[out] speed Speed of the port
  259. * @retval ESP_OK Device speed obtained
  260. * @retval ESP_ERR_INVALID_STATE: No valid device connected to the port
  261. * @retval ESP_ERR_INVALID_ARG: Invalid arguments
  262. */
  263. esp_err_t hcd_port_get_speed(hcd_port_handle_t port_hdl, usb_speed_t *speed);
  264. /**
  265. * @brief Handle a ports event
  266. *
  267. * When an port event occurs (as indicated by a callback), this function should be called the handle this event. A
  268. * port's event should always be handled before attempting to execute a port command. Note that is actually handled
  269. * may be different than the event reflected in the callback.
  270. *
  271. * If the port has no events, this function will return HCD_PORT_EVENT_NONE.
  272. *
  273. * @note If callbacks are not used, this function can also be used in a polling manner to repeatedely check for and
  274. * handle a port's events.
  275. * @note This function is internally protected by a mutex. If multiple threads call this function, this function will
  276. * can block.
  277. *
  278. * @param port_hdl Port handle
  279. * @return hcd_port_event_t The port event that was handled
  280. */
  281. hcd_port_event_t hcd_port_handle_event(hcd_port_handle_t port_hdl);
  282. /**
  283. * @brief Recover a port after a fatal error has occurred on it
  284. *
  285. * The port must be in the HCD_PORT_STATE_RECOVERY state to be called. Recovering the port will involve issuing a soft
  286. * reset on the underlying USB controller. The port will be returned to the HCD_PORT_STATE_NOT_POWERED state.
  287. *
  288. * @param port_hdl Port handle
  289. * @retval ESP_OK Port recovered successfully
  290. * @retval ESP_ERR_INVALID_STATE Port is not in the HCD_PORT_STATE_RECOVERY state
  291. */
  292. esp_err_t hcd_port_recover(hcd_port_handle_t port_hdl);
  293. /**
  294. * @brief Get the context variable of a port
  295. *
  296. * @param port_hdl Port handle
  297. * @return void* Context variable
  298. */
  299. void *hcd_port_get_ctx(hcd_port_handle_t port_hdl);
  300. // --------------------------------------------------- HCD Pipes -------------------------------------------------------
  301. /**
  302. * @brief Allocate a pipe
  303. *
  304. * When allocating a pipe, the HCD will assess whether there are sufficient resources (i.e., bus time, and controller
  305. * channels). If sufficient, the pipe will be allocated.
  306. *
  307. * @note Currently, Interrupt and Isochronous pipes are not supported yet
  308. * @note The host port must be in the enabled state before a pipe can be allcoated
  309. *
  310. * @param[in] port_hdl Handle of the port this pipe will be routed through
  311. * @param[in] pipe_config Pipe configuration
  312. * @param[out] pipe_hdl Pipe handle
  313. *
  314. * @retval ESP_OK: Pipe successfully allocated
  315. * @retval ESP_ERR_NO_MEM: Insufficient memory
  316. * @retval ESP_ERR_INVALID_ARG: Arguments are invalid
  317. * @retval ESP_ERR_INVALID_STATE: Host port is not in the correct state to allocate a pipe
  318. * @retval ESP_ERR_NOT_SUPPORTED: The pipe cannot be supported
  319. */
  320. esp_err_t hcd_pipe_alloc(hcd_port_handle_t port_hdl, const hcd_pipe_config_t *pipe_config, hcd_pipe_handle_t *pipe_hdl);
  321. /**
  322. * @brief Free a pipe
  323. *
  324. * Frees the resources used by an HCD pipe. The pipe's handle should be discarded after calling this function. The pipe
  325. * must be in following condition before it can be freed:
  326. * - All transfers have been dequeued
  327. *
  328. * @param pipe_hdl Pipe handle
  329. *
  330. * @retval ESP_OK: Pipe successfully freed
  331. * @retval ESP_ERR_INVALID_STATE: Pipe is not in a condition to be freed
  332. */
  333. esp_err_t hcd_pipe_free(hcd_pipe_handle_t pipe_hdl);
  334. /**
  335. * @brief Update a pipe's device address and maximum packet size
  336. *
  337. * This function is intended to be called on default pipes during enumeration in order to update the pipe's device
  338. * address and maximum packet size. This function can only be called on a pipe that has met the following conditions:
  339. * - Pipe is still valid (i.e., not in the HCD_PIPE_STATE_INVALID state)
  340. * - Pipe is not currently processing a command
  341. * - All transfer request have been dequeued from the pipe
  342. *
  343. * @param pipe_hdl Pipe handle
  344. * @param dev_addr New device address
  345. * @param mps New Maximum Packet Size
  346. *
  347. * @retval ESP_OK: Pipe successfully updated
  348. * @retval ESP_ERR_INVALID_STATE: Pipe is no in a condition to be updated
  349. */
  350. esp_err_t hcd_pipe_update(hcd_pipe_handle_t pipe_hdl, uint8_t dev_addr, int mps);
  351. /**
  352. * @brief Get the context variable of a pipe from its handle
  353. *
  354. * @param pipe_hdl Pipe handle
  355. * @return void* Context variable
  356. */
  357. void *hcd_pipe_get_ctx(hcd_pipe_handle_t pipe_hdl);
  358. /**
  359. * @brief Get the current sate of the pipe
  360. *
  361. * @param pipe_hdl Pipe handle
  362. * @return hcd_pipe_state_t Current state of the pipe
  363. */
  364. hcd_pipe_state_t hcd_pipe_get_state(hcd_pipe_handle_t pipe_hdl);
  365. /**
  366. * @brief Execute a command on a particular pipe
  367. *
  368. * Pipe commands allow a pipe to be manipulated (such as clearing a halt, retiring all transfer requests etc). The
  369. * following conditions must for a pipe command to be issued:
  370. * - Pipe is still valid (i.e., not in the HCD_PIPE_STATE_INVALID)
  371. * - No other thread/task processing a command on the pipe concurrently (will return)
  372. *
  373. * @note Some pipe commands will block until the pipe's current inflight transfer is completed. If the pipe's state
  374. * changes unexpectedley, this function will return ESP_ERR_INVALID_RESPONSE
  375. *
  376. * @param pipe_hdl Pipe handle
  377. * @param command Pipe command
  378. * @retval ESP_OK: Command executed successfully
  379. * @retval ESP_ERR_INVALID_STATE: The pipe is not in the correct state/condition too execute the command
  380. * @retval ESP_ERR_INVALID_RESPONSE: The pipe's state changed unexpectedley
  381. */
  382. esp_err_t hcd_pipe_command(hcd_pipe_handle_t pipe_hdl, hcd_pipe_cmd_t command);
  383. /**
  384. * @brief Get the last event that occurred on a pipe
  385. *
  386. * This function allows a pipe to be polled for events (i.e., when callbacks are not used). Once an event has been
  387. * obtained, this function reset the last event of the pipe to HCD_PIPE_EVENT_NONE.
  388. *
  389. * @param pipe_hdl Pipe handle
  390. * @return hcd_pipe_event_t Last pipe event to occur
  391. */
  392. hcd_pipe_event_t hcd_pipe_get_event(hcd_pipe_handle_t pipe_hdl);
  393. // ----------------------------------------------- HCD Transfer Requests -----------------------------------------------
  394. /**
  395. * @brief Allocate a transfer request
  396. *
  397. * @note The allocate transfer request will not have its target set (i.e., no target pipe and associated IRP). Call
  398. * hcd_xfer_req_set_target() before enqueueing the transfer request
  399. *
  400. * @return hcd_xfer_req_handle_t Transfer request handle or NULL if failed.
  401. */
  402. hcd_xfer_req_handle_t hcd_xfer_req_alloc(void);
  403. /**
  404. * @brief Free a transfer request
  405. *
  406. * @note The transfer request must be dequeued before it can be freed
  407. *
  408. * @param req_hdl Transfer request handle
  409. */
  410. void hcd_xfer_req_free(hcd_xfer_req_handle_t req_hdl);
  411. /**
  412. * @brief Set a transfer request's target
  413. *
  414. * Setting a transfer request's target will associate a transfer request with a pipe and a USB IRP (i.e., the data). A
  415. * transfer request's target must be set before it can be enqueued.
  416. *
  417. * @note This should only be called when a transfer requests that are not currently enqueued
  418. *
  419. * @param req_hdl Transfer request handle
  420. * @param pipe_hdl Target pipe's handle
  421. * @param irp Target IRP handle
  422. * @param context Context variable to associate transfer request with upper layer object
  423. */
  424. void hcd_xfer_req_set_target(hcd_xfer_req_handle_t req_hdl, hcd_pipe_handle_t pipe_hdl, usb_irp_t *irp, void *context);
  425. /**
  426. * @brief Get the target of a transfer request
  427. *
  428. * @note This should only be called when a transfer requests that are not currently enqueued
  429. *
  430. * @param[in] req_hdl Transfer request handle
  431. * @param[out] pipe_hdl Target pipe's handle
  432. * @param[out] irp Target IRP's handle
  433. * @param[out] context Context variable
  434. */
  435. void hcd_xfer_req_get_target(hcd_xfer_req_handle_t req_hdl, hcd_pipe_handle_t *pipe_hdl, usb_irp_t **irp, void **context);
  436. /**
  437. * @brief Enqueue a transfer request
  438. *
  439. * The following conditions must be met for a transfer request to be enqueued:
  440. * - The transfer request's target must be set
  441. * - Transfer request must not already be enqueued
  442. * - The target pipe must be in the HCD_PIPE_STATE_ACTIVE state
  443. *
  444. * @param req_hdl Transfer request handle
  445. * @retval ESP_OK: Transfer request enqueued successfully
  446. * @retval ESP_ERR_INVALID_STATE: Conditions not met to enqueue transfer request
  447. */
  448. esp_err_t hcd_xfer_req_enqueue(hcd_xfer_req_handle_t req_hdl);
  449. /**
  450. * @brief Dequeue a completed transfer request from a pipe
  451. *
  452. * This function should be called on a pipe after it receives an pipe event. If a pipe has multiple transfer requests
  453. * that can be dequeued, this function must be called repeatedely until all transfer requests are dequeued. If a pipe
  454. * has no more transfer requests to dequeue, this function will return NULL.
  455. *
  456. * @param pipe_hdl Pipe handle
  457. * @return hcd_xfer_req_handle_t Transfer request handle or NULL if no more transfer requests to dequeue.
  458. */
  459. hcd_xfer_req_handle_t hcd_xfer_req_dequeue(hcd_pipe_handle_t pipe_hdl);
  460. /**
  461. * @brief Abort an ongoing transfer request
  462. *
  463. * This function will attempt to abort an enqueued transfer request. If the transfer request has not yet been executed,
  464. * it will be marked as "cancelled" and can be dequeued. If a transfer request is already in progress or has completed,
  465. * it will not be affected by this function.
  466. *
  467. * @param req_hdl Transfer request handle
  468. * @retval ESP_OK: Transfer request successfully aborted, or did not need to be aborted
  469. * @retval ESP_ERR_INVALID_STATE: Transfer request was never enqueued
  470. */
  471. esp_err_t hcd_xfer_req_abort(hcd_xfer_req_handle_t req_hdl);
  472. #ifdef __cplusplus
  473. }
  474. #endif