diff --git a/cores/nRF5/main.cpp b/cores/nRF5/main.cpp index ad33bebf..ff56e514 100644 --- a/cores/nRF5/main.cpp +++ b/cores/nRF5/main.cpp @@ -46,7 +46,6 @@ void initVariant() __attribute__((weak)); void initVariant() { } #define LOOP_STACK_SZ (512*3) -#define USBD_STACK_SZ (150) static void loop_task(void* arg) { @@ -75,20 +74,6 @@ static void loop_task(void* arg) } } -// USB Device Driver task -// This top level thread process all usb events and invoke callbacks -static void usb_device_task(void* param) -{ - (void) param; - - // RTOS forever loop - while (1) - { - // tinyusb device task - tud_task(); - } -} - // \brief Main entry point of Arduino application int main( void ) { @@ -99,9 +84,6 @@ int main( void ) USBDevice.addInterface( (Adafruit_USBDev_Interface&) Serial); USBDevice.begin(USB_VID, USB_PID); usb_init(); - - // Create a task for tinyusb device stack - xTaskCreate( usb_device_task, "usbd", USBD_STACK_SZ, NULL, TASK_PRIO_HIGH, NULL); #endif #if CFG_DEBUG >= 3 diff --git a/cores/nRF5/nordic/nrfx/mdk/system_nrf52.c b/cores/nRF5/nordic/nrfx/mdk/system_nrf52.c index be6abbf2..d7149a9d 100644 --- a/cores/nRF5/nordic/nrfx/mdk/system_nrf52.c +++ b/cores/nRF5/nordic/nrfx/mdk/system_nrf52.c @@ -23,6 +23,8 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA. /* NOTE: Template files (including this one) are application specific and therefore expected to be copied into the application project folder prior to its use! */ +#ifdef NRF52832_XXAA + #include #include #include "nrf.h" @@ -369,5 +371,6 @@ static bool errata_182(void) return false; } - /*lint --flb "Leave library region" */ + +#endif diff --git a/cores/nRF5/nordic/nrfx/mdk/system_nrf52840.c b/cores/nRF5/nordic/nrfx/mdk/system_nrf52840.c index 07a878c8..ea93ac3c 100644 --- a/cores/nRF5/nordic/nrfx/mdk/system_nrf52840.c +++ b/cores/nRF5/nordic/nrfx/mdk/system_nrf52840.c @@ -22,7 +22,9 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA. /* NOTE: Template files (including this one) are application specific and therefore expected to be copied into the application project folder prior to its use! */ - + +#ifdef NRF52840_XXAA + #include #include #include "nrf.h" @@ -298,3 +300,5 @@ static bool errata_136(void) } /*lint --flb "Leave library region" */ +#endif + diff --git a/cores/nRF5/usb/usb.c b/cores/nRF5/usb/usb.c index 93707ab0..83855451 100644 --- a/cores/nRF5/usb/usb.c +++ b/cores/nRF5/usb/usb.c @@ -32,12 +32,19 @@ #include "tusb.h" #include "usb.h" +#include "rtos.h" + //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM DECLARATION //--------------------------------------------------------------------+ + +#define USBD_STACK_SZ (150) + // Serial is 64-bit DeviceID -> 16 chars len uint16_t usb_desc_str_serial[1+16] = { TUD_DESC_STR_HEADER(16) }; +static void usb_device_task(void* param); + // Init usb when starting up. Softdevice is not enabled yet void usb_init(void) { @@ -73,6 +80,9 @@ void usb_init(void) // Init tinyusb stack tusb_init(); + + // Create a task for tinyusb device stack + xTaskCreate( usb_device_task, "usbd", USBD_STACK_SZ, NULL, TASK_PRIO_HIGH, NULL); } // Must be called before sd_softdevice_enable() @@ -93,6 +103,19 @@ void usb_softdevice_post_enable(void) sd_power_usbremoved_enable(true); } +// USB Device Driver task +// This top level thread process all usb events and invoke callbacks +static void usb_device_task(void* param) +{ + (void) param; + + // RTOS forever loop + while (1) + { + // tinyusb device task + tud_task(); + } +} // Invoked when cdc when line state changed e.g connected/disconnected // Use to reset to DFU when disconnect with 1200 bps @@ -110,6 +133,4 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) } } - - #endif diff --git a/libraries/Adafruit_USBDev_MSC/Adafruit_USBDev_MSC.cpp b/libraries/Adafruit_USB_Library/Adafruit_USBDev_MSC.cpp similarity index 100% rename from libraries/Adafruit_USBDev_MSC/Adafruit_USBDev_MSC.cpp rename to libraries/Adafruit_USB_Library/Adafruit_USBDev_MSC.cpp diff --git a/libraries/Adafruit_USBDev_MSC/Adafruit_USBDev_MSC.h b/libraries/Adafruit_USB_Library/Adafruit_USBDev_MSC.h similarity index 100% rename from libraries/Adafruit_USBDev_MSC/Adafruit_USBDev_MSC.h rename to libraries/Adafruit_USB_Library/Adafruit_USBDev_MSC.h