Skip to content

Commit

Permalink
Merge tag '1.0.0' into merge_1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
soburi committed Sep 4, 2021
2 parents e1c51af + c11f3e9 commit 968c800
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 10 deletions.
15 changes: 15 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Adafruit nRF52 Arduino Core Changelog

## 1.0.0 - 2021.08.18

Core is stable enough to be released as 1.0.0. Following is chagnes since last release

- Add UART missing baudrate of 31250 and 56000
- Fix peer bonding with public/static address
- Fix PDM driver issue when BLE is enabled
- Update nrfutil binary to post17 for windows 7
- Add analogSampleTime() to set ADC sample time
- Add readCPUTemperature() to get CPU die temperature
- Add analogCalibrateOffset() to calibrate ADC offset
- Fix UART is not powered down correctly
- Update included bootlaoder binaries to 0.6.1
- Update included TinyUSB lib to 1.4.4

## 0.24.0 - 2021.06.25

- Update included TinyUSB libraries to 1.3.0
Expand Down
12 changes: 12 additions & 0 deletions cores/nRF5/Uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ void Uart::begin(unsigned long baudrate, uint16_t config)
nrfBaudRate = UARTE_BAUDRATE_BAUDRATE_Baud19200;
} else if (baudrate <= 28800) {
nrfBaudRate = UARTE_BAUDRATE_BAUDRATE_Baud28800;
} else if (baudrate <= 31250) {
nrfBaudRate = UARTE_BAUDRATE_BAUDRATE_Baud31250;
} else if (baudrate <= 38400) {
nrfBaudRate = UARTE_BAUDRATE_BAUDRATE_Baud38400;
} else if (baudrate <= 56000) {
nrfBaudRate = UARTE_BAUDRATE_BAUDRATE_Baud56000;
} else if (baudrate <= 57600) {
nrfBaudRate = UARTE_BAUDRATE_BAUDRATE_Baud57600;
} else if (baudrate <= 76800) {
Expand Down Expand Up @@ -152,9 +156,17 @@ void Uart::end()

nrfUart->INTENCLR = UARTE_INTENSET_ENDRX_Msk | UARTE_INTENSET_ENDTX_Msk;

nrfUart->EVENTS_RXTO = 0;
nrfUart->EVENTS_TXSTOPPED = 0;

nrfUart->TASKS_STOPRX = 0x1UL;
nrfUart->TASKS_STOPTX = 0x1UL;

// Wait for TXSTOPPED event and for RXTO event
// This is required before disabling UART to fully power down transceiver PHY.
// Otherwise transceiver will continue to consume ~900uA
while ( !(nrfUart->EVENTS_TXSTOPPED && nrfUart->EVENTS_RXTO) ) yield();

nrfUart->ENABLE = UARTE_ENABLE_ENABLE_Disabled;

nrfUart->PSEL.TXD = 0xFFFFFFFF;
Expand Down
2 changes: 2 additions & 0 deletions cores/nRF5/common_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@


#ifdef __cplusplus
extern "C++" {
// namespace and templates must be outside the `extern "C"` declaration...
namespace ADAFRUIT_DETAIL
{
Expand All @@ -48,6 +49,7 @@
return N;
}
}
}
extern "C" {
#define arrcount(arr) ADAFRUIT_DETAIL::arrcount_fails_if_not_array(arr)
#define ADA_STATIC_ASSERT(const_expr, message) static_assert(const_expr, message)
Expand Down
24 changes: 24 additions & 0 deletions cores/nRF5/wiring.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,27 @@ void systemOff(uint32_t pin, uint8_t wake_logic)
NRF_POWER->SYSTEMOFF = 1;
}
}


float readCPUTemperature( void )
{
uint8_t en;
int32_t temp;
(void) sd_softdevice_is_enabled(&en);
if (en)
{
sd_temp_get(&temp);
}
else
{
NRF_TEMP->EVENTS_DATARDY = 0x00; // Only needed in case another function is also looking at this event flag
NRF_TEMP->TASKS_START = 0x01;

while (!NRF_TEMP->EVENTS_DATARDY);
temp = NRF_TEMP->TEMP; // Per anomaly 29 (unclear whether still applicable), TASKS_STOP will clear the TEMP register.

NRF_TEMP->TASKS_STOP = 0x01; // Per anomaly 30 (unclear whether still applicable), the temp peripheral needs to be shut down
NRF_TEMP->EVENTS_DATARDY = 0x00;
}
return temp / 4.0F;
}
6 changes: 6 additions & 0 deletions cores/nRF5/wiring.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ static inline bool isInISR(void)
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0 ;
}

/*
* \brief Reads the on-chip temperature sensor, returning the temperature in degrees C
* with a resolution of 0.25 degrees.
*/
float readCPUTemperature( void );

#ifdef __cplusplus
}
#endif
17 changes: 17 additions & 0 deletions cores/nRF5/wiring_analog.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@ extern void analogReadResolution(int res);
*/
extern void analogWriteResolution(uint8_t res);

/*
* \brief Set the ADC sample time. Default is 3us (appropriate for low source resistance).
* See the chart of appropriate sample time vs. source resistance in the SAADC section
* of the Nordic nrf52 product specification.
*
* \param time Should be set to 3, 5, 10, 15, 20 or 40.
*/
extern void analogSampleTime(uint8_t sTime);

/*
* \brief Calibrate the ADC offset. This is recommended occasionally, or any time the
* chip temperature changes by more than 10 C. See the SAADC section of the Nordic
* nrf52 product pecification.
*
*/
extern void analogCalibrateOffset( void );

extern void analogOutputInit( void ) ;

#ifdef __cplusplus
Expand Down
44 changes: 43 additions & 1 deletion cores/nRF5/wiring_analog_nRF52.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" {

static uint32_t saadcReference = SAADC_CH_CONFIG_REFSEL_Internal;
static uint32_t saadcGain = SAADC_CH_CONFIG_GAIN_Gain1_6;
static uint32_t saadcSampleTime = SAADC_CH_CONFIG_TACQ_3us;

static bool saadcBurst = SAADC_CH_CONFIG_BURST_Disabled;

Expand Down Expand Up @@ -140,6 +141,28 @@ void analogOversampling( uint32_t ulOversampling )
}
}

void analogSampleTime( uint8_t sTime)
{
saadcSampleTime = SAADC_CH_CONFIG_TACQ_3us; // default is 3 us
switch (sTime) {
case 5:
saadcSampleTime = SAADC_CH_CONFIG_TACQ_5us;
break;
case 10:
saadcSampleTime = SAADC_CH_CONFIG_TACQ_10us;
break;
case 15:
saadcSampleTime = SAADC_CH_CONFIG_TACQ_15us;
break;
case 20:
saadcSampleTime = SAADC_CH_CONFIG_TACQ_20us;
break;
case 40:
saadcSampleTime = SAADC_CH_CONFIG_TACQ_40us;
break;
}
}

static uint32_t analogRead_internal( uint32_t psel )
{
uint32_t saadcResolution;
Expand Down Expand Up @@ -171,7 +194,7 @@ static uint32_t analogRead_internal( uint32_t psel )
| ((SAADC_CH_CONFIG_RESP_Bypass << SAADC_CH_CONFIG_RESN_Pos) & SAADC_CH_CONFIG_RESN_Msk)
| ((saadcGain << SAADC_CH_CONFIG_GAIN_Pos) & SAADC_CH_CONFIG_GAIN_Msk)
| ((saadcReference << SAADC_CH_CONFIG_REFSEL_Pos) & SAADC_CH_CONFIG_REFSEL_Msk)
| ((SAADC_CH_CONFIG_TACQ_3us << SAADC_CH_CONFIG_TACQ_Pos) & SAADC_CH_CONFIG_TACQ_Msk)
| ((saadcSampleTime << SAADC_CH_CONFIG_TACQ_Pos) & SAADC_CH_CONFIG_TACQ_Msk)
| ((SAADC_CH_CONFIG_MODE_SE << SAADC_CH_CONFIG_MODE_Pos) & SAADC_CH_CONFIG_MODE_Msk)
| ((saadcBurst << SAADC_CH_CONFIG_BURST_Pos) & SAADC_CH_CONFIG_BURST_Msk);
NRF_SAADC->CH[0].PSELN = psel;
Expand Down Expand Up @@ -261,6 +284,25 @@ uint32_t analogReadVDD( void )
return analogRead_internal(SAADC_CH_PSELP_PSELP_VDD);
}

void analogCalibrateOffset( void )
{
// Enable the SAADC
NRF_SAADC->ENABLE = 0x01;

// Be sure the done flag is cleared, then trigger offset calibration
NRF_SAADC->EVENTS_CALIBRATEDONE = 0x00;
NRF_SAADC->TASKS_CALIBRATEOFFSET = 0x01;

// Wait for completion
while (!NRF_SAADC->EVENTS_CALIBRATEDONE);

// Clear the done flag (really shouldn't have to do this both times)
NRF_SAADC->EVENTS_CALIBRATEDONE = 0x00;

// Disable the SAADC
NRF_SAADC->ENABLE = 0x00;
}

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion libraries/Adafruit_TinyUSB_Arduino
Submodule Adafruit_TinyUSB_Arduino updated 78 files
+1 −1 .github/ISSUE_TEMPLATE/bug_report.yml
+32 −8 README.md
+41 −0 changelog.md
+0 −1 examples/Composite/hid_generic_inout_ramdisk/README.md
+0 −135 examples/Composite/hid_generic_inout_ramdisk/hid_generic_inout_ramdisk.ino
+0 −113 examples/Composite/hid_generic_inout_ramdisk/ramdisk.h
+6 −1 examples/Composite/mouse_external_flash/mouse_external_flash.ino
+9 −2 examples/Composite/mouse_ramdisk/mouse_ramdisk.ino
+38 −38 examples/HID/hid_boot_keyboard/hid_boot_keyboard.ino
+18 −9 examples/HID/hid_boot_mouse/hid_boot_mouse.ino
+8 −6 examples/HID/hid_composite/hid_composite.ino
+3 −3 examples/HID/hid_composite_joy_featherwing/hid_composite_joy_featherwing.ino
+8 −3 examples/HID/hid_gamepad/hid_gamepad.ino
+3 −4 examples/HID/hid_generic_inout/boards.js
+24 −11 examples/HID/hid_generic_inout/hid_generic_inout.ino
+4 −7 examples/HID/hid_generic_inout/hid_test.js
+4 −1 examples/HID/hid_generic_inout/hid_test.py
+1 −1 examples/MIDI/midi_pizza_box_dj/midi_pizza_box_dj.ino
+22 −5 examples/MIDI/midi_test/midi_test.ino
+5 −0 examples/MassStorage/msc_external_flash/msc_external_flash.ino
+6 −1 examples/MassStorage/msc_external_flash_sdcard/msc_external_flash_sdcard.ino
+11 −6 examples/MassStorage/msc_ramdisk/msc_ramdisk.ino
+6 −1 examples/MassStorage/msc_ramdisk_dual/msc_ramdisk_dual.ino
+0 −0 examples/MassStorage/msc_sd/.metroesp32s2_tinyusb.test.skip
+1 −1 examples/MassStorage/msc_sd/msc_sd.ino
+1 −1 examples/MassStorage/msc_sdfat/msc_sdfat.ino
+1 −1 examples/WebUSB/webusb_rgb/webusb_rgb.ino
+6 −1 examples/WebUSB/webusb_serial/webusb_serial.ino
+1 −1 library.properties
+1 −1 src/Adafruit_TinyUSB.h
+1 −1 src/arduino/Adafruit_TinyUSB_API.cpp
+2 −2 src/arduino/Adafruit_USBD_CDC.cpp
+35 −6 src/arduino/Adafruit_USBD_Device.cpp
+7 −1 src/arduino/Adafruit_USBD_Device.h
+1 −1 src/arduino/hid/Adafruit_USBD_HID.cpp
+1 −1 src/arduino/midi/Adafruit_USBD_MIDI.cpp
+1 −1 src/arduino/msc/Adafruit_USBD_MSC.cpp
+0 −86 src/arduino/ports/esp32/tusb_config_esp32.h
+6 −6 src/arduino/ports/nrf/Adafruit_TinyUSB_nrf.cpp
+58 −16 src/arduino/ports/rp2040/Adafruit_TinyUSB_rp2040.cpp
+0 −4 src/arduino/ports/rp2040/tusb_config_rp2040.h
+1 −1 src/arduino/ports/samd/tusb_config_samd.h
+2 −2 src/arduino/webusb/Adafruit_USBD_WebUSB.cpp
+28 −1 src/class/audio/audio.h
+215 −185 src/class/audio/audio_device.c
+11 −6 src/class/cdc/cdc.h
+4 −6 src/class/cdc/cdc_device.c
+24 −23 src/class/dfu/dfu.h
+458 −0 src/class/dfu/dfu_device.c
+98 −0 src/class/dfu/dfu_device.h
+3 −3 src/class/dfu/dfu_rt_device.c
+2 −2 src/class/hid/hid.h
+26 −2 src/class/hid/hid_device.c
+14 −14 src/class/midi/midi_device.c
+12 −8 src/class/msc/msc_device.c
+16 −8 src/common/tusb_common.h
+59 −8 src/common/tusb_compiler.h
+2 −10 src/common/tusb_fifo.c
+1 −1 src/common/tusb_fifo.h
+16 −5 src/common/tusb_types.h
+1 −1 src/common/tusb_verify.h
+13 −0 src/device/dcd.h
+164 −0 src/device/dcd_attr.h
+48 −29 src/device/usbd.c
+54 −18 src/device/usbd.h
+1 −0 src/device/usbd_control.c
+0 −1 src/device/usbd_pvt.h
+74 −31 src/portable/nordic/nrf5x/dcd_nrf5x.c
+55 −79 src/portable/raspberrypi/rp2040/dcd_rp2040.c
+136 −112 src/portable/raspberrypi/rp2040/hcd_rp2040.c
+201 −196 src/portable/raspberrypi/rp2040/rp2040_usb.c
+25 −38 src/portable/raspberrypi/rp2040/rp2040_usb.h
+20 −1 src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+4 −0 src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h
+37 −4 src/portable/st/synopsys/dcd_synopsys.c
+1 −1 src/tusb.h
+3 −2 src/tusb_config.h
+23 −25 src/tusb_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ BLEDfu bledfu;
void setup()
{
Serial.begin(115200);
while ( !Serial ) delay(10); // for nrf52840 with native usb

#if CFG_DEBUG
// Blocking wait for connection when debug mode is enabled via IDE
while ( !Serial ) yield();
#endif

Serial.println("Bluefruit52 Blinky Example");
Serial.println("--------------------------\n");
Expand Down
1 change: 1 addition & 0 deletions libraries/Bluefruit52Lib/src/BLECharacteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
{
LOG_LV2("GATTS", "attr's value, uuid = 0x%04X, len = %d", request->uuid.uuid, request->len);
LOG_LV2_BUFFER(NULL, request->data, request->len);
LOG_LV2(NULL, "\r\n");

if (_wr_cb)
{
Expand Down
7 changes: 7 additions & 0 deletions libraries/Bluefruit52Lib/src/BLESecurity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ void BLESecurity::_eventHandler(ble_evt_t* evt)
// Pairing succeeded --> save encryption keys ( Bonding )
if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status)
{
if (!status->kdist_peer.id)
{
// Peer does not provide IRK, it is possible that device uses Public/Static address which
// IRK is not needed. We will use the connect address instead
_bond_keys.peer_id.id_addr_info = conn->getPeerAddr();
}

conn->saveBondKey(&_bond_keys);
}

Expand Down
8 changes: 7 additions & 1 deletion libraries/Bluefruit52Lib/src/bluefruit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,14 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
_setConnLed(true);

ble_gap_evt_connected_t const * para = &evt->evt.gap_evt.params.connected;
ble_gap_addr_t const* peer_addr = &para->peer_addr;

LOG_LV1("GAP", "Conn Interval= %.2f ms, Latency = %d, Supervisor Timeout = %d ms",
(void) peer_addr;

LOG_LV2("GAP", "MAC = %02X:%02X:%02X:%02X:%02X:%02X, Type = %d, Resolved = %d",
peer_addr->addr[5], peer_addr->addr[4], peer_addr->addr[3], peer_addr->addr[2], peer_addr->addr[1], peer_addr->addr[0],
peer_addr->addr_type, peer_addr->addr_id_peer);
LOG_LV2("GAP", "Conn Interval = %.2f ms, Latency = %d, Supervisor Timeout = %d ms",
para->conn_params.max_conn_interval*1.25f, para->conn_params.slave_latency, 10*para->conn_params.conn_sup_timeout);

if ( _connection[conn_hdl] )
Expand Down
4 changes: 2 additions & 2 deletions libraries/PDM/examples/PDMSerialPlotter/PDMSerialPlotter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ volatile int samplesRead;

void setup() {
Serial.begin(9600);
while (!Serial);
while (!Serial) yield();

// configure the data receive callback
PDM.onReceive(onPDMdata);
Expand All @@ -31,7 +31,7 @@ void setup() {
// - a 16 kHz sample rate
if (!PDM.begin(1, 16000)) {
Serial.println("Failed to start PDM!");
while (1);
while (1) yield();
}
}

Expand Down
26 changes: 23 additions & 3 deletions libraries/PDM/src/PDM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,29 @@ int PDMClass::begin(int channels, long sampleRate)
_channels = channels;

// Enable high frequency oscillator if not already enabled
if (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {
NRF_CLOCK->TASKS_HFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) { }
uint8_t sd_en = 0;
sd_softdevice_is_enabled(&sd_en);

if (sd_en)
{
uint32_t is_running;
sd_clock_hfclk_is_running(&is_running);

if (!is_running) {
sd_clock_hfclk_request();

while(!is_running) {
yield();
sd_clock_hfclk_is_running(&is_running);
}
}
}
else
{
if (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {
NRF_CLOCK->TASKS_HFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) yield();
}
}

// configure the sample rate and channels
Expand Down
Binary file modified tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe
100755 → 100644
Binary file not shown.
5 changes: 4 additions & 1 deletion tools/update_bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
with zipfile.ZipFile(name, "r") as zip_ref:
zip_ref.extractall("bootloader/{}".format(variant))

# Remove update.uf2
# Remove update.uf2 for 832
if variant == 'feather_nrf52832':
os.remove("bootloader/{}/update-{}_nosd.uf2".format(variant, name[:-4]))

# remove zip file
os.remove(name)

0 comments on commit 968c800

Please sign in to comment.