Skip to content

Add support for nRF52810 #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1953,3 +1953,58 @@ Waveshare_BLE400.menu.cppDbgLvl.debug.build.cpp_debug=4
Waveshare_BLE400.menu.bootloader.none=No bootloader
Waveshare_BLE400.menu.bootloader.none.bootloader.flags=
Waveshare_BLE400.menu.bootloader.none.build.bootloader.file=tools/none_bootloader.hex

# nRF52810 variants
###################

Generic_nRF52810.name=Generic nRF52810

Generic_nRF52810.upload.tool=openocd
Generic_nRF52810.upload.target=nrf52
Generic_nRF52810.upload.jlink_device=nRF52810_xxAA
Generic_nRF52810.upload.maximum_size=180224

Generic_nRF52810.bootloader.tool=openocd

Generic_nRF52810.build.mcu=cortex-m4
Generic_nRF52810.build.f_cpu=64000000
Generic_nRF52810.build.board=GENERIC
Generic_nRF52810.build.core=nRF5
Generic_nRF52810.build.variant=Generic
Generic_nRF52810.build.variant_system_lib=
Generic_nRF52810.build.float_flags=
Generic_nRF52810.build.ldscript=nRF52810_xxaa.ld
Generic_nRF52810.build.extra_flags=-DNRF52_SERIES -DnRF52810_XXAA {bootloader.flags} -DCONFIG_NIMBLE_CPP_LOG_LEVEL={build.cpp_debug} {build.nimble_flags}

Generic_nRF52810.menu.lfclk.lfxo=Crystal Oscillator
Generic_nRF52810.menu.lfclk.lfxo.build.lfclk_flags=-DUSE_LFXO
Generic_nRF52810.menu.lfclk.lfrc=RC Oscillator
Generic_nRF52810.menu.lfclk.lfrc.build.lfclk_flags=-DUSE_LFRC
Generic_nRF52810.menu.lfclk.lfsynt=Synthesized
Generic_nRF52810.menu.lfclk.lfsynt.build.lfclk_flags=-DUSE_LFSYNT

Generic_nRF52810.menu.role.all=All
Generic_nRF52810.menu.role.all.build.nimble_flags=
Generic_nRF52810.menu.role.periph=Peripheral
Generic_nRF52810.menu.role.periph.build.nimble_flags=-DCONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED -DCONFIG_BT_NIMBLE_ROLE_OBSERVER_DISABLED
Generic_nRF52810.menu.role.adv=Advertiser
Generic_nRF52810.menu.role.adv.build.nimble_flags=-DCONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED -DCONFIG_BT_NIMBLE_ROLE_OBSERVER_DISABLED -DCONFIG_BT_NIMBLE_ROLE_PERIPHERAL_DISABLED
Generic_nRF52810.menu.role.scan=Scanner
Generic_nRF52810.menu.role.scan.build.nimble_flags=-DCONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED -DCONFIG_BT_NIMBLE_ROLE_PERIPHERAL_DISABLED -DCONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED
Generic_nRF52810.menu.role.central=Client
Generic_nRF52810.menu.role.central.build.nimble_flags=-DCONFIG_BT_NIMBLE_ROLE_PERIPHERAL_DISABLED -DCONFIG_BT_NIMBLE_ROLE_BROADCASTER_DISABLED

Generic_nRF52810.menu.cppDbgLvl.none=None
Generic_nRF52810.menu.cppDbgLvl.none.build.cpp_debug=0
Generic_nRF52810.menu.cppDbgLvl.error=Error
Generic_nRF52810.menu.cppDbgLvl.error.build.cpp_debug=1
Generic_nRF52810.menu.cppDbgLvl.warn=Warn
Generic_nRF52810.menu.cppDbgLvl.warn.build.cpp_debug=2
Generic_nRF52810.menu.cppDbgLvl.info=Info
Generic_nRF52810.menu.cppDbgLvl.info.build.cpp_debug=3
Generic_nRF52810.menu.cppDbgLvl.debug=Debug
Generic_nRF52810.menu.cppDbgLvl.debug.build.cpp_debug=4

Generic_nRF52810.menu.bootloader.none=No bootloader
Generic_nRF52810.menu.bootloader.none.bootloader.flags=
Generic_nRF52810.menu.bootloader.none.build.bootloader.file=tools/none_bootloader.hex
9 changes: 9 additions & 0 deletions cores/nRF5/Uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
#include "Arduino.h"
#include "wiring_private.h"

// these nRF52s have different UART PSEL definition
#if defined(NRF52810_XXAA) || defined(NRF52805_XXAA) \
|| defined(NRF52811_XXAA) || defined(NRF52833_XXAA) \
|| defined(NRF52840_XXAA)
#define PSELTXD PSEL.TXD
#define PSELRXD PSEL.RXD
#define PSELCTS PSEL.CTS
#define PSELRTS PSEL.RTS
#endif

void serialEventRun(void)
{
Expand Down
4 changes: 4 additions & 0 deletions cores/nRF5/freertos/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,11 @@ void xPortPendSVHandler( void )
" ldr r3, =pxCurrentTCB \n" /* Get the location of the current TCB. */
" ldr r2, [r3] \n"
" \n"
#if (__FPU_PRESENT == 1U)
" tst r14, #0x10 \n" /* Is the task using the FPU context? If so, push high vfp registers. */
" it eq \n"
" vstmdbeq r0!, {s16-s31} \n"
#endif
" \n"
" stmdb r0!, {r4-r11, r14} \n" /* Save the core registers. */
" \n"
Expand All @@ -228,9 +230,11 @@ void xPortPendSVHandler( void )
" \n"
" ldmia r0!, {r4-r11, r14} \n" /* Pop the core registers. */
" \n"
#if (__FPU_PRESENT == 1U)
" tst r14, #0x10 \n" /* Is the task using the FPU context? If so, pop the high vfp registers too. */
" it eq \n"
" vldmiaeq r0!, {s16-s31} \n"
#endif
" \n"
" msr psp, r0 \n"
" isb \n"
Expand Down
9 changes: 6 additions & 3 deletions cores/nRF5/freertos/port_nrf52.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
#include "app_util_platform.h"
#endif

#if !(__FPU_USED) && !(__LINT__)
#error This port can only be used when the project options are configured to enable hardware floating point support.
#endif
//* see https://devzone.nordicsemi.com/f/nordic-q-a/30103/freertos-on-nrf52810
// #if !(__FPU_USED) && !(__LINT__)
// #error This port can only be used when the project options are configured to enable hardware floating point support.
// #endif

#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0
#error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html
Expand Down Expand Up @@ -227,8 +228,10 @@ BaseType_t xPortStartScheduler( void )
/* Ensure the VFP is enabled - it should be anyway. */
vPortEnableVFP();

#if (__FPU_PRESENT == 1U)
/* Lazy save always. */
FPU->FPCCR |= FPU_FPCCR_ASPEN_Msk | FPU_FPCCR_LSPEN_Msk;
#endif

/* Finally this port requires SEVONPEND to be active */
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
Expand Down
2 changes: 2 additions & 0 deletions cores/nRF5/freertos/port_nrf52_systick.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,15 @@ void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
else
#endif
{
#if (__FPU_PRESENT == 1U)
// Fix ERRATA 87 (https://infocenter.nordicsemi.com/index.jsp?topic=%252Fcom.nordic.infocenter.sdk5.v11.0.0%252Findex.html&cp=4_0_0)
// Clear FPU interrupt before going to sleep. This prevent unexpected wake-up.
#define FPU_EXCEPTION_MASK 0x0000009F
/* Clear exceptions and PendingIRQ from the FPU unit */
__set_FPSCR(__get_FPSCR() & ~(FPU_EXCEPTION_MASK));
(void) __get_FPSCR();
NVIC_ClearPendingIRQ(FPU_IRQn);
#endif

/* No SD - we would just block interrupts globally.
* BASEPRI cannot be used for that because it would prevent WFE from wake up.
Expand Down
2 changes: 2 additions & 0 deletions cores/nRF5/nimble_config/ext_nimble_config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#if defined(NRF51)
#include "nrf51_nimconfig.h"
#elif defined(NRF52810_XXAA)
#include "nrf52810_nimconfig.h"
#elif defined(NRF52832_XXAA) || defined(NRF52832_XXAB)
#include "nrf52832_nimconfig.h"
#elif defined(NRF52833_XXAA)
Expand Down
Loading