Skip to content

Commit 6a2dcbc

Browse files
committed
remove tinyusb core submodule, move tinyusb src to its own library to reduce dependency
1 parent 50b43ec commit 6a2dcbc

File tree

11 files changed

+154
-212
lines changed

11 files changed

+154
-212
lines changed

cores/nRF5/Arduino.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ void resumeLoop(void);
6969
#include "utility/AdaCallback.h"
7070

7171
#ifdef USE_TINYUSB
72-
#include "Adafruit_TinyUSB_Core.h"
72+
#include "Adafruit_USBD_Interface.h"
73+
#include "Adafruit_USBD_CDC.h"
7374
#endif
7475

7576
// Include board variant

cores/nRF5/TinyUSB/Adafruit_TinyUSB_nRF.cpp

Lines changed: 0 additions & 137 deletions
This file was deleted.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019 Ha Thach for Adafruit Industries
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+
#ifndef ADAFRUIT_USBD_CDC_H_
26+
#define ADAFRUIT_USBD_CDC_H_
27+
28+
#ifdef __cplusplus
29+
30+
#include "Adafruit_USBD_Interface.h"
31+
#include "Stream.h"
32+
33+
class Adafruit_USBD_CDC : public Stream, public Adafruit_USBD_Interface
34+
{
35+
public:
36+
Adafruit_USBD_CDC(void);
37+
38+
// fron Adafruit_USBD_Interface
39+
virtual uint16_t getDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize);
40+
41+
void setPins(uint8_t pin_rx, uint8_t pin_tx) { (void) pin_rx; (void) pin_tx; }
42+
void begin(uint32_t baud_count);
43+
void begin(uint32_t baud, uint8_t config);
44+
void end(void);
45+
46+
// return line coding set by host
47+
uint32_t baud(void);
48+
uint8_t stopbits(void);
49+
uint8_t paritytype(void);
50+
uint8_t numbits(void);
51+
int dtr(void);
52+
53+
// Stream API
54+
virtual int available(void);
55+
virtual int peek(void);
56+
virtual int read(void);
57+
virtual void flush(void);
58+
virtual size_t write(uint8_t);
59+
60+
virtual size_t write(const uint8_t *buffer, size_t size);
61+
size_t write(const char *buffer, size_t size) {
62+
return write((const uint8_t *)buffer, size);
63+
}
64+
65+
virtual int availableForWrite(void);
66+
using Print::write; // pull in write(str) from Print
67+
operator bool();
68+
};
69+
70+
extern Adafruit_USBD_CDC Serial;
71+
72+
#endif // __cplusplus
73+
#endif
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2021 Ha Thach (tinyusb.org) for Adafruit Industries
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+
#ifndef ADAFRUIT_USBD_INTERFACE_H_
26+
#define ADAFRUIT_USBD_INTERFACE_H_
27+
28+
#ifdef __cplusplus
29+
30+
class Adafruit_USBD_Interface
31+
{
32+
protected:
33+
const char* _desc_str;
34+
35+
public:
36+
Adafruit_USBD_Interface(void) { _desc_str = NULL; }
37+
38+
virtual uint16_t getDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize) = 0;
39+
void setStringDescriptor(const char* str) { _desc_str = str; }
40+
const char* getStringDescriptor(void) { return _desc_str; }
41+
};
42+
43+
#endif
44+
45+
#endif

cores/nRF5/common_inc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
#ifndef COMMON_INC_H_
3737
#define COMMON_INC_H_
3838

39+
#define ATTR_PACKED __attribute__ ((packed))
40+
#define ATTR_WEAK __attribute__((weak))
41+
3942
#include <stdint.h>
4043
#include <stdbool.h>
4144
#include <stddef.h>
4245

43-
#include "compiler_macro.h"
4446
#include "common_func.h"
4547
#include "verify.h"
4648

cores/nRF5/compiler_macro.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

cores/nRF5/delay.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
extern "C" {
2626
#endif
2727

28+
uint32_t tud_cdc_n_write_flush(uint8_t itf) ATTR_WEAK;
29+
2830
uint32_t millis( void )
2931
{
3032
return tick2ms(xTaskGetTickCount());
@@ -37,7 +39,7 @@ void delay( uint32_t ms )
3739
#ifdef USE_TINYUSB
3840
// Take chance to flush usb cdc
3941
uint32_t flush_tick = xTaskGetTickCount();
40-
tud_cdc_write_flush();
42+
tud_cdc_n_write_flush(0);
4143

4244
flush_tick = xTaskGetTickCount()-flush_tick;
4345
if (flush_tick >= ticks) return;

0 commit comments

Comments
 (0)