Skip to content

Commit d94023e

Browse files
committed
Fix CPBlue LFCLKSRC; CPB has no status neopixel
1 parent 42143ca commit d94023e

6 files changed

Lines changed: 25 additions & 7 deletions

File tree

ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
#define FLASH_SIZE (0x100000)
3535
#define FLASH_PAGE_SIZE (4096)
3636

37-
#define MICROPY_HW_NEOPIXEL (&pin_P0_13)
38-
3937
#define MICROPY_HW_LED_STATUS (&pin_P1_14)
4038

4139
#if QSPI_FLASH_FILESYSTEM

ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ MCU_CHIP = nrf52840
1010
SD ?= s140
1111
SOFTDEV_VERSION ?= 6.1.0
1212

13+
# Unusually, board does not have a 32 kHz xtal.
14+
BOARD_HAS_32KHZ_XTAL = 0
15+
1316
BOOT_SETTING_ADDR = 0xFF000
1417

1518
ifeq ($(SD),)

ports/nrf/common-hal/bleio/Adapter.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,17 @@ STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) {
4747

4848
STATIC uint32_t ble_stack_enable(void) {
4949
nrf_clock_lf_cfg_t clock_config = {
50-
.source = NRF_CLOCK_LF_SRC_XTAL,
51-
.accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM
50+
#if BOARD_HAS_32KHZ_XTAL
51+
.source = NRF_CLOCK_LF_SRC_XTAL,
52+
.rc_ctiv = 0,
53+
.rc_temp_ctiv = 0,
54+
.accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM
55+
#else
56+
.source = NRF_CLOCK_LF_SRC_RC,
57+
.rc_ctiv = 16,
58+
.rc_temp_ctiv = 2,
59+
.accuracy = NRF_CLOCK_LF_ACCURACY_250_PPM
60+
#endif
5261
};
5362

5463
uint32_t err_code = sd_softdevice_enable(&clock_config, softdevice_assert_handler);

ports/nrf/common-hal/bleio/Characteristic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self,
183183
(self->props & CHAR_PROP_WRITE_NO_RESPONSE));
184184
} else {
185185
if (self->fixed_length && bufinfo->len != self->max_length) {
186-
mp_raise_ValueError(translate("Value length required fixed length"));
186+
mp_raise_ValueError(translate("Value length != required fixed length"));
187187
}
188188
if (bufinfo->len > self->max_length) {
189189
mp_raise_ValueError(translate("Value length > max_length"));

ports/nrf/mpconfigport.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ CIRCUITPY_RTC = 1
2828
# frequencyio not yet implemented
2929
CIRCUITPY_FREQUENCYIO = 0
3030

31+
ifndef BOARD_HAS_32KHZ_XTAL
32+
# Assume crystal is present, which is the most common case.
33+
BOARD_HAS_32KHZ_XTAL = 1
34+
endif
35+
3136
# CircuitPython doesn't yet support NFC so force the NFC antenna pins to be GPIO.
3237
# See https://github.com/adafruit/circuitpython/issues/1300
3338
# Defined here because system_nrf52840.c doesn't #include any of our own include files.

ports/nrf/peripherals/nrf/clocks.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@
2828
#include "nrfx.h"
2929

3030
void nrf_peripherals_clocks_init(void) {
31-
// Set low-frequency clock source to be crystal. If there's a crystalless board, this will need to be
32-
// generalized.
31+
32+
#if BOARD_HAS_32KHZ_XTAL
3333
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
34+
#else
35+
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
36+
#endif
3437
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
3538

3639
// Wait for clocks to start.

0 commit comments

Comments
 (0)