<h3>Contribution description</h3>
<p>This PR extends the USBUS stack with RIOT serial console over USB.</p>
<p>Output from <code>stdio_write</code> is buffered until a host opens the serial device. This can be configured with <code>USBUS_CDCACM_BUFFER_FOR_DTE</code>. In practice this means that no output produced by <code>stdio_write</code> is discarded.</p>
<h3>Testing procedure</h3>
<p>Add <code>USEMODULE += stdio_cdc_acm</code> to a project.</p>
<h3>Issues/PRs references</h3>
<p>depends on <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="415334690" data-permission-text="Issue title is private" data-url="https://github.com/RIOT-OS/RIOT/issues/11075" data-hovercard-type="pull_request" data-hovercard-url="/RIOT-OS/RIOT/pull/11075/hovercard" href="https://github.com/RIOT-OS/RIOT/pull/11075">#11075</a></p>
<p><a target="_blank" rel="noopener noreferrer" href="https://camo.githubusercontent.com/549ff6bdd94b1c355e9e6853484fe40d12c4d28a/68747470733a2f2f626572677a616e642e6e65742f6d6973632f75736275732e646f742e737667"><img src="https://camo.githubusercontent.com/549ff6bdd94b1c355e9e6853484fe40d12c4d28a/68747470733a2f2f626572677a616e642e6e65742f6d6973632f75736275732e646f742e737667" alt="image" data-canonical-src="https://bergzand.net/misc/usbus.dot.svg" style="max-width:100%;"></a></p>
<h3>Todo</h3>
<p>Prevent hangs when the <code>tsrb</code> is full</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/RIOT-OS/RIOT/pull/11085'>https://github.com/RIOT-OS/RIOT/pull/11085</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>usb: Add defines for USB peripheral devices</li>
  <li>usbopt: Add usb control operation enum</li>
  <li>usbdev: Introduce a common API for USB peripherals</li>
  <li>fixup! usbdev: Introduce a common API for USB peripherals</li>
  <li>fixup! usbopt: Add usb control operation enum</li>
  <li>fixup! usbdev: Introduce a common API for USB peripherals</li>
  <li>usbdev: add configurables for usb device drivers</li>
  <li>fixup! usbopt: Add usb control operation enum</li>
  <li>fixup! fixup! usbdev: Introduce a common API for USB peripherals</li>
  <li>fixup! fixup! fixup! usbdev: Introduce a common API for USB peripherals</li>
  <li>drivers: Add usb device group</li>
  <li>fixup! fixup! fixup! fixup! usbdev: Introduce a common API for USB peripherals</li>
  <li>fixup! fixup! usbopt: Add usb control operation enum</li>
  <li>fixup! usb: Add defines for USB peripheral devices</li>
  <li>fixup! fixup! fixup! usbopt: Add usb control operation enum</li>
  <li>fixup! fixup! fixup! fixup! fixup! usbdev: Introduce a common API for USB peripherals</li>
  <li>fixup! fixup! fixup! fixup! fixup! fixup! usbdev: Introduce a common API for USB peripherals</li>
  <li>fixup! fixup! usb: Add defines for USB peripheral devices</li>
  <li>fixup! fixup! fixup! fixup! usbopt: Add usb control operation enum</li>
  <li>sam0_common: Add USB peripheral driver</li>
  <li>samr21-xpro: Enable USB driver when required</li>
  <li>fixup! sam0_common: Add USB peripheral driver</li>
  <li>fixup! fixup! sam0_common: Add USB peripheral driver</li>
  <li>fixup! fixup! fixup! sam0_common: Add USB peripheral driver</li>
  <li>fixup! fixup! fixup! fixup! sam0_common: Add USB peripheral driver</li>
  <li>fixup! fixup! fixup! fixup! fixup! sam0_common: Add USB peripheral driver</li>
  <li>fixup! fixup! fixup! fixup! fixup! fixup! sam0_common: Add USB peripheral driver</li>
  <li>fixup! fixup! fixup! fixup! fixup! fixup! fixup! sam0_common: Add USB peripheral driver</li>
  <li>fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! sam0_common: Add USB peripheral driver</li>
  <li>usb: Add generic USB structs and functions</li>
  <li>usbus: Initial work to a unified USB stack</li>
  <li>USBUS: add minimal working example</li>
  <li>fixup! USBUS: add minimal working example</li>
  <li>fixup! usbus: Initial work to a unified USB stack</li>
  <li>fixup! usb: Add generic USB structs and functions</li>
  <li>fixup! fixup! usbus: Initial work to a unified USB stack</li>
  <li>fixup! fixup! fixup! usbus: Initial work to a unified USB stack</li>
  <li>fixup! fixup! USBUS: add minimal working example</li>
  <li>fixup! fixup! fixup! fixup! usbus: Initial work to a unified USB stack</li>
  <li>fixup! fixup! fixup! fixup! fixup! usbus: Initial work to a unified USB stack</li>
  <li>fixup! fixup! fixup! fixup! fixup! fixup! usbus: Initial work to a unified USB stack</li>
  <li>fixup! fixup! fixup! fixup! fixup! fixup! fixup! usbus: Initial work to a unified USB stack</li>
  <li>fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! usbus: Initial work to a unified USB stack</li>
  <li>fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! usbus: Initial work to a unified USB stack</li>
  <li>fixup! fixup! usb: Add generic USB structs and functions</li>
  <li>fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! usbus: Initial work to a unified USB stack</li>
  <li>fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! usbus: Initial work to a unified USB stack</li>
  <li>auto_init_usb: initial implementation</li>
  <li>usbus_minimal: Adapt example to auto_init</li>
  <li>usb_cdc: Add common defines and message structs</li>
  <li>usb cdc acm: add common defines for cdc acm</li>
  <li>usbus: Add cdc acm function</li>
  <li>USBUS cdc acm: Add STDIO wrapper for CDC ACM</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-0">Makefile.dep</a>
    (17)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-1">boards/samr21-xpro/Makefile.dep</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-2">cpu/sam0_common/Makefile</a>
    (4)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-3">cpu/sam0_common/include/sam_usb.h</a>
    (71)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-4">cpu/sam0_common/usb/Makefile</a>
    (3)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-5">cpu/sam0_common/usb/usb.c</a>
    (695)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-6">drivers/doc.txt</a>
    (6)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-7">drivers/include/usb/usbdev.h</a>
    (560)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-8">examples/usbus_minimal/Makefile</a>
    (24)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-9">examples/usbus_minimal/main.c</a>
    (41)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-10">makefiles/pseudomodules.inc.mk</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-11">sys/Makefile</a>
    (3)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-12">sys/auto_init/Makefile</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-13">sys/auto_init/auto_init.c</a>
    (6)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-14">sys/auto_init/usb/Makefile</a>
    (3)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-15">sys/auto_init/usb/auto_init_sam0.c</a>
    (31)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-16">sys/auto_init/usb/auto_init_usb.c</a>
    (63)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-17">sys/include/usb.h</a>
    (134)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-18">sys/include/usb/cdc.h</a>
    (98)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-19">sys/include/usb/cdc/acm.h</a>
    (28)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-20">sys/include/usb/descriptor.h</a>
    (221)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-21">sys/include/usb/usbopt.h</a>
    (122)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-22">sys/include/usb/usbus.h</a>
    (515)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-23">sys/include/usb/usbus/cdc/acm.h</a>
    (71)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-24">sys/include/usb/usbus/fmt.h</a>
    (45)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-25">sys/usb/usbus/Makefile</a>
    (4)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-26">sys/usb/usbus/cdc/acm/Makefile</a>
    (7)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-27">sys/usb/usbus/cdc/acm/cdc_acm.c</a>
    (327)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-28">sys/usb/usbus/cdc/acm/cdc_acm_stdio.c</a>
    (127)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-29">sys/usb/usbus/usbus.c</a>
    (318)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-30">sys/usb/usbus/usbus_control.c</a>
    (444)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11085/files#diff-31">sys/usb/usbus/usbus_fmt.c</a>
    (242)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/11085.patch'>https://github.com/RIOT-OS/RIOT/pull/11085.patch</a></li>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/11085.diff'>https://github.com/RIOT-OS/RIOT/pull/11085.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/11085">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AEn7YGw2fzn7D4iatlBuE-maNS74hmqlks5vSEE9gaJpZM4bXtZh">mute the thread</a>.<img src="https://github.com/notifications/beacon/AEn7YGyNvipiKVtSko9kGY9m4CNAjbjjks5vSEE9gaJpZM4bXtZh.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/RIOT-OS/RIOT","title":"RIOT-OS/RIOT","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/RIOT-OS/RIOT"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"usbus: Add CDC-ACM (Serial console) function (#11085)"}],"action":{"name":"View Pull Request","url":"https://github.com/RIOT-OS/RIOT/pull/11085"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/11085",
"url": "https://github.com/RIOT-OS/RIOT/pull/11085",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>