From ab5b6ae5fff20358855fc5ab1a9f9eff39d4bc3c Mon Sep 17 00:00:00 2001 From: nikolac Date: Fri, 18 Dec 2020 16:07:12 -0600 Subject: [PATCH 1/5] Fix UART references for 52805 --- .travis.yml | 1 + boards.txt | 32 ++++++++++++++++++++++++++++++++ cores/nRF5/Uart.cpp | 18 ++++++++++++++++++ cores/nRF5/wiring_analog_nRF52.c | 4 ++++ 4 files changed, 55 insertions(+) diff --git a/.travis.yml b/.travis.yml index c576ed57..196ae9b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,3 +43,4 @@ script: - buildExampleSketch sandeepmistry:nRF5:SeeedArchLink 01.Basics Blink - buildExampleSketch sandeepmistry:nRF5:Generic_nRF52833 01.Basics Blink - buildExampleSketch sandeepmistry:nRF5:BBCmicrobitV2 01.Basics Blink + - buildExampleSketch sandeepmistry:nRF5:Generic_nRF52805 01.Basics Blink diff --git a/boards.txt b/boards.txt index a050d27e..1149b27b 100644 --- a/boards.txt +++ b/boards.txt @@ -21,6 +21,38 @@ menu.version=Version menu.lfclk=Low Frequency Clock menu.board_variant=Board Variant +# nRF52805 variants +################### + +Generic_nRF52805.name=Generic nRF52805 + +Generic_nRF52805.upload.tool=sandeepmistry:openocd +Generic_nRF52805.upload.target=nrf52 +Generic_nRF52805.upload.maximum_size=192000 + +Generic_nRF52805.bootloader.tool=sandeepmistry:openocd + +Generic_nRF52805.build.mcu=cortex-m4 +Generic_nRF52805.build.f_cpu=64000000 +Generic_nRF52805.build.board=GENERIC +Generic_nRF52805.build.core=nRF5 +Generic_nRF52805.build.variant=Generic +Generic_nRF52805.build.variant_system_lib= +Generic_nRF52805.build.extra_flags=-DNRF52805_XXAA +Generic_nRF52805.build.float_flags= +Generic_nRF52805.build.ldscript=nrf52805_xxaa.ld + +Generic_nRF52805.menu.softdevice.none=None +Generic_nRF52805.menu.softdevice.none.softdevice=none +Generic_nRF52805.menu.softdevice.none.softdeviceversion= + +Generic_nRF52805.menu.lfclk.lfxo=Crystal Oscillator +Generic_nRF52805.menu.lfclk.lfxo.build.lfclk_flags=-DUSE_LFXO +Generic_nRF52805.menu.lfclk.lfrc=RC Oscillator +Generic_nRF52805.menu.lfclk.lfrc.build.lfclk_flags=-DUSE_LFRC +Generic_nRF52805.menu.lfclk.lfsynt=Synthesized +Generic_nRF52805.menu.lfclk.lfsynt.build.lfclk_flags=-DUSE_LFSYNT + # nRF52833 variants ################### diff --git a/cores/nRF5/Uart.cpp b/cores/nRF5/Uart.cpp index bc6b923f..3b07679a 100644 --- a/cores/nRF5/Uart.cpp +++ b/cores/nRF5/Uart.cpp @@ -64,12 +64,22 @@ void Uart::begin(unsigned long baudrate) void Uart::begin(unsigned long baudrate, uint16_t /*config*/) { +#ifdef NRF52805_XXAA + nrfUart->PSEL.TXD = uc_pinTX; + nrfUart->PSEL.RXD = uc_pinRX; +#else nrfUart->PSELTXD = uc_pinTX; nrfUart->PSELRXD = uc_pinRX; +#endif if (uc_hwFlow == 1) { +#ifdef NRF52805_XXAA + nrfUart->PSEL.CTS = uc_pinCTS; + nrfUart->PSEL.RTS = uc_pinRTS; +#else nrfUart->PSELCTS = uc_pinCTS; nrfUart->PSELRTS = uc_pinRTS; +#endif nrfUart->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos) | UART_CONFIG_HWFC_Enabled; } else { nrfUart->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos) | UART_CONFIG_HWFC_Disabled; @@ -175,12 +185,20 @@ void Uart::end() nrfUart->TASKS_STOPTX = 0x1UL; nrfUart->ENABLE = UART_ENABLE_ENABLE_Disabled; + +#ifdef NRF52805_XXAA + nrfUart->PSEL.TXD = 0xFFFFFFFF; + nrfUart->PSEL.RXD = 0xFFFFFFFF; + nrfUart->PSEL.RTS = 0xFFFFFFFF; + nrfUart->PSEL.CTS = 0xFFFFFFFF; +#else nrfUart->PSELTXD = 0xFFFFFFFF; nrfUart->PSELRXD = 0xFFFFFFFF; nrfUart->PSELRTS = 0xFFFFFFFF; nrfUart->PSELCTS = 0xFFFFFFFF; +#endif rxBuffer.clear(); } diff --git a/cores/nRF5/wiring_analog_nRF52.c b/cores/nRF5/wiring_analog_nRF52.c index e7db64a5..cc1b4add 100644 --- a/cores/nRF5/wiring_analog_nRF52.c +++ b/cores/nRF5/wiring_analog_nRF52.c @@ -29,6 +29,7 @@ extern "C" { static uint32_t saadcReference = SAADC_CH_CONFIG_REFSEL_Internal; static uint32_t saadcGain = SAADC_CH_CONFIG_GAIN_Gain1_5; +#ifdef PWM_PRESENT static NRF_PWM_Type* pwms[PWM_COUNT] = { NRF_PWM0, NRF_PWM1, @@ -47,6 +48,7 @@ static uint32_t pwmChannelPins[PWM_COUNT] = { #endif }; static uint16_t pwmChannelSequence[PWM_COUNT]; +#endif static int readResolution = 10; static int writeResolution = 8; @@ -215,6 +217,7 @@ uint32_t analogRead( uint32_t ulPin ) // to digital output. void analogWrite( uint32_t ulPin, uint32_t ulValue ) { +#ifdef PWM_PRESENT if (ulPin >= PINS_COUNT) { return; } @@ -247,6 +250,7 @@ void analogWrite( uint32_t ulPin, uint32_t ulValue ) break; } } +#endif } #ifdef __cplusplus From 8dd6eca43eb48ec1687721e3567ba5077bbfdebf Mon Sep 17 00:00:00 2001 From: nikolac Date: Sat, 19 Dec 2020 10:27:26 -0600 Subject: [PATCH 2/5] Add condition for SPI NRF52805 --- libraries/SPI/SPI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp index d803c953..7de8830b 100644 --- a/libraries/SPI/SPI.cpp +++ b/libraries/SPI/SPI.cpp @@ -256,7 +256,7 @@ void SPIClass::detachInterrupt() { } #if SPI_INTERFACES_COUNT > 0 -#if defined(NRF52_SERIES) +#if defined(NRF52_SERIES) && !defined(NRF52805_XXAA) SPIClass SPI (NRF_SPI2, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI); #else SPIClass SPI (NRF_SPI0, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI); From 980f0dcd6a8ae27583e39eaea7908ea4e5837243 Mon Sep 17 00:00:00 2001 From: nikolac Date: Sat, 19 Dec 2020 11:15:09 -0600 Subject: [PATCH 3/5] Add condition for I2C NRF52805 --- libraries/Wire/Wire_nRF52.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/libraries/Wire/Wire_nRF52.cpp b/libraries/Wire/Wire_nRF52.cpp index a54c201e..35ac8ed2 100755 --- a/libraries/Wire/Wire_nRF52.cpp +++ b/libraries/Wire/Wire_nRF52.cpp @@ -401,17 +401,34 @@ void TwoWire::onService(void) } } -TwoWire Wire(NRF_TWIM1, NRF_TWIS1, SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, PIN_WIRE_SDA, PIN_WIRE_SCL); +#if defined(NRF52805_XXAA) -#if WIRE_INTERFACES_COUNT > 0 -extern "C" -{ - void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void) + TwoWire Wire(NRF_TWIM0, NRF_TWIS0, TWIM0_TWIS0_TWI0_IRQn, PIN_WIRE_SDA, PIN_WIRE_SCL); + + #if WIRE_INTERFACES_COUNT > 0 + extern "C" { - Wire.onService(); + void TWIM0_TWIS0_TWI0_IRQn_IRQHandler(void) + { + Wire.onService(); + } } -} -#endif + #endif + +#else + + TwoWire Wire(NRF_TWIM1, NRF_TWIS1, SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, PIN_WIRE_SDA, PIN_WIRE_SCL); + + #if WIRE_INTERFACES_COUNT > 0 + extern "C" + { + void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void) + { + Wire.onService(); + } + } + #endif +#endif //defined(NRF52805_XXAA) #if WIRE_INTERFACES_COUNT > 1 From a60f6db675d687bf964930a0505a94a1a9ad17d6 Mon Sep 17 00:00:00 2001 From: nikolac Date: Tue, 5 Jan 2021 10:42:39 -0600 Subject: [PATCH 4/5] Set appropriate max upload size --- boards.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards.txt b/boards.txt index 1149b27b..eb877576 100644 --- a/boards.txt +++ b/boards.txt @@ -28,7 +28,7 @@ Generic_nRF52805.name=Generic nRF52805 Generic_nRF52805.upload.tool=sandeepmistry:openocd Generic_nRF52805.upload.target=nrf52 -Generic_nRF52805.upload.maximum_size=192000 +Generic_nRF52805.upload.maximum_size=196608 Generic_nRF52805.bootloader.tool=sandeepmistry:openocd From 110910239fad390fcc3d9abfcfde84f11df1d041 Mon Sep 17 00:00:00 2001 From: nikolac Date: Tue, 5 Jan 2021 10:45:44 -0600 Subject: [PATCH 5/5] Init SPI2 if defined --- libraries/SPI/SPI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp index 7de8830b..4d7101ad 100644 --- a/libraries/SPI/SPI.cpp +++ b/libraries/SPI/SPI.cpp @@ -256,7 +256,7 @@ void SPIClass::detachInterrupt() { } #if SPI_INTERFACES_COUNT > 0 -#if defined(NRF52_SERIES) && !defined(NRF52805_XXAA) +#if defined(NRF_SPI2) SPIClass SPI (NRF_SPI2, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI); #else SPIClass SPI (NRF_SPI0, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI);