Skip to content

Commit 4468594

Browse files
authored
Merge pull request #258 from adafruit/develop
move and rename usb files
2 parents a317abe + 290b3b7 commit 4468594

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+66
-100
lines changed

README.md

Lines changed: 4 additions & 3 deletions

cores/nRF5/usb/usb.c renamed to cores/nRF5/Adafruit_TinyUSB_core/Adafruit_TinyUSB_Core.cpp

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,9 @@
2525

2626
#include "nrfx.h"
2727
#include "nrfx_power.h"
28-
#include "nrf_sdm.h"
29-
#include "nrf_soc.h"
3028

31-
#include "nrf_usbd.h"
32-
#include "tusb.h"
33-
#include "usb.h"
34-
35-
#include "rtos.h"
29+
#include "Arduino.h"
30+
#include "Adafruit_TinyUSB_Core.h"
3631

3732
//--------------------------------------------------------------------+
3833
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
@@ -43,7 +38,35 @@
4338
// Serial is 64-bit DeviceID -> 16 chars len
4439
uint16_t usb_desc_str_serial[1+16] = { TUD_DESC_STR_HEADER(16) };
4540

46-
static void usb_device_task(void* param);
41+
/* tinyusb function that handles power event (detected, ready, removed)
42+
* We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. */
43+
extern "C" void tusb_hal_nrf_power_event(uint32_t event);
44+
45+
void usb_init(void);
46+
47+
void Adafruit_TinyUSB_Core_init(void)
48+
{
49+
USBDevice.addInterface( (Adafruit_USBD_Interface&) Serial);
50+
USBDevice.setID(USB_VID, USB_PID);
51+
USBDevice.begin();
52+
53+
usb_init();
54+
}
55+
56+
57+
// USB Device Driver task
58+
// This top level thread process all usb events and invoke callbacks
59+
static void usb_device_task(void* param)
60+
{
61+
(void) param;
62+
63+
// RTOS forever loop
64+
while (1)
65+
{
66+
// tinyusb device task
67+
tud_task();
68+
}
69+
}
4770

4871
// Init usb when starting up. Softdevice is not enabled yet
4972
void usb_init(void)
@@ -85,36 +108,4 @@ void usb_init(void)
85108
xTaskCreate( usb_device_task, "usbd", USBD_STACK_SZ, NULL, TASK_PRIO_HIGH, NULL);
86109
}
87110

88-
// Must be called before sd_softdevice_enable()
89-
// NRF_POWER is restricted prph used by Softdevice, must be release before enable SD
90-
void usb_softdevice_pre_enable(void)
91-
{
92-
nrfx_power_usbevt_disable();
93-
nrfx_power_usbevt_uninit();
94-
nrfx_power_uninit();
95-
}
96-
97-
// Must be called after sd_softdevice_enable()
98-
// To re-enable USB
99-
void usb_softdevice_post_enable(void)
100-
{
101-
sd_power_usbdetected_enable(true);
102-
sd_power_usbpwrrdy_enable(true);
103-
sd_power_usbremoved_enable(true);
104-
}
105-
106-
// USB Device Driver task
107-
// This top level thread process all usb events and invoke callbacks
108-
static void usb_device_task(void* param)
109-
{
110-
(void) param;
111-
112-
// RTOS forever loop
113-
while (1)
114-
{
115-
// tinyusb device task
116-
tud_task();
117-
}
118-
}
119-
120111
#endif

cores/nRF5/usb/Adafruit_TinyUSB_core/Adafruit_TinyUSB_core.h renamed to cores/nRF5/Adafruit_TinyUSB_core/Adafruit_TinyUSB_Core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@
3232
#include "Adafruit_USBD_CDC.h"
3333
#endif
3434

35+
void Adafruit_TinyUSB_Core_init(void);
36+
3537
#endif /* ADAFRUIT_TINYUSB_CORE_H_ */

0 commit comments

Comments
 (0)