Skip to content

Commit 1046ce6

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents dff8112 + b03d6e5 commit 1046ce6

File tree

169 files changed

+60161
-7116
lines changed

Some content is hidden

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

169 files changed

+60161
-7116
lines changed

.github/workflows/githubci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ jobs:
5252
rm -r $HOME/$BSP_PATH/*
5353
ln -s $GITHUB_WORKSPACE $HOME/$BSP_PATH/$BSP_VERSION
5454
# Install library dependency
55-
arduino-cli lib install "Adafruit AHRS" "Adafruit APDS9960 Library" "Adafruit BMP280 Library" "Adafruit Circuit Playground" "Adafruit EPD" "Adafruit GFX Library" "Adafruit HX8357 Library" "Adafruit ILI9341" "Adafruit LIS3MDL" "Adafruit LSM6DS" "Adafruit NeoPixel" "Adafruit NeoMatrix" "Adafruit Sensor Calibration" "Adafruit SHT31 Library" "Adafruit SSD1306" "Adafruit ST7735 and ST7789 Library" "Firmata" "MIDI Library" "SdFat - Adafruit Fork"
55+
arduino-cli lib install "Adafruit AHRS" "Adafruit APDS9960 Library" "Adafruit BMP280 Library" "Adafruit Circuit Playground" "Adafruit EPD" "Adafruit GFX Library" "Adafruit HX8357 Library" "Adafruit ILI9341" "Adafruit LIS3MDL" "Adafruit LSM6DS" "Adafruit NeoPixel" "Adafruit NeoMatrix" "Adafruit Sensor Calibration" "Adafruit SHT31 Library" "Adafruit SSD1306" "Adafruit ST7735 and ST7789 Library" "Firmata" "SdFat - Adafruit Fork"
56+
57+
# TODO update to support MIDI version 5 later on
58+
arduino-cli lib install "MIDI Library"@4.3.1
5659
5760
- name: Build examples
5861
run: python3 tools/build_all.py ${{ matrix.arduino-platform }}

changelog.md

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

3+
## 0.20.1 - 2020.04.23
4+
5+
- Update TinyUSB to commit c59fa77 due to a bug in the stack
6+
7+
## 0.20.0 - 2020.04.21
8+
9+
- Fixed Wire write ambigou
10+
- Improved debugging with log and sysview, thanks to @henrygab
11+
- Fixed recipe to compute SRAM and ROM of sketch
12+
- Removed the force waiting Serial when debug is enabled
13+
- Updated nrfx to v2.1.0
14+
- Updated TinyUSB to commit 718db7e
15+
316
## 0.19.0 - 2020.03.12
417

518
- Add BLECharacteristic::isFixedLen()

cores/nRF5/TinyUSB/Adafruit_TinyUSB_nRF.cpp

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

33+
//--------------------------------------------------------------------+
34+
// Forward USB interrupt events to TinyUSB IRQ Handler
35+
//--------------------------------------------------------------------+
36+
extern "C" void USBD_IRQHandler(void)
37+
{
38+
#if CFG_SYSVIEW
39+
SEGGER_SYSVIEW_RecordEnterISR();
40+
#endif
41+
42+
tud_int_handler(0);
43+
44+
#if CFG_SYSVIEW
45+
SEGGER_SYSVIEW_RecordExitISR();
46+
#endif
47+
}
48+
3349
//--------------------------------------------------------------------+
3450
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
3551
//--------------------------------------------------------------------+
@@ -106,15 +122,6 @@ void Adafruit_TinyUSB_Core_touch1200(void)
106122
//--------------------------------------------------------------------+
107123
// Adafruit_USBD_Device platform dependent
108124
//--------------------------------------------------------------------+
109-
void Adafruit_USBD_Device::detach(void)
110-
{
111-
NRF_USBD->USBPULLUP = 0;
112-
}
113-
114-
void Adafruit_USBD_Device::attach(void)
115-
{
116-
NRF_USBD->USBPULLUP = 1;
117-
}
118125

119126
uint8_t Adafruit_USBD_Device::getSerialDescriptor(uint16_t* serial_str)
120127
{

cores/nRF5/TinyUSB/tusb_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
#define CFG_TUD_HID_BUFSIZE 64
6969

7070
// MIDI FIFO size of TX and RX
71-
#define CFG_TUD_MIDI_RX_BUFSIZE 64
72-
#define CFG_TUD_MIDI_TX_BUFSIZE 64
71+
#define CFG_TUD_MIDI_RX_BUFSIZE 128
72+
#define CFG_TUD_MIDI_TX_BUFSIZE 128
7373

7474
// Vendor FIFO size of TX and RX
7575
#define CFG_TUD_VENDOR_RX_BUFSIZE 64

cores/nRF5/WInterrupts.c

Lines changed: 81 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "Arduino.h"
2323
#include "wiring_private.h"
24+
#include "nrf_gpiote.h"
2425

2526
#include <string.h>
2627

@@ -95,25 +96,59 @@ int attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
9596
return 0;
9697
}
9798

98-
for (int ch = 0; ch < NUMBER_OF_GPIO_TE; ch++) {
99-
if (channelMap[ch] == -1 || (uint32_t)channelMap[ch] == pin) {
100-
channelMap[ch] = pin;
101-
callbacksInt[ch] = callback;
102-
callbackDeferred[ch] = deferred;
103-
104-
NRF_GPIOTE->CONFIG[ch] &= ~(GPIOTE_CONFIG_PORT_PIN_Msk | GPIOTE_CONFIG_POLARITY_Msk);
105-
NRF_GPIOTE->CONFIG[ch] |= ((pin << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk) |
106-
((polarity << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk);
99+
// All information for the configuration is known, except the prior values
100+
// of the config register. Pre-compute the mask and new bits for later use.
101+
// CONFIG[n] = (CONFIG[n] & oldRegMask) | newRegBits;
102+
//
103+
// Three fields are configured here: PORT/PIN, POLARITY, MODE
104+
const uint32_t oldRegMask = ~(GPIOTE_CONFIG_PORT_PIN_Msk | GPIOTE_CONFIG_POLARITY_Msk | GPIOTE_CONFIG_MODE_Msk);
105+
const uint32_t newRegBits =
106+
((pin << GPIOTE_CONFIG_PSEL_Pos ) & GPIOTE_CONFIG_PORT_PIN_Msk) |
107+
((polarity << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk) |
108+
((GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos ) & GPIOTE_CONFIG_MODE_Msk ) ;
109+
110+
int ch = -1;
111+
int newChannel = 0;
112+
113+
// Find channel where pin is already assigned, if any
114+
for (int i = 0; i < NUMBER_OF_GPIO_TE; i++) {
115+
if ((uint32_t)channelMap[i] != pin) continue;
116+
ch = i;
117+
break;
118+
}
119+
// else, find one not already mapped and also not in use by others
120+
if (ch == -1) {
121+
for (int i = 0; i < NUMBER_OF_GPIO_TE; i++) {
122+
if (channelMap[i] != -1) continue;
123+
if (nrf_gpiote_te_is_enabled(NRF_GPIOTE, i)) continue;
124+
125+
ch = i;
126+
newChannel = 1;
127+
break;
128+
}
129+
}
130+
// if no channel found, exit
131+
if (ch == -1) {
132+
return 0; // no channel available
133+
}
107134

108-
NRF_GPIOTE->CONFIG[ch] |= GPIOTE_CONFIG_MODE_Event;
135+
channelMap[ch] = pin; // harmless for existing channel
136+
callbacksInt[ch] = callback; // caller might be updating this for existing channel
137+
callbackDeferred[ch] = deferred; // caller might be updating this for existing channel
109138

110-
NRF_GPIOTE->INTENSET = (1 << ch);
139+
uint32_t tmp = NRF_GPIOTE->CONFIG[ch];
140+
tmp &= oldRegMask;
141+
tmp |= newRegBits; // for existing channel, effectively updates only the polarity
142+
NRF_GPIOTE->CONFIG[ch] = tmp;
111143

112-
return (1 << ch);
113-
}
144+
// For a new channel, additionally ensure no old events existed, and enable the interrupt
145+
if (newChannel) {
146+
NRF_GPIOTE->EVENTS_IN[ch] = 0;
147+
NRF_GPIOTE->INTENSET = (1 << ch);
114148
}
115149

116-
return 0;
150+
// Finally, indicate to caller the allocated / updated channel
151+
return (1 << ch);
117152
}
118153

119154
/*
@@ -129,14 +164,14 @@ void detachInterrupt(uint32_t pin)
129164

130165
for (int ch = 0; ch < NUMBER_OF_GPIO_TE; ch++) {
131166
if ((uint32_t)channelMap[ch] == pin) {
167+
NRF_GPIOTE->INTENCLR = (1 << ch);
168+
NRF_GPIOTE->CONFIG[ch] = 0;
169+
NRF_GPIOTE->EVENTS_IN[ch] = 0; // clear any final events
170+
171+
// now cleanup the rest of the use of the channel
132172
channelMap[ch] = -1;
133173
callbacksInt[ch] = NULL;
134174
callbackDeferred[ch] = false;
135-
136-
NRF_GPIOTE->CONFIG[ch] &= ~GPIOTE_CONFIG_MODE_Event;
137-
138-
NRF_GPIOTE->INTENCLR = (1 << ch);
139-
140175
break;
141176
}
142177
}
@@ -148,30 +183,39 @@ void GPIOTE_IRQHandler()
148183
SEGGER_SYSVIEW_RecordEnterISR();
149184
#endif
150185

151-
uint32_t event = offsetof(NRF_GPIOTE_Type, EVENTS_IN[0]);
152-
186+
// Read this once (not 8x), as it's a volatile read
187+
// across the AHB, which adds up to 3 cycles.
188+
uint32_t const enabledInterruptMask = NRF_GPIOTE->INTENSET;
153189
for (int ch = 0; ch < NUMBER_OF_GPIO_TE; ch++) {
154-
if ((*(uint32_t *)((uint32_t)NRF_GPIOTE + event) == 0x1UL) && (NRF_GPIOTE->INTENSET & (1 << ch))) {
155-
if (channelMap[ch] != -1 && callbacksInt[ch]) {
156-
if ( callbackDeferred[ch] ) {
157-
// Adafruit defer callback to non-isr if configured so
158-
ada_callback(NULL, 0, callbacksInt[ch]);
159-
}else{
160-
callbacksInt[ch]();
161-
}
190+
// only process where the interrupt is enabled and the event register is set
191+
// check interrupt enabled mask first, as already read that IOM value, to
192+
// reduce delays from AHB (16MHz) reads.
193+
if ( 0 == (enabledInterruptMask & (1 << ch))) continue;
194+
if ( 0 == NRF_GPIOTE->EVENTS_IN[ch]) continue;
195+
196+
// If the event was set and interrupts are enabled,
197+
// call the callback function only if it exists,
198+
// but ALWAYS clear the event to prevent an interrupt storm.
199+
if (channelMap[ch] != -1 && callbacksInt[ch]) {
200+
if ( callbackDeferred[ch] ) {
201+
// Adafruit defer callback to non-isr if configured so
202+
ada_callback(NULL, 0, callbacksInt[ch]);
203+
} else {
204+
callbacksInt[ch]();
162205
}
163-
164-
*(uint32_t *)((uint32_t)NRF_GPIOTE + event) = 0;
165-
#if __CORTEX_M == 0x04
166-
volatile uint32_t dummy = *((volatile uint32_t *)((uint32_t)NRF_GPIOTE + event));
167-
(void)dummy;
168-
#endif
169206
}
170207

171-
event = (uint32_t)((uint32_t)event + 4);
208+
// clear the event
209+
NRF_GPIOTE->EVENTS_IN[ch] = 0;
172210
}
211+
#if __CORTEX_M == 0x04
212+
// See note at nRF52840_PS_v1.1.pdf section 6.1.8 ("interrupt clearing")
213+
// See also https://gcc.gnu.org/onlinedocs/gcc/Volatiles.html for why
214+
// using memory barrier instead of read of an unrelated volatile
215+
__DSB(); __NOP();__NOP();__NOP();__NOP();
216+
#endif
173217

174218
#if CFG_SYSVIEW
175-
SEGGER_SYSVIEW_RecordExitISR();
219+
SEGGER_SYSVIEW_RecordExitISR();
176220
#endif
177221
}

cores/nRF5/main.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,13 @@ static void loop_task(void* arg)
4646

4747
#if CFG_DEBUG
4848
// If Serial is not begin(), call it to avoid hard fault
49-
Serial.begin(115200);
50-
51-
// Wait for Serial connection in debug mode
52-
while ( !Serial ) yield();
53-
54-
dbgPrintVersion();
49+
if(!Serial) Serial.begin(115200);
5550
#endif
5651

5752
setup();
5853

5954
#if CFG_DEBUG
55+
dbgPrintVersion();
6056
Bluefruit_printInfo();
6157
#endif
6258

cores/nRF5/nordic/nrfx/CHANGELOG.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,93 @@
11
# Changelog
22
All notable changes to this project are documented in this file.
33

4+
## [2.1.0] - 2020-01-24
5+
### Added
6+
- Added HALs for DCNF, OSCILLATORS, USBREG, and VREQCTRL.
7+
- Added support for 1-MHz clock frequency in TWIM.
8+
- Introduced the NRFX_I2S_STATUS_TRANSFER_STOPPED flag in the I2S driver.
9+
- Introduced the nrfx_power_compat layer that allows use of the nrfx_power API with new SoC.
10+
- Added encryption support in the QSPI driver.
11+
- Added support for USBD in nRF5340.
12+
- Expanded HALs to cover new functions in nRF5340: GPIO, I2S, PDM, POWER, QSPI, and REGULATORS.
13+
- Introduced new clock management system in the CLOCK driver.
14+
- Introduced new audio clock configuration settings in the I2S and PDM drivers for nRF5340.
15+
- Implemented workaround for nRF5340 anomaly 4 in the CLOCK driver.
16+
- Implemented workaround for nRF5340 anomaly 10 in the CCM HAL.
17+
- Implemented workaround for nRF9160 anomaly 21 and nRF5340 anomaly 6 in the NVMC HAL.
18+
- Implemented workaround for nRF9160 anomaly 23 and nRF5340 anomaly 44 in the UARTE driver.
19+
- Introduced the NRFX_TWIM_NO_SPURIOUS_STOP_CHECK flag in the TWIM driver.
20+
- Added functions for getting shortcut configuration in the TWIM HAL.
21+
22+
### Changed
23+
- Updated MDK to 8.30.2.
24+
- Reorganized templates of nrfx_config header files for different SoCs. Now they are included through one common file according to the selected SoC.
25+
- Improved the UARTE driver to consume less current after the driver uninitialization. Now all clocks are disabled properly after uninitialization.
26+
- Improved the GPIOTE driver robustness by setting the LATCH functionality to be used by default.
27+
- Changed names of the frequency divider symbols in the QSPI HAL to reflect the new frequencies in nRF5340. Old API names were preserved and are still supported.
28+
- Improved spurious STOP condition handling in the TWIM driver.
29+
- Improved sampling procedure in the advanced blocking mode in the SAADC driver.
30+
- Improved calibration procedure in the SAADC driver for nRF5340 and nRF9160.
31+
32+
### Fixed
33+
- Fixed address assertions in NVMC driver for the nRF5340 network core.
34+
- Fixed an issue in the TWI driver that would make the driver stuck when a premature STOP condition was generated by a slave device. The driver now handles this situation properly and signals that a bus error occurred.
35+
- Fixed the stopping procedure in the PWM driver. Previously in very specific circumstances the PWM output might be not stopped at all or might be immediately restarted.
36+
37+
## [2.0.0] - 2019-11-06
38+
### Added
39+
- Added support for nRF5340.
40+
- Added HALs for: CACHE, FPU, MUTEX, and RESET.
41+
- Added driver and HAL for IPC.
42+
- Added possibility to configure in UART and UARTE the number of stop bits and the type of parity, when a given SoC allows it.
43+
- Added function in the GPIO HAL for selecting the MCU to control the specified pin.
44+
- Added support for ONESHOT register in the TIMER HAL.
45+
- Added support for LIST feature in HALs for SPIS and TWIS.
46+
- Added possibility to choose TIMER instance used for workarounds in the NFCT driver.
47+
48+
### Changed
49+
- Updated MDK to 8.29.0.
50+
- Enhanced PWM driver API: added the "p_context" parameter to the event handler.
51+
- Updated address and task getters in all HALs to return values as uint32_t type.
52+
- Updated all HAL functions to take the pointer to the structure of registers of the peripheral as their first argument.
53+
- Changed __STATIC_INLINE symbol to NRF_STATIC_INLINE for HALs and NRFX_STATIC_INLINE for drivers.
54+
- Refactored the SAADC driver and HAL.
55+
- Refactored the WDT driver and HAL to support multiple instances.
56+
- Changed nrfx_gpiote_init() function to take the interrupt priority as its parameter. Previously this priority was an nrfx_config option.
57+
- Changed nrf_usbd_ep_all_disable() function to disable really all endpoints. Use nrf_usbd_ep_default_config() to restore the default endpoint configuration.
58+
- Updated nrfx_gpiote_out_init() and nrfx_gpiote_in_init() return codes. Now NRFX_ERROR_INVALID_STATE is changed to NRFX_ERROR_BUSY.
59+
- Replaced the SWI/EGU driver with one for EGU only.
60+
- Aligned symbol names for default IRQ priority in nrfx_config. These symbols are now adhering to the following standard: NRFX_xxx_DEFAULT_CONFIG_IRQ_PRIORITY.
61+
- Changed the way of configuring the MISO pin pull setting in SPI and SPIM drivers. Now it can be set separately for each instance.
62+
63+
### Removed
64+
- Removed deprecated functions from drivers: TWI and TWIM. See migration guide for details.
65+
- Removed deprecated functions from HALs: ECB, NVMC, and TEMP. See migration guide for details.
66+
- Removed redundant bariers in the nrfx_usbd driver.
67+
- Removed the default configuration values for drivers from the nrfx_config header files.
68+
69+
## [1.8.1] - 2019-10-21
70+
### Added
71+
- Added functions in the GPIOTE driver for getting task or event for the specified GPIO pin.
72+
73+
### Changed
74+
- Updated MDK to version 8.27.1.
75+
- Moved the nrfx_gppi helper from helpers/nrfx_gppi/ to helpers/.
76+
- Changed the interrupt initialization in the GPIOTE driver, so that mapping of the GPIOTEx_IRQn enumeration values is no longer needed for nRF9160.
77+
78+
## [1.8.0] - 2019-08-27
79+
### Added
80+
- Added support for nRF52833.
81+
- Added bus recovery feature in the TWI and TWIM drivers.
82+
- Added the nrfx_gppi helper layer to facilitate developing generic code that can utilize PPI or DPPI, depending on which interface is available in a given SoC.
83+
84+
### Changed
85+
- Updated MDK to version 8.27.0.
86+
87+
### Fixed
88+
- Fixed an issue in the TWIM driver that would make the driver stuck when a premature STOP condition was generated by a slave device. The driver now handles this situation properly and signals that a bus error occurred.
89+
- Fixed a frame timing bug in the NFCT driver. Previously, the timing of the SENS_RES response could be violated after the NFCT peripheral was put to the Sleep state with the SLP_REQ command.
90+
491
## [1.7.2] - 2019-07-25
592
### Added
693
- Added functions in the DPPI, GPIOTE, PPI, RTC, and TIMER HALs for getting tasks and events specified by index.

cores/nRF5/nordic/nrfx/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
1+
Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

cores/nRF5/nordic/nrfx/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@ SoCs, as well as startup and initialization files for them.
1616
* nRF52810
1717
* nRF52811
1818
* nRF52832
19+
* nRF52833
1920
* nRF52840
21+
* nRF5340
2022
* nRF9160
2123

2224
## Directories
2325

2426
```
2527
.
2628
├── doc # Project documentation files
27-
├── drivers # nrfx drivers files
28-
│ └── include # nrfx drivers headers
29-
│ └── src # nrfx drivers sources
29+
├── drivers # nrfx driver files
30+
│ └── include # nrfx driver headers
31+
│ └── src # nrfx driver sources
3032
├── hal # Hardware Access Layer files
31-
├── mdk # Nordic MDK files
32-
├── soc # Nordic SoC related files
33+
├── helpers # nrfx driver helper files
34+
├── mdk # nRF MDK files
35+
├── soc # SoC specific files
3336
└── templates # Templates of nrfx integration files
3437
```
3538

0 commit comments

Comments
 (0)