@@ -59,6 +59,7 @@ Structure containing the USB endpoint configuration.
59
59
USB_DC_DISCONNECTED,
60
60
USB_DC_SUSPEND,
61
61
USB_DC_RESUME,
62
+ USB_DC_INTERFACE,
62
63
USB_DC_UNKNOWN
63
64
};
64
65
@@ -70,6 +71,7 @@ Status codes reported by the registered device status callback.
70
71
* USB_DC_DISCONNECTED: USB connection lost.
71
72
* USB_DC_SUSPEND: USB connection suspended by the HOST.
72
73
* USB_DC_RESUME: USB connection resumed by the HOST.
74
+ * USB_DC_INTERFACE: USB Interface selected by the HOST.
73
75
* USB_DC_UNKNOWN: Initial USB connection status.
74
76
75
77
.. code-block :: c
@@ -155,6 +157,21 @@ The following APIs are provided by the device controller driver:
155
157
and available to application or transmit done on the selected endpoint.
156
158
The callback status code is described by usb_dc_ep_cb_status_code.
157
159
160
+ :c:func: `usb_dc_ep_read_wait() `
161
+ This function is similar to usb_dc_ep_read, the difference being that, it
162
+ doesn't clear the endpoint NAKs so that the consumer is not bogged down by
163
+ further upcalls till he is done with the processing of the data. The caller
164
+ should reactivate ep by invoking usb_dc_ep_read_continue() do so.
165
+
166
+ :c:func: `usb_dc_ep_read_continue() `
167
+ Clear the endpoint NAK and enable the endpoint to accept more data from the
168
+ host. Usually called after usb_dc_ep_read_wait() when the consumer is fine
169
+ to accept more data. Thus these calls together acts as flow control
170
+ mechanism.
171
+
172
+ :c:func: `usb_dc_ep_mps() `
173
+ Get endpoint max packet size.
174
+
158
175
USB device core layer
159
176
*********************
160
177
@@ -282,6 +299,14 @@ APIs
282
299
interrupt has been received for that EP. The application must only call
283
300
this function through the supplied usb_ep_callback function.
284
301
302
+ :c:func: `usb_transfer() `
303
+ This asynchronous function starts a usb transfer from/to a specified buffer.
304
+ A callback can be provided and will be called on transfer completion.
305
+ This function can be used in IRQ context.
306
+
307
+ :c:func: `usb_transfer_sync() `
308
+ This function is the synchronous version of the usb_transfer function,
309
+ waiting for transfer completion before returning.
285
310
286
311
USB device class drivers
287
312
************************
@@ -525,18 +550,28 @@ class requests:
525
550
return 0;
526
551
}
527
552
528
- The class driver should wait for the USB_DC_CONFIGURED device status code
553
+ The class driver should wait for the USB_DC_INTERFACE device status code
529
554
before transmitting any data.
530
555
556
+ There are two ways to transmit data, using the 'low' level read/write API or
557
+ the 'high' level transfer API.
558
+
559
+ low level API:
560
+
531
561
To transmit data to the host, the class driver should call usb_write().
532
562
Upon completion the registered endpoint callback will be called. Before
533
563
sending another packet the class driver should wait for the completion of
534
- the previous transfer.
564
+ the previous write. When data is received, the registered endpoint callback
565
+ is called. usb_read() should be used for retrieving the received data.
566
+ For CDC ACM sample driver this happens via the OUT bulk endpoint handler
567
+ (cdc_acm_bulk_out) mentioned in the endpoint array (cdc_acm_ep_data).
568
+
569
+ high level API:
570
+
571
+ The usb_transfer method can be used to transfer data to/from the host. The
572
+ transfer API will automatically split the data transmission into one or more
573
+ USB transaction(s), depending endpoint max packet size. The class driver does
574
+ not have to implement endpoint callback and should set this callback to the
575
+ generic usb_transfer_ep_callback.
535
576
536
- When data is received, the registered endpoint callback is called.
537
- usb_read() should be used for retrieving the received data. It must
538
- always be called through the registered endpoint callback. For CDC ACM
539
- sample driver this happens via the OUT bulk endpoint handler (cdc_acm_bulk_out)
540
- mentioned in the endpoint array (cdc_acm_ep_data).
541
577
542
- Only CDC ACM and DFU class driver examples are provided for now.
0 commit comments