Skip to content

Commit 3287414

Browse files
committed
add rp2040 port
1 parent f2ef5db commit 3287414

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

src/arduino/ports/Adafruit_TinyUSB_nrf.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#if defined ARDUINO_NRF52_ADAFRUIT && defined USE_TINYUSB
25+
#include "tusb_option.h"
26+
27+
#if defined ARDUINO_NRF52_ADAFRUIT && TUSB_OPT_DEVICE_ENABLED
2628

2729
#include "nrfx.h"
2830
#include "nrfx_power.h"
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019, hathach for Adafruit
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#include "tusb_option.h"
26+
27+
#if defined ARDUINO_ARCH_RP2040 & TUSB_OPT_DEVICE_ENABLED
28+
29+
#include "Arduino.h"
30+
#include "arduino/Adafruit_USBD_Device.h"
31+
32+
#include "pico/bootrom.h"
33+
#include "pico/unique_id.h"
34+
35+
//--------------------------------------------------------------------+
36+
// Forward USB interrupt events to TinyUSB IRQ Handler
37+
// rp2040 implementation will install approriate handler when initializing
38+
// tinyusb. There is no need to forward IRQ from application
39+
//--------------------------------------------------------------------+
40+
41+
extern "C"
42+
{
43+
44+
// run TinyUSB background task when yield()
45+
void yield(void)
46+
{
47+
tud_task();
48+
tud_cdc_write_flush();
49+
}
50+
51+
} // extern C
52+
53+
//--------------------------------------------------------------------+
54+
// Porting API
55+
//--------------------------------------------------------------------+
56+
57+
58+
void TinyUSB_Port_InitDeviceController(uint8_t rhport)
59+
{
60+
(void) rhport;
61+
62+
// no specific hardware initialization
63+
// TOOD maybe set up sdtio usb
64+
}
65+
66+
void TinyUSB_Port_EnterDFU(void)
67+
{
68+
reset_usb_boot(0,0);
69+
while(1) {}
70+
}
71+
72+
uint8_t TinyUSB_Port_GetSerialNumber(uint8_t serial_id[16])
73+
{
74+
pico_get_unique_board_id( (pico_unique_board_id_t*) serial_id );
75+
return PICO_UNIQUE_BOARD_ID_SIZE_BYTES;
76+
}
77+
78+
#endif // USE_TINYUSB

src/arduino/ports/Adafruit_TinyUSB_samd.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#if defined ARDUINO_ARCH_SAMD & defined USE_TINYUSB
25+
#include "tusb_option.h"
26+
27+
#if defined ARDUINO_ARCH_SAMD & TUSB_OPT_DEVICE_ENABLED
2628

2729
#include "Arduino.h"
2830
#include "arduino/Adafruit_USBD_Device.h"

0 commit comments

Comments
 (0)