From 7c6bf37f5e07a5c5cc68765312b84c5e8798b8c7 Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 8 May 2021 00:58:38 +0700 Subject: [PATCH] add libraries/Adafruit_TinyUSB_Arduino as submodule include Adafruit_USBD_CDC.h from submodule --- .gitmodules | 3 + cores/nRF5/TinyUSB/Adafruit_USBD_CDC.h | 74 -------------------- cores/nRF5/TinyUSB/Adafruit_USBD_Interface.h | 44 ------------ cores/nRF5/{TinyUSB => }/tusb_config.h | 0 libraries/Adafruit_TinyUSB_Arduino | 1 + platform.txt | 2 +- 6 files changed, 5 insertions(+), 119 deletions(-) delete mode 100644 cores/nRF5/TinyUSB/Adafruit_USBD_CDC.h delete mode 100644 cores/nRF5/TinyUSB/Adafruit_USBD_Interface.h rename cores/nRF5/{TinyUSB => }/tusb_config.h (100%) create mode 160000 libraries/Adafruit_TinyUSB_Arduino diff --git a/.gitmodules b/.gitmodules index ef2d7254..2ef987bf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "libraries/Adafruit_nRFCrypto"] path = libraries/Adafruit_nRFCrypto url = https://github.com/adafruit/Adafruit_nRFCrypto.git +[submodule "libraries/Adafruit_TinyUSB_Arduino"] + path = libraries/Adafruit_TinyUSB_Arduino + url = https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git diff --git a/cores/nRF5/TinyUSB/Adafruit_USBD_CDC.h b/cores/nRF5/TinyUSB/Adafruit_USBD_CDC.h deleted file mode 100644 index 3a2aa8a8..00000000 --- a/cores/nRF5/TinyUSB/Adafruit_USBD_CDC.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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_USBD_CDC_H_ -#define ADAFRUIT_USBD_CDC_H_ - -#include "Adafruit_USBD_Interface.h" -#include "Stream.h" - -class Adafruit_USBD_CDC : public Stream, public Adafruit_USBD_Interface -{ -public: - Adafruit_USBD_CDC(void); - - // fron Adafruit_USBD_Interface - virtual uint16_t getInterfaceDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize); - - void setPins(uint8_t pin_rx, uint8_t pin_tx) { (void) pin_rx; (void) pin_tx; } - void begin(uint32_t baud); - void begin(uint32_t baud, uint8_t config); - void end(void); - - // return line coding set by host - uint32_t baud(void); - uint8_t stopbits(void); - uint8_t paritytype(void); - uint8_t numbits(void); - int dtr(void); - - // Stream API - virtual int available(void); - virtual int peek(void); - virtual int read(void); - virtual void flush(void); - virtual size_t write(uint8_t); - - virtual size_t write(const uint8_t *buffer, size_t size); - size_t write(const char *buffer, size_t size) { - return write((const uint8_t *)buffer, size); - } - - virtual int availableForWrite(void); - using Print::write; // pull in write(str) from Print - operator bool(); - -private: - bool _begun; - uint8_t _itf; -}; - -extern Adafruit_USBD_CDC Serial; - -#endif diff --git a/cores/nRF5/TinyUSB/Adafruit_USBD_Interface.h b/cores/nRF5/TinyUSB/Adafruit_USBD_Interface.h deleted file mode 100644 index ac9d34d7..00000000 --- a/cores/nRF5/TinyUSB/Adafruit_USBD_Interface.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2021 Ha Thach (tinyusb.org) 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_USBD_INTERFACE_H_ -#define ADAFRUIT_USBD_INTERFACE_H_ - -class Adafruit_USBD_Interface -{ - protected: - const char* _desc_str; - - public: - Adafruit_USBD_Interface(void) { _desc_str = NULL; } - - // Get Interface Descriptor - // Device fill descriptor and return its length - virtual uint16_t getInterfaceDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize) = 0; - - void setStringDescriptor(const char* str) { _desc_str = str; } - const char* getStringDescriptor(void) { return _desc_str; } -}; - -#endif diff --git a/cores/nRF5/TinyUSB/tusb_config.h b/cores/nRF5/tusb_config.h similarity index 100% rename from cores/nRF5/TinyUSB/tusb_config.h rename to cores/nRF5/tusb_config.h diff --git a/libraries/Adafruit_TinyUSB_Arduino b/libraries/Adafruit_TinyUSB_Arduino new file mode 160000 index 00000000..2b16928b --- /dev/null +++ b/libraries/Adafruit_TinyUSB_Arduino @@ -0,0 +1 @@ +Subproject commit 2b16928b90a764b1e0b5b135d2ebad1518a329b2 diff --git a/platform.txt b/platform.txt index bf573a6b..4fcb5f8a 100644 --- a/platform.txt +++ b/platform.txt @@ -64,7 +64,7 @@ nordic.path={build.core.path}/nordic # build.logger_flags and build.sysview_flags are intentionally empty, # to allow modification via a user's own boards.local.txt or platform.local.txt files. -build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/TinyUSB" +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" # usb flags build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'