diff --git a/boards.txt b/boards.txt index 3cb2ade4..9757e232 100644 --- a/boards.txt +++ b/boards.txt @@ -34,7 +34,7 @@ feather52.upload.native_usb=false feather52.bootloader.tool=nrfjprog feather52.build.mcu=cortex-m4 -feather52.build.f_cpu=16000000 +feather52.build.f_cpu=64000000 feather52.build.board=FEATHER52 feather52.build.core=nRF5 feather52.build.variant=feather52 @@ -43,6 +43,8 @@ feather52.build.extra_flags=-DNRF52 -DS132 -DNRF51_S132 feather52.build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 feather52.build.ldscript=feather52_s132.ld +feather52.build.lfclk_flags=-DUSE_LFXO + feather52.build.nrfutil=nrfutil feather52.build.nrfutil.windows={runtime.platform.path}/tools/nrfutil-0.5.2/binaries/win32/nrfutil.exe feather52.build.nrfutil.macosx=/usr/local/bin/nrfutil diff --git a/cores/nRF5/wiring.c b/cores/nRF5/wiring.c index 81f448ca..1c333ac9 100644 --- a/cores/nRF5/wiring.c +++ b/cores/nRF5/wiring.c @@ -27,7 +27,16 @@ extern "C" { void init( void ) { +#if defined( USE_LFXO ) + // 32Khz XTAL + NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); +#elif defined(USE_LFRC) + // Internal OSC NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); +#else + #error Clock Source is not configured, define USE_LFXO or USE_LFRC according to your board +#endif + NRF_CLOCK->TASKS_LFCLKSTART = 1UL; } diff --git a/libraries/Bluefruit52Lib/src/bluefruit.cpp b/libraries/Bluefruit52Lib/src/bluefruit.cpp index 01f1befb..9be84189 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.cpp +++ b/libraries/Bluefruit52Lib/src/bluefruit.cpp @@ -74,7 +74,6 @@ AdafruitBluefruit Bluefruit; static void bluefruit_blinky_cb( TimerHandle_t xTimer ) { (void) xTimer; - ledToggle(LED_CONN); } @@ -128,10 +127,19 @@ err_t AdafruitBluefruit::begin(bool prph_enable, bool central_enable) // Configure Clock nrf_clock_lf_cfg_t clock_cfg = { +#if defined( USE_LFXO ) + // LFXO + .source = NRF_CLOCK_LF_SRC_XTAL, + .rc_ctiv = 0, + .rc_temp_ctiv = 0, + .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM +#else + // LFRC .source = NRF_CLOCK_LF_SRC_RC, .rc_ctiv = 16, .rc_temp_ctiv = 2, .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM +#endif }; VERIFY_STATUS( sd_softdevice_enable(&clock_cfg, NULL) ); diff --git a/platform.txt b/platform.txt index 01adce08..241c5df7 100644 --- a/platform.txt +++ b/platform.txt @@ -50,6 +50,7 @@ compiler.size.cmd=arm-none-eabi-size # this can be overriden in boards.txt build.extra_flags= +build.lfclk_flags= build.debug_flags= nrf.sdk.path={build.core.path}/SDK @@ -74,13 +75,13 @@ compiler.elf2hex.extra_flags= # ---------------- ## Compile c files -recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_flags} {compiler.nrf.flags} {includes} {nffs.includes} "{source_file}" -o "{object_file}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.lfclk_flags} {build.debug_flags} {compiler.nrf.flags} {includes} {nffs.includes} "{source_file}" -o "{object_file}" ## Compile c++ files -recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BSP_VERSION="{version}" {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_flags} {compiler.nrf.flags} {includes} {nffs.includes} "{source_file}" -o "{object_file}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BSP_VERSION="{version}" {compiler.cpp.extra_flags} {build.extra_flags} {build.lfclk_flags} {build.debug_flags} {compiler.nrf.flags} {includes} {nffs.includes} "{source_file}" -o "{object_file}" ## Compile S files -recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_flags} {includes} {nffs.includes} "{source_file}" -o "{object_file}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.lfclk_flags} {build.debug_flags} {includes} {nffs.includes} "{source_file}" -o "{object_file}" ## Create archives recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"