-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# name of your application | ||
APPLICATION = usbus_minimal | ||
|
||
# If no BOARD is found in the environment, use this default: | ||
BOARD ?= samr21-xpro | ||
|
||
# This has to be the absolute path to the RIOT base directory: | ||
RIOTBASE ?= $(CURDIR)/../.. | ||
|
||
# Comment this out to disable code in RIOT that does safety checking | ||
# which is not needed in a production environment but helps in the | ||
# development process: | ||
DEVELHELP ?= 1 | ||
|
||
USEMODULE += usbus | ||
|
||
# USB device vendor and product ID | ||
USB_VID ?= 1209 | ||
USB_PID ?= 0001 | ||
|
||
# Change this to 0 show compiler invocation lines by default: | ||
QUIET ?= 1 | ||
|
||
CFLAGS += -DUSB_CONFIG_VID=0x$(USB_PID) -DUSB_CONFIG_PID=0x$(USB_VID) | ||
|
||
include $(RIOTBASE)/Makefile.include | ||
|
||
ifeq ($(USB_VID):$(USB_PID), 1209:0001) | ||
$(shell $(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2) | ||
$(shell $(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# usbus_minimal example | ||
|
||
This is a minimalistic example for RIOT's USB stack. The application will | ||
initialize and start the USB stack. The stack is started without any USB | ||
handlers, it should show up as an empty USB device on the host. | ||
|
||
RIOT doesn't own any USB vendor and product ID. To compile this example, add | ||
your own vendor and product ID to the makefile: | ||
|
||
``` | ||
CFLAGS += -DUSB_CONFIG_VID=0xYOURVID -DUSB_CONFIG_PID=0xYOURPID | ||
``` | ||
|
||
The example demonstrates basic USB communication between a host and a RIOT | ||
based USB peripheral. Tools such as `lsusb` should display the device and | ||
detailed information about the device such as descriptor strings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (C) 2019 Koen Zandberg | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup examples | ||
* @{ | ||
* | ||
* @file | ||
* @brief Example application for demonstrating the RIOT USB stack | ||
* | ||
* @author Koen Zandberg <koen@bergzand.net> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include "usb/usbus.h" | ||
|
||
static char _stack[USBUS_STACKSIZE]; | ||
|
||
static usbus_t usbus; | ||
/* TODO: remove as soon as we have decent auto_init */ | ||
#include "periph_conf.h" | ||
#include "sam_usb.h" | ||
|
||
int main(void) | ||
{ | ||
puts("RIOT USB stack example application"); | ||
|
||
/* TODO: remove as soon as we have decent auto_init */ | ||
usbdev_t *usbdev_ctx = usbdev_get_ctx(0); | ||
/* start usb stack */ | ||
usbus_init(&usbus, usbdev_ctx); | ||
usbus_create(_stack, sizeof(_stack), USBUS_PRIO, USBUS_TNAME, &usbus); | ||
|
||
/* start shell */ | ||
puts("Started USB stack!"); | ||
return 0; | ||
} |