1
0

usbd_core.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. /* This file is the part of the Lightweight USB device Stack for STM32 microcontrollers
  2. *
  3. * Copyright ©2016 Dmitry Filimonchuk <dmitrystu[at]gmail[dot]com>
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. .*/
  15. #ifndef _USBD_CORE_H_
  16. #define _USBD_CORE_H_
  17. #if defined(__cplusplus)
  18. extern "C" {
  19. #endif
  20. /**\addtogroup USBD_HW_CORE USB Device HW driver and core API
  21. * @{ */
  22. #if defined(__DOXYGEN__)
  23. /**\name Compile-time control macros
  24. * @{ */
  25. #define USBD_PINS_REMAP /**<\brief Remap USB pins for uC with low pin count packages.*/
  26. #define USBD_SOF_DISABLED /**<\brief Disables SOF handling.*/
  27. #define USBD_VBUS_DETECT /**<\brief Enables Vbus detection for L4/F4 driver.*/
  28. #define USBD_DP_PORT /**<\brief DP pullup port for F103/F303 driver.*/
  29. #define USBD_DP_PIN /**<\brief DP pullup pin for F103/F303 driver.*/
  30. #define USBD_SOF_OUT /**<\brief Enables SOF output pin for F4 OTGFS. */
  31. #define USBD_PRIMARY_OTGHS /**<\brief Sets OTGHS as primary interface for F4*/
  32. #define USBD_USE_EXT_ULPI /**<\brief Enables external ULPI interface for OTGHS */
  33. #define USB_PMA_SIZE /**<\brief PMA memoty size in bytes. Adjust this for
  34. * the devices that shares PMA memory with CAN in case
  35. * of both USB and CAN in use to avoid data corruption. */
  36. /** @} */
  37. #endif
  38. /**\addtogroup USBD_HW USB hardware driver
  39. * @{ */
  40. /**\anchor USB_EVENTS
  41. * \name USB device events
  42. * @{ */
  43. #define usbd_evt_reset 0 /**<\brief Reset.*/
  44. #define usbd_evt_sof 1 /**<\brief Start of frame.*/
  45. #define usbd_evt_susp 2 /**<\brief Suspend.*/
  46. #define usbd_evt_wkup 3 /**<\brief Wakeup.*/
  47. #define usbd_evt_eptx 4 /**<\brief Data packet transmitted*/
  48. #define usbd_evt_eprx 5 /**<\brief Data packet received.*/
  49. #define usbd_evt_epsetup 6 /**<\brief Setup packet received.*/
  50. #define usbd_evt_error 7 /**<\brief Data error.*/
  51. #define usbd_evt_count 8
  52. /** @}*/
  53. /**\anchor USB_LANES_STATUS
  54. * \name USB lanes connection states
  55. * @{ */
  56. #define usbd_lane_unk 0 /**<\brief Unknown or proprietary charger.*/
  57. #define usbd_lane_dsc 1 /**<\brief Lanes disconnected.*/
  58. #define usbd_lane_sdp 2 /**<\brief Lanes connected to standard downstream port.*/
  59. #define usbd_lane_cdp 3 /**<\brief Lanes connected to charging downstream port.*/
  60. #define usbd_lane_dcp 4 /**<\brief Lanes connected to dedicated charging port.*/
  61. /** @} */
  62. /**\anchor USBD_HW_CAPS
  63. * \name USB HW capabilities and status
  64. * @{ */
  65. #define USBD_HW_ADDRFST (1 << 0) /**<\brief Set address before STATUS_OUT.*/
  66. #define USBD_HW_BC (1 << 1) /**<\brief Battery charging detection supported.*/
  67. #define USND_HW_HS (1 << 2) /**<\brief High speed supported.*/
  68. #define USBD_HW_ENABLED (1 << 3) /**<\brief USB device enabled. */
  69. #define USBD_HW_ENUMSPEED (3 << 4) /**<\brief USB device enumeration speed mask.*/
  70. #define USBD_HW_SPEED_NC (0 << 4) /**<\brief Not connected */
  71. #define USBD_HW_SPEED_LS (1 << 4) /**<\brief Low speed */
  72. #define USBD_HW_SPEED_FS (2 << 4) /**<\brief Full speed */
  73. #define USBD_HW_SPEED_HS (3 << 4) /**<\brief High speed */
  74. /** @} */
  75. /** @} */
  76. /**\addtogroup USBD_CORE USB device core
  77. * \brief Contains core API
  78. * @{ */
  79. #define USB_EPTYPE_DBLBUF 0x04 /**<\brief Doublebuffered endpoint (bulk endpoint only).*/
  80. /**\name bmRequestType bitmapped field
  81. * @{ */
  82. #define USB_REQ_DIRECTION (1 << 7) /**<\brief Request direction mask.*/
  83. #define USB_REQ_HOSTTODEV (0 << 7) /**<\brief Request direction is HOST to DEVICE.*/
  84. #define USB_REQ_DEVTOHOST (1 << 7) /**<\brief Request direction is DEVICE to HOST.*/
  85. #define USB_REQ_TYPE (3 << 5) /**<\brief Request type mask.*/
  86. #define USB_REQ_STANDARD (0 << 5) /**<\brief Standard request.*/
  87. #define USB_REQ_CLASS (1 << 5) /**<\brief Class specified request.*/
  88. #define USB_REQ_VENDOR (2 << 5) /**<\brief Vendor specified request.*/
  89. #define USB_REQ_RECIPIENT (3 << 0) /**<\brief Request recipient mask.*/
  90. #define USB_REQ_DEVICE (0 << 0) /**<\brief Request to device.*/
  91. #define USB_REQ_INTERFACE (1 << 0) /**<\brief Request to interface.*/
  92. #define USB_REQ_ENDPOINT (2 << 0) /**<\brief Request to endpoint.*/
  93. #define USB_REQ_OTHER (3 << 0) /**<\brief Other request.*/
  94. /** @} */
  95. #if !defined(__ASSEMBLER__)
  96. #include <stdbool.h>
  97. #include <stddef.h>
  98. /** @brief USB device machine states
  99. */
  100. enum usbd_machine_state {
  101. usbd_state_disabled,
  102. usbd_state_disconnected,
  103. usbd_state_default, /**< Default.*/
  104. usbd_state_addressed, /**< Addressed.*/
  105. usbd_state_configured, /**< Configured.*/
  106. };
  107. /**\brief USB device control endpoint machine state.*/
  108. enum usbd_ctl_state {
  109. usbd_ctl_idle, /**<\brief Idle stage. Awaiting for SETUP packet.*/
  110. usbd_ctl_rxdata, /**<\brief RX stage. Receiving DATA-OUT payload.*/
  111. usbd_ctl_txdata, /**<\brief TX stage. Transmitting DATA-IN payload.*/
  112. usbd_ctl_ztxdata, /**<\brief TX stage. Transmitting DATA-IN payload. Zero length
  113. * packet maybe required..*/
  114. usbd_ctl_lastdata, /**<\brief TX stage. Last DATA-IN packed passed to buffer. Awaiting
  115. * for the TX completion.*/
  116. usbd_ctl_statusin, /**<\brief STATUS-IN stage.*/
  117. usbd_ctl_statusout, /**<\brief STATUS-OUT stage.*/
  118. };
  119. /**\brief Reporting status results.*/
  120. typedef enum _usbd_respond {
  121. usbd_fail, /**<\brief Function has an error, STALLPID will be issued.*/
  122. usbd_ack, /**<\brief Function completes request accepted ZLP or data will be send.*/
  123. usbd_nak, /**<\brief Function is busy. NAK handshake.*/
  124. } usbd_respond;
  125. typedef struct _usbd_device usbd_device;
  126. /**\brief Represents generic USB control request.*/
  127. typedef struct {
  128. uint8_t bmRequestType; /**<\brief This bitmapped field identifies the characteristics of
  129. * the specific request.*/
  130. uint8_t bRequest; /**<\brief This field specifies the particular request.*/
  131. uint16_t wValue; /**<\brief It is used to pass a parameter to the device, specific to
  132. * the request.*/
  133. uint16_t wIndex; /**<\brief It is used to pass a parameter to the device, specific to
  134. * the request.*/
  135. uint16_t wLength; /**<\brief This field specifies the length of the data transferred
  136. * during the second phase of the control transfer.*/
  137. uint8_t data[]; /**<\brief Data payload.*/
  138. } usbd_ctlreq;
  139. /** USB device status data.*/
  140. typedef struct {
  141. void *data_buf; /**<\brief Pointer to data buffer used for control requests.*/
  142. void *data_ptr; /**<\brief Pointer to current data for control request.*/
  143. uint16_t data_count; /**<\brief Count remained data for control request.*/
  144. uint16_t data_maxsize; /**<\brief Size of the data buffer for control requests.*/
  145. uint8_t ep0size; /**<\brief Size of the control endpoint.*/
  146. uint8_t device_cfg; /**<\brief Current device configuration number.*/
  147. volatile uint8_t device_state; /**<\brief Current \ref usbd_machine_state.*/
  148. uint8_t control_state; /**<\brief Current \ref usbd_ctl_state.*/
  149. } usbd_status;
  150. /**\brief Generic USB device event callback for events and endpoints processing
  151. * \param[in] dev pointer to USB device
  152. * \param event \ref USB_EVENTS "USB event"
  153. * \param ep active endpoint number
  154. * \note endpoints with same indexes i.e. 0x01 and 0x81 shares same callback.
  155. */
  156. typedef void (*usbd_evt_callback)(usbd_device *dev, uint8_t event, uint8_t ep);
  157. /**\brief USB control transfer completed callback function.
  158. * \param[in] dev pointer to USB device
  159. * \param[in] req pointer to usb request structure
  160. * \note usbd_device->complete_callback will be set to NULL after this callback completion.
  161. */
  162. typedef void (*usbd_rqc_callback)(usbd_device *dev, usbd_ctlreq *req);
  163. /**\brief USB control callback function.
  164. * \details Uses for the control request processing.
  165. * Some requests will be handled by core if callback don't process it (returns FALSE).
  166. * If request was not processed STALL PID will be issued.
  167. * - GET_CONFIGURATION
  168. * - SET_CONFIGURATION (passes to \ref usbd_cfg_callback)
  169. * - GET_DESCRIPTOR (passes to \ref usbd_dsc_callback)
  170. * - GET_STATUS
  171. * - SET_FEATURE, CLEAR_FEATURE (endpoints only)
  172. * - SET_ADDRESS
  173. * \param[in] dev points to USB device
  174. * \param[in] req points to usb control request
  175. * \param[out] *callback USB control transfer completion callback, default is NULL (no callback)
  176. * \return usbd_respond status.
  177. */
  178. typedef usbd_respond (*usbd_ctl_callback)(usbd_device *dev, usbd_ctlreq *req, usbd_rqc_callback *callback);
  179. /**\brief USB get descriptor callback function
  180. * \details Called when GET_DESCRIPTOR request issued
  181. * \param[in] req pointer to usb control request structure
  182. * \param[in,out] address pointer to the descriptor in memory. Points to req->data by default. You
  183. * can use this buffer.
  184. * \param[in,out] dsize descriptor size. maximum buffer size by default.
  185. * \return usbd_ack if you passed the correct descriptor, usbd_fail otherwise.
  186. */
  187. typedef usbd_respond (*usbd_dsc_callback)(usbd_ctlreq *req, void **address, uint16_t *dsize);
  188. /**\brief USB set configuration callback function
  189. * \details called when SET_CONFIGURATION request issued
  190. * \param[in] dev pointer to USB device
  191. * \param[in] cfg configuration number.
  192. * \note if config is 0 device endpoints should be de-configured
  193. * \return TRUE if success
  194. */
  195. typedef usbd_respond (*usbd_cfg_callback)(usbd_device *dev, uint8_t cfg);
  196. /** @} */
  197. /**\addtogroup USBD_HW
  198. * @{ */
  199. /**\brief Get USB device status and capabilities.
  200. * \return Hardware status and capabilities \ref USBD_HW_CAPS */
  201. typedef uint32_t (*usbd_hw_getinfo)(void);
  202. /**\brief Enables or disables USB hardware
  203. * \param enable Enables USB when TRUE disables otherwise.
  204. */
  205. typedef void (*usbd_hw_enable)(bool enable);
  206. /** Connects or disconnects USB hardware to/from usb host
  207. * \param connect Connects USB to host if TRUE, disconnects otherwise
  208. * \return lanes connection status.
  209. */
  210. typedef uint8_t (*usbd_hw_connect)(bool connect);
  211. /**\brief Sets USB hardware address
  212. * \param address USB address
  213. */
  214. typedef void (*usbd_hw_setaddr)(uint8_t address);
  215. /**\brief Configures endpoint
  216. * \param ep endpoint address. Use USB_EPDIR_ macros to set endpoint direction
  217. * \param eptype endpoint type. Use USB_EPTYPE_* macros.
  218. * \param epsize endpoint size in bytes
  219. * \return TRUE if success
  220. */
  221. typedef bool (*usbd_hw_ep_config)(uint8_t ep, uint8_t eptype, uint16_t epsize);
  222. /**\brief De-configures, cleans and disables endpoint
  223. * \param ep endpoint index
  224. * \note if you have two one-direction single-buffered endpoints with same index (i.e. 0x02 and 0x82)
  225. * both will be deconfigured.
  226. */
  227. typedef void (*usbd_hw_ep_deconfig)(uint8_t ep);
  228. /**\brief Reads data from OUT or control endpoint
  229. * \param ep endpoint index, should belong to OUT or CONTROL endpoint.
  230. * \param buf pointer to read buffer
  231. * \param blen size of the read buffer in bytes
  232. * \return size of the actually received data, -1 on error.
  233. * \note if data does not fit buffer it will be truncated
  234. */
  235. typedef int32_t (*usbd_hw_ep_read)(uint8_t ep, void *buf, uint16_t blen);
  236. /**\brief Writes data to IN or control endpoint
  237. * \param ep endpoint index, hould belong to IN or CONTROL endpoint
  238. * \param buf pointer to data buffer
  239. * \param blen size of data will be written
  240. * \return number of written bytes
  241. *
  242. * The \ref usbd_evt_eptx event will fire for the endpoint once the
  243. * write is \e complete. A trick commonly used is to enqueue a zero-length
  244. * write as soon as the endpoint is configured, so that it would
  245. * "complete", firing an event, the next time an IN request arrives.
  246. */
  247. typedef int32_t (*usbd_hw_ep_write)(uint8_t ep, const void *buf, uint16_t blen);
  248. /** Stalls and unstalls endpoint
  249. * \param ep endpoint address
  250. * \param stall endpoint will be stalled if TRUE and unstalled otherwise.
  251. * \note Has no effect on inactive endpoints.
  252. */
  253. typedef void (*usbd_hw_ep_setstall)(uint8_t ep, bool stall);
  254. /**\brief Checks endpoint for stalled state
  255. * \param ep endpoint address
  256. * \return TRUE if endpoint is stalled
  257. */
  258. typedef bool (*usbd_hw_ep_isstalled)(uint8_t ep);
  259. /**\brief Polls USB hardware for the events
  260. * \param[in] dev pointer to usb device structure
  261. * \param callback callback to event processing subroutine
  262. */
  263. typedef void (*usbd_hw_poll)(usbd_device *dev, usbd_evt_callback callback);
  264. /**\brief Gets frame number from usb hardware.*/
  265. typedef uint16_t (*usbd_hw_get_frameno)(void);
  266. /**\brief Makes a string descriptor contains unique serial number from hardware ID's
  267. * \param[in] buffer pointer to buffer for the descriptor
  268. * \return of the descriptor in bytes
  269. */
  270. typedef uint16_t (*usbd_hw_get_serialno)(void *buffer);
  271. /**\brief Represents a hardware USB driver call table.*/
  272. struct usbd_driver {
  273. usbd_hw_getinfo getinfo; /**<\copybrief usbd_hw_getinfo */
  274. usbd_hw_enable enable; /**<\copybrief usbd_hw_enable */
  275. usbd_hw_connect connect; /**<\copybrief usbd_hw_connect */
  276. usbd_hw_setaddr setaddr; /**<\copybrief usbd_hw_setaddr */
  277. usbd_hw_ep_config ep_config; /**<\copybrief usbd_hw_ep_config */
  278. usbd_hw_ep_deconfig ep_deconfig; /**<\copybrief usbd_hw_ep_deconfig */
  279. usbd_hw_ep_read ep_read; /**<\copybrief usbd_hw_ep_read */
  280. usbd_hw_ep_write ep_write; /**<\copybrief usbd_hw_ep_write */
  281. usbd_hw_ep_setstall ep_setstall; /**<\copybrief usbd_hw_ep_setstall */
  282. usbd_hw_ep_isstalled ep_isstalled; /**<\copybrief usbd_hw_ep_isstalled */
  283. usbd_hw_poll poll; /**<\copybrief usbd_hw_poll */
  284. usbd_hw_get_frameno frame_no; /**<\copybrief usbd_hw_get_frameno */
  285. usbd_hw_get_serialno get_serialno_desc; /**<\copybrief usbd_hw_get_serialno */
  286. };
  287. /** @} */
  288. /**\addtogroup USBD_CORE
  289. * @{ */
  290. /**\brief Represents a USB device data.*/
  291. struct _usbd_device {
  292. const struct usbd_driver *driver; /**<\copybrief usbd_driver */
  293. usbd_ctl_callback control_callback; /**<\copybrief usbd_ctl_callback */
  294. usbd_rqc_callback complete_callback; /**<\copybrief usbd_rqc_callback */
  295. usbd_cfg_callback config_callback; /**<\copybrief usbd_cfg_callback */
  296. usbd_dsc_callback descriptor_callback; /**<\copybrief usbd_dsc_callback */
  297. usbd_evt_callback events[usbd_evt_count]; /**<\brief array of the event callbacks.*/
  298. usbd_evt_callback endpoint[8]; /**<\brief array of the endpoint callbacks.*/
  299. usbd_status status; /**<\copybrief usbd_status */
  300. };
  301. /**\brief Initializes device structure
  302. * \param dev USB device that will be initialized
  303. * \param drv Pointer to hardware driver
  304. * \param ep0size Control endpoint 0 size
  305. * \param buffer Pointer to control request data buffer (32-bit aligned)
  306. * \param bsize Size of the data buffer
  307. */
  308. inline static void usbd_init(usbd_device *dev, const struct usbd_driver *drv,
  309. const uint8_t ep0size, uint32_t *buffer, const uint16_t bsize) {
  310. dev->driver = drv;
  311. dev->status.ep0size = ep0size;
  312. dev->status.data_ptr = buffer;
  313. dev->status.data_buf = buffer;
  314. dev->status.data_maxsize = bsize - offsetof(usbd_ctlreq, data);
  315. }
  316. /**\brief Polls USB for events
  317. * \param dev Pointer to device structure
  318. * \note can be called as from main routine as from USB interrupt
  319. */
  320. void usbd_poll(usbd_device *dev);
  321. /**\brief Register callback for all control requests
  322. * \param dev usb device \ref _usbd_device
  323. * \param callback user control callback \ref usbd_ctl_callback
  324. */
  325. inline static void usbd_reg_control(usbd_device *dev, usbd_ctl_callback callback) {
  326. dev->control_callback = callback;
  327. }
  328. /**\brief Register callback for SET_CONFIG control request
  329. * \param dev dev usb device \ref _usbd_device
  330. * \param callback pointer to user \ref usbd_cfg_callback
  331. */
  332. inline static void usbd_reg_config(usbd_device *dev, usbd_cfg_callback callback) {
  333. dev->config_callback = callback;
  334. }
  335. /**\brief Register callback for GET_DESCRIPTOR control request
  336. * \param dev dev usb device \ref _usbd_device
  337. * \param callback pointer to user \ref usbd_ctl_callback
  338. */
  339. inline static void usbd_reg_descr(usbd_device *dev, usbd_dsc_callback callback) {
  340. dev->descriptor_callback = callback;
  341. }
  342. /**\brief Configure endpoint
  343. * \param dev dev usb device \ref _usbd_device
  344. * \copydetails usbd_hw_ep_config
  345. */
  346. inline static bool usbd_ep_config(usbd_device *dev, uint8_t ep, uint8_t eptype, uint16_t epsize) {
  347. return dev->driver->ep_config(ep, eptype, epsize);
  348. }
  349. /**\brief Deconfigure endpoint
  350. * \param dev dev usb device \ref _usbd_device
  351. * \copydetails usbd_hw_ep_deconfig
  352. */
  353. inline static void usbd_ep_deconfig(usbd_device *dev, uint8_t ep) {
  354. dev->driver->ep_deconfig(ep);
  355. }
  356. /**\brief Register endpoint callback
  357. * \param dev dev usb device \ref _usbd_device
  358. * \param ep endpoint index
  359. * \param callback pointer to user \ref usbd_evt_callback callback for endpoint events
  360. */
  361. inline static void usbd_reg_endpoint(usbd_device *dev, uint8_t ep, usbd_evt_callback callback) {
  362. dev->endpoint[ep & 0x07] = callback;
  363. }
  364. /**\brief Registers event callback
  365. * \param dev dev usb device \ref _usbd_device
  366. * \param evt device \ref USB_EVENTS "event" wants to be registered
  367. * \param callback pointer to user \ref usbd_evt_callback for this event
  368. */
  369. inline static void usbd_reg_event(usbd_device *dev, uint8_t evt, usbd_evt_callback callback) {
  370. dev->events[evt] = callback;
  371. }
  372. /**\brief Write data to endpoint
  373. * \param dev dev usb device \ref _usbd_device
  374. * \copydetails usbd_hw_ep_write
  375. */
  376. inline static int32_t usbd_ep_write(usbd_device *dev, uint8_t ep, const void *buf, uint16_t blen) {
  377. return dev->driver->ep_write(ep, buf, blen);
  378. }
  379. /**\brief Read data from endpoint
  380. * \param dev dev usb device \ref _usbd_device
  381. * \copydetails usbd_hw_ep_read
  382. */
  383. inline static int32_t usbd_ep_read(usbd_device *dev, uint8_t ep, void *buf, uint16_t blen) {
  384. return dev->driver->ep_read(ep, buf, blen);
  385. }
  386. /**\brief Stall endpoint
  387. * \param dev dev usb device \ref _usbd_device
  388. * \param ep endpoint address
  389. */
  390. inline static void usbd_ep_stall(usbd_device *dev, uint8_t ep) {
  391. dev->driver->ep_setstall(ep, 1);
  392. }
  393. /**\brief Unstall endpoint
  394. * \param dev dev usb device \ref _usbd_device
  395. * \param ep endpoint address
  396. */
  397. inline static void usbd_ep_unstall(usbd_device *dev, uint8_t ep) {
  398. dev->driver->ep_setstall(ep, 0);
  399. }
  400. /**\brief Enables or disables USB hardware
  401. * \param dev dev usb device \ref _usbd_device
  402. * \param enable Enables USB when TRUE disables otherwise
  403. */
  404. inline static void usbd_enable(usbd_device *dev, bool enable) {
  405. dev->driver->enable(enable);
  406. }
  407. /**\brief Connects or disconnects USB hardware to/from usb host
  408. * \param dev dev usb device \ref _usbd_device
  409. * \param connect Connects USB to host if TRUE, disconnects otherwise
  410. * \return lanes connection status. \ref USB_LANES_STATUS
  411. */
  412. inline static uint8_t usbd_connect(usbd_device *dev, bool connect) {
  413. return dev->driver->connect(connect);
  414. }
  415. /**\brief Retrieves status and capabilities.
  416. * \return current HW status, enumeration speed and capabilities \ref USBD_HW_CAPS */
  417. inline static uint32_t usbd_getinfo(usbd_device *dev) {
  418. return dev->driver->getinfo();
  419. }
  420. #endif //(__ASSEMBLER__)
  421. /** @} */
  422. /** @} */
  423. #if defined(__cplusplus)
  424. }
  425. #endif
  426. #endif //_USBD_STD_H_