-
-
Notifications
You must be signed in to change notification settings - Fork 16
Update TinyUSB to version 3.7.3 #91
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
Merged
Changes from all commits
Commits
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
103 changes: 103 additions & 0 deletions
103
cores/nRF5/TinyUSB/Adafruit_TinyUSB_ArduinoCore/Adafruit_TinyUSB_API.cpp
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,103 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2019 Ha Thach for Adafruit Industries | ||
| * | ||
| * 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. | ||
| */ | ||
|
|
||
| #include "tusb_option.h" | ||
|
|
||
| #if CFG_TUD_ENABLED || CFG_TUH_ENABLED | ||
|
|
||
| #include "Adafruit_USBD_Device.h" | ||
| #include "Arduino.h" | ||
|
|
||
| extern "C" { | ||
|
|
||
| uint32_t tusb_time_millis_api(void) { return millis(); } | ||
|
|
||
| //--------------------------------------------------------------------+ | ||
| // Device | ||
| //--------------------------------------------------------------------+ | ||
| #if CFG_TUD_ENABLED | ||
| void TinyUSB_Device_Init(uint8_t rhport) { | ||
| // Init USB Device controller and stack | ||
| TinyUSBDevice.begin(rhport); | ||
| } | ||
|
|
||
| // RP2040 has its own implementation since it needs mutex for dual core | ||
| #ifndef ARDUINO_ARCH_RP2040 | ||
| void TinyUSB_Device_Task(void) { | ||
| // Run tinyusb device task | ||
| tud_task(); | ||
| } | ||
| #endif | ||
|
|
||
| #ifndef ARDUINO_ARCH_ESP32 | ||
| void TinyUSB_Device_FlushCDC(void) { | ||
| uint8_t const cdc_instance = Adafruit_USBD_CDC::getInstanceCount(); | ||
| for (uint8_t instance = 0; instance < cdc_instance; instance++) { | ||
| tud_cdc_n_write_flush(instance); | ||
| } | ||
| } | ||
| #endif | ||
| #endif // CFG_TUD_ENABLED | ||
|
|
||
| //------------- Debug log with Serial1 -------------// | ||
| #if CFG_TUSB_DEBUG && defined(CFG_TUSB_DEBUG_PRINTF) && \ | ||
| !defined(ARDUINO_ARCH_ESP32) | ||
|
|
||
| // #define USE_SEGGER_RTT | ||
| #ifndef SERIAL_TUSB_DEBUG | ||
| #define SERIAL_TUSB_DEBUG Serial1 | ||
| #endif | ||
|
|
||
| #ifdef USE_SEGGER_RTT | ||
| #include "SEGGER_RTT/RTT/SEGGER_RTT.h" | ||
| #endif | ||
|
|
||
| __attribute__((used)) int CFG_TUSB_DEBUG_PRINTF(const char *__restrict format, | ||
| ...) { | ||
| char buf[256]; | ||
| int len; | ||
| va_list ap; | ||
| va_start(ap, format); | ||
| len = vsnprintf(buf, sizeof(buf), format, ap); | ||
|
|
||
| #ifdef USE_SEGGER_RTT | ||
| SEGGER_RTT_Write(0, buf, len); | ||
| #else | ||
| static volatile bool ser_inited = false; | ||
| if (!ser_inited) { | ||
| ser_inited = true; | ||
| SERIAL_TUSB_DEBUG.begin(115200); | ||
| // SERIAL_TUSB_DEBUG.begin(921600); | ||
| } | ||
| SERIAL_TUSB_DEBUG.write(buf); | ||
| #endif | ||
|
|
||
| va_end(ap); | ||
| return len; | ||
| } | ||
| #endif // CFG_TUSB_DEBUG | ||
|
|
||
| } // extern C | ||
|
|
||
| #endif // CFG_TUD_ENABLED || CFG_TUH_ENABLED |
76 changes: 76 additions & 0 deletions
76
cores/nRF5/TinyUSB/Adafruit_TinyUSB_ArduinoCore/Adafruit_TinyUSB_API.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,76 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2019 Ha Thach for Adafruit Industries | ||
| * | ||
| * 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 ADAFRUIT_TINYUSB_API_H_ | ||
| #define ADAFRUIT_TINYUSB_API_H_ | ||
|
|
||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
|
|
||
| // API Version, need to be updated when there is changes for | ||
| // TinyUSB_API, USBD_CDC, USBD_Device, USBD_Interface, | ||
| #define TINYUSB_API_VERSION 30000 | ||
|
|
||
| //--------------------------------------------------------------------+ | ||
| // Core API | ||
| // Should be called by BSP Core to initialize, process task | ||
| // Weak function allow compile arduino core before linking with this library | ||
| //--------------------------------------------------------------------+ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| // Called by core/sketch to initialize usb device hardware and stack | ||
| // This also initialize Serial as CDC device | ||
| void TinyUSB_Device_Init(uint8_t rhport) __attribute__((weak)); | ||
|
|
||
| // Called by core/sketch to handle device event | ||
| void TinyUSB_Device_Task(void) __attribute__((weak)); | ||
|
|
||
| // Called by core/sketch to flush write on CDC | ||
| void TinyUSB_Device_FlushCDC(void) __attribute__((weak)); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| //--------------------------------------------------------------------+ | ||
| // Port API | ||
| // Must be implemented by each BSP core/platform | ||
| //--------------------------------------------------------------------+ | ||
|
|
||
| // To enter/reboot to bootloader | ||
| // usually when host disconnects cdc at baud 1200 (touch 1200) | ||
| void TinyUSB_Port_EnterDFU(void); | ||
|
|
||
| // Init device hardware. | ||
| // Called by TinyUSB_Device_Init() | ||
| void TinyUSB_Port_InitDevice(uint8_t rhport); | ||
|
|
||
| // Get unique serial number, needed for Serial String Descriptor | ||
| // Fill serial_id (raw bytes) and return its length (limit to 16 bytes) | ||
| // Note: Serial descriptor can be overwritten by user API | ||
| uint8_t TinyUSB_Port_GetSerialNumber(uint8_t serial_id[16]); | ||
|
|
||
| #endif |
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.
Uh oh!
There was an error while loading. Please reload this page.