hcd.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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 "esp_err.h"
  21. #include "usb.h"
  22. // ------------------------------------------------- Macros & Types ----------------------------------------------------
  23. // ----------------------- States --------------------------
  24. /**
  25. * @brief States of the HCD port
  26. *
  27. * @note The port can be thought of as an abstraction of the Root Hub that contains
  28. * a single port.
  29. * @note These states roughly match the port states outlined in 11.5.1 of the
  30. * USB2.0 specification.
  31. */
  32. typedef enum {
  33. HCD_PORT_STATE_NOT_POWERED, /**< The port is not powered */
  34. HCD_PORT_STATE_DISCONNECTED, /**< The port is powered but no device is connected */
  35. HCD_PORT_STATE_DISABLED, /**< A device has connected to the port but has not been reset. SOF/keep alive are not being sent */
  36. HCD_PORT_STATE_RESETTING, /**< The port is issuing a reset condition */
  37. HCD_PORT_STATE_SUSPENDED, /**< The port has been suspended. */
  38. HCD_PORT_STATE_RESUMING, /**< The port is issuing a resume condition */
  39. HCD_PORT_STATE_ENABLED, /**< The port has been enabled. SOF/keep alive are being sent */
  40. HCD_PORT_STATE_RECOVERY, /**< Port needs to be recovered from a fatal error (port error, overcurrent, or sudden disconnection) */
  41. } hcd_port_state_t;
  42. /**
  43. * @brief States of an HCD pipe
  44. *
  45. * Active:
  46. * - Pipe is able to transmit data. IRPs can be enqueued.
  47. * - Event if pipe has no IRPs enqueued, it can still be in the active state.
  48. * Halted:
  49. * - An error has occurred on the pipe. IRPs will no longer be executed.
  50. * - Halt should be cleared using the clear command
  51. * Invalid:
  52. * - The underlying device that the pipe connects is not longer valid, thus making the pipe invalid.
  53. * - Pending IRPs should be dequeued and the pipe should be freed.
  54. */
  55. typedef enum {
  56. HCD_PIPE_STATE_ACTIVE, /**< The pipe is active */
  57. HCD_PIPE_STATE_HALTED, /**< The pipe is halted */
  58. HCD_PIPE_STATE_INVALID, /**< The pipe no longer exists and should be freed */
  59. } hcd_pipe_state_t;
  60. // ----------------------- Events --------------------------
  61. /**
  62. * @brief HCD port events
  63. *
  64. * On receiving a port event, hcd_port_handle_event() should be called to handle that event
  65. */
  66. typedef enum {
  67. HCD_PORT_EVENT_NONE, /**< No event has occurred. Or the previous event is no longer valid */
  68. HCD_PORT_EVENT_CONNECTION, /**< A device has been connected to the port */
  69. HCD_PORT_EVENT_DISCONNECTION, /**< A device disconnection has been detected */
  70. HCD_PORT_EVENT_ERROR, /**< A port error has been detected. Port is now HCD_PORT_STATE_RECOVERY */
  71. HCD_PORT_EVENT_OVERCURRENT, /**< Overcurrent detected on the port. Port is now HCD_PORT_STATE_RECOVERY */
  72. HCD_PORT_EVENT_SUDDEN_DISCONN, /**< The port has suddenly disconnected (i.e., there was an enabled device connected
  73. to the port when the disconnection occurred. Port is now HCD_PORT_STATE_RECOVERY. */
  74. } hcd_port_event_t;
  75. /**
  76. * @brief HCD pipe events
  77. *
  78. * @note Pipe error events will put the pipe into the HCD_PIPE_STATE_HALTED state
  79. * @note The HCD_PIPE_EVENT_INVALID will put the pipe in the HCD_PIPE_STATE_INVALID state
  80. */
  81. typedef enum {
  82. HCD_PIPE_EVENT_NONE, /**< The pipe has no events (used to indicate no events when polling) */
  83. HCD_PIPE_EVENT_IRP_DONE, /**< The pipe has completed an IRP. The IRP can be dequeued */
  84. HCD_PIPE_EVENT_INVALID, /**< The pipe is invalid because */
  85. HCD_PIPE_EVENT_ERROR_XFER, /**< Excessive (three consecutive) transaction errors (e.g., no ACK, bad CRC etc) */
  86. HCD_PIPE_EVENT_ERROR_IRP_NOT_AVAIL, /**< IRP was not available */
  87. HCD_PIPE_EVENT_ERROR_OVERFLOW, /**< Received more data than requested. Usually a Packet babble error
  88. (i.e., an IN packet has exceeded the endpoint's MPS) */
  89. HCD_PIPE_EVENT_ERROR_STALL, /**< Pipe received a STALL response received */
  90. } hcd_pipe_event_t;
  91. // ---------------------- Commands -------------------------
  92. /**
  93. * @brief HCD port commands
  94. */
  95. typedef enum {
  96. HCD_PORT_CMD_POWER_ON, /**< Power ON the port */
  97. HCD_PORT_CMD_POWER_OFF, /**< Power OFF the port */
  98. HCD_PORT_CMD_RESET, /**< Issue a reset on the port */
  99. HCD_PORT_CMD_SUSPEND, /**< Suspend the port */
  100. HCD_PORT_CMD_RESUME, /**< Resume the port */
  101. HCD_PORT_CMD_DISABLE, /**< Disable the port (stops the SOFs or keep alive) */
  102. } hcd_port_cmd_t;
  103. /**
  104. * @brief HCD pipe commands
  105. *
  106. * The pipe commands represent the list of pipe manipulations outlined in 10.5.2.2. of USB2.0 specification.
  107. */
  108. typedef enum {
  109. HCD_PIPE_CMD_ABORT, /**< Retire all scheduled IRPs. Pipe's state remains unchanged */
  110. HCD_PIPE_CMD_RESET, /**< Retire all scheduled IRPs. Pipe's state moves to active */
  111. HCD_PIPE_CMD_CLEAR, /**< Pipe's state moves from halted to active */
  112. HCD_PIPE_CMD_HALT /**< Pipe's state moves to halted */
  113. } hcd_pipe_cmd_t;
  114. // -------------------- Object Types -----------------------
  115. /**
  116. * @brief Port handle type
  117. */
  118. typedef void * hcd_port_handle_t;
  119. /**
  120. * @brief Pipe handle type
  121. */
  122. typedef void * hcd_pipe_handle_t;
  123. /**
  124. * @brief Port event callback type
  125. *
  126. * This callback is run when a port event occurs
  127. */
  128. 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);
  129. /**
  130. * @brief Pipe event callback
  131. *
  132. * This callback is run when a pipe event occurs
  133. */
  134. 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);
  135. typedef enum {
  136. HCD_PORT_FIFO_BIAS_BALANCED, /**< Balanced FIFO sizing for RX, Non-periodic TX, and periodic TX */
  137. HCD_PORT_FIFO_BIAS_RX, /**< Bias towards a large RX FIFO */
  138. HCD_PORT_FIFO_BIAS_PTX, /**< Bias towards periodic TX FIFO */
  139. } hcd_port_fifo_bias_t;
  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; /**< Context variable used to associate the port with upper layer object */
  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. const usb_desc_ep_t *ep_desc; /**< Pointer to endpoint descriptor of the pipe */
  164. usb_speed_t dev_speed; /**< Speed of the device */
  165. uint8_t dev_addr; /**< Device address of the pipe */
  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 repeatedly 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_context(hcd_port_handle_t port_hdl);
  300. /**
  301. * @brief Set the bias of the HCD port's internal FIFO
  302. *
  303. * @note This function can only be called when the following conditions are met:
  304. * - Port is initialized
  305. * - Port does not have any pending events
  306. * - Port does not have any allocated pipes
  307. *
  308. * @param port_hdl Port handle
  309. * @param bias Fifo bias
  310. * @retval ESP_OK FIFO sizing successfully set
  311. * @retval ESP_ERR_INVALID_STATE Incorrect state for FIFO sizes to be set
  312. */
  313. esp_err_t hcd_port_set_fifo_bias(hcd_port_handle_t port_hdl, hcd_port_fifo_bias_t bias);
  314. // --------------------------------------------------- HCD Pipes -------------------------------------------------------
  315. /**
  316. * @brief Allocate a pipe
  317. *
  318. * When allocating a pipe, the HCD will assess whether there are sufficient resources (i.e., bus time, and controller
  319. * channels). If sufficient, the pipe will be allocated.
  320. *
  321. * @note Currently, Interrupt and Isochronous pipes are not supported yet
  322. * @note The host port must be in the enabled state before a pipe can be allcoated
  323. *
  324. * @param[in] port_hdl Handle of the port this pipe will be routed through
  325. * @param[in] pipe_config Pipe configuration
  326. * @param[out] pipe_hdl Pipe handle
  327. *
  328. * @retval ESP_OK: Pipe successfully allocated
  329. * @retval ESP_ERR_NO_MEM: Insufficient memory
  330. * @retval ESP_ERR_INVALID_ARG: Arguments are invalid
  331. * @retval ESP_ERR_INVALID_STATE: Host port is not in the correct state to allocate a pipe
  332. * @retval ESP_ERR_NOT_SUPPORTED: The pipe's configuration cannot be supported
  333. */
  334. 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);
  335. /**
  336. * @brief Free a pipe
  337. *
  338. * Frees the resources used by an HCD pipe. The pipe's handle should be discarded after calling this function. The pipe
  339. * must be in following condition before it can be freed:
  340. * - All IRPs have been dequeued
  341. *
  342. * @param pipe_hdl Pipe handle
  343. *
  344. * @retval ESP_OK: Pipe successfully freed
  345. * @retval ESP_ERR_INVALID_STATE: Pipe is not in a condition to be freed
  346. */
  347. esp_err_t hcd_pipe_free(hcd_pipe_handle_t pipe_hdl);
  348. /**
  349. * @brief Update a pipe's maximum packet size
  350. *
  351. * This function is intended to be called on default pipes during enumeration in order to update the pipe's maximum
  352. * packet size. This function can only be called on a pipe that has met the following conditions:
  353. * - Pipe is still valid (i.e., not in the HCD_PIPE_STATE_INVALID state)
  354. * - Pipe is not currently processing a command
  355. * - All IRPs have been dequeued from the pipe
  356. *
  357. * @param pipe_hdl Pipe handle
  358. * @param mps New Maximum Packet Size
  359. *
  360. * @retval ESP_OK: Pipe successfully updated
  361. * @retval ESP_ERR_INVALID_STATE: Pipe is not in a condition to be updated
  362. */
  363. esp_err_t hcd_pipe_update_mps(hcd_pipe_handle_t pipe_hdl, int mps);
  364. /**
  365. * @brief Update a pipe's device address
  366. *
  367. * This function is intended to be called on default pipes during enumeration in order to update the pipe's device
  368. * address. This function can only be called on a pipe that has met the following conditions:
  369. * - Pipe is still valid (i.e., not in the HCD_PIPE_STATE_INVALID state)
  370. * - Pipe is not currently processing a command
  371. * - All IRPs have been dequeued from the pipe
  372. *
  373. * @param pipe_hdl Pipe handle
  374. * @param dev_addr New device address
  375. *
  376. * @retval ESP_OK: Pipe successfully updated
  377. * @retval ESP_ERR_INVALID_STATE: Pipe is not in a condition to be updated
  378. */
  379. esp_err_t hcd_pipe_update_dev_addr(hcd_pipe_handle_t pipe_hdl, uint8_t dev_addr);
  380. /**
  381. * @brief Get the context variable of a pipe from its handle
  382. *
  383. * @param pipe_hdl Pipe handle
  384. * @return void* Context variable
  385. */
  386. void *hcd_pipe_get_context(hcd_pipe_handle_t pipe_hdl);
  387. /**
  388. * @brief Get the current sate of the pipe
  389. *
  390. * @param pipe_hdl Pipe handle
  391. * @return hcd_pipe_state_t Current state of the pipe
  392. */
  393. hcd_pipe_state_t hcd_pipe_get_state(hcd_pipe_handle_t pipe_hdl);
  394. /**
  395. * @brief Execute a command on a particular pipe
  396. *
  397. * Pipe commands allow a pipe to be manipulated (such as clearing a halt, retiring all IRPs etc). The following
  398. * conditions must for a pipe command to be issued:
  399. * - Pipe is still valid (i.e., not in the HCD_PIPE_STATE_INVALID)
  400. * - No other thread/task processing a command on the pipe concurrently (will return)
  401. *
  402. * @note Some pipe commands will block until the pipe's current in-flight IRP is complete. If the pipe's state
  403. * changes unexpectedly, this function will return ESP_ERR_INVALID_RESPONSE
  404. *
  405. * @param pipe_hdl Pipe handle
  406. * @param command Pipe command
  407. * @retval ESP_OK: Command executed successfully
  408. * @retval ESP_ERR_INVALID_STATE: The pipe is not in the correct state/condition too execute the command
  409. * @retval ESP_ERR_INVALID_RESPONSE: The pipe's state changed unexpectedley
  410. */
  411. esp_err_t hcd_pipe_command(hcd_pipe_handle_t pipe_hdl, hcd_pipe_cmd_t command);
  412. /**
  413. * @brief Get the last event that occurred on a pipe
  414. *
  415. * This function allows a pipe to be polled for events (i.e., when callbacks are not used). Once an event has been
  416. * obtained, this function reset the last event of the pipe to HCD_PIPE_EVENT_NONE.
  417. *
  418. * @param pipe_hdl Pipe handle
  419. * @return hcd_pipe_event_t Last pipe event to occur
  420. */
  421. hcd_pipe_event_t hcd_pipe_get_event(hcd_pipe_handle_t pipe_hdl);
  422. // ---------------------------------------------------- HCD IRPs -------------------------------------------------------
  423. /**
  424. * @brief Enqueue an IRP to a particular pipe
  425. *
  426. * The following conditions must be met before an IRP can be enqueued:
  427. * - The IRP is properly initialized (data buffer and transfer length are set)
  428. * - The IRP must not already be enqueued
  429. * - The pipe must be in the HCD_PIPE_STATE_ACTIVE state
  430. *
  431. * @param pipe_hdl Pipe handle
  432. * @param irp I/O Request Packet to enqueue
  433. * @retval ESP_OK: IRP enqueued successfully
  434. * @retval ESP_ERR_INVALID_STATE: Conditions not met to enqueue IRP
  435. */
  436. esp_err_t hcd_irp_enqueue(hcd_pipe_handle_t pipe_hdl, usb_irp_t *irp);
  437. /**
  438. * @brief Dequeue an IRP from a particular pipe
  439. *
  440. * This function should be called on a pipe after a pipe receives a HCD_PIPE_EVENT_IRP_DONE event. If a pipe has
  441. * multiple IRPs that can be dequeued, this function should be called repeatedly until all IRPs are dequeued. If a pipe
  442. * has no more IRPs to dequeue, this function will return NULL.
  443. *
  444. * @param pipe_hdl Pipe handle
  445. * @return usb_irp_t* Dequeued I/O Request Packet, or NULL if no more IRPs to dequeue
  446. */
  447. usb_irp_t *hcd_irp_dequeue(hcd_pipe_handle_t pipe_hdl);
  448. /**
  449. * @brief Abort an enqueued IRP
  450. *
  451. * This function will attempt to abort an IRP that is already enqueued. If the IRP has yet to be executed, it will be
  452. * "cancelled" and can then be dequeued. If the IRP is currenty in-flight or has already completed, the IRP will not be
  453. * affected by this function.
  454. *
  455. * @param irp I/O Request Packet to abort
  456. * @retval ESP_OK: IRP successfully aborted, or was not affected by this function
  457. * @retval ESP_ERR_INVALID_STATE: IRP was never enqueued
  458. */
  459. esp_err_t hcd_irp_abort(usb_irp_t *irp);
  460. #ifdef __cplusplus
  461. }
  462. #endif