[riot-notifications] [RIOT-OS/RIOT] USBUS: Initial work towards an USB stack (#10916)

Dylan Laduranty notifications at github.com
Wed May 22 21:39:57 CEST 2019


dylad commented on this pull request.

@bergzand 
Another small round
Some others comments from previous round still need to be addressed.

> +     * @param usbus     USBUS context
+     * @param handler   handler context
+     * @param state     setup request state
+     * @param setup     setup packet
+     *
+     * @returns         Size of the returned data when the request is handled
+     * @returns         negative to have the stack return an USB stall to the
+     *                  host
+     * @returns         zero when the request is not handled by this handler
+     */
+    int (*setup_handler)(usbus_t * usbus, struct usbus_handler *handler,
+                         usbus_setuprq_state_t state, usb_setup_t *request);
+} usbus_handler_driver_t;
+
+/**
+ * @ USBUS handler struct

missing brief ?

> + * @param[in] usbus   USBUS context
+ * @param[in] iface   USB interface to add
+ *
+ * @return          interface index
+ */
+uint16_t usbus_add_interface(usbus_t *usbus, usbus_interface_t *iface);
+
+/**
+ * @brief Add an endpoint to the specified interface
+ *
+ * An @ref usbdev_ep_t is requested from the low level peripheral matching the
+ * type, direction and buffer length.
+ *
+ * @param[in] usbus USBUS context
+ * @param[in] iface USB interface to add the endpoint to
+ * @param[in] ep    USB endpoint struct to use

This param is not used by the function, should be removed

> +uint16_t usbus_add_interface(usbus_t *usbus, usbus_interface_t *iface);
+
+/**
+ * @brief Add an endpoint to the specified interface
+ *
+ * An @ref usbdev_ep_t is requested from the low level peripheral matching the
+ * type, direction and buffer length.
+ *
+ * @param[in] usbus USBUS context
+ * @param[in] iface USB interface to add the endpoint to
+ * @param[in] ep    USB endpoint struct to use
+ * @param[in] type  USB endpoint type
+ * @param[in] dir   USB endpoint direction
+ * @param[in] len   Buffer space for the endpoint to allocate
+ */
+usbus_endpoint_t *usbus_add_endpoint(usbus_t *usbus, usbus_interface_t *iface,

missing return in doxygen description

> +        uint16_t us = USB_CONFIG_DEFAULT_LANGID;
+        usbus_control_slicer_put_bytes(usbus, (uint8_t *)&us, sizeof(uint16_t));
+    }
+    else {
+        usb_descriptor_string_t desc;
+        desc.type = USB_TYPE_DESCRIPTOR_STRING;
+        usbus_string_t *str = _get_descriptor(usbus, idx);
+        if (str) {
+            desc.length = sizeof(usb_descriptor_string_t);
+            desc.length += 2 * strlen(str->str); /* USB strings are UTF-16 */
+            usbus_control_slicer_put_bytes(usbus, (uint8_t *)&desc,
+                                           sizeof(desc));
+            _cpy_str_to_utf16(usbus, str->str);
+        }
+    }
+    return 1;

Is it needed to return 1 all the time ?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10916#pullrequestreview-240824522
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190522/366468de/attachment.html>


More information about the notifications mailing list