gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
Universal Serial Bus

Functions for configuring and using the USB peripheral. More...

Functions

void usb_init (void)
 Initializes the USB preipheral, and assigns the USB pins to their relevant functions. In the process, this function also sets up the 48 MHz DFLL clock on GCLK1.
 
void usb_enable (void)
 Initializes the TinyUSB stack and enables the USB peripheral.
 
bool usb_is_enabled (void)
 Checks if the USB peripheral is enabled.
 
void usb_disable (void)
 Disables the USB peripheral.
 

Detailed Description

Functions for configuring and using the USB peripheral.

Gossamer uses the TinyUSB stack for USB support.

Function Documentation

◆ usb_disable()

void usb_disable ( void  )

Disables the USB peripheral.

Note
Has not been extensively tested, TinyUSB may not like this.

◆ usb_enable()

void usb_enable ( void  )

Initializes the TinyUSB stack and enables the USB peripheral.

In order to make use of the tinyUSB stack, there are two additional setup steps you must take:

  1. In your Makefile, set the type and number of TinyUSB device classes you intend to use. For example, if you want to use a USB mass storage class, you would add TINYUSB_MSC=1 to your app's Makefile. You can also add more than one class, e.g. for two CDC interfaces, you would add TINYUSB_CDC=2. Available TinyUSB classes are:
    • TINYUSB_CDC
    • TINYUSB_MSC
    • TINYUSB_HID
    • TINYUSB_MIDI
    • TINYUSB_VENDOR
  2. You must also set up your USB device descriptor. This is typically done in a usb_descriptors.c file. See the usb app for an example of how to do this.
  3. Depending on which classes you enable, you may need to do some additional setup. Check out tinyusb's examples for more info.

◆ usb_is_enabled()

bool usb_is_enabled ( void  )

Checks if the USB peripheral is enabled.

Returns
true if the USB peripheral is enabled, false otherwise.