Skip to content

Commit 6b41c19

Browse files
authored
Merge pull request #542 from adafruit/update-tinyusbcore-11d669b4d2a40eb2fc5e51b2a9707a6de9d42363
update TinyUSB Core
2 parents 15c1161 + cb6d216 commit 6b41c19

File tree

5 files changed

+35
-35
lines changed

5 files changed

+35
-35
lines changed

cores/nRF5/TinyUSB/Adafruit_TinyUSB_nRF.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
#include "Arduino.h"
3131
#include "Adafruit_TinyUSB_Core.h"
3232

33+
//--------------------------------------------------------------------+
34+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
35+
//--------------------------------------------------------------------+
36+
37+
#define USBD_STACK_SZ (200)
38+
39+
// tinyusb function that handles power event (detected, ready, removed)
40+
// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled.
41+
extern "C" void tusb_hal_nrf_power_event(uint32_t event);
42+
3343
//--------------------------------------------------------------------+
3444
// Forward USB interrupt events to TinyUSB IRQ Handler
3545
//--------------------------------------------------------------------+
@@ -42,34 +52,10 @@ extern "C" void USBD_IRQHandler(void)
4252
tud_int_handler(0);
4353

4454
#if CFG_SYSVIEW
45-
SEGGER_SYSVIEW_RecordExitISR();
55+
SEGGER_SYSVIEW_RecordExitISR();
4656
#endif
4757
}
4858

49-
//--------------------------------------------------------------------+
50-
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
51-
//--------------------------------------------------------------------+
52-
53-
#define USBD_STACK_SZ (200)
54-
55-
// tinyusb function that handles power event (detected, ready, removed)
56-
// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled.
57-
extern "C" void tusb_hal_nrf_power_event(uint32_t event);
58-
59-
// USB Device Driver task
60-
// This top level thread process all usb events and invoke callbacks
61-
static void usb_device_task(void* param)
62-
{
63-
(void) param;
64-
65-
// RTOS forever loop
66-
while (1)
67-
{
68-
// tinyusb device task
69-
tud_task();
70-
}
71-
}
72-
7359
//--------------------------------------------------------------------+
7460
// Core Init & Touch1200
7561
//--------------------------------------------------------------------+
@@ -99,8 +85,12 @@ static void usb_hardware_init(void)
9985
if ( usb_reg & POWER_USBREGSTATUS_OUTPUTRDY_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY);
10086
}
10187

102-
void Adafruit_TinyUSB_Core_init(void)
88+
// USB Device Driver task
89+
// This top level thread process all usb events and invoke callbacks
90+
static void usb_device_task(void* param)
10391
{
92+
(void) param;
93+
10494
USBDevice.addInterface( (Adafruit_USBD_Interface&) Serial);
10595
USBDevice.setID(USB_VID, USB_PID);
10696
USBDevice.begin();
@@ -110,6 +100,16 @@ void Adafruit_TinyUSB_Core_init(void)
110100
// Init tinyusb stack
111101
tusb_init();
112102

103+
// RTOS forever loop
104+
while (1)
105+
{
106+
// tinyusb device task
107+
tud_task();
108+
}
109+
}
110+
111+
void Adafruit_TinyUSB_Core_init(void)
112+
{
113113
// Create a task for tinyusb device stack
114114
xTaskCreate( usb_device_task, "usbd", USBD_STACK_SZ, NULL, TASK_PRIO_HIGH, NULL);
115115
}

cores/nRF5/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ int main( void )
7272
init();
7373
initVariant();
7474

75-
#ifdef USE_TINYUSB
76-
Adafruit_TinyUSB_Core_init();
77-
#endif
78-
7975
#if CFG_SYSVIEW
8076
SEGGER_SYSVIEW_Conf();
8177
#endif
8278

79+
#ifdef USE_TINYUSB
80+
Adafruit_TinyUSB_Core_init();
81+
#endif
82+
8383
// Create a task for loop()
8484
xTaskCreate( loop_task, "loop", LOOP_STACK_SZ, NULL, TASK_PRIO_LOW, &_loopHandle);
8585

platform.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ nordic.path={build.core.path}/nordic
6060

6161
# build.logger_flags and build.sysview_flags and intentionally empty,
6262
# to allow modification via a user's own boards.local.txt or platform.local.txt files.
63-
build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 -Ofast {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{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" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
63+
build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 -Ofast {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" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
6464

6565
# usb flags
6666
build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'

tools/build_all.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
fail_count = 0
1111
skip_count = 0
1212

13-
build_format = '| {:20} | {:35} | {:9} '
13+
build_format = '| {:20} | {:35} | {:9} | {:6} |'
1414
build_separator = '-' * 83
1515

1616
default_boards = [ 'cluenrf52840', 'cplaynrf52840', 'feather52832', 'feather52840', 'feather52840sense', 'itsybitsy52840' ]
@@ -39,7 +39,7 @@ def build_examples(variant):
3939
print(build_separator)
4040
print('| {:^79} |'.format('Board ' + variant))
4141
print(build_separator)
42-
print((build_format + '| {:6} |').format('Library', 'Example', 'Result', 'Time'))
42+
print(build_format.format('Library', 'Example', 'Result', 'Time'))
4343
print(build_separator)
4444

4545
fqbn = "adafruit:nrf52:{}:softdevice={},debug=l0".format(variant, 's140v6' if variant != 'feather52832' else 's132v6')
@@ -83,7 +83,7 @@ def build_examples(variant):
8383

8484
build_duration = time.monotonic() - start_time
8585

86-
print((build_format + '| {:5.2f}s |').format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, build_duration))
86+
print(build_format.format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, '{:5.2f}s'.format(build_duration)))
8787

8888
if success != "\033[33mskipped\033[0m ":
8989
if build_result.returncode != 0:

0 commit comments

Comments
 (0)