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

Koen Zandberg notifications at github.com
Mon Mar 4 15:30:43 CET 2019


bergzand commented on this pull request.



> + * Must return the length of the header that will be generated by @ref gen_hdr
+ *
+ * @param usbus The usbus context
+ * @param arg   Additional argument for the header generator
+ *
+ * @return      Length of the generated header
+ */
+typedef size_t (*hdr_len)(usbus_t *usbus, void *arg);
+
+/**
+ * @brief USBUS header generator function pointers
+ */
+typedef struct {
+    gen_hdr get_header;         /**< function ptr to retrieve the header */
+    hdr_len get_header_len;     /**< function ptr to retrieve the header len */
+} usbus_hdr_gen_funcs_t;

Experience has learned that most headers have a fixed size. Changing this to:
```
typedef struct {
    gen_hdr get_header;         /**< function ptr to retrieve the header */
    union {
        hdr_len get_header_len;     /**< function ptr to retrieve the header len */
        size_t fixed;               /**< Fixed length of the header */
    } len;
    usbus_hdr_len_t len_type     /**< Either USBUS_HDR_LEN_FIXED or USBUS_HDR_LEN_FUNC */
} usbus_hdr_gen_funcs_t;
```
Allows for both fixed size and function based at almost zero cost (current function calls for the length are 4B of flash)

-- 
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-210167370
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190304/c3d44067/attachment.html>


More information about the notifications mailing list