From 313705e15cd1f5dc6ead34f3190e600fdbc26960 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 17 Apr 2018 17:20:22 +0700 Subject: [PATCH] add nrf52 series common macros NRF52_SERIES --- cores/nRF5/Uart.cpp | 6 +++--- cores/nRF5/WInterrupts.c | 2 +- cores/nRF5/wiring_analog.h | 2 +- cores/nRF5/wiring_analog_nRF52.c | 2 +- libraries/Wire/Wire.h | 8 ++++---- libraries/Wire/Wire_nRF52.cpp | 2 +- platform.txt | 2 +- variants/feather52840/variant.h | 1 + 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cores/nRF5/Uart.cpp b/cores/nRF5/Uart.cpp index f478f21a..b5211673 100644 --- a/cores/nRF5/Uart.cpp +++ b/cores/nRF5/Uart.cpp @@ -74,7 +74,7 @@ void Uart::begin(unsigned long baudrate, uint16_t /*config*/) uint32_t nrfBaudRate; -#ifdef NRF52 +#if defined(NRF52) || defined(NRF52_SERIES) if (baudrate <= 1200) { nrfBaudRate = UARTE_BAUDRATE_BAUDRATE_Baud1200; } else if (baudrate <= 2400) { @@ -229,7 +229,7 @@ size_t Uart::write(const uint8_t data) return 1; } -#if defined(NRF52) +#if defined(NRF52) || defined(NRF52_SERIES) #define NRF_UART0_IRQn UARTE0_UART0_IRQn #elif defined(NRF51) #define NRF_UART0_IRQn UART0_IRQn @@ -241,7 +241,7 @@ size_t Uart::write(const uint8_t data) Uart Serial( NRF_UART0, NRF_UART0_IRQn, PIN_SERIAL_RX, PIN_SERIAL_TX ); #endif -#if defined(NRF52) +#if defined(NRF52) || defined(NRF52_SERIES) extern "C" { void UARTE0_UART0_IRQHandler() diff --git a/cores/nRF5/WInterrupts.c b/cores/nRF5/WInterrupts.c index b3c6c357..919e9db7 100644 --- a/cores/nRF5/WInterrupts.c +++ b/cores/nRF5/WInterrupts.c @@ -24,7 +24,7 @@ #include -#ifdef NRF52 +#if defined(NRF52) || defined(NRF52_SERIES) #define NUMBER_OF_GPIO_TE 8 #else #define NUMBER_OF_GPIO_TE 4 diff --git a/cores/nRF5/wiring_analog.h b/cores/nRF5/wiring_analog.h index e20e8c01..dd16eef7 100644 --- a/cores/nRF5/wiring_analog.h +++ b/cores/nRF5/wiring_analog.h @@ -29,7 +29,7 @@ extern "C" { /* * \brief SAMD products have only one reference for ADC */ -#ifdef NRF52 +#if defined(NRF52) || defined(NRF52_SERIES) typedef enum _eAnalogReference { AR_DEFAULT, diff --git a/cores/nRF5/wiring_analog_nRF52.c b/cores/nRF5/wiring_analog_nRF52.c index e01b0b38..13439aa7 100644 --- a/cores/nRF5/wiring_analog_nRF52.c +++ b/cores/nRF5/wiring_analog_nRF52.c @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifdef NRF52 +#if defined(NRF52) || defined(NRF52_SERIES) #include "nrf.h" diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h index 412ec588..f2af3a41 100755 --- a/libraries/Wire/Wire.h +++ b/libraries/Wire/Wire.h @@ -34,13 +34,13 @@ class TwoWire : public Stream { public: -#ifdef NRF52 +#if defined(NRF52) || defined(NRF52_SERIES) TwoWire(NRF_TWIM_Type * p_twim, NRF_TWIS_Type * p_twis, IRQn_Type IRQn, uint8_t pinSDA, uint8_t pinSCL); #else TwoWire(NRF_TWI_Type * p_twi, uint8_t pinSDA, uint8_t pinSCL); #endif void begin(); -#ifdef NRF52 +#if defined(NRF52) || defined(NRF52_SERIES) void begin(uint8_t); #endif void end(); @@ -60,7 +60,7 @@ class TwoWire : public Stream virtual int read(void); virtual int peek(void); virtual void flush(void); -#ifdef NRF52 +#if defined(NRF52) || defined(NRF52_SERIES) void onReceive(void(*)(int)); void onRequest(void(*)(void)); void onService(void); @@ -69,7 +69,7 @@ class TwoWire : public Stream using Print::write; private: -#ifdef NRF52 +#if defined(NRF52) || defined(NRF52_SERIES) NRF_TWIM_Type * _p_twim; NRF_TWIS_Type * _p_twis; #else diff --git a/libraries/Wire/Wire_nRF52.cpp b/libraries/Wire/Wire_nRF52.cpp index 36de1f5d..f7537ab1 100755 --- a/libraries/Wire/Wire_nRF52.cpp +++ b/libraries/Wire/Wire_nRF52.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifdef NRF52 +#if defined(NRF52) || defined(NRF52_SERIES) extern "C" { #include diff --git a/platform.txt b/platform.txt index bc04fa72..928e24da 100644 --- a/platform.txt +++ b/platform.txt @@ -63,7 +63,7 @@ nffs.includes="-I{nffs.path}/fs/nffs/include" "-I{nffs.path}/fs/fs/include" "-I # ARDUINO_FEATHER52 is defined for backward compatiable with other lib only # should be replaced by ARDUINO_NRF52_ADAFRUIT in the future -compiler.nrf.flags= -DARDUINO_FEATHER52 -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DUSE_LFXO {build.sd_flags} {build.debug_flags} "-I{nrf.sdk.path}/components/toolchain/" "-I{nrf.sdk.path}/components/toolchain/cmsis/include" "-I{nrf.sdk.path}/components/toolchain/gcc/" "-I{nrf.sdk.path}/components/device/" "-I{nrf.sdk.path}/components/drivers_nrf/delay/" "-I{nrf.sdk.path}/components/drivers_nrf/hal/" "-I{nrf.sdk.path}/components/libraries/util/" "-I{build.core.path}/softdevice/{build.sd_name}/{build.sd_version}/headers/" "-I{rtos.path}/source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" {nffs.includes} +compiler.nrf.flags= -DARDUINO_FEATHER52 -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DUSE_LFXO {build.sd_flags} {build.debug_flags} "-I{nrf.sdk.path}/components/toolchain/cmsis/include" "-I{nrf.sdk.path}/components/device/" "-I{nrf.sdk.path}/components/drivers_nrf/delay/" "-I{nrf.sdk.path}/components/drivers_nrf/hal/" "-I{nrf.sdk.path}/components/libraries/util/" "-I{build.core.path}/softdevice/{build.sd_name}/{build.sd_version}/headers/" "-I{rtos.path}/source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" {nffs.includes} # These can be overridden in platform.local.txt compiler.c.extra_flags= diff --git a/variants/feather52840/variant.h b/variants/feather52840/variant.h index 6c00200f..48e3091c 100644 --- a/variants/feather52840/variant.h +++ b/variants/feather52840/variant.h @@ -119,6 +119,7 @@ static const uint8_t SCK = PIN_SPI_SCK ; #define PIN_WIRE_SCL (26u) +// TODO remove static inline bool isPinValid(uint32_t pin) { // 0, 1 is xtal