From 117d251d4b6dc27c6a93a1868007411d5e56ad0b Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 12 Apr 2017 12:43:33 +0700 Subject: [PATCH] fix RTC1 compare interrupt is not clear by bootloader --- cores/nRF5/freertos/source/include/projdefs.h | 9 +-------- .../examples/Central/central_scan/central_scan.ino | 2 ++ variants/feather52/variant.cpp | 7 +++++++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cores/nRF5/freertos/source/include/projdefs.h b/cores/nRF5/freertos/source/include/projdefs.h index 759ed9b8..9cb48fa4 100644 --- a/cores/nRF5/freertos/source/include/projdefs.h +++ b/cores/nRF5/freertos/source/include/projdefs.h @@ -77,16 +77,9 @@ typedef void (*TaskFunction_t)( void * ); /* Converts a time in milliseconds to a time in ticks. */ -#if configTICK_RATE_HZ == 1000 -#define ms2tick(ms) (ms) -#define tick2ms(tck) (tck) -#define tick2us(tck) (1000*(tck)) -#else #define ms2tick( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) #define tick2ms(tck) ( ( ((uint64_t)(tck)) * 1000) / configTICK_RATE_HZ ) #define tick2us(tck) ( ( ((uint64_t)(tck)) * 1000000) / configTICK_RATE_HZ ) -#endif - #define pdFALSE ( ( BaseType_t ) 0 ) #define pdTRUE ( ( BaseType_t ) 1 ) @@ -115,7 +108,7 @@ typedef void (*TaskFunction_t)( void * ); /* The following endian values are used by FreeRTOS+ components, not FreeRTOS itself. */ #define pdFREERTOS_LITTLE_ENDIAN 0 -#define pdFREERTOS_BIG_ENDIAN 1 +#define pdFREERTOS_BIG_ENDIAN 1 #endif /* PROJDEFS_H */ diff --git a/libraries/Bluefruit52Lib/examples/Central/central_scan/central_scan.ino b/libraries/Bluefruit52Lib/examples/Central/central_scan/central_scan.ino index cca781ae..3ec3d66d 100644 --- a/libraries/Bluefruit52Lib/examples/Central/central_scan/central_scan.ino +++ b/libraries/Bluefruit52Lib/examples/Central/central_scan/central_scan.ino @@ -28,6 +28,8 @@ void setup() Bluefruit.setConnLedInterval(250); Bluefruit.Central.setScanCallback(scan_callback); Bluefruit.Central.startScanning(); + + Serial.println("Scanning ..."); } void scan_callback(ble_gap_evt_adv_report_t* report) diff --git a/variants/feather52/variant.cpp b/variants/feather52/variant.cpp index a53fb3d9..7f4ea3d9 100644 --- a/variants/feather52/variant.cpp +++ b/variants/feather52/variant.cpp @@ -76,6 +76,13 @@ void initVariant() { bootloaderVersion = BOOTLOADER_VERSION_REGISTER; + // RTC1 is already configured by bootloader. Disable it here + NVIC_DisableIRQ(RTC1_IRQn); + NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk; + NRF_RTC1->INTENCLR = RTC_INTENSET_COMPARE0_Msk; + NRF_RTC1->TASKS_STOP = 1; + NRF_RTC1->TASKS_CLEAR = 1; + // LED1 & LED2 pinMode(PIN_LED1, OUTPUT); ledOff(PIN_LED1);