-
Notifications
You must be signed in to change notification settings - Fork 489
Port Adafruit_TinyUSB_Arduino lib #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
earlephilhower
merged 13 commits into
earlephilhower:master
from
adafruit:port-tinyusb-lib
May 19, 2021
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8335f15
initial tinyusb lib port
hathach 32817be
add Adafruit_TinyUSB_Arduino as submodules
hathach c0b04bc
add yield() to main loop
hathach c75d1a8
sync with tinyusb lib latest
hathach e4abb49
add USB manufacturer and product
hathach 0de7f3e
fix typo in tinyusb lib
hathach fda1b8f
sync with master
hathach 04ceed7
Rationalize link stage command line
earlephilhower d5f21ab
Merge remote-tracking branch 'upstream/nomnom' into port-tinyusb-lib
hathach f9cc401
clean up delay
hathach b1b3e5d
clean up platform and board
hathach b8272ae
update makeboards.py for generating usbstack menu
hathach 8ffea32
update tinyusb lib to 1.0.0
hathach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -1 +1 @@ | ||
#include "api/String.h" | ||
#include "api/Stream.h" |
This file contains hidden or 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,90 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018, hathach for Adafruit | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef _TUSB_CONFIG_H_ | ||
#define _TUSB_CONFIG_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
//-------------------------------------------------------------------- | ||
// COMMON CONFIGURATION | ||
//-------------------------------------------------------------------- | ||
#ifdef USE_TINYUSB | ||
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE | ||
#else | ||
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE | ||
#endif | ||
|
||
//#ifndef CFG_TUSB_MCU | ||
// #define CFG_TUSB_MCU OPT_MCU_RP2040 | ||
//#endif | ||
#define CFG_TUSB_OS OPT_OS_PICO | ||
|
||
#define CFG_TUSB_DEBUG 0 | ||
//#if CFG_TUSB_DEBUG | ||
// #define tu_printf serial1_printf | ||
// extern int serial1_printf(const char *__restrict __format, ...); | ||
//#endif | ||
|
||
#define CFG_TUSB_MEM_SECTION | ||
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) | ||
|
||
//-------------------------------------------------------------------- | ||
// DEVICE CONFIGURATION | ||
//-------------------------------------------------------------------- | ||
|
||
#define CFG_TUD_ENDOINT0_SIZE 64 | ||
|
||
//------------- CLASS -------------// | ||
#define CFG_TUD_CDC 1 | ||
#define CFG_TUD_MSC 1 | ||
#define CFG_TUD_HID 1 | ||
#define CFG_TUD_MIDI 1 | ||
#define CFG_TUD_VENDOR 1 | ||
|
||
// CDC FIFO size of TX and RX | ||
#define CFG_TUD_CDC_RX_BUFSIZE 256 | ||
#define CFG_TUD_CDC_TX_BUFSIZE 256 | ||
|
||
// MSC Buffer size of Device Mass storage | ||
#define CFG_TUD_MSC_BUFSIZE 512 | ||
|
||
// HID buffer size Should be sufficient to hold ID (if any) + Data | ||
#define CFG_TUD_HID_BUFSIZE 64 | ||
|
||
// MIDI FIFO size of TX and RX | ||
#define CFG_TUD_MIDI_RX_BUFSIZE 128 | ||
#define CFG_TUD_MIDI_TX_BUFSIZE 128 | ||
|
||
// Vendor FIFO size of TX and RX | ||
#define CFG_TUD_VENDOR_RX_BUFSIZE 64 | ||
#define CFG_TUD_VENDOR_TX_BUFSIZE 64 | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* _TUSB_CONFIG_H_ */ |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rp2040 port from the Arduino Lib is changed to call the tud_task() from irq context like "pico-sdk" stack. The TinyUSB_Device_Task() is also implemented in the way the require mutex to run. Therefore it no longer needs to use the task ready event API as previous commit.
The reason for not pursuing thread-context task, is that the sleep_ms() from pico-sdk call wfe() does not provide hook() to run background work in thread-context. In short CPU will wake in case of USB IRQ, run the handler and then sleep again without any chances to run tud_task() in thread-context.
PS: Let me know if you want to revert to have extern "C" for each function instead of block {}.