diff --git a/boards.txt b/boards.txt index 2d27acee..144c4c35 100644 --- a/boards.txt +++ b/boards.txt @@ -44,7 +44,6 @@ feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 -DARDUINO_NRF52_FEATHER # Ram & ROM size varies depending on SoftDevice (check linker script) feather52832.menu.softdevice.s132v6=0.2.9 (s132 6.1.1) -feather52832.menu.softdevice.s132v6.build.sd_flags=-DS132 feather52832.menu.softdevice.s132v6.build.sd_name=s132 feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1 feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7 @@ -98,13 +97,12 @@ feather52840.build.f_cpu=64000000 feather52840.build.board=NRF52840_FEATHER feather52840.build.core=nRF5 feather52840.build.variant=feather_nrf52840_express -feather52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_FEATHER +feather52840.build.extra_flags=-DARDUINO_NRF52_FEATHER {build.nrf52840_flags} # SofDevice Menu # Ram & ROM size varies depending on SoftDevice (check linker script) feather52840.menu.softdevice.s140v6=0.2.9 (s140 6.1.1) -feather52840.menu.softdevice.s140v6.build.sd_flags=-DS140 feather52840.menu.softdevice.s140v6.build.sd_name=s140 feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1 feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 @@ -156,13 +154,12 @@ metro52840.build.f_cpu=64000000 metro52840.build.board=NRF52840_METRO metro52840.build.core=nRF5 metro52840.build.variant=metro_nrf52840_express -metro52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_FEATHER +metro52840.build.extra_flags=-DARDUINO_NRF52_FEATHER {build.nrf52840_flags} # SofDevice Menu # Ram & ROM size varies depending on SoftDevice (check linker script) metro52840.menu.softdevice.s140v6=0.2.9 (s140 6.1.1) -metro52840.menu.softdevice.s140v6.build.sd_flags=-DS140 metro52840.menu.softdevice.s140v6.build.sd_name=s140 metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1 metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 @@ -198,13 +195,12 @@ pca10056.build.f_cpu=64000000 pca10056.build.board=NRF52840_PCA10056 pca10056.build.core=nRF5 pca10056.build.variant=pca10056 -pca10056.build.extra_flags=-DNRF52840_XXAA +pca10056.build.extra_flags={build.nrf52840_flags} # SofDevice Menu # Ram & ROM size varies depending on SoftDevice (check linker script) pca10056.menu.softdevice.s140v6=0.2.9 (s140 6.1.1) -pca10056.menu.softdevice.s140v6.build.sd_flags=-DS140 pca10056.menu.softdevice.s140v6.build.sd_name=s140 pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1 pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6 diff --git a/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_TinyUSB_Core.cpp b/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_TinyUSB_Core.cpp index 0d526cab..b9012feb 100644 --- a/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_TinyUSB_Core.cpp +++ b/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_TinyUSB_Core.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#ifdef NRF52840_XXAA +#ifdef USBCON #include "nrfx.h" #include "nrfx_power.h" diff --git a/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_USBD_CDC.cpp b/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_USBD_CDC.cpp index 7a2dd62f..869f1fdb 100644 --- a/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_USBD_CDC.cpp +++ b/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_USBD_CDC.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#ifdef NRF52840_XXAA +#ifdef USBCON #include "Arduino.h" #include "Adafruit_USBD_CDC.h" @@ -137,4 +137,4 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) } -#endif // NRF52840_XXAA +#endif // USBCON diff --git a/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_USBD_Device.cpp b/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_USBD_Device.cpp index 9eafb5de..ec472741 100644 --- a/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_USBD_Device.cpp +++ b/cores/nRF5/Adafruit_TinyUSB_core/Adafruit_USBD_Device.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#ifdef NRF52840_XXAA +#ifdef USBCON #include "Adafruit_USBD_Device.h" diff --git a/cores/nRF5/Arduino.h b/cores/nRF5/Arduino.h index de02f084..93ef4d5e 100644 --- a/cores/nRF5/Arduino.h +++ b/cores/nRF5/Arduino.h @@ -67,7 +67,7 @@ void suspendLoop(void); #include "utility/utilities.h" #include "utility/AdaCallback.h" -#ifdef NRF52840_XXAA +#ifdef USBCON #include "Adafruit_TinyUSB_Core.h" #endif diff --git a/cores/nRF5/delay.c b/cores/nRF5/delay.c index bf0e6f39..688fa5a8 100644 --- a/cores/nRF5/delay.c +++ b/cores/nRF5/delay.c @@ -39,7 +39,7 @@ void delay( uint32_t ms ) { uint32_t ticks = ms2tick(ms); -#ifdef NRF52840_XXAA +#ifdef USBCON // Take chance to flush usb cdc uint32_t flush_tick = xTaskGetTickCount(); tud_cdc_write_flush(); diff --git a/cores/nRF5/main.cpp b/cores/nRF5/main.cpp index 58a383e3..23daf656 100644 --- a/cores/nRF5/main.cpp +++ b/cores/nRF5/main.cpp @@ -57,7 +57,7 @@ static void loop_task(void* arg) { loop(); -#ifdef NRF52840_XXAA +#ifdef USBCON tud_cdc_write_flush(); #endif @@ -72,7 +72,7 @@ int main( void ) init(); initVariant(); -#ifdef NRF52840_XXAA +#ifdef USBCON Adafruit_TinyUSB_Core_init(); #endif diff --git a/cores/nRF5/utility/debug.cpp b/cores/nRF5/utility/debug.cpp index d7862020..58fc0d23 100644 --- a/cores/nRF5/utility/debug.cpp +++ b/cores/nRF5/utility/debug.cpp @@ -115,7 +115,7 @@ void dbgMemInfo(void) printf("| Name | Addr 0x2000xxxx | Usage |\n"); printf("| ---------------------------------------------|\n"); - // Pritn SRAM used for Stack executed by S132 and ISR + // Pritn SRAM used for Stack executed by Softdevice and ISR printMemRegion("Stack", ((uint32_t) __StackTop), ((uint32_t) __StackLimit), dbgStackUsed() ); // Print Heap usage overall (including memory malloced to tasks) @@ -125,7 +125,7 @@ void dbgMemInfo(void) printMemRegion("Bss", ((uint32_t) __bss_end__), ((uint32_t) __data_start__), 0); // Print SRAM Used by SoftDevice - printMemRegion("S132", (uint32_t) __data_start__, 0x20000000, 0); + printMemRegion("SD", (uint32_t) __data_start__, 0x20000000, 0); printf("|______________________________________________|\n"); printf("\n"); diff --git a/libraries/Bluefruit52Lib/src/bluefruit.cpp b/libraries/Bluefruit52Lib/src/bluefruit.cpp index ccde4dd4..35cdb879 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.cpp +++ b/libraries/Bluefruit52Lib/src/bluefruit.cpp @@ -54,7 +54,7 @@ #define CFG_SOC_TASK_STACKSIZE (200) #endif -#ifdef NRF52840_XXAA +#ifdef USBCON #include "nrfx_power.h" /* tinyusb function that handles power event (detected, ready, removed) @@ -290,7 +290,7 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count) _prph_count = prph_count; _central_count = central_count; -#ifdef NRF52840_XXAA +#ifdef USBCON usb_softdevice_pre_enable(); #endif @@ -319,7 +319,7 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count) VERIFY_STATUS( sd_softdevice_enable(&clock_cfg, nrf_error_cb), false ); -#ifdef NRF52840_XXAA +#ifdef USBCON usb_softdevice_post_enable(); #endif @@ -461,7 +461,7 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count) VERIFY_STATUS(sd_ble_gap_device_name_set(&sec_mode, (uint8_t const *) CFG_DEFAULT_NAME, strlen(CFG_DEFAULT_NAME)), false); //------------- USB -------------// -#if NRF52840_XXAA +#ifdef USBCON sd_power_usbdetected_enable(true); sd_power_usbpwrrdy_enable(true); sd_power_usbremoved_enable(true); @@ -713,7 +713,7 @@ void adafruit_soc_task(void* arg) if ( flash_nrf5x_event_cb ) flash_nrf5x_event_cb(soc_evt); break; - #ifdef NRF52840_XXAA + #ifdef USBCON /*------------- usb power event handler -------------*/ case NRF_EVT_POWER_USB_DETECTED: case NRF_EVT_POWER_USB_POWER_READY: diff --git a/platform.txt b/platform.txt index fa14a3fe..5fab2714 100644 --- a/platform.txt +++ b/platform.txt @@ -60,7 +60,10 @@ nordic.path={build.core.path}/nordic # 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 {build.sd_flags} {build.debug_flags} "-I{build.core.path}/cmsis/include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-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" "-I{build.core.path}/Adafruit_TinyUSB_core" "-I{build.core.path}/Adafruit_TinyUSB_core/tinyusb/src" +compiler.nrf.flags= -DARDUINO_FEATHER52 -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES {build.debug_flags} "-I{build.core.path}/cmsis/include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-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" + +# nRF52840 flags +build.nrf52840_flags= -DNRF52840_XXAA -DUSBCON "-I{build.core.path}/Adafruit_TinyUSB_core" "-I{build.core.path}/Adafruit_TinyUSB_core/tinyusb/src" # These can be overridden in platform.local.txt compiler.c.extra_flags=