Skip to content

Commit dce9c93

Browse files
committed
use USBCON macro to detect usb
1 parent be7eae2 commit dce9c93

File tree

10 files changed

+22
-23
lines changed

10 files changed

+22
-23
lines changed

boards.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 -DARDUINO_NRF52_FEATHER
4444
# Ram & ROM size varies depending on SoftDevice (check linker script)
4545

4646
feather52832.menu.softdevice.s132v6=0.2.9 (s132 6.1.1)
47-
feather52832.menu.softdevice.s132v6.build.sd_flags=-DS132
4847
feather52832.menu.softdevice.s132v6.build.sd_name=s132
4948
feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1
5049
feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7
@@ -98,13 +97,12 @@ feather52840.build.f_cpu=64000000
9897
feather52840.build.board=NRF52840_FEATHER
9998
feather52840.build.core=nRF5
10099
feather52840.build.variant=feather_nrf52840_express
101-
feather52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_FEATHER
100+
feather52840.build.extra_flags=-DARDUINO_NRF52_FEATHER {build.nrf52840_flags}
102101

103102
# SofDevice Menu
104103
# Ram & ROM size varies depending on SoftDevice (check linker script)
105104

106105
feather52840.menu.softdevice.s140v6=0.2.9 (s140 6.1.1)
107-
feather52840.menu.softdevice.s140v6.build.sd_flags=-DS140
108106
feather52840.menu.softdevice.s140v6.build.sd_name=s140
109107
feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1
110108
feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
@@ -156,13 +154,12 @@ metro52840.build.f_cpu=64000000
156154
metro52840.build.board=NRF52840_METRO
157155
metro52840.build.core=nRF5
158156
metro52840.build.variant=metro_nrf52840_express
159-
metro52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_FEATHER
157+
metro52840.build.extra_flags=-DARDUINO_NRF52_FEATHER {build.nrf52840_flags}
160158

161159
# SofDevice Menu
162160
# Ram & ROM size varies depending on SoftDevice (check linker script)
163161

164162
metro52840.menu.softdevice.s140v6=0.2.9 (s140 6.1.1)
165-
metro52840.menu.softdevice.s140v6.build.sd_flags=-DS140
166163
metro52840.menu.softdevice.s140v6.build.sd_name=s140
167164
metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1
168165
metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
@@ -198,13 +195,12 @@ pca10056.build.f_cpu=64000000
198195
pca10056.build.board=NRF52840_PCA10056
199196
pca10056.build.core=nRF5
200197
pca10056.build.variant=pca10056
201-
pca10056.build.extra_flags=-DNRF52840_XXAA
198+
pca10056.build.extra_flags={build.nrf52840_flags}
202199

203200
# SofDevice Menu
204201
# Ram & ROM size varies depending on SoftDevice (check linker script)
205202

206203
pca10056.menu.softdevice.s140v6=0.2.9 (s140 6.1.1)
207-
pca10056.menu.softdevice.s140v6.build.sd_flags=-DS140
208204
pca10056.menu.softdevice.s140v6.build.sd_name=s140
209205
pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1
210206
pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6

cores/nRF5/Adafruit_TinyUSB_core/Adafruit_TinyUSB_Core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24-
#ifdef NRF52840_XXAA
24+
#ifdef USBCON
2525

2626
#include "nrfx.h"
2727
#include "nrfx_power.h"

cores/nRF5/Adafruit_TinyUSB_core/Adafruit_USBD_CDC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#ifdef NRF52840_XXAA
25+
#ifdef USBCON
2626

2727
#include "Arduino.h"
2828
#include "Adafruit_USBD_CDC.h"
@@ -137,4 +137,4 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
137137

138138
}
139139

140-
#endif // NRF52840_XXAA
140+
#endif // USBCON

cores/nRF5/Adafruit_TinyUSB_core/Adafruit_USBD_Device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#ifdef NRF52840_XXAA
25+
#ifdef USBCON
2626

2727
#include "Adafruit_USBD_Device.h"
2828

cores/nRF5/Arduino.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void suspendLoop(void);
6767
#include "utility/utilities.h"
6868
#include "utility/AdaCallback.h"
6969

70-
#ifdef NRF52840_XXAA
70+
#ifdef USBCON
7171
#include "Adafruit_TinyUSB_Core.h"
7272
#endif
7373

cores/nRF5/delay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void delay( uint32_t ms )
3939
{
4040
uint32_t ticks = ms2tick(ms);
4141

42-
#ifdef NRF52840_XXAA
42+
#ifdef USBCON
4343
// Take chance to flush usb cdc
4444
uint32_t flush_tick = xTaskGetTickCount();
4545
tud_cdc_write_flush();

cores/nRF5/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void loop_task(void* arg)
5757
{
5858
loop();
5959

60-
#ifdef NRF52840_XXAA
60+
#ifdef USBCON
6161
tud_cdc_write_flush();
6262
#endif
6363

@@ -72,7 +72,7 @@ int main( void )
7272
init();
7373
initVariant();
7474

75-
#ifdef NRF52840_XXAA
75+
#ifdef USBCON
7676
Adafruit_TinyUSB_Core_init();
7777
#endif
7878

cores/nRF5/utility/debug.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void dbgMemInfo(void)
115115
printf("| Name | Addr 0x2000xxxx | Usage |\n");
116116
printf("| ---------------------------------------------|\n");
117117

118-
// Pritn SRAM used for Stack executed by S132 and ISR
118+
// Pritn SRAM used for Stack executed by Softdevice and ISR
119119
printMemRegion("Stack", ((uint32_t) __StackTop), ((uint32_t) __StackLimit), dbgStackUsed() );
120120

121121
// Print Heap usage overall (including memory malloced to tasks)
@@ -125,7 +125,7 @@ void dbgMemInfo(void)
125125
printMemRegion("Bss", ((uint32_t) __bss_end__), ((uint32_t) __data_start__), 0);
126126

127127
// Print SRAM Used by SoftDevice
128-
printMemRegion("S132", (uint32_t) __data_start__, 0x20000000, 0);
128+
printMemRegion("SD", (uint32_t) __data_start__, 0x20000000, 0);
129129

130130
printf("|______________________________________________|\n");
131131
printf("\n");

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#define CFG_SOC_TASK_STACKSIZE (200)
5555
#endif
5656

57-
#ifdef NRF52840_XXAA
57+
#ifdef USBCON
5858
#include "nrfx_power.h"
5959

6060
/* tinyusb function that handles power event (detected, ready, removed)
@@ -290,7 +290,7 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
290290
_prph_count = prph_count;
291291
_central_count = central_count;
292292

293-
#ifdef NRF52840_XXAA
293+
#ifdef USBCON
294294
usb_softdevice_pre_enable();
295295
#endif
296296

@@ -319,7 +319,7 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
319319

320320
VERIFY_STATUS( sd_softdevice_enable(&clock_cfg, nrf_error_cb), false );
321321

322-
#ifdef NRF52840_XXAA
322+
#ifdef USBCON
323323
usb_softdevice_post_enable();
324324
#endif
325325

@@ -461,7 +461,7 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
461461
VERIFY_STATUS(sd_ble_gap_device_name_set(&sec_mode, (uint8_t const *) CFG_DEFAULT_NAME, strlen(CFG_DEFAULT_NAME)), false);
462462

463463
//------------- USB -------------//
464-
#if NRF52840_XXAA
464+
#ifdef USBCON
465465
sd_power_usbdetected_enable(true);
466466
sd_power_usbpwrrdy_enable(true);
467467
sd_power_usbremoved_enable(true);
@@ -713,7 +713,7 @@ void adafruit_soc_task(void* arg)
713713
if ( flash_nrf5x_event_cb ) flash_nrf5x_event_cb(soc_evt);
714714
break;
715715

716-
#ifdef NRF52840_XXAA
716+
#ifdef USBCON
717717
/*------------- usb power event handler -------------*/
718718
case NRF_EVT_POWER_USB_DETECTED:
719719
case NRF_EVT_POWER_USB_POWER_READY:

platform.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ nordic.path={build.core.path}/nordic
6060
# ARDUINO_FEATHER52 is defined for backward compatiable with other lib only
6161
# should be replaced by ARDUINO_NRF52_ADAFRUIT in the future
6262

63-
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"
63+
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"
64+
65+
# nRF52840 flags
66+
build.nrf52840_flags= -DNRF52840_XXAA -DUSBCON "-I{build.core.path}/Adafruit_TinyUSB_core" "-I{build.core.path}/Adafruit_TinyUSB_core/tinyusb/src"
6467

6568
# These can be overridden in platform.local.txt
6669
compiler.c.extra_flags=

0 commit comments

Comments
 (0)