Skip to content

Commit 067059b

Browse files
author
Ladyada
committed
Merge branch 'master' into cplay_nrf
2 parents 1d41610 + 6c23375 commit 067059b

File tree

74 files changed

+13810
-800
lines changed

Some content is hidden

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

74 files changed

+13810
-800
lines changed

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ git:
44
depth: false
55
quiet: true
66

7+
env:
8+
- BSP_PATH="$HOME/.arduino15/packages/adafruit/hardware/nrf52"
9+
710
addons:
811
apt:
912
packages:
@@ -19,8 +22,12 @@ install:
1922
- umake electronics arduino $HOME/arduino_ide
2023
- export PATH=$HOME/arduino_ide:$PATH
2124
- arduino --pref "boardsmanager.additional.urls=https://adafruit.github.io/arduino-board-index/package_adafruit_index.json" --save-prefs
25+
# Install BSP for tools, then remove and create symlink the git code
2226
- arduino --install-boards adafruit:nrf52
23-
- arduino --install-library "Adafruit NeoPixel","Adafruit NeoMatrix","Adafruit GFX Library","Adafruit SSD1306","MIDI Library",
27+
- BSP_VERSION=`eval ls $BSP_PATH`
28+
- rm -r $BSP_PATH/*
29+
- ln -s $TRAVIS_BUILD_DIR $BSP_PATH/$BSP_VERSION
30+
- arduino --install-library "Adafruit NeoPixel","Adafruit NeoMatrix","Adafruit GFX Library","Adafruit SSD1306","MIDI Library","Adafruit ILI9341"
2431

2532
before_script:
2633

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This repository contains the Arduino BSP for Adafruit Bluefruit nRF52 series:
88

99
Following boards are also included but are not officially supported:
1010

11-
- [Noric nRF52840DK PCA10056](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK)
11+
- [Nordic nRF52840DK PCA10056](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK)
1212

1313
## BSP Installation
1414

@@ -115,4 +115,3 @@ The following libraries are used:
115115
- [tinyusb](https://github.com/hathach/tinyusb) as usb stack
116116
- [nrfx](https://github.com/NordicSemiconductor/nrfx) for peripherals driver
117117
- [littlefs](https://github.com/ARMmbed/littlefs) for internal file system
118-
- [fatfs by elm-chan](http://elm-chan.org/fsw/ff/00index_e.html) for external file system

bootloader/particle_xenon/particle_xenon_bootloader-0.2.11_s140_6.1.1.hex

Lines changed: 11431 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

changelog.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
# Adafruit nRF52 Arduino Core Changelog
22

3-
# 0.11.1
3+
## Next Release
44

5+
## 0.12.0 - 2019.08.05
6+
7+
- Update tinyusb core to support webUSB & vendor class
8+
- Added a couple delete operators to make std=gnu++14/17, PR #312 thanks to @kevinfrei
9+
- Fix Serial.read() return clean 8-bit, PR #308 thanks to @pyro9
10+
- Added availableForWrite(), PR #311 thanks to @pyro9
11+
12+
## 0.11.1 - 2019.07.10
13+
14+
- Update tinyusb core to support USB MIDI
515
- Refactor Ada Callback, use ISCR to detect isr context. Use function instead of macro
616
- Implement #240 run travis test with all example sketches
7-
- Fix auto-start of advertising when central is connected, thanks to @ogatatsu PR #268
17+
- Fixed auto-start of advertising when central is connected, thanks to @ogatatsu PR #268
818
- Added Tone()/noTone() functions
19+
- Travis-ci builds all sketches when commit code
20+
- Fixed setAppearance/getAppearance() typo, thanks to @paulmand3l PR #292
21+
- Fixed rssi_proximity_peripheral sketch, thanks to @dicobrazz PR #295
22+
- Fixed doc typo, thanks to @yvadher PR #296
23+
- Fixed HID usage code location comment in exmaple sketch, thanks to @stefandz PR #297
24+
- Fixed #277 conn LED doesn't stop when scanner is time out
25+
- Added connection handle to Bluefruit.connParied()
926

10-
# 0.11.0
27+
## 0.11.0
1128

1229
- Rework USB driver to support Adafruit_TinyUSB library (support HID and MSC)
1330
- Added Metro nRF52840 Express
@@ -29,7 +46,7 @@
2946
- enhance Serial.available()/write() to prevent blocking wait without yield/delay
3047
- Clean up compiler warnings
3148

32-
# 0.10.1
49+
## 0.10.1
3350

3451
This release added multiple concurrent peripheral connections support, allow Bluefruit device to multiple central (phones/PC) simultaneously. It introduces new BLE class: BLEPeriph, BLEConnection, remove BLEGap, refactor/rename/move functions and callbacks.
3552

@@ -72,7 +89,7 @@ This release added multiple concurrent peripheral connections support, allow Blu
7289
- Removed keyboardReport() variant with flat keycode parameters
7390
- Added conn_handle parameter to keyboard led callback
7491

75-
# 0.9.3
92+
## 0.9.3
7693

7794
- Correct bootloader version text in IDE to 0.2.6
7895
- Fixed #173 bleuart return incorrect value when failed to send (PR #178 thanks Nenik)

cores/nRF5/Adafruit_TinyUSB_Core/Adafruit_USBD_CDC.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ Adafruit_USBD_CDC::Adafruit_USBD_CDC(void)
3737

3838
}
3939

40-
uint16_t Adafruit_USBD_CDC::getDescriptor(uint8_t* buf, uint16_t bufsize)
40+
uint16_t Adafruit_USBD_CDC::getDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize)
4141
{
4242
// CDC is mostly always existed for DFU
43-
uint8_t desc[] = { TUD_CDC_DESCRIPTOR(0, 0, EPIN, 8, EPOUT, EPIN, 64) };
43+
// usb core will automatically update endpoint number
44+
uint8_t desc[] = { TUD_CDC_DESCRIPTOR(itfnum, 0, EPIN, 8, EPOUT, EPIN, 64) };
4445
uint16_t const len = sizeof(desc);
4546

4647
if ( bufsize < len ) return 0;
@@ -52,9 +53,13 @@ uint16_t Adafruit_USBD_CDC::getDescriptor(uint8_t* buf, uint16_t bufsize)
5253
// Baud and config is ignore in CDC
5354
void Adafruit_USBD_CDC::begin (uint32_t baud)
5455
{
56+
(void) baud;
5557
}
58+
5659
void Adafruit_USBD_CDC::begin (uint32_t baud, uint8_t config)
5760
{
61+
(void) baud;
62+
(void) config;
5863
}
5964

6065
void Adafruit_USBD_CDC::end(void)
@@ -86,7 +91,8 @@ int Adafruit_USBD_CDC::available(void)
8691

8792
int Adafruit_USBD_CDC::peek(void)
8893
{
89-
return tud_cdc_peek(0);
94+
uint8_t ch;
95+
return tud_cdc_peek(0, &ch) ? (int) ch : -1;
9096
}
9197

9298
int Adafruit_USBD_CDC::read(void)
@@ -101,7 +107,7 @@ void Adafruit_USBD_CDC::flush(void)
101107

102108
size_t Adafruit_USBD_CDC::write(uint8_t ch)
103109
{
104-
return tud_cdc_write_char((char) ch);
110+
return write(&ch, 1);
105111
}
106112

107113
size_t Adafruit_USBD_CDC::write(const uint8_t *buffer, size_t size)
@@ -120,6 +126,11 @@ size_t Adafruit_USBD_CDC::write(const uint8_t *buffer, size_t size)
120126
return size - remain;
121127
}
122128

129+
int Adafruit_USBD_CDC::availableForWrite(void)
130+
{
131+
return tud_cdc_write_available();
132+
}
133+
123134
extern "C"
124135
{
125136

@@ -128,6 +139,7 @@ extern "C"
128139
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
129140
{
130141
(void) itf; // interface ID, not used
142+
(void) rts;
131143

132144
// DTR = false is counted as disconnected
133145
if ( !dtr )

cores/nRF5/Adafruit_TinyUSB_Core/Adafruit_USBD_CDC.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,24 @@ class Adafruit_USBD_CDC : public Stream, Adafruit_USBD_Interface
3434
Adafruit_USBD_CDC(void);
3535

3636
// fron Adafruit_USBD_Interface
37-
virtual uint16_t getDescriptor(uint8_t* buf, uint16_t bufsize);
37+
virtual uint16_t getDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize);
3838

3939
void setPins(uint8_t pin_rx, uint8_t pin_tx) { (void) pin_rx; (void) pin_tx; }
4040
void begin(uint32_t baud_count);
4141
void begin(uint32_t baud, uint8_t config);
4242
void end(void);
4343

44-
virtual int available(void);
45-
virtual int peek(void);
46-
virtual int read(void);
47-
virtual void flush(void);
44+
virtual int available(void);
45+
virtual int peek(void);
46+
virtual int read(void);
47+
virtual void flush(void);
4848
virtual size_t write(uint8_t);
49+
4950
virtual size_t write(const uint8_t *buffer, size_t size);
5051
size_t write(const char *buffer, size_t size) {
5152
return write((const uint8_t *)buffer, size);
5253
}
54+
virtual int availableForWrite(void);
5355
operator bool();
5456
};
5557

cores/nRF5/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Adafruit_USBD_Device USBDevice;
4040

4141
Adafruit_USBD_Device::Adafruit_USBD_Device(void)
4242
{
43-
tusb_desc_device_t desc_dev =
43+
tusb_desc_device_t const desc_dev =
4444
{
4545
.bLength = sizeof(tusb_desc_device_t),
4646
.bDescriptorType = TUSB_DESC_DEVICE,
@@ -57,25 +57,22 @@ Adafruit_USBD_Device::Adafruit_USBD_Device(void)
5757
.idVendor = 0,
5858
.idProduct = 0,
5959
.bcdDevice = 0x0100,
60-
6160
.iManufacturer = 0x01,
6261
.iProduct = 0x02,
6362
.iSerialNumber = 0x03,
64-
6563
.bNumConfigurations = 0x01
6664
};
6765

6866
_desc_device = desc_dev;
6967

70-
tusb_desc_configuration_t dev_cfg =
68+
tusb_desc_configuration_t const dev_cfg =
7169
{
7270
.bLength = sizeof(tusb_desc_configuration_t),
7371
.bDescriptorType = TUSB_DESC_CONFIGURATION,
7472

7573
// Total Length & Interface Number will be updated later
7674
.wTotalLength = 0,
7775
.bNumInterfaces = 0,
78-
7976
.bConfigurationValue = 1,
8077
.iConfiguration = 0x00,
8178
.bmAttributes = TU_BIT(7) | TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP,
@@ -95,26 +92,17 @@ Adafruit_USBD_Device::Adafruit_USBD_Device(void)
9592
bool Adafruit_USBD_Device::addInterface(Adafruit_USBD_Interface& itf)
9693
{
9794
uint8_t* desc = _desc_cfg+_desc_cfglen;
98-
uint16_t const len = itf.getDescriptor(desc, sizeof(_desc_cfg)-_desc_cfglen);
95+
uint16_t const len = itf.getDescriptor(_itf_count, desc, sizeof(_desc_cfg)-_desc_cfglen);
9996
uint8_t* desc_end = desc+len;
10097

10198
if ( !len ) return false;
10299

103-
// Handle IAD
104-
if ( desc[1] == TUSB_DESC_INTERFACE_ASSOCIATION )
105-
{
106-
// update starting interface
107-
((tusb_desc_interface_assoc_t*) desc)->bFirstInterface = _itf_count;
108-
109-
desc += desc[0]; // next
110-
}
111-
112100
while (desc < desc_end)
113101
{
114102
if (desc[1] == TUSB_DESC_INTERFACE)
115103
{
116-
// No alternate interface support
117-
((tusb_desc_interface_t*) desc)->bInterfaceNumber = _itf_count++;
104+
tusb_desc_interface_t* desc_itf = (tusb_desc_interface_t*) desc;
105+
if (desc_itf->bAlternateSetting == 0) _itf_count++;
118106
}else if (desc[1] == TUSB_DESC_ENDPOINT)
119107
{
120108
tusb_desc_endpoint_t* desc_ep = (tusb_desc_endpoint_t*) desc;
@@ -127,7 +115,7 @@ bool Adafruit_USBD_Device::addInterface(Adafruit_USBD_Interface& itf)
127115

128116
_desc_cfglen += len;
129117

130-
// Update config descriptor
118+
// Update configuration descriptor
131119
tusb_desc_configuration_t* config = (tusb_desc_configuration_t*)_desc_cfg;
132120
config->wTotalLength = _desc_cfglen;
133121
config->bNumInterfaces = _itf_count;
@@ -141,6 +129,11 @@ void Adafruit_USBD_Device::setID(uint16_t vid, uint16_t pid)
141129
_desc_device.idProduct = pid;
142130
}
143131

132+
void Adafruit_USBD_Device::setVersion(uint16_t bcd)
133+
{
134+
_desc_device.bcdUSB = bcd;
135+
}
136+
144137
bool Adafruit_USBD_Device::begin(void)
145138
{
146139
return true;

cores/nRF5/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class Adafruit_USBD_Interface
3131
{
3232
public:
33-
virtual uint16_t getDescriptor(uint8_t* buf, uint16_t bufsize) = 0;
33+
virtual uint16_t getDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize) = 0;
3434
};
3535

3636
class Adafruit_USBD_Device
@@ -52,12 +52,13 @@ class Adafruit_USBD_Device
5252
bool addInterface(Adafruit_USBD_Interface& itf);
5353

5454
void setID(uint16_t vid, uint16_t pid);
55+
void setVersion(uint16_t bcd);
5556
bool begin(void);
5657

57-
bool mounted(void) { return tud_mounted(); }
58-
bool suspended(void) { return tud_suspended(); }
59-
bool ready(void) { return tud_ready(); }
60-
bool remoteWakeup(void) { return tud_remote_wakeup(); }
58+
bool mounted (void) { return tud_mounted(); }
59+
bool suspended (void) { return tud_suspended(); }
60+
bool ready (void) { return tud_ready(); }
61+
bool remoteWakeup (void) { return tud_remote_wakeup(); }
6162

6263
friend uint8_t const * tud_descriptor_device_cb(void);
6364
friend uint8_t const * tud_descriptor_configuration_cb(uint8_t index);

cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/class/audio/audio.h

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
* Currently only MIDI subclass is supported
3030
* @{ */
3131

32-
#ifndef _TUSB_CDC_H__
33-
#define _TUSB_CDC_H__
32+
#ifndef _TUSB_AUDIO_H__
33+
#define _TUSB_AUDIO_H__
3434

3535
#include "common/tusb_common.h"
3636

@@ -41,9 +41,9 @@
4141
/// Audio Interface Subclass Codes
4242
typedef enum
4343
{
44-
AUDIO_SUBCLASS_AUDIO_CONTROL = 0x01 , ///< Audio Control
45-
AUDIO_SUBCLASS_AUDIO_STREAMING , ///< Audio Streaming
46-
AUDIO_SUBCLASS_MIDI_STREAMING , ///< MIDI Streaming
44+
AUDIO_SUBCLASS_CONTROL = 0x01 , ///< Audio Control
45+
AUDIO_SUBCLASS_STREAMING , ///< Audio Streaming
46+
AUDIO_SUBCLASS_MIDI_STREAMING , ///< MIDI Streaming
4747
} audio_subclass_type_t;
4848

4949
/// Audio Protocol Codes
@@ -54,6 +54,40 @@ typedef enum
5454
AUDIO_PROTOCOL_V3 = 0x30, ///< Version 3.0
5555
} audio_protocol_type_t;
5656

57+
/// Audio Function Category Codes
58+
typedef enum
59+
{
60+
AUDIO_FUNC_DESKTOP_SPEAKER = 0x01,
61+
AUDIO_FUNC_HOME_THEATER = 0x02,
62+
AUDIO_FUNC_MICROPHONE = 0x03,
63+
AUDIO_FUNC_HEADSET = 0x04,
64+
AUDIO_FUNC_TELEPHONE = 0x05,
65+
AUDIO_FUNC_CONVERTER = 0x06,
66+
AUDIO_FUNC_SOUND_RECODER = 0x07,
67+
AUDIO_FUNC_IO_BOX = 0x08,
68+
AUDIO_FUNC_MUSICAL_INSTRUMENT = 0x09,
69+
AUDIO_FUNC_PRO_AUDIO = 0x0A,
70+
AUDIO_FUNC_AUDIO_VIDEO = 0x0B,
71+
AUDIO_FUNC_CONTROL_PANEL = 0x0C
72+
} audio_function_t;
73+
74+
/// Audio Class-Specific AC Interface Descriptor Subtypes
75+
typedef enum
76+
{
77+
AUDIO_CS_INTERFACE_HEADER = 0x01,
78+
AUDIO_CS_INTERFACE_INPUT_TERMINAL = 0x02,
79+
AUDIO_CS_INTERFACE_OUTPUT_TERMINAL = 0x03,
80+
AUDIO_CS_INTERFACE_MIXER_UNIT = 0x04,
81+
AUDIO_CS_INTERFACE_SELECTOR_UNIT = 0x05,
82+
AUDIO_CS_INTERFACE_FEATURE_UNIT = 0x06,
83+
AUDIO_CS_INTERFACE_EFFECT_UNIT = 0x07,
84+
AUDIO_CS_INTERFACE_PROCESSING_UNIT = 0x08,
85+
AUDIO_CS_INTERFACE_EXTENSION_UNIT = 0x09,
86+
AUDIO_CS_INTERFACE_CLOCK_SOURCE = 0x0A,
87+
AUDIO_CS_INTERFACE_CLOCK_SELECTOR = 0x0B,
88+
AUDIO_CS_INTERFACE_CLOCK_MULTIPLIER = 0x0C,
89+
AUDIO_CS_INTERFACE_SAMPLE_RATE_CONVERTER = 0x0D,
90+
} audio_cs_interface_subtype_t;
5791

5892
/** @} */
5993

0 commit comments

Comments
 (0)