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

Koen Zandberg notifications at github.com
Mon Mar 4 15:23:47 CET 2019

bergzand commented on this pull request.

> +     * @param usbus     USBUS context
+     * @param handler   handler context
+     */
+    void (*init)(usbus_t *usbus, struct usbus_handler *handler);
+    /**
+     * @brief event handler function
+     *
+     * This function is passed USBUS events
+     *
+     * @param usbus     USBUS context
+     * @param handler   handler context
+     * @param event     @ref USBUS_MSG_TYPES "event" to handle
+     * @param arg       Additional argument
+     */
+    int (*event_handler)(usbus_t *usbus, struct usbus_handler *handler, uint16_t event, void *arg);

One flaw of the API I've found so far is that too many event-like operations are multiplexed over this single callback. Splitting this into multiple callbacks {events, transfer, setup} reduces the API complexity, allows for not handling certain events (leaving the function ptr at `NULL`) and prevents every handler from having [switch-case statements](https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-4f2c0a81a745c2641ad7a3c388997c8dR313) to demultiplex the reported event

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190304/4dbd5480/attachment-0001.html>

More information about the notifications mailing list