Merge branch 'master' into temp
This commit is contained in:
commit
a71a669343
82 files changed
+51936
-51684
No files matched your search
@@ -3,3 +3,6 @@ contact_links:
|
||||
- name: Adafruit Support Forum
|
||||
url: https://forums.adafruit.com
|
||||
about: If you have other questions or need help, post it here.
|
||||
- name: Discussion
|
||||
url: https://github.com/adafruit/Adafruit_nRF52_Arduino/discussions
|
||||
about: If you have other questions or need help, post it here.
|
||||
@@ -2,8 +2,13 @@ name: Build
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -16,17 +21,15 @@ jobs:
|
||||
- 'feather52840sense'
|
||||
- 'itsybitsy52840'
|
||||
- 'ledglasses_nrf52840'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v1
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: 'true'
|
||||
|
||||
@@ -58,14 +61,11 @@ jobs:
|
||||
|
||||
# Install library dependency
|
||||
arduino-cli lib install "Adafruit AHRS" "Adafruit APDS9960 Library" "Adafruit Arcada Library" "Adafruit BMP280 Library" "Adafruit Circuit Playground" "Adafruit EPD" "Adafruit GFX Library" "Adafruit HX8357 Library" "Adafruit ILI9341" "Adafruit LIS3MDL" "Adafruit LSM6DS" "Adafruit NeoPixel" "Adafruit NeoMatrix" "Adafruit Sensor Calibration" "Adafruit SHT31 Library" "Adafruit SSD1306" "Adafruit ST7735 and ST7789 Library" "SdFat - Adafruit Fork"
|
||||
arduino-cli lib install "Arduino_TensorFlowLite" "MIDI Library"
|
||||
arduino-cli lib install "MIDI Library" "Firmata"
|
||||
|
||||
# TODO use firmata master to prevent build error with gcc v9 (should be remove after 2.5.9 is released)
|
||||
# https://github.com/firmata/arduino/pull/438
|
||||
git clone --depth 1 https://github.com/firmata/arduino.git $HOME/Arduino/libraries/firmata
|
||||
|
||||
# TODO temporarily remove TinyUSB pre-1.0.0 version install by arduino-cli
|
||||
rm -r $HOME/Arduino/libraries/Adafruit_TinyUSB_Library
|
||||
# Arduino_TensorFlowLite is removed per maintainer request https://github.com/arduino/library-registry/pull/1748
|
||||
# Find a way to compile later, skip TFL example for now
|
||||
# arduino-cli lib install "Arduino_TensorFlowLite"
|
||||
|
||||
# Library summary
|
||||
arduino-cli lib list
|
||||
|
||||
+5
-2
@@ -3,7 +3,10 @@
|
||||
*.obj
|
||||
|
||||
# Visual Studio Code
|
||||
**/.vscode/
|
||||
.vscode/
|
||||
.idea/
|
||||
.pio/
|
||||
.piopm
|
||||
|
||||
# Executables
|
||||
*.out
|
||||
@@ -20,4 +23,4 @@
|
||||
# Ignore local overrides of platform.txt and boards.txt,
|
||||
/boards.local.txt
|
||||
/platform.local.txt
|
||||
/libraries/**/build/
|
||||
|
||||
+47
-37
@@ -1,6 +1,6 @@
|
||||
menu.softdevice=SoftDevice
|
||||
menu.debug=Debug
|
||||
menu.debug_output=Debug Output
|
||||
menu.debug=Debug Level
|
||||
menu.debug_output=Debug Port
|
||||
|
||||
# -----------------------------------
|
||||
# Adafruit Feather nRF52832
|
||||
@@ -29,14 +29,15 @@ feather52832.build.usb_manufacturer="Adafruit"
|
||||
feather52832.build.usb_product="Feather nRF52832"
|
||||
feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52
|
||||
feather52832.build.ldscript=nrf52832_s132_v6.ld
|
||||
feather52832.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
feather52832.menu.softdevice.s132v6=S132 6.1.1
|
||||
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
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
feather52832.menu.debug.l0=Level 0 (Release)
|
||||
feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
feather52832.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -47,7 +48,7 @@ feather52832.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
feather52832.menu.debug_output.serial=Serial
|
||||
feather52832.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
feather52832.menu.debug_output.serial1=Serial1
|
||||
@@ -89,16 +90,17 @@ feather52840.build.usb_manufacturer="Adafruit"
|
||||
feather52840.build.usb_product="Feather nRF52840 Express"
|
||||
feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
feather52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
feather52840.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
feather52840.build.vid=0x239A
|
||||
feather52840.build.pid=0x8029
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
feather52840.menu.softdevice.s140v6=S140 6.1.1
|
||||
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
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
feather52840.menu.debug.l0=Level 0 (Release)
|
||||
feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
feather52840.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -109,7 +111,7 @@ feather52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
feather52840.menu.debug_output.serial=Serial
|
||||
feather52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
feather52840.menu.debug_output.serial1=Serial1
|
||||
@@ -151,16 +153,17 @@ feather52840sense.build.usb_manufacturer="Adafruit"
|
||||
feather52840sense.build.usb_product="Feather nRF52840 Sense"
|
||||
feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
feather52840sense.build.ldscript=nrf52840_s140_v6.ld
|
||||
feather52840sense.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
feather52840sense.build.vid=0x239A
|
||||
feather52840sense.build.pid=0x8087
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
feather52840sense.menu.softdevice.s140v6=S140 6.1.1
|
||||
feather52840sense.menu.softdevice.s140v6.build.sd_name=s140
|
||||
feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
feather52840sense.menu.debug.l0=Level 0 (Release)
|
||||
feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
feather52840sense.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -171,7 +174,7 @@ feather52840sense.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
feather52840sense.menu.debug_output.serial=Serial
|
||||
feather52840sense.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
feather52840sense.menu.debug_output.serial1=Serial1
|
||||
@@ -213,16 +216,17 @@ itsybitsy52840.build.usb_manufacturer="Adafruit"
|
||||
itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express"
|
||||
itsybitsy52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
itsybitsy52840.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
itsybitsy52840.build.vid=0x239A
|
||||
itsybitsy52840.build.pid=0x8051
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
itsybitsy52840.menu.softdevice.s140v6=S140 6.1.1
|
||||
itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
itsybitsy52840.menu.debug.l0=Level 0 (Release)
|
||||
itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
itsybitsy52840.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -233,7 +237,7 @@ itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
itsybitsy52840.menu.debug_output.serial=Serial
|
||||
itsybitsy52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
itsybitsy52840.menu.debug_output.serial1=Serial1
|
||||
@@ -273,16 +277,17 @@ cplaynrf52840.build.usb_manufacturer="Adafruit"
|
||||
cplaynrf52840.build.usb_product="Circuit Playground Bluefruit"
|
||||
cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
cplaynrf52840.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
cplaynrf52840.build.vid=0x239A
|
||||
cplaynrf52840.build.pid=0x8045
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
cplaynrf52840.menu.softdevice.s140v6=S140 6.1.1
|
||||
cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
cplaynrf52840.menu.debug.l0=Level 0 (Release)
|
||||
cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
cplaynrf52840.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -293,7 +298,7 @@ cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
cplaynrf52840.menu.debug_output.serial=Serial
|
||||
cplaynrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
cplaynrf52840.menu.debug_output.serial1=Serial1
|
||||
@@ -333,16 +338,17 @@ cluenrf52840.build.usb_manufacturer="Adafruit"
|
||||
cluenrf52840.build.usb_product="CLUE"
|
||||
cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
cluenrf52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
cluenrf52840.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
cluenrf52840.build.vid=0x239A
|
||||
cluenrf52840.build.pid=0x8071
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
cluenrf52840.menu.softdevice.s140v6=S140 6.1.1
|
||||
cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
cluenrf52840.menu.debug.l0=Level 0 (Release)
|
||||
cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
cluenrf52840.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -353,7 +359,7 @@ cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
cluenrf52840.menu.debug_output.serial=Serial
|
||||
cluenrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
cluenrf52840.menu.debug_output.serial1=Serial1
|
||||
@@ -393,16 +399,17 @@ ledglasses_nrf52840.build.usb_manufacturer="Adafruit"
|
||||
ledglasses_nrf52840.build.usb_product="LED Glasses Driver nRF52840"
|
||||
ledglasses_nrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
ledglasses_nrf52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
ledglasses_nrf52840.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
ledglasses_nrf52840.build.vid=0x239A
|
||||
ledglasses_nrf52840.build.pid=0x810D
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
ledglasses_nrf52840.menu.softdevice.s140v6=S140 6.1.1
|
||||
ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
ledglasses_nrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
ledglasses_nrf52840.menu.debug.l0=Level 0 (Release)
|
||||
ledglasses_nrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
ledglasses_nrf52840.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -413,7 +420,7 @@ ledglasses_nrf52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
ledglasses_nrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
ledglasses_nrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
ledglasses_nrf52840.menu.debug_output.serial=Serial
|
||||
ledglasses_nrf52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
ledglasses_nrf52840.menu.debug_output.serial1=Serial1
|
||||
@@ -453,16 +460,17 @@ mdbt50qrx.build.usb_manufacturer="Raytac"
|
||||
mdbt50qrx.build.usb_product="nRF52840 Dongle"
|
||||
mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld
|
||||
mdbt50qrx.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
mdbt50qrx.build.vid=0x239A
|
||||
mdbt50qrx.build.pid=0x810B
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
mdbt50qrx.menu.softdevice.s140v6=S140 6.1.1
|
||||
mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140
|
||||
mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
mdbt50qrx.menu.debug.l0=Level 0 (Release)
|
||||
mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
mdbt50qrx.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -473,7 +481,7 @@ mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
mdbt50qrx.menu.debug_output.serial=Serial
|
||||
mdbt50qrx.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
mdbt50qrx.menu.debug_output.serial1=Serial1
|
||||
@@ -515,16 +523,17 @@ metro52840.build.usb_manufacturer="Adafruit"
|
||||
metro52840.build.usb_product="Metro nRF52840 Express"
|
||||
metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
metro52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
metro52840.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
metro52840.build.vid=0x239A
|
||||
metro52840.build.pid=0x803F
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
metro52840.menu.softdevice.s140v6=S140 6.1.1
|
||||
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
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
metro52840.menu.debug.l0=Level 0 (Release)
|
||||
metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
metro52840.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -535,7 +544,7 @@ metro52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
metro52840.menu.debug_output.serial=Serial
|
||||
metro52840.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
metro52840.menu.debug_output.serial1=Serial1
|
||||
@@ -545,9 +554,8 @@ metro52840.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DE
|
||||
|
||||
|
||||
# -------------------------------------------------------
|
||||
#
|
||||
# Boards that aren't made by Adafruit
|
||||
#
|
||||
# and are not officially supported
|
||||
# -------------------------------------------------------
|
||||
|
||||
# -----------------------------------
|
||||
@@ -580,16 +588,17 @@ pca10056.build.usb_manufacturer="Nordic"
|
||||
pca10056.build.usb_product="nRF52840 DK"
|
||||
pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
pca10056.build.ldscript=nrf52840_s140_v6.ld
|
||||
pca10056.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
pca10056.build.vid=0x239A
|
||||
pca10056.build.pid=0x8029
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
pca10056.menu.softdevice.s140v6=S140 6.1.1
|
||||
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
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
pca10056.menu.debug.l0=Level 0 (Release)
|
||||
pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
pca10056.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -600,7 +609,7 @@ pca10056.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
pca10056.menu.debug_output.serial=Serial
|
||||
pca10056.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
pca10056.menu.debug_output.serial1=Serial1
|
||||
@@ -638,16 +647,17 @@ particle_xenon.build.usb_manufacturer="Particle"
|
||||
particle_xenon.build.usb_product="Xenon"
|
||||
particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
particle_xenon.build.ldscript=nrf52840_s140_v6.ld
|
||||
particle_xenon.build.openocdscript=scripts/openocd/daplink_nrf52.cfg
|
||||
particle_xenon.build.vid=0x239A
|
||||
particle_xenon.build.pid=0x8029
|
||||
|
||||
# SoftDevice Menu
|
||||
# Menu: SoftDevice
|
||||
particle_xenon.menu.softdevice.s140v6=S140 6.1.1
|
||||
particle_xenon.menu.softdevice.s140v6.build.sd_name=s140
|
||||
particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
# Menu: Debug Level
|
||||
particle_xenon.menu.debug.l0=Level 0 (Release)
|
||||
particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
particle_xenon.menu.debug.l1=Level 1 (Error Message)
|
||||
@@ -658,7 +668,7 @@ particle_xenon.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# Debug Output Menu
|
||||
# Menu: Debug Port
|
||||
particle_xenon.menu.debug_output.serial=Serial
|
||||
particle_xenon.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0
|
||||
particle_xenon.menu.debug_output.serial1=Serial1
|
||||
|
||||
-11787
File diff suppressed because it is too large.
Load diff
+2048
-2120
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1276
-1271
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
-11791
File diff suppressed because it is too large.
Load diff
+2052
-2093
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
-11791
File diff suppressed because it is too large.
Load diff
+2048
-2099
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+2055
-2124
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
+11720
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+2044
-2126
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2041
-2126
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1991
-2066
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -205,6 +205,15 @@ bool HardwarePWM::removePin(uint8_t pin)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HardwarePWM::removeAllPins(void)
|
||||
{
|
||||
for(int ch=0; ch<MAX_CHANNELS; ch++)
|
||||
{
|
||||
_set_psel(ch, 0xFFFFFFFFUL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HardwarePWM::writeChannel(uint8_t ch, uint16_t value, bool inverted)
|
||||
{
|
||||
VERIFY( ch < MAX_CHANNELS );
|
||||
|
||||
@@ -88,6 +88,9 @@ class HardwarePWM
|
||||
// Remove a pin from PWM module
|
||||
bool removePin (uint8_t pin);
|
||||
|
||||
// Remove all pins from PWM module
|
||||
bool removeAllPins (void);
|
||||
|
||||
// Get the mapped channel of a pin
|
||||
int pin2channel(uint8_t pin) const
|
||||
{
|
||||
|
||||
@@ -179,13 +179,13 @@ const char* dbg_err_str(int32_t err_id); // TODO move to other place
|
||||
#define PRINT_LOCATION() PRINTF("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
|
||||
#define PRINT_MESS(x) PRINTF("%s: %d: %s \r\n" , __FUNCTION__, __LINE__, (char*)(x))
|
||||
#define PRINT_HEAP() if (CFG_DEBUG >= 3) PRINTF("\n%s: %d: Heap free: %d\r\n", __FUNCTION__, __LINE__, util_heap_get_free_size())
|
||||
#define PRINT_STR(x) PRINTF("%s: %d: " #x " = %s\r\n" , __FUNCTION__, __LINE__, (char*)(x) )
|
||||
#define PRINT_INT(x) PRINTF("%s: %d: " #x " = %ld\r\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
|
||||
#define PRINT_FLOAT(x) PRINTF("%s: %d: " #x " = %f\r\n" , __FUNCTION__, __LINE__, (float) (x) )
|
||||
#define PRINT_STR(x) PRINTF(#x " = %s\r\n" , (char*)(x) )
|
||||
#define PRINT_INT(x) PRINTF(#x " = %ld\r\n", (uint32_t) (x) )
|
||||
#define PRINT_FLOAT(x) PRINTF(#x " = %f\r\n" , (float) (x) )
|
||||
|
||||
#define PRINT_HEX(x) \
|
||||
do {\
|
||||
PRINTF("%s: %d: " #x " = 0x", __PRETTY_FUNCTION__, __LINE__);\
|
||||
PRINTF(#x " = 0x");\
|
||||
char fmt[] = "%00X\r\n";\
|
||||
fmt[2] += 2*sizeof(x); /* Hex with correct size */\
|
||||
PRINTF(fmt, (x) );\
|
||||
|
||||
@@ -0,0 +1,504 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - 2020, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIS_ENABLED)
|
||||
|
||||
#if !(NRFX_CHECK(NRFX_SPIS0_ENABLED) || \
|
||||
NRFX_CHECK(NRFX_SPIS1_ENABLED) || \
|
||||
NRFX_CHECK(NRFX_SPIS2_ENABLED) || \
|
||||
NRFX_CHECK(NRFX_SPIS3_ENABLED))
|
||||
#error "No enabled SPIS instances. Check <nrfx_config.h>."
|
||||
#endif
|
||||
|
||||
#include <nrfx_spis.h>
|
||||
#include "prs/nrfx_prs.h"
|
||||
|
||||
#define NRFX_LOG_MODULE SPIS
|
||||
#include <nrfx_log.h>
|
||||
|
||||
#define EVT_TO_STR(event) \
|
||||
(event == NRF_SPIS_EVENT_ACQUIRED ? "NRF_SPIS_EVENT_ACQUIRED" : \
|
||||
(event == NRF_SPIS_EVENT_END ? "NRF_SPIS_EVENT_END" : \
|
||||
"UNKNOWN ERROR"))
|
||||
|
||||
#define SPISX_LENGTH_VALIDATE(peripheral, drv_inst_idx, rx_len, tx_len) \
|
||||
(((drv_inst_idx) == NRFX_CONCAT_3(NRFX_, peripheral, _INST_IDX)) && \
|
||||
NRFX_EASYDMA_LENGTH_VALIDATE(peripheral, rx_len, tx_len))
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIS0_ENABLED)
|
||||
#define SPIS0_LENGTH_VALIDATE(...) SPISX_LENGTH_VALIDATE(SPIS0, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIS0_LENGTH_VALIDATE(...) 0
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIS1_ENABLED)
|
||||
#define SPIS1_LENGTH_VALIDATE(...) SPISX_LENGTH_VALIDATE(SPIS1, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIS1_LENGTH_VALIDATE(...) 0
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIS2_ENABLED)
|
||||
#define SPIS2_LENGTH_VALIDATE(...) SPISX_LENGTH_VALIDATE(SPIS2, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIS2_LENGTH_VALIDATE(...) 0
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIS3_ENABLED)
|
||||
#define SPIS3_LENGTH_VALIDATE(...) SPISX_LENGTH_VALIDATE(SPIS3, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIS3_LENGTH_VALIDATE(...) 0
|
||||
#endif
|
||||
|
||||
#define SPIS_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) \
|
||||
(SPIS0_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
|
||||
SPIS1_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
|
||||
SPIS2_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
|
||||
SPIS3_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len))
|
||||
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED)
|
||||
#include <nrfx_gpiote.h>
|
||||
#define USE_DMA_ISSUE_WORKAROUND
|
||||
// This handler is called by the GPIOTE driver when a falling edge is detected
|
||||
// on the CSN line. There is no need to do anything here. The handling of the
|
||||
// interrupt itself provides a protection for DMA transfers.
|
||||
static void csn_event_handler(nrfx_gpiote_pin_t pin,
|
||||
nrf_gpiote_polarity_t action)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**@brief States of the SPI transaction state machine. */
|
||||
typedef enum
|
||||
{
|
||||
SPIS_STATE_INIT, /**< Initialization state. In this state the module waits for a call to @ref spi_slave_buffers_set. */
|
||||
SPIS_BUFFER_RESOURCE_REQUESTED, /**< State where the configuration of the memory buffers, which are to be used in SPI transaction, has started. */
|
||||
SPIS_BUFFER_RESOURCE_CONFIGURED, /**< State where the configuration of the memory buffers, which are to be used in SPI transaction, has completed. */
|
||||
SPIS_XFER_COMPLETED /**< State where SPI transaction has been completed. */
|
||||
} nrfx_spis_state_t;
|
||||
|
||||
/**@brief SPIS control block - driver instance local data. */
|
||||
typedef struct
|
||||
{
|
||||
volatile uint32_t tx_buffer_size; //!< SPI slave TX buffer size in bytes.
|
||||
volatile uint32_t rx_buffer_size; //!< SPI slave RX buffer size in bytes.
|
||||
nrfx_spis_event_handler_t handler; //!< SPI event handler.
|
||||
volatile const uint8_t * tx_buffer; //!< SPI slave TX buffer.
|
||||
volatile uint8_t * rx_buffer; //!< SPI slave RX buffer.
|
||||
nrfx_drv_state_t state; //!< driver initialization state.
|
||||
volatile nrfx_spis_state_t spi_state; //!< SPI slave state.
|
||||
void * p_context; //!< Context set on initialization.
|
||||
} spis_cb_t;
|
||||
|
||||
static spis_cb_t m_cb[NRFX_SPIS_ENABLED_COUNT];
|
||||
|
||||
nrfx_err_t nrfx_spis_init(nrfx_spis_t const * p_instance,
|
||||
nrfx_spis_config_t const * p_config,
|
||||
nrfx_spis_event_handler_t event_handler,
|
||||
void * p_context)
|
||||
{
|
||||
NRFX_ASSERT(p_config);
|
||||
NRFX_ASSERT(event_handler);
|
||||
spis_cb_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
nrfx_err_t err_code;
|
||||
|
||||
NRF_SPIS_Type * p_spis = p_instance->p_reg;
|
||||
|
||||
if (p_cb->state != NRFX_DRV_STATE_UNINITIALIZED)
|
||||
{
|
||||
err_code = NRFX_ERROR_INVALID_STATE;
|
||||
NRFX_LOG_WARNING("Function: %s, error code: %s.",
|
||||
__func__,
|
||||
NRFX_LOG_ERROR_STRING_GET(err_code));
|
||||
return err_code;
|
||||
}
|
||||
|
||||
if ((uint32_t)p_config->mode > (uint32_t)NRF_SPIS_MODE_3)
|
||||
{
|
||||
err_code = NRFX_ERROR_INVALID_PARAM;
|
||||
NRFX_LOG_WARNING("Function: %s, error code: %s.",
|
||||
__func__,
|
||||
NRFX_LOG_ERROR_STRING_GET(err_code));
|
||||
return err_code;
|
||||
}
|
||||
#if NRFX_CHECK(NRFX_PRS_ENABLED)
|
||||
static nrfx_irq_handler_t const irq_handlers[NRFX_SPIS_ENABLED_COUNT] = {
|
||||
#if NRFX_CHECK(NRFX_SPIS0_ENABLED)
|
||||
nrfx_spis_0_irq_handler,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_SPIS1_ENABLED)
|
||||
nrfx_spis_1_irq_handler,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_SPIS2_ENABLED)
|
||||
nrfx_spis_2_irq_handler,
|
||||
#endif
|
||||
#if NRFX_CHECK(NRFX_SPIS3_ENABLED)
|
||||
nrfx_spis_3_irq_handler,
|
||||
#endif
|
||||
};
|
||||
if (nrfx_prs_acquire(p_spis,
|
||||
irq_handlers[p_instance->drv_inst_idx]) != NRFX_SUCCESS)
|
||||
{
|
||||
err_code = NRFX_ERROR_BUSY;
|
||||
NRFX_LOG_WARNING("Function: %s, error code: %s.",
|
||||
__func__,
|
||||
NRFX_LOG_ERROR_STRING_GET(err_code));
|
||||
return err_code;
|
||||
}
|
||||
#endif // NRFX_CHECK(NRFX_PRS_ENABLED)
|
||||
|
||||
// Configure the SPI pins for input.
|
||||
uint32_t mosi_pin;
|
||||
uint32_t miso_pin;
|
||||
|
||||
if (p_config->miso_pin != NRFX_SPIS_PIN_NOT_USED)
|
||||
{
|
||||
nrf_gpio_cfg(p_config->miso_pin,
|
||||
NRF_GPIO_PIN_DIR_INPUT,
|
||||
NRF_GPIO_PIN_INPUT_CONNECT,
|
||||
NRF_GPIO_PIN_NOPULL,
|
||||
p_config->miso_drive,
|
||||
NRF_GPIO_PIN_NOSENSE);
|
||||
miso_pin = p_config->miso_pin;
|
||||
}
|
||||
else
|
||||
{
|
||||
miso_pin = NRF_SPIS_PIN_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
if (p_config->mosi_pin != NRFX_SPIS_PIN_NOT_USED)
|
||||
{
|
||||
nrf_gpio_cfg(p_config->mosi_pin,
|
||||
NRF_GPIO_PIN_DIR_INPUT,
|
||||
NRF_GPIO_PIN_INPUT_CONNECT,
|
||||
NRF_GPIO_PIN_NOPULL,
|
||||
NRF_GPIO_PIN_S0S1,
|
||||
NRF_GPIO_PIN_NOSENSE);
|
||||
mosi_pin = p_config->mosi_pin;
|
||||
}
|
||||
else
|
||||
{
|
||||
mosi_pin = NRF_SPIS_PIN_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
nrf_gpio_cfg(p_config->csn_pin,
|
||||
NRF_GPIO_PIN_DIR_INPUT,
|
||||
NRF_GPIO_PIN_INPUT_CONNECT,
|
||||
p_config->csn_pullup,
|
||||
NRF_GPIO_PIN_S0S1,
|
||||
NRF_GPIO_PIN_NOSENSE);
|
||||
|
||||
nrf_gpio_cfg(p_config->sck_pin,
|
||||
NRF_GPIO_PIN_DIR_INPUT,
|
||||
NRF_GPIO_PIN_INPUT_CONNECT,
|
||||
NRF_GPIO_PIN_NOPULL,
|
||||
NRF_GPIO_PIN_S0S1,
|
||||
NRF_GPIO_PIN_NOSENSE);
|
||||
|
||||
nrf_spis_pins_set(p_spis, p_config->sck_pin, mosi_pin, miso_pin, p_config->csn_pin);
|
||||
|
||||
nrf_spis_rx_buffer_set(p_spis, NULL, 0);
|
||||
nrf_spis_tx_buffer_set(p_spis, NULL, 0);
|
||||
|
||||
// Configure SPI mode.
|
||||
nrf_spis_configure(p_spis, p_config->mode, p_config->bit_order);
|
||||
|
||||
// Configure DEF and ORC characters.
|
||||
nrf_spis_def_set(p_spis, p_config->def);
|
||||
nrf_spis_orc_set(p_spis, p_config->orc);
|
||||
|
||||
// Clear possible pending events.
|
||||
nrf_spis_event_clear(p_spis, NRF_SPIS_EVENT_END);
|
||||
nrf_spis_event_clear(p_spis, NRF_SPIS_EVENT_ACQUIRED);
|
||||
|
||||
// Enable END_ACQUIRE shortcut.
|
||||
nrf_spis_shorts_enable(p_spis, NRF_SPIS_SHORT_END_ACQUIRE);
|
||||
|
||||
p_cb->spi_state = SPIS_STATE_INIT;
|
||||
p_cb->handler = event_handler;
|
||||
p_cb->p_context = p_context;
|
||||
|
||||
#if defined(USE_DMA_ISSUE_WORKAROUND)
|
||||
// Configure a GPIOTE channel to generate interrupts on each falling edge
|
||||
// on the CSN line. Handling of these interrupts will make the CPU active,
|
||||
// and thus will protect the DMA transfers started by SPIS right after it
|
||||
// is selected for communication.
|
||||
// [the GPIOTE driver may be already initialized at this point (by this
|
||||
// driver when another SPIS instance is used, or by an application code),
|
||||
// so just ignore the returned value]
|
||||
(void)nrfx_gpiote_init(NRFX_GPIOTE_DEFAULT_CONFIG_IRQ_PRIORITY);
|
||||
static nrfx_gpiote_in_config_t const csn_gpiote_config =
|
||||
NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
|
||||
nrfx_err_t gpiote_err_code = nrfx_gpiote_in_init(p_config->csn_pin,
|
||||
&csn_gpiote_config, csn_event_handler);
|
||||
if (gpiote_err_code != NRFX_SUCCESS)
|
||||
{
|
||||
err_code = NRFX_ERROR_INTERNAL;
|
||||
NRFX_LOG_INFO("Function: %s, error code: %s.",
|
||||
__func__,
|
||||
NRFX_LOG_ERROR_STRING_GET(err_code));
|
||||
return err_code;
|
||||
}
|
||||
nrfx_gpiote_in_event_enable(p_config->csn_pin, true);
|
||||
#endif
|
||||
|
||||
// Enable IRQ.
|
||||
nrf_spis_int_enable(p_spis, NRF_SPIS_INT_ACQUIRED_MASK |
|
||||
NRF_SPIS_INT_END_MASK);
|
||||
NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(p_instance->p_reg),
|
||||
p_config->irq_priority);
|
||||
NRFX_IRQ_ENABLE(nrfx_get_irq_number(p_instance->p_reg));
|
||||
|
||||
p_cb->state = NRFX_DRV_STATE_INITIALIZED;
|
||||
|
||||
// Enable SPI slave device.
|
||||
nrf_spis_enable(p_spis);
|
||||
|
||||
NRFX_LOG_INFO("Initialized.");
|
||||
return NRFX_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void nrfx_spis_uninit(nrfx_spis_t const * p_instance)
|
||||
{
|
||||
spis_cb_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
NRFX_ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED);
|
||||
|
||||
NRF_SPIS_Type * p_spis = p_instance->p_reg;
|
||||
|
||||
#define DISABLE_ALL 0xFFFFFFFF
|
||||
nrf_spis_disable(p_spis);
|
||||
NRFX_IRQ_DISABLE(nrfx_get_irq_number(p_instance->p_reg));
|
||||
nrf_spis_int_disable(p_spis, DISABLE_ALL);
|
||||
#undef DISABLE_ALL
|
||||
|
||||
#if NRFX_CHECK(NRFX_PRS_ENABLED)
|
||||
nrfx_prs_release(p_spis);
|
||||
#endif
|
||||
|
||||
p_cb->state = NRFX_DRV_STATE_UNINITIALIZED;
|
||||
NRFX_LOG_INFO("Uninitialized.");
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for executing the state entry action. */
|
||||
static void spis_state_entry_action_execute(NRF_SPIS_Type * p_spis,
|
||||
spis_cb_t * p_cb)
|
||||
{
|
||||
nrfx_spis_evt_t event;
|
||||
|
||||
switch (p_cb->spi_state)
|
||||
{
|
||||
case SPIS_BUFFER_RESOURCE_REQUESTED:
|
||||
nrf_spis_task_trigger(p_spis, NRF_SPIS_TASK_ACQUIRE);
|
||||
break;
|
||||
|
||||
case SPIS_BUFFER_RESOURCE_CONFIGURED:
|
||||
event.evt_type = NRFX_SPIS_BUFFERS_SET_DONE;
|
||||
event.rx_amount = 0;
|
||||
event.tx_amount = 0;
|
||||
|
||||
NRFX_ASSERT(p_cb->handler != NULL);
|
||||
p_cb->handler(&event, p_cb->p_context);
|
||||
break;
|
||||
|
||||
case SPIS_XFER_COMPLETED:
|
||||
event.evt_type = NRFX_SPIS_XFER_DONE;
|
||||
event.rx_amount = nrf_spis_rx_amount_get(p_spis);
|
||||
event.tx_amount = nrf_spis_tx_amount_get(p_spis);
|
||||
NRFX_LOG_INFO("Transfer rx_len:%d.", event.rx_amount);
|
||||
NRFX_LOG_DEBUG("Rx data:");
|
||||
NRFX_LOG_HEXDUMP_DEBUG((uint8_t const *)p_cb->rx_buffer,
|
||||
event.rx_amount * sizeof(p_cb->rx_buffer[0]));
|
||||
NRFX_ASSERT(p_cb->handler != NULL);
|
||||
p_cb->handler(&event, p_cb->p_context);
|
||||
break;
|
||||
|
||||
default:
|
||||
// No implementation required.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**@brief Function for changing the state of the SPI state machine.
|
||||
*
|
||||
* @param[in] p_spis SPIS instance register.
|
||||
* @param[in] p_cb SPIS instance control block.
|
||||
* @param[in] new_state State where the state machine transits to.
|
||||
*/
|
||||
static void spis_state_change(NRF_SPIS_Type * p_spis,
|
||||
spis_cb_t * p_cb,
|
||||
nrfx_spis_state_t new_state)
|
||||
{
|
||||
p_cb->spi_state = new_state;
|
||||
spis_state_entry_action_execute(p_spis, p_cb);
|
||||
}
|
||||
|
||||
nrfx_err_t nrfx_spis_buffers_set(nrfx_spis_t const * p_instance,
|
||||
uint8_t const * p_tx_buffer,
|
||||
size_t tx_buffer_length,
|
||||
uint8_t * p_rx_buffer,
|
||||
size_t rx_buffer_length)
|
||||
{
|
||||
NRFX_ASSERT(p_tx_buffer != NULL || tx_buffer_length == 0);
|
||||
NRFX_ASSERT(p_rx_buffer != NULL || rx_buffer_length == 0);
|
||||
|
||||
spis_cb_t * p_cb = &m_cb[p_instance->drv_inst_idx];
|
||||
nrfx_err_t err_code;
|
||||
|
||||
if (!SPIS_LENGTH_VALIDATE(p_instance->drv_inst_idx,
|
||||
rx_buffer_length,
|
||||
tx_buffer_length))
|
||||
{
|
||||
return NRFX_ERROR_INVALID_LENGTH;
|
||||
}
|
||||
|
||||
// EasyDMA requires that transfer buffers are placed in Data RAM region;
|
||||
// signal error if they are not.
|
||||
if ((p_tx_buffer != NULL && !nrfx_is_in_ram(p_tx_buffer)) ||
|
||||
(p_rx_buffer != NULL && !nrfx_is_in_ram(p_rx_buffer)))
|
||||
{
|
||||
err_code = NRFX_ERROR_INVALID_ADDR;
|
||||
NRFX_LOG_WARNING("Function: %s, error code: %s.",
|
||||
__func__,
|
||||
NRFX_LOG_ERROR_STRING_GET(err_code));
|
||||
return err_code;
|
||||
}
|
||||
|
||||
switch (p_cb->spi_state)
|
||||
{
|
||||
case SPIS_STATE_INIT:
|
||||
case SPIS_XFER_COMPLETED:
|
||||
case SPIS_BUFFER_RESOURCE_CONFIGURED:
|
||||
p_cb->tx_buffer = p_tx_buffer;
|
||||
p_cb->rx_buffer = p_rx_buffer;
|
||||
p_cb->tx_buffer_size = tx_buffer_length;
|
||||
p_cb->rx_buffer_size = rx_buffer_length;
|
||||
err_code = NRFX_SUCCESS;
|
||||
|
||||
spis_state_change(p_instance->p_reg, p_cb, SPIS_BUFFER_RESOURCE_REQUESTED);
|
||||
break;
|
||||
|
||||
case SPIS_BUFFER_RESOURCE_REQUESTED:
|
||||
err_code = NRFX_ERROR_INVALID_STATE;
|
||||
break;
|
||||
|
||||
default:
|
||||
// @note: execution of this code path would imply internal error in the design.
|
||||
err_code = NRFX_ERROR_INTERNAL;
|
||||
break;
|
||||
}
|
||||
|
||||
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
|
||||
return err_code;
|
||||
}
|
||||
|
||||
static void spis_irq_handler(NRF_SPIS_Type * p_spis, spis_cb_t * p_cb)
|
||||
{
|
||||
// @note: as multiple events can be pending for processing, the correct event processing order
|
||||
// is as follows:
|
||||
// - SPI semaphore acquired event.
|
||||
// - SPI transaction complete event.
|
||||
|
||||
// Check for SPI semaphore acquired event.
|
||||
if (nrf_spis_event_check(p_spis, NRF_SPIS_EVENT_ACQUIRED))
|
||||
{
|
||||
nrf_spis_event_clear(p_spis, NRF_SPIS_EVENT_ACQUIRED);
|
||||
NRFX_LOG_DEBUG("SPIS: Event: %s.", EVT_TO_STR(NRF_SPIS_EVENT_ACQUIRED));
|
||||
|
||||
switch (p_cb->spi_state)
|
||||
{
|
||||
case SPIS_BUFFER_RESOURCE_REQUESTED:
|
||||
nrf_spis_tx_buffer_set(p_spis, (uint8_t *)p_cb->tx_buffer, p_cb->tx_buffer_size);
|
||||
nrf_spis_rx_buffer_set(p_spis, (uint8_t *)p_cb->rx_buffer, p_cb->rx_buffer_size);
|
||||
|
||||
nrf_spis_task_trigger(p_spis, NRF_SPIS_TASK_RELEASE);
|
||||
|
||||
spis_state_change(p_spis, p_cb, SPIS_BUFFER_RESOURCE_CONFIGURED);
|
||||
break;
|
||||
|
||||
default:
|
||||
// No implementation required.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for SPI transaction complete event.
|
||||
if (nrf_spis_event_check(p_spis, NRF_SPIS_EVENT_END))
|
||||
{
|
||||
nrf_spis_event_clear(p_spis, NRF_SPIS_EVENT_END);
|
||||
NRFX_LOG_DEBUG("SPIS: Event: %s.", EVT_TO_STR(NRF_SPIS_EVENT_END));
|
||||
|
||||
switch (p_cb->spi_state)
|
||||
{
|
||||
case SPIS_BUFFER_RESOURCE_CONFIGURED:
|
||||
spis_state_change(p_spis, p_cb, SPIS_XFER_COMPLETED);
|
||||
break;
|
||||
|
||||
default:
|
||||
// No implementation required.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIS0_ENABLED)
|
||||
void nrfx_spis_0_irq_handler(void)
|
||||
{
|
||||
spis_irq_handler(NRF_SPIS0, &m_cb[NRFX_SPIS0_INST_IDX]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIS1_ENABLED)
|
||||
void nrfx_spis_1_irq_handler(void)
|
||||
{
|
||||
spis_irq_handler(NRF_SPIS1, &m_cb[NRFX_SPIS1_INST_IDX]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIS2_ENABLED)
|
||||
void nrfx_spis_2_irq_handler(void)
|
||||
{
|
||||
spis_irq_handler(NRF_SPIS2, &m_cb[NRFX_SPIS2_INST_IDX]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NRFX_CHECK(NRFX_SPIS3_ENABLED)
|
||||
void nrfx_spis_3_irq_handler(void)
|
||||
{
|
||||
spis_irq_handler(NRF_SPIS3, &m_cb[NRFX_SPIS3_INST_IDX]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_CHECK(NRFX_SPIS_ENABLED)
|
||||
@@ -14,6 +14,17 @@
|
||||
#define NRFX_SPIM1_ENABLED 0 // used as I2C
|
||||
#define NRFX_SPIM2_ENABLED 1
|
||||
|
||||
#define NRFX_SPIS_ENABLED 0
|
||||
#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 7
|
||||
#define NRFX_SPIS_CONFIG_LOG_ENABLED 0
|
||||
#define NRFX_SPIS_CONFIG_LOG_LEVEL 3
|
||||
#define NRFX_SPIS_CONFIG_INFO_COLOR 0
|
||||
#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0
|
||||
|
||||
#define NRFX_SPIS0_ENABLED 0
|
||||
#define NRFX_SPIS1_ENABLED 0
|
||||
#define NRFX_SPIS2_ENABLED 0
|
||||
|
||||
#define NRFX_PWM_ENABLED 0
|
||||
#define NRFX_PWM0_ENABLED 0
|
||||
#define NRFX_PWM1_ENABLED 0
|
||||
|
||||
+25
-6
@@ -74,22 +74,41 @@ uint32_t readResetReason(void)
|
||||
return _reset_reason;
|
||||
}
|
||||
|
||||
static void reset_mcu(uint32_t gpregret)
|
||||
{
|
||||
// disable SD
|
||||
sd_softdevice_disable();
|
||||
|
||||
// Disable all interrupts
|
||||
NVIC->ICER[0]=0xFFFFFFFF;
|
||||
NVIC->ICPR[0]=0xFFFFFFFF;
|
||||
#if defined(__NRF_NVIC_ISER_COUNT) && __NRF_NVIC_ISER_COUNT == 2
|
||||
NVIC->ICER[1]=0xFFFFFFFF;
|
||||
NVIC->ICPR[1]=0xFFFFFFFF;
|
||||
#endif
|
||||
|
||||
NRF_POWER->GPREGRET = gpregret;
|
||||
|
||||
NVIC_SystemReset();
|
||||
|
||||
// maybe yield ?
|
||||
while(1) {}
|
||||
}
|
||||
|
||||
void enterUf2Dfu(void)
|
||||
{
|
||||
NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET;
|
||||
NVIC_SystemReset();
|
||||
reset_mcu(DFU_MAGIC_UF2_RESET);
|
||||
}
|
||||
|
||||
void enterSerialDfu(void)
|
||||
{
|
||||
NRF_POWER->GPREGRET = DFU_MAGIC_SERIAL_ONLY_RESET;
|
||||
NVIC_SystemReset();
|
||||
// shut down everything
|
||||
reset_mcu(DFU_MAGIC_SERIAL_ONLY_RESET);
|
||||
}
|
||||
|
||||
void enterOTADfu(void)
|
||||
{
|
||||
NRF_POWER->GPREGRET = DFU_MAGIC_OTA_RESET;
|
||||
NVIC_SystemReset();
|
||||
reset_mcu(DFU_MAGIC_OTA_RESET);
|
||||
}
|
||||
|
||||
void waitForEvent(void)
|
||||
|
||||
Submodule libraries/Adafruit_TinyUSB_Arduino updated: e58ed11de1...1c5cb1d07c.
Submodule libraries/Adafruit_nRFCrypto updated: 7444c2e947...41059f507f.
@@ -18,21 +18,33 @@
|
||||
*/
|
||||
#include <bluefruit.h>
|
||||
|
||||
// Polling or callback implementation
|
||||
#define POLLING 1
|
||||
/*
|
||||
* Polling or callback implementation
|
||||
* 0 = Request data using a poll
|
||||
* 1 = Use callbacks
|
||||
*/
|
||||
#define POLLING 0
|
||||
/*
|
||||
* Device Type flag for use in the example
|
||||
* Change this if you want to demo the Gamepad!
|
||||
* 0 = Keyboard + Mouse
|
||||
* 1 = Gamepad
|
||||
*/
|
||||
#define DEVICE_TYPE 0
|
||||
|
||||
BLEClientHidAdafruit hid;
|
||||
|
||||
// Last checked report, to detect if there is changes between reports
|
||||
hid_keyboard_report_t last_kbd_report = { 0 };
|
||||
hid_mouse_report_t last_mse_report = { 0 };
|
||||
hid_gamepad_report_t last_gpd_report = { 0 };
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
// while ( !Serial ) delay(10); // for nrf52840 with native usb
|
||||
|
||||
Serial.println("Bluefruit52 Central HID (Keyboard + Mouse) Example");
|
||||
Serial.println("Bluefruit52 Central HID (Keyboard + Mouse + Gamepad) Example");
|
||||
Serial.println("--------------------------------------------------\n");
|
||||
|
||||
// Initialize Bluefruit with maximum connections as Peripheral = 0, Central = 1
|
||||
@@ -46,6 +58,7 @@ void setup()
|
||||
|
||||
#if POLLING == 0
|
||||
hid.setKeyboardReportCallback(keyboard_report_callback);
|
||||
hid.setGamepadReportCallback(gamepad_report_callback);
|
||||
#endif
|
||||
|
||||
// Increase Blink rate to different from PrPh advertising mode
|
||||
@@ -69,7 +82,7 @@ void setup()
|
||||
Bluefruit.Scanner.restartOnDisconnect(true);
|
||||
Bluefruit.Scanner.setInterval(160, 80); // in unit of 0.625 ms
|
||||
Bluefruit.Scanner.filterService(hid); // only report HID service
|
||||
Bluefruit.Scanner.useActiveScan(false);
|
||||
Bluefruit.Scanner.useActiveScan(true);
|
||||
Bluefruit.Scanner.start(0); // 0 = Don't stop scanning after n seconds
|
||||
}
|
||||
|
||||
@@ -137,8 +150,11 @@ void connection_secured_callback(uint16_t conn_handle)
|
||||
Serial.printf("HID Flags : 0x%02X\n", hidInfo[3]);
|
||||
|
||||
// BLEClientHidAdafruit currently only supports Boot Protocol Mode
|
||||
// for Keyboard and Mouse. Let's set the protocol mode on prph to Boot Mode
|
||||
// for Keyboard and Mouse. If we are using a Keyboard + Mouse,
|
||||
// let's set the protocol mode on prph to Boot Mode.
|
||||
#if DEVICE_TYPE == 0
|
||||
hid.setBootMode(true);
|
||||
#endif
|
||||
|
||||
// Enable Keyboard report notification if present on prph
|
||||
if ( hid.keyboardPresent() ) hid.enableKeyboard();
|
||||
@@ -146,6 +162,9 @@ void connection_secured_callback(uint16_t conn_handle)
|
||||
// Enable Mouse report notification if present on prph
|
||||
if ( hid.mousePresent() ) hid.enableMouse();
|
||||
|
||||
// Enable Gamepad report notification if present on prph
|
||||
if ( hid.gamepadPresent() ) hid.enableGamepad();
|
||||
|
||||
Serial.println("Ready to receive from peripheral");
|
||||
}
|
||||
}
|
||||
@@ -169,15 +188,26 @@ void loop()
|
||||
#if POLLING == 1
|
||||
// nothing to do if hid not discovered
|
||||
if ( !hid.discovered() ) return;
|
||||
|
||||
if ( hid.keyboardPresent() ) {
|
||||
/*------------- Polling Keyboard -------------*/
|
||||
hid_keyboard_report_t kbd_report;
|
||||
|
||||
/*------------- Polling Keyboard -------------*/
|
||||
hid_keyboard_report_t kbd_report;
|
||||
|
||||
// Get latest report
|
||||
hid.getKeyboardReport(&kbd_report);
|
||||
|
||||
processKeyboardReport(&kbd_report);
|
||||
// Get latest report
|
||||
Serial.println("Get report from Keyboard");
|
||||
hid.getKeyboardReport(&kbd_report);
|
||||
processKeyboardReport(&kbd_report);
|
||||
}
|
||||
|
||||
if ( hid.gamepadPresent() ) {
|
||||
/*------------- Polling Gamepad -------------*/
|
||||
hid_gamepad_report_t gpd_report;
|
||||
|
||||
// Get latest report
|
||||
Serial.println("Get report from Gamepad");
|
||||
hid.getGamepadReport(&gpd_report);
|
||||
processGamepadReport(&gpd_report);
|
||||
}
|
||||
|
||||
// polling interval is 5 ms
|
||||
delay(5);
|
||||
@@ -186,6 +216,24 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
void gamepad_report_callback(hid_gamepad_report_t* report)
|
||||
{
|
||||
Serial.println("Recieved report from Gamepad");
|
||||
processGamepadReport(report);
|
||||
}
|
||||
|
||||
void processGamepadReport(hid_gamepad_report_t* report)
|
||||
{
|
||||
memcpy(&last_gpd_report, report, sizeof(hid_gamepad_report_t));
|
||||
|
||||
Serial.print("Current Gamepad State: Buttons: ");
|
||||
Serial.print(report->buttons, BIN);
|
||||
Serial.print(" X: ");
|
||||
Serial.print(report->x);
|
||||
Serial.print(" Y: ");
|
||||
Serial.println(report->y);
|
||||
}
|
||||
|
||||
void keyboard_report_callback(hid_keyboard_report_t* report)
|
||||
{
|
||||
processKeyboardReport(report);
|
||||
|
||||
@@ -13,32 +13,34 @@
|
||||
*********************************************************************/
|
||||
#include <bluefruit.h>
|
||||
|
||||
// Beacon uses the Manufacturer Specific Data field in the advertising
|
||||
// packet, which means you must provide a valid Manufacturer ID. Update
|
||||
// Beacon uses the Manufacturer Specific Data field in the advertising packet,
|
||||
// which means you must provide a valid Manufacturer ID. Update
|
||||
// the field below to an appropriate value. For a list of valid IDs see:
|
||||
// https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers
|
||||
// 0x004C is Apple
|
||||
// 0x0822 is Adafruit
|
||||
// 0x0059 is Nordic
|
||||
// - 0x004C is Apple
|
||||
// - 0x0822 is Adafruit
|
||||
// - 0x0059 is Nordic
|
||||
// For testing with this sketch, you can use nRF Beacon app
|
||||
// - on Android you may need change the MANUFACTURER_ID to Nordic
|
||||
// - on iOS you may need to change the MANUFACTURER_ID to Apple.
|
||||
// You will also need to "Add Other Beacon, then enter Major, Minor that you set in the sketch
|
||||
#define MANUFACTURER_ID 0x0059
|
||||
|
||||
// "nRF Connect" app can be used to detect beacon
|
||||
uint8_t beaconUuid[16] =
|
||||
{
|
||||
uint8_t beaconUuid[16] = {
|
||||
0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,
|
||||
0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0
|
||||
};
|
||||
|
||||
// A valid Beacon packet consists of the following information:
|
||||
// UUID, Major, Minor, RSSI @ 1M
|
||||
BLEBeacon beacon(beaconUuid, 0x0102, 0x0304, -54);
|
||||
BLEBeacon beacon(beaconUuid, 1, 2, -54);
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
// Uncomment to blocking wait for Serial connection
|
||||
// while ( !Serial ) delay(10);
|
||||
// while ( !Serial ) delay(10);
|
||||
|
||||
Serial.println("Bluefruit52 Beacon Example");
|
||||
Serial.println("--------------------------\n");
|
||||
@@ -55,7 +57,10 @@ void setup()
|
||||
// Setup the advertising packet
|
||||
startAdv();
|
||||
|
||||
Serial.println("Broadcasting beacon, open your beacon app to test");
|
||||
Serial.printf("Broadcasting beacon with MANUFACTURER_ID = 0x%04X\n", MANUFACTURER_ID);
|
||||
Serial.println("open your beacon app to test such as: nRF Beacon");
|
||||
Serial.println("- on Android you may need to change the MANUFACTURER_ID to 0x0059");
|
||||
Serial.println("- on iOS you may need to change the MANUFACTURER_ID to 0x004C");
|
||||
|
||||
// Suspend Loop() to save power, since we didn't have any code there
|
||||
suspendLoop();
|
||||
@@ -78,17 +83,16 @@ void startAdv(void)
|
||||
* - Start(timeout) with timeout = 0 will advertise forever (until connected)
|
||||
*
|
||||
* Apple Beacon specs
|
||||
* - Type: Non connectable, undirected
|
||||
* - Type: Non-connectable, scannable, undirected
|
||||
* - Fixed interval: 100 ms -> fast = slow = 100 ms
|
||||
*/
|
||||
//Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_ADV_NONCONN_IND);
|
||||
Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED);
|
||||
Bluefruit.Advertising.restartOnDisconnect(true);
|
||||
Bluefruit.Advertising.setInterval(160, 160); // in unit of 0.625 ms
|
||||
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
||||
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
void loop() {
|
||||
// loop is already suspended, CPU will not run loop() at all
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -42,7 +42,7 @@
|
||||
BLEAdvertisingData::BLEAdvertisingData(void)
|
||||
{
|
||||
_count = 0;
|
||||
varclr(_data);
|
||||
arrclr(_data);
|
||||
}
|
||||
|
||||
bool BLEAdvertisingData::addData(uint8_t type, const void* data, uint8_t len)
|
||||
@@ -242,7 +242,7 @@ bool BLEAdvertisingData::setData(uint8_t const * data, uint8_t count)
|
||||
void BLEAdvertisingData::clearData(void)
|
||||
{
|
||||
_count = 0;
|
||||
varclr(_data);
|
||||
arrclr(_data);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
@@ -315,6 +315,10 @@ void BLEAdvertising::setStopCallback(stop_callback_t fp)
|
||||
_stop_cb = fp;
|
||||
}
|
||||
|
||||
void BLEAdvertising::setPeerAddress(const ble_gap_addr_t& peer_addr) {
|
||||
_peer_addr = peer_addr;
|
||||
}
|
||||
|
||||
bool BLEAdvertising::isRunning(void)
|
||||
{
|
||||
return _runnning;
|
||||
@@ -338,8 +342,7 @@ void BLEAdvertising::restartOnDisconnect(bool enable)
|
||||
bool BLEAdvertising::_start(uint16_t interval, uint16_t timeout)
|
||||
{
|
||||
// ADV Params
|
||||
ble_gap_adv_params_t adv_para =
|
||||
{
|
||||
ble_gap_adv_params_t adv_para = {
|
||||
.properties = { .type = _type, .anonymous = 0 },
|
||||
.p_peer_addr = NULL , // Undirected advertisement
|
||||
.interval = interval , // advertising interval (in units of 0.625 ms)
|
||||
@@ -354,9 +357,20 @@ bool BLEAdvertising::_start(uint16_t interval, uint16_t timeout)
|
||||
// , .set_id, .scan_req_notification
|
||||
};
|
||||
|
||||
switch(_type) {
|
||||
case BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE:
|
||||
case BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED:
|
||||
case BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_DIRECTED:
|
||||
case BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_DIRECTED:
|
||||
case BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_DIRECTED:
|
||||
adv_para.p_peer_addr = &_peer_addr;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
// gap_adv long-live is required by SD v6
|
||||
static ble_gap_adv_data_t gap_adv =
|
||||
{
|
||||
static ble_gap_adv_data_t gap_adv = {
|
||||
.adv_data = { .p_data = _data, .len = _count },
|
||||
.scan_rsp_data = { .p_data = Bluefruit.ScanResponse.getData(), .len = Bluefruit.ScanResponse.count() }
|
||||
};
|
||||
@@ -464,5 +478,4 @@ void BLEAdvertising::_eventHandler(ble_evt_t* evt)
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -134,6 +134,9 @@ public:
|
||||
bool setBeacon(BLEBeacon& beacon);
|
||||
bool setBeacon(EddyStoneUrl& eddy_url);
|
||||
|
||||
// Advertise to a single peer instead of broadcasting
|
||||
void setPeerAddress(const ble_gap_addr_t& peer_addr);
|
||||
|
||||
bool isRunning(void);
|
||||
|
||||
void restartOnDisconnect(bool enable);
|
||||
@@ -152,6 +155,7 @@ private:
|
||||
uint8_t _type;
|
||||
bool _start_if_disconnect;
|
||||
bool _runnning;
|
||||
ble_gap_addr_t _peer_addr; //! Target address for an ADV_DIRECT_IND advertisement
|
||||
|
||||
uint32_t _conn_mask;
|
||||
|
||||
|
||||
@@ -240,6 +240,10 @@ void BLEDiscovery::_eventHandler(ble_evt_t* evt)
|
||||
|
||||
LOG_LV2("DISC", "[CHR] Characteristic Count: %d", chr_rsp->count);
|
||||
|
||||
for (uint8_t i=0; i < chr_rsp->count; i++) {
|
||||
LOG_LV2("DISC", "[CHR] Characteristic #%d: 0x%04X", i, chr_rsp->chars[i].uuid.uuid);
|
||||
}
|
||||
|
||||
if (gattc->gatt_status == BLE_GATT_STATUS_SUCCESS)
|
||||
{
|
||||
if ( chr_rsp->count )
|
||||
|
||||
@@ -101,6 +101,18 @@ class BLEDiscovery
|
||||
return discoverCharacteristic(conn_handle, chr_arr, arrcount(chr_arr));
|
||||
}
|
||||
|
||||
uint8_t discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic& chr1, BLEClientCharacteristic& chr2, BLEClientCharacteristic& chr3, BLEClientCharacteristic& chr4, BLEClientCharacteristic& chr5, BLEClientCharacteristic& chr6, BLEClientCharacteristic& chr7)
|
||||
{
|
||||
BLEClientCharacteristic* chr_arr[] = {&chr1, &chr2, &chr3, &chr4, &chr5, &chr6, &chr7};
|
||||
return discoverCharacteristic(conn_handle, chr_arr, arrcount(chr_arr));
|
||||
}
|
||||
|
||||
uint8_t discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic& chr1, BLEClientCharacteristic& chr2, BLEClientCharacteristic& chr3, BLEClientCharacteristic& chr4, BLEClientCharacteristic& chr5, BLEClientCharacteristic& chr6, BLEClientCharacteristic& chr7, BLEClientCharacteristic& chr8)
|
||||
{
|
||||
BLEClientCharacteristic* chr_arr[] = {&chr1, &chr2, &chr3, &chr4, &chr5, &chr6, &chr7, &chr8};
|
||||
return discoverCharacteristic(conn_handle, chr_arr, arrcount(chr_arr));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* INTERNAL USAGE ONLY
|
||||
* Although declare as public, it is meant to be invoked by internal
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include "services/BLEDfu.h"
|
||||
#include "services/BLEUart.h"
|
||||
#include "services/BLEBas.h"
|
||||
#include "services/BLEIas.h"
|
||||
#include "services/BLEBeacon.h"
|
||||
#include "services/BLEHidGeneric.h"
|
||||
#include "services/BLEHidAdafruit.h"
|
||||
@@ -75,6 +76,7 @@
|
||||
#include "clients/BLEClientCts.h"
|
||||
#include "clients/BLEClientHidAdafruit.h"
|
||||
#include "clients/BLEClientBas.h"
|
||||
#include "clients/BLEClientIas.h"
|
||||
|
||||
#include "utility/AdaCallback.h"
|
||||
#include "utility/bonding.h"
|
||||
|
||||
@@ -41,12 +41,15 @@ BLEClientHidAdafruit::BLEClientHidAdafruit(void)
|
||||
_protcol_mode(UUID16_CHR_PROTOCOL_MODE),
|
||||
_hid_info(UUID16_CHR_HID_INFORMATION), _hid_control(UUID16_CHR_HID_CONTROL_POINT),
|
||||
_kbd_boot_input(UUID16_CHR_BOOT_KEYBOARD_INPUT_REPORT), _kbd_boot_output(UUID16_CHR_BOOT_KEYBOARD_OUTPUT_REPORT),
|
||||
_mse_boot_input(UUID16_CHR_BOOT_MOUSE_INPUT_REPORT)
|
||||
_mse_boot_input(UUID16_CHR_BOOT_MOUSE_INPUT_REPORT),
|
||||
_gpd_report(UUID16_CHR_REPORT)
|
||||
{
|
||||
_kbd_cb = NULL;
|
||||
_mse_cb = NULL;
|
||||
_gpd_cb = NULL;
|
||||
varclr(&_last_kbd_report);
|
||||
varclr(&_last_mse_report);
|
||||
varclr(&_last_gpd_report);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +65,12 @@ void mse_client_notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t
|
||||
svc._handle_mse_input(data, len);
|
||||
}
|
||||
|
||||
void gpd_client_notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
BLEClientHidAdafruit& svc = (BLEClientHidAdafruit&) chr->parentService();
|
||||
svc._handle_gpd_input(data, len);
|
||||
}
|
||||
|
||||
|
||||
bool BLEClientHidAdafruit::begin(void)
|
||||
{
|
||||
@@ -77,10 +86,13 @@ bool BLEClientHidAdafruit::begin(void)
|
||||
|
||||
_mse_boot_input.begin(this);
|
||||
|
||||
_gpd_report.begin(this);
|
||||
|
||||
|
||||
// set notify callback
|
||||
_kbd_boot_input.setNotifyCallback(kbd_client_notify_cb);
|
||||
_mse_boot_input.setNotifyCallback(mse_client_notify_cb);
|
||||
_gpd_report.setNotifyCallback(gpd_client_notify_cb);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -95,6 +107,12 @@ void BLEClientHidAdafruit::setMouseReportCallback(mse_callback_t fp)
|
||||
_mse_cb = fp;
|
||||
}
|
||||
|
||||
void BLEClientHidAdafruit::setGamepadReportCallback(gpd_callback_t fp)
|
||||
{
|
||||
_gpd_cb = fp;
|
||||
}
|
||||
|
||||
|
||||
bool BLEClientHidAdafruit::discover(uint16_t conn_handle)
|
||||
{
|
||||
// Call Base class discover
|
||||
@@ -102,10 +120,10 @@ bool BLEClientHidAdafruit::discover(uint16_t conn_handle)
|
||||
_conn_hdl = BLE_CONN_HANDLE_INVALID; // make as invalid until we found all chars
|
||||
|
||||
// Discover all characteristics
|
||||
Bluefruit.Discovery.discoverCharacteristic(conn_handle, _protcol_mode, _kbd_boot_input, _kbd_boot_output, _mse_boot_input, _hid_info, _hid_control);
|
||||
Bluefruit.Discovery.discoverCharacteristic(conn_handle, _protcol_mode, _kbd_boot_input, _kbd_boot_output, _mse_boot_input, _hid_info, _hid_control, _gpd_report);
|
||||
|
||||
VERIFY( _protcol_mode.discovered() && _hid_info.discovered() && _hid_control.discovered() );
|
||||
VERIFY ( keyboardPresent() || mousePresent() );
|
||||
VERIFY( _hid_info.discovered() && _hid_control.discovered() );
|
||||
VERIFY (keyboardPresent() || mousePresent() || gamepadPresent());
|
||||
|
||||
_conn_hdl = conn_handle;
|
||||
return true;
|
||||
@@ -138,7 +156,7 @@ bool BLEClientHidAdafruit::setBootMode(bool boot)
|
||||
*------------------------------------------------------------------*/
|
||||
bool BLEClientHidAdafruit::keyboardPresent(void)
|
||||
{
|
||||
return _kbd_boot_input.discovered() && _kbd_boot_output.discovered();
|
||||
return _kbd_boot_input.discovered() && _kbd_boot_output.discovered() && _protcol_mode.discovered();
|
||||
}
|
||||
|
||||
bool BLEClientHidAdafruit::enableKeyboard(void)
|
||||
@@ -169,7 +187,7 @@ void BLEClientHidAdafruit::getKeyboardReport(hid_keyboard_report_t* report)
|
||||
*------------------------------------------------------------------*/
|
||||
bool BLEClientHidAdafruit::mousePresent(void)
|
||||
{
|
||||
return _mse_boot_input.discovered();
|
||||
return _mse_boot_input.discovered() && _protcol_mode.discovered();
|
||||
}
|
||||
|
||||
bool BLEClientHidAdafruit::enableMouse(void)
|
||||
@@ -195,3 +213,34 @@ void BLEClientHidAdafruit::getMouseReport(hid_mouse_report_t* report)
|
||||
memcpy(report, &_last_mse_report, sizeof(hid_mouse_report_t));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Gamepad
|
||||
*------------------------------------------------------------------*/
|
||||
bool BLEClientHidAdafruit::gamepadPresent(void)
|
||||
{
|
||||
return _gpd_report.discovered();
|
||||
}
|
||||
|
||||
bool BLEClientHidAdafruit::enableGamepad(void)
|
||||
{
|
||||
return _gpd_report.enableNotify();
|
||||
}
|
||||
|
||||
bool BLEClientHidAdafruit::disableGamepad(void)
|
||||
{
|
||||
return _gpd_report.disableNotify();
|
||||
}
|
||||
|
||||
void BLEClientHidAdafruit::_handle_gpd_input(uint8_t* data, uint16_t len)
|
||||
{
|
||||
varclr(&_last_gpd_report);
|
||||
memcpy(&_last_gpd_report, data, len);
|
||||
|
||||
if ( _gpd_cb ) _gpd_cb(&_last_gpd_report);
|
||||
}
|
||||
|
||||
void BLEClientHidAdafruit::getGamepadReport(hid_gamepad_report_t* report)
|
||||
{
|
||||
memcpy(report, &_last_gpd_report, sizeof(hid_gamepad_report_t));
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ class BLEClientHidAdafruit : public BLEClientService
|
||||
// Callback Signatures
|
||||
typedef void (*kbd_callback_t ) (hid_keyboard_report_t* report);
|
||||
typedef void (*mse_callback_t ) (hid_mouse_report_t* report);
|
||||
typedef void (*gpd_callback_t ) (hid_gamepad_report_t* report);
|
||||
|
||||
BLEClientHidAdafruit(void);
|
||||
|
||||
@@ -74,16 +75,26 @@ class BLEClientHidAdafruit : public BLEClientService
|
||||
|
||||
void getMouseReport(hid_mouse_report_t* report);
|
||||
|
||||
// Gamepad API
|
||||
bool gamepadPresent(void);
|
||||
bool enableGamepad(void);
|
||||
bool disableGamepad(void);
|
||||
|
||||
void getGamepadReport(hid_gamepad_report_t* report);
|
||||
|
||||
// Report callback
|
||||
void setKeyboardReportCallback(kbd_callback_t fp);
|
||||
void setMouseReportCallback(mse_callback_t fp);
|
||||
void setGamepadReportCallback(gpd_callback_t fp);
|
||||
|
||||
protected:
|
||||
kbd_callback_t _kbd_cb;
|
||||
mse_callback_t _mse_cb;
|
||||
gpd_callback_t _gpd_cb;
|
||||
|
||||
hid_keyboard_report_t _last_kbd_report;
|
||||
hid_mouse_report_t _last_mse_report;
|
||||
hid_gamepad_report_t _last_gpd_report;
|
||||
|
||||
// Only support Boot protocol for keyboard and Mouse
|
||||
BLEClientCharacteristic _protcol_mode;
|
||||
@@ -95,11 +106,15 @@ class BLEClientHidAdafruit : public BLEClientService
|
||||
|
||||
BLEClientCharacteristic _mse_boot_input;
|
||||
|
||||
BLEClientCharacteristic _gpd_report;
|
||||
|
||||
void _handle_kbd_input(uint8_t* data, uint16_t len);
|
||||
void _handle_mse_input(uint8_t* data, uint16_t len);
|
||||
void _handle_gpd_input(uint8_t* data, uint16_t len);
|
||||
|
||||
friend void kbd_client_notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
friend void mse_client_notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
friend void gpd_client_notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Created by Charlie Bershatsky on 4/19/23.
|
||||
//
|
||||
|
||||
#include "BLEClientIas.h"
|
||||
#include "bluefruit.h"
|
||||
|
||||
BLEClientIas::BLEClientIas() :
|
||||
BLEClientService(UUID16_SVC_IMMEDIATE_ALERT), _alert(UUID16_SVC_IMMEDIATE_ALERT) {
|
||||
|
||||
}
|
||||
|
||||
bool BLEClientIas::begin(void) {
|
||||
// invoke superclass begin()
|
||||
BLEClientService::begin();
|
||||
|
||||
_alert.begin(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLEClientIas::discover(uint16_t conn_handle) {
|
||||
VERIFY(BLEClientService::discover(conn_handle));
|
||||
_conn_hdl = conn_handle;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t BLEClientIas::getAlertLevel() {
|
||||
|
||||
uint8_t level = 0;
|
||||
ble_gattc_handle_range_t bck_range = Bluefruit.Discovery.getHandleRange();
|
||||
|
||||
_alert.begin(this);
|
||||
|
||||
if (Bluefruit.Discovery.discoverCharacteristic(_conn_hdl, _alert)) {
|
||||
level = _alert.read8();
|
||||
}
|
||||
|
||||
Bluefruit.Discovery.setHandleRange(bck_range);
|
||||
|
||||
return level;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by Charlie Bershatsky on 4/19/23.
|
||||
//
|
||||
|
||||
#ifndef ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
|
||||
#define ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
|
||||
|
||||
#include "bluefruit_common.h"
|
||||
#include "BLEClientCharacteristic.h"
|
||||
#include "BLEClientService.h"
|
||||
|
||||
class BLEClientIas : public BLEClientService {
|
||||
|
||||
public:
|
||||
BLEClientIas(void);
|
||||
|
||||
virtual bool begin(void);
|
||||
virtual bool discover(uint16_t conn_handle);
|
||||
|
||||
uint16_t getAlertLevel (void);
|
||||
|
||||
private:
|
||||
BLEClientCharacteristic _alert;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by Charlie Bershatsky on 4/19/23.
|
||||
//
|
||||
|
||||
#include "BLEIas.h"
|
||||
#include "bluefruit.h"
|
||||
#include "utility/utilities.h"
|
||||
#include "BLEService.h"
|
||||
|
||||
BLEIas::BLEIas(void) :
|
||||
BLEService(UUID16_SVC_IMMEDIATE_ALERT), _alert(UUID16_SVC_IMMEDIATE_ALERT) {
|
||||
|
||||
}
|
||||
|
||||
void BLEIas::write(uint8_t alert_level) {
|
||||
_alert.write8(alert_level);
|
||||
}
|
||||
|
||||
err_t BLEIas::begin(void) {
|
||||
|
||||
// Invoke the superclass begin()
|
||||
VERIFY_STATUS(BLEService::begin());
|
||||
|
||||
_alert.setProperties(CHR_PROPS_READ);
|
||||
_alert.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS);
|
||||
_alert.setFixedLen(1);
|
||||
|
||||
VERIFY_STATUS( _alert.begin() );
|
||||
|
||||
return ERROR_NONE;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Created by Charlie Bershatsky on 4/19/23.
|
||||
//
|
||||
|
||||
#ifndef ADAFRUIT_NRF52_ARDUINO_BLEIAS_H
|
||||
#define ADAFRUIT_NRF52_ARDUINO_BLEIAS_H
|
||||
|
||||
#include "bluefruit_common.h"
|
||||
|
||||
#include "BLEService.h"
|
||||
#include "BLECharacteristic.h"
|
||||
|
||||
|
||||
class BLEIas : public BLEService {
|
||||
|
||||
protected:
|
||||
BLECharacteristic _alert;
|
||||
|
||||
public:
|
||||
BLEIas(void);
|
||||
|
||||
void write(uint8_t level);
|
||||
|
||||
virtual err_t begin(void);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //ADAFRUIT_NRF52_ARDUINO_BLEIAS_H
|
||||
@@ -41,7 +41,10 @@
|
||||
#include "bonding.h"
|
||||
#include "bluefruit.h"
|
||||
|
||||
using namespace Adafruit_LittleFS_Namespace;
|
||||
enum {
|
||||
FO_READ = Adafruit_LittleFS_Namespace::FILE_O_READ,
|
||||
FO_WRITE = Adafruit_LittleFS_Namespace::FILE_O_WRITE,
|
||||
};
|
||||
|
||||
#define BOND_DEBUG 1
|
||||
|
||||
@@ -68,7 +71,7 @@ static void get_fname (char* fname, uint8_t role, uint8_t const mac[6])
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
}
|
||||
|
||||
static bool bdata_skip_field(File* file)
|
||||
static bool bdata_skip_field(Adafruit_LittleFS_Namespace::File* file)
|
||||
{
|
||||
int len = file->read();
|
||||
VERIFY(len > 0);
|
||||
@@ -77,7 +80,7 @@ static bool bdata_skip_field(File* file)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void bdata_write(File* file, void const* buffer, uint16_t bufsize)
|
||||
static void bdata_write(Adafruit_LittleFS_Namespace::File* file, void const* buffer, uint16_t bufsize)
|
||||
{
|
||||
file->write( (uint8_t) bufsize );
|
||||
file->write( (uint8_t const*) buffer, bufsize);
|
||||
@@ -106,7 +109,7 @@ static void bond_save_keys_dfr (uint8_t role, uint16_t conn_hdl, bond_keys_t con
|
||||
// delete if file already exists
|
||||
if ( InternalFS.exists(filename) ) InternalFS.remove(filename);
|
||||
|
||||
File file(filename, FILE_O_WRITE, InternalFS);
|
||||
Adafruit_LittleFS_Namespace::File file(filename, FO_WRITE, InternalFS);
|
||||
VERIFY(file,);
|
||||
|
||||
//------------- save keys -------------//
|
||||
@@ -150,8 +153,8 @@ bool bond_load_keys(uint8_t role, ble_gap_addr_t* addr, bond_keys_t* bkeys)
|
||||
char filename[BOND_FNAME_LEN];
|
||||
get_fname(filename, role, addr->addr);
|
||||
|
||||
File file(InternalFS);
|
||||
if( file.open(filename, FILE_O_READ) )
|
||||
Adafruit_LittleFS_Namespace::File file(InternalFS);
|
||||
if( file.open(filename, FO_READ) )
|
||||
{
|
||||
int keylen = file.read();
|
||||
if ( keylen > 0 )
|
||||
@@ -172,10 +175,10 @@ bool bond_load_keys(uint8_t role, ble_gap_addr_t* addr, bond_keys_t* bkeys)
|
||||
// Resolvable address, we have to go through the whole list to perform IRK Address matching
|
||||
|
||||
char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);
|
||||
File dir(dpath, FILE_O_READ, InternalFS);
|
||||
File file(InternalFS);
|
||||
Adafruit_LittleFS_Namespace::File dir(dpath, FO_READ, InternalFS);
|
||||
Adafruit_LittleFS_Namespace::File file(InternalFS);
|
||||
|
||||
while ( !ret && (file = dir.openNextFile(FILE_O_READ)) )
|
||||
while ( !ret && (file = dir.openNextFile(FO_READ)) )
|
||||
{
|
||||
int keylen = file.read();
|
||||
if ( keylen == sizeof(bond_keys_t) )
|
||||
@@ -217,7 +220,7 @@ static void bond_save_cccd_dfr (uint8_t role, uint16_t conn_hdl, ble_gap_addr_t
|
||||
char filename[BOND_FNAME_LEN];
|
||||
get_fname(filename, role, id_addr->addr);
|
||||
|
||||
File file(filename, FILE_O_WRITE, InternalFS);
|
||||
Adafruit_LittleFS_Namespace::File file(filename, FO_WRITE, InternalFS);
|
||||
VERIFY(file,);
|
||||
|
||||
file.seek(0); // write mode start at the end, seek to beginning
|
||||
@@ -266,7 +269,7 @@ bool bond_load_cccd(uint8_t role, uint16_t conn_hdl, ble_gap_addr_t const* id_ad
|
||||
char filename[BOND_FNAME_LEN];
|
||||
get_fname(filename, role, id_addr->addr);
|
||||
|
||||
File file(filename, FILE_O_READ, InternalFS);
|
||||
Adafruit_LittleFS_Namespace::File file(filename, FO_READ, InternalFS);
|
||||
if ( file )
|
||||
{
|
||||
bdata_skip_field(&file); // skip key
|
||||
@@ -298,10 +301,10 @@ void bond_print_list(uint8_t role)
|
||||
{
|
||||
char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);
|
||||
|
||||
File dir(dpath, FILE_O_READ, InternalFS);
|
||||
File file(InternalFS);
|
||||
Adafruit_LittleFS_Namespace::File dir(dpath, FO_READ, InternalFS);
|
||||
Adafruit_LittleFS_Namespace::File file(InternalFS);
|
||||
|
||||
while ( (file = dir.openNextFile(FILE_O_READ)) )
|
||||
while ( (file = dir.openNextFile(FO_READ)) )
|
||||
{
|
||||
if ( !file.isDirectory() && bdata_skip_field(&file) ) // skip key
|
||||
{
|
||||
|
||||
@@ -120,14 +120,14 @@ void SwRotaryEncoder::clearAbs(void)
|
||||
|
||||
void SwRotaryEncoder::_irq_handler(void)
|
||||
{
|
||||
uint32_t val = NRF_GPIO->IN;
|
||||
uint8_t bita = bitRead(val, _pina);
|
||||
uint8_t bita = digitalRead(_pina);
|
||||
uint8_t bitb = digitalRead(_pinb);
|
||||
|
||||
if ( bita != _a_last)
|
||||
{
|
||||
int32_t step;
|
||||
|
||||
if ( bita != bitRead(val, _pinb) )
|
||||
if ( bita != bitb )
|
||||
{
|
||||
step = 1;
|
||||
}else
|
||||
|
||||
+29
-6
@@ -17,7 +17,7 @@
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
name=Adafruit nRF52 Boards
|
||||
version=1.3.0
|
||||
version=1.5.0
|
||||
|
||||
# Compile variables
|
||||
# -----------------
|
||||
@@ -128,11 +128,11 @@ recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).*
|
||||
recipe.output.tmp_file={build.project_name}.hex
|
||||
recipe.output.save_file={build.project_name}.{build.variant}.hex
|
||||
|
||||
#***************************************************
|
||||
# ------------------------------------------------
|
||||
# adafruit-nrfutil for uploading
|
||||
# https://github.com/adafruit/Adafruit_nRF52_nrfutil
|
||||
# pre-built binaries are provided for macos and windows
|
||||
#***************************************************
|
||||
# ------------------------------------------------
|
||||
tools.nrfutil.cmd=adafruit-nrfutil
|
||||
tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe
|
||||
tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil
|
||||
@@ -141,12 +141,12 @@ tools.nrfutil.upload.params.verbose=--verbose
|
||||
tools.nrfutil.upload.params.quiet=
|
||||
tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank
|
||||
|
||||
#***************************************************
|
||||
# ---------------------------------------------------
|
||||
# Burning bootloader with either jlink or nrfutil
|
||||
#***************************************************
|
||||
# ---------------------------------------------------
|
||||
|
||||
# Bootloader version
|
||||
tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.6.2_{build.sd_name}_{build.sd_version}
|
||||
tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.8.0_{build.sd_name}_{build.sd_version}
|
||||
|
||||
tools.bootburn.bootloader.params.verbose=
|
||||
tools.bootburn.bootloader.params.quiet=
|
||||
@@ -157,3 +157,26 @@ tools.bootburn.erase.params.verbose=
|
||||
tools.bootburn.erase.params.quiet=
|
||||
tools.bootburn.erase.pattern=
|
||||
|
||||
# ----------------------------------------
|
||||
# Debugger configuration (general options)
|
||||
# ----------------------------------------
|
||||
# EXPERIMENTAL feature:
|
||||
# - this is alpha and may be subject to change without notice
|
||||
debug.executable={build.path}/{build.project_name}.elf
|
||||
debug.toolchain=gcc
|
||||
debug.toolchain.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
|
||||
debug.toolchain.prefix=arm-none-eabi-
|
||||
|
||||
debug.server=openocd
|
||||
debug.server.openocd.path={runtime.tools.openocd-0.11.0-arduino2.path}/bin/openocd
|
||||
debug.server.openocd.scripts_dir={runtime.tools.openocd-0.11.0-arduino2.path}/share/openocd/scripts/
|
||||
debug.server.openocd.script={runtime.platform.path}/{build.openocdscript}
|
||||
|
||||
# JLinkServer is not supported by arduino-cli yet
|
||||
# https://github.com/arduino/arduino-cli/blob/eca9d9a8f00582a08fadea8a4b7e3ef01b40d082/commands/debug/debug.go#L160
|
||||
# use debug_custom.json to run JLinkGDBServer instead
|
||||
# https://docs.arduino.cc/tutorials/mkr-wifi-1010/mkr-jlink-setup
|
||||
#debug.server=jlink
|
||||
#debug.server.jlink.path=JLinkGDBServer
|
||||
#debug.server.jlink.device=nrf52840_xxaa
|
||||
#debug.server.jlink.script={runtime.platform.path}/{build.openocdscript}
|
||||
+1
-1
@@ -27,7 +27,7 @@ nrfutil_boot.program.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/
|
||||
nrfutil_boot.program.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil
|
||||
|
||||
# Burn bootloader pattern
|
||||
nrfutil_boot.program.burn_pattern={program.cmd} --verbose dfu serial -pkg "{bootloader.file}.zip" -p {serial.port} -b 115200 --touch 1200
|
||||
nrfutil_boot.program.burn_pattern="{program.cmd}" --verbose dfu serial -pkg "{bootloader.file}.zip" -p {serial.port} -b 115200 --touch 1200
|
||||
|
||||
# Remind user to select Jlink when used to upload sketch
|
||||
nrfutil_boot.program.params.quiet=
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"servertype": "jlink",
|
||||
"device": "nrf52840_xxaa",
|
||||
"interface": "SWD",
|
||||
"serverpath": "JLinkGDBServer"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
source [find interface/cmsis-dap.cfg]
|
||||
transport select swd
|
||||
source [find target/nrf52.cfg]
|
||||
@@ -0,0 +1,3 @@
|
||||
source [find interface/jlink.cfg]
|
||||
transport select swd
|
||||
source [find target/nrf52.cfg]
|
||||
+88
-64
@@ -2,98 +2,122 @@ import os
|
||||
import glob
|
||||
import sys
|
||||
import subprocess
|
||||
from subprocess import Popen, PIPE
|
||||
import time
|
||||
from multiprocessing import Pool
|
||||
|
||||
SUCCEEDED = "\033[32msucceeded\033[0m"
|
||||
FAILED = "\033[31mfailed\033[0m"
|
||||
SKIPPED = "\033[35mskipped\033[0m"
|
||||
WARNING = "\033[33mwarnings\033[0m "
|
||||
|
||||
exit_status = 0
|
||||
success_count = 0
|
||||
fail_count = 0
|
||||
skip_count = 0
|
||||
|
||||
build_format = '| {:25} | {:35} | {:18} | {:6} |'
|
||||
build_separator = '-' * 88
|
||||
|
||||
default_boards = [ 'cluenrf52840', 'cplaynrf52840', 'feather52832', 'feather52840', 'feather52840sense', 'itsybitsy52840' ]
|
||||
default_boards = [
|
||||
'cluenrf52840',
|
||||
'cplaynrf52840',
|
||||
'feather52832',
|
||||
'feather52840',
|
||||
'feather52840sense',
|
||||
'itsybitsy52840'
|
||||
]
|
||||
build_boards = []
|
||||
|
||||
# build all variants if input not existed
|
||||
if len(sys.argv) > 1:
|
||||
build_boards.append(sys.argv[1])
|
||||
else:
|
||||
build_boards = default_boards
|
||||
|
||||
all_examples = list(glob.iglob('libraries/**/*.ino', recursive=True))
|
||||
all_examples.sort()
|
||||
def build_a_example(arg):
|
||||
variant = arg[0]
|
||||
sketch = arg[1]
|
||||
|
||||
def build_examples(variant):
|
||||
global exit_status, success_count, fail_count, skip_count, build_format, build_separator
|
||||
fqbn = "adafruit:nrf52:{}:softdevice={},debug=l0".format(variant,
|
||||
's140v6' if variant != 'feather52832' else 's132v6')
|
||||
# succeeded, failed, skipped
|
||||
ret = [0, 0, 0]
|
||||
|
||||
start_time = time.monotonic()
|
||||
|
||||
# Skip if contains: ".board.test.skip" or ".all.test.skip"
|
||||
# Skip if not contains: ".board.test.only" for a specific board
|
||||
sketchdir = os.path.dirname(sketch)
|
||||
if os.path.exists(sketchdir + '/.all.test.skip') or os.path.exists(sketchdir + '/.' + variant + '.test.skip'):
|
||||
success = SKIPPED
|
||||
ret[2] = 1
|
||||
elif glob.glob(sketchdir + "/.*.test.only") and not os.path.exists(sketchdir + '/.' + variant + '.test.only'):
|
||||
success = SKIPPED
|
||||
ret[2] = 1
|
||||
else:
|
||||
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
# get stderr into a form where warning/error was output to stderr
|
||||
if build_result.returncode != 0:
|
||||
ret[1] = 1
|
||||
success = FAILED
|
||||
else:
|
||||
ret[0] = 1
|
||||
if build_result.stderr:
|
||||
success = WARNING
|
||||
else:
|
||||
success = SUCCEEDED
|
||||
|
||||
build_duration = time.monotonic() - start_time
|
||||
print(build_format.format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success,
|
||||
'{:5.2f}s'.format(build_duration)))
|
||||
|
||||
if success != SKIPPED:
|
||||
# Build failed
|
||||
if build_result.returncode != 0:
|
||||
print(build_result.stdout.decode("utf-8"))
|
||||
|
||||
# Build with warnings
|
||||
if build_result.stderr:
|
||||
print(f"::group::warning-message")
|
||||
print(build_result.stderr.decode("utf-8"))
|
||||
print(f"::endgroup::")
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def build_all_examples(variant):
|
||||
print('\n')
|
||||
print(build_separator)
|
||||
print('| {:^84} |'.format('Board ' + variant))
|
||||
print(build_separator)
|
||||
print(build_format.format('Library', 'Example', '\033[39mResult\033[0m', 'Time'))
|
||||
print(build_separator)
|
||||
|
||||
fqbn = "adafruit:nrf52:{}:softdevice={},debug=l0".format(variant, 's140v6' if variant != 'feather52832' else 's132v6')
|
||||
|
||||
for sketch in all_examples:
|
||||
# skip TinyUSB library examples for nRF52832
|
||||
if variant == 'feather52832' and "libraries/Adafruit_TinyUSB_Arduino" in sketch:
|
||||
continue
|
||||
args = [[variant, s] for s in all_examples]
|
||||
with Pool() as pool:
|
||||
result = pool.map(build_a_example, args)
|
||||
# sum all element of same index (column sum)
|
||||
return list(map(sum, list(zip(*result))))
|
||||
|
||||
start_time = time.monotonic()
|
||||
|
||||
# Skip if contains: ".board.test.skip" or ".all.test.skip"
|
||||
# Skip if not contains: ".board.test.only" for a specific board
|
||||
sketchdir = os.path.dirname(sketch)
|
||||
if os.path.exists(sketchdir + '/.all.test.skip') or os.path.exists(sketchdir + '/.' + variant + '.test.skip'):
|
||||
success = SKIPPED
|
||||
skip_count += 1
|
||||
elif glob.glob(sketchdir+"/.*.test.only") and not os.path.exists(sketchdir + '/.' + variant + '.test.only'):
|
||||
success = SKIPPED
|
||||
skip_count += 1
|
||||
else:
|
||||
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=PIPE, stderr=PIPE)
|
||||
if __name__ == "__main__":
|
||||
# build all variants if input not existed
|
||||
if len(sys.argv) > 1:
|
||||
build_boards.append(sys.argv[1])
|
||||
else:
|
||||
build_boards = default_boards
|
||||
|
||||
# get stderr into a form where warning/error was output to stderr
|
||||
if build_result.returncode != 0:
|
||||
exit_status = build_result.returncode
|
||||
success = FAILED
|
||||
fail_count += 1
|
||||
else:
|
||||
success_count += 1
|
||||
if build_result.stderr:
|
||||
success = WARNING
|
||||
else:
|
||||
success = SUCCEEDED
|
||||
# All examples in libraries except TinyUSB which has its own ci to build
|
||||
all_examples = list(glob.iglob('libraries/**/*.ino', recursive=True))
|
||||
all_examples = [i for i in all_examples if "Adafruit_TinyUSB_Arduino" not in i]
|
||||
all_examples.sort()
|
||||
|
||||
build_duration = time.monotonic() - start_time
|
||||
build_time = time.monotonic()
|
||||
|
||||
print(build_format.format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, '{:5.2f}s'.format(build_duration)))
|
||||
# succeeded, failed, skipped
|
||||
total_result = [0, 0, 0]
|
||||
|
||||
if success != SKIPPED:
|
||||
# Build failed
|
||||
if build_result.returncode != 0:
|
||||
print(build_result.stdout.decode("utf-8"))
|
||||
|
||||
# Build with warnings
|
||||
if build_result.stderr:
|
||||
print(build_result.stderr.decode("utf-8"))
|
||||
for board in build_boards:
|
||||
fret = build_all_examples(board)
|
||||
if len(fret) == len(total_result):
|
||||
total_result = [total_result[i] + fret[i] for i in range(len(fret))]
|
||||
|
||||
build_time = time.monotonic()
|
||||
build_time = time.monotonic() - build_time
|
||||
|
||||
for board in build_boards:
|
||||
build_examples(board)
|
||||
print(build_separator)
|
||||
print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(total_result[0], SUCCEEDED, total_result[1], FAILED, total_result[2], SKIPPED, build_time))
|
||||
print(build_separator)
|
||||
|
||||
print(build_separator)
|
||||
build_time = time.monotonic() - build_time
|
||||
print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(success_count, SUCCEEDED, fail_count, FAILED, skip_count, SKIPPED, build_time))
|
||||
print(build_separator)
|
||||
|
||||
sys.exit(exit_status)
|
||||
sys.exit(total_result[1])
|
||||
+99
-77
@@ -26,18 +26,18 @@ def get_mcu(name):
|
||||
def build_upload(name):
|
||||
mcu = get_mcu(name)
|
||||
print("# Upload")
|
||||
print("%s.bootloader.tool=bootburn" % name)
|
||||
print("%s.upload.tool=nrfutil" % name)
|
||||
print("%s.upload.protocol=nrfutil" % name)
|
||||
print(f"{name}.bootloader.tool=bootburn")
|
||||
print(f"{name}.upload.tool=nrfutil")
|
||||
print(f"{name}.upload.protocol=nrfutil")
|
||||
if mcu == 52832:
|
||||
print("%s.upload.use_1200bps_touch=false" % name)
|
||||
print("%s.upload.wait_for_upload_port=false" % name)
|
||||
print("%s.upload.native_usb=false" % name)
|
||||
print(f"{name}.upload.use_1200bps_touch=false")
|
||||
print(f"{name}.upload.wait_for_upload_port=false")
|
||||
print(f"{name}.upload.native_usb=false")
|
||||
else:
|
||||
print("%s.upload.use_1200bps_touch=true" % name)
|
||||
print("%s.upload.wait_for_upload_port=true" % name)
|
||||
print("%s.upload.maximum_size=%d" % (name, mcu_dict[mcu]['flash_size']))
|
||||
print("%s.upload.maximum_data_size=%d" % (name, mcu_dict[mcu]['data_size']))
|
||||
print(f"{name}.upload.use_1200bps_touch=true")
|
||||
print(f"{name}.upload.wait_for_upload_port=true")
|
||||
print(f"{name}.upload.maximum_size={mcu_dict[mcu]['flash_size']}")
|
||||
print(f"{name}.upload.maximum_data_size={mcu_dict[mcu]['data_size']}")
|
||||
print()
|
||||
|
||||
|
||||
@@ -45,78 +45,79 @@ def build_header(name, variant, vendor_name, product_name, boarddefine, vid, pid
|
||||
prettyname = vendor_name + " " + product_name
|
||||
print()
|
||||
print("# -----------------------------------")
|
||||
print("# %s" % prettyname)
|
||||
print(f"# {prettyname}")
|
||||
print("# -----------------------------------")
|
||||
print("%s.name=%s" % (name, prettyname))
|
||||
print(f"{name}.name={prettyname}")
|
||||
print()
|
||||
|
||||
print("# VID/PID for Bootloader, Arduino & CircuitPython")
|
||||
for i in range(len(pid_list)):
|
||||
print("%s.vid.%d=%s" % (name, i, vid))
|
||||
print("%s.pid.%d=%s" % (name, i, pid_list[i]))
|
||||
print(f"{name}.vid.{i}={vid}")
|
||||
print(f"{name}.pid.{i}={pid_list[i]}")
|
||||
print()
|
||||
|
||||
build_upload(name)
|
||||
|
||||
print("# Build")
|
||||
print("%s.build.mcu=cortex-m4" % name)
|
||||
print("%s.build.f_cpu=64000000" % name)
|
||||
print("%s.build.board=%s" % (name, boarddefine))
|
||||
print("%s.build.core=nRF5" % name)
|
||||
print("%s.build.variant=%s" % (name, variant))
|
||||
print('%s.build.usb_manufacturer="%s"' % (name, vendor_name))
|
||||
print('%s.build.usb_product="%s"' % (name, product_name))
|
||||
print(f"{name}.build.mcu=cortex-m4")
|
||||
print(f"{name}.build.f_cpu=64000000")
|
||||
print(f"{name}.build.board={boarddefine}")
|
||||
print(f"{name}.build.core=nRF5")
|
||||
print(f"{name}.build.variant={variant}")
|
||||
print(f'{name}.build.usb_manufacturer="{vendor_name}"')
|
||||
print(f'{name}.build.usb_product="{product_name}"')
|
||||
|
||||
mcu = get_mcu(name)
|
||||
print("%s.build.extra_flags=%s" % (name, mcu_dict[mcu]['extra_flags']))
|
||||
print("%s.build.ldscript=%s" % (name, mcu_dict[mcu]['ldscript']))
|
||||
print(f"{name}.build.extra_flags={mcu_dict[mcu]['extra_flags']}")
|
||||
print(f"{name}.build.ldscript={mcu_dict[mcu]['ldscript']}")
|
||||
print(f"{name}.build.openocdscript=scripts/openocd/daplink_nrf52.cfg")
|
||||
if mcu != 52832:
|
||||
print("%s.build.vid=%s" % (name, vid))
|
||||
print("%s.build.pid=%s" % (name, pid_list[0]))
|
||||
print(f"{name}.build.vid={vid}")
|
||||
print(f"{name}.build.pid={pid_list[0]}")
|
||||
print()
|
||||
|
||||
|
||||
def build_softdevice(name):
|
||||
print("# SoftDevice Menu")
|
||||
print("# Menu: SoftDevice")
|
||||
if get_mcu(name) == 52832:
|
||||
print("%s.menu.softdevice.s132v6=S132 6.1.1" % name)
|
||||
print("%s.menu.softdevice.s132v6.build.sd_name=s132" % name)
|
||||
print("%s.menu.softdevice.s132v6.build.sd_version=6.1.1" % name)
|
||||
print("%s.menu.softdevice.s132v6.build.sd_fwid=0x00B7" % name)
|
||||
print(f"{name}.menu.softdevice.s132v6=S132 6.1.1")
|
||||
print(f"{name}.menu.softdevice.s132v6.build.sd_name=s132")
|
||||
print(f"{name}.menu.softdevice.s132v6.build.sd_version=6.1.1")
|
||||
print(f"{name}.menu.softdevice.s132v6.build.sd_fwid=0x00B7")
|
||||
else:
|
||||
print("%s.menu.softdevice.s140v6=S140 6.1.1" % name)
|
||||
print("%s.menu.softdevice.s140v6.build.sd_name=s140" % name)
|
||||
print("%s.menu.softdevice.s140v6.build.sd_version=6.1.1" % name)
|
||||
print("%s.menu.softdevice.s140v6.build.sd_fwid=0x00B6" % name)
|
||||
print(f"{name}.menu.softdevice.s140v6=S140 6.1.1")
|
||||
print(f"{name}.menu.softdevice.s140v6.build.sd_name=s140")
|
||||
print(f"{name}.menu.softdevice.s140v6.build.sd_version=6.1.1")
|
||||
print(f"{name}.menu.softdevice.s140v6.build.sd_fwid=0x00B6")
|
||||
print()
|
||||
|
||||
|
||||
def build_debug(name):
|
||||
print("# Debug Menu")
|
||||
print("%s.menu.debug.l0=Level 0 (Release)" % name)
|
||||
print("%s.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0" % name)
|
||||
print("%s.menu.debug.l1=Level 1 (Error Message)" % name)
|
||||
print("%s.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1" % name)
|
||||
print("%s.menu.debug.l2=Level 2 (Full Debug)" % name)
|
||||
print("%s.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2" % name)
|
||||
print("%s.menu.debug.l3=Level 3 (Segger SystemView)" % name)
|
||||
print("%s.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3" % name)
|
||||
print("%s.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1" % name)
|
||||
print("# Menu: Debug Level")
|
||||
print(f"{name}.menu.debug.l0=Level 0 (Release)")
|
||||
print(f"{name}.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0")
|
||||
print(f"{name}.menu.debug.l1=Level 1 (Error Message)")
|
||||
print(f"{name}.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1")
|
||||
print(f"{name}.menu.debug.l2=Level 2 (Full Debug)")
|
||||
print(f"{name}.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2")
|
||||
print(f"{name}.menu.debug.l3=Level 3 (Segger SystemView)")
|
||||
print(f"{name}.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3")
|
||||
print(f"{name}.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1")
|
||||
print()
|
||||
|
||||
def build_debug_output(name):
|
||||
print("# Debug Output Menu")
|
||||
print("%s.menu.debug_output.serial=Serial" % name)
|
||||
print("%s.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0" % name)
|
||||
print("%s.menu.debug_output.serial1=Serial1" % name)
|
||||
print("%s.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG" % name)
|
||||
print("%s.menu.debug_output.rtt=Segger RTT" % name)
|
||||
print("%s.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL" % name)
|
||||
print("# Menu: Debug Port")
|
||||
print(f"{name}.menu.debug_output.serial=Serial")
|
||||
print(f"{name}.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0")
|
||||
print(f"{name}.menu.debug_output.serial1=Serial1")
|
||||
print(f"{name}.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG")
|
||||
print(f"{name}.menu.debug_output.rtt=Segger RTT")
|
||||
print(f"{name}.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL")
|
||||
|
||||
def build_global_menu():
|
||||
print("menu.softdevice=SoftDevice")
|
||||
print("menu.debug=Debug")
|
||||
print("menu.debug_output=Debug Output")
|
||||
print("menu.debug=Debug Level")
|
||||
print("menu.debug_output=Debug Port")
|
||||
|
||||
def make_board(name, variant, vendor_name, product_name, boarddefine, vid, pid_list):
|
||||
build_header(name, variant, vendor_name, product_name, boarddefine, vid, pid_list)
|
||||
@@ -125,44 +126,65 @@ def make_board(name, variant, vendor_name, product_name, boarddefine, vid, pid_l
|
||||
build_debug_output(name)
|
||||
|
||||
|
||||
# ------------------------------
|
||||
# main
|
||||
# ------------------------------
|
||||
build_global_menu()
|
||||
|
||||
make_board("feather52832", "feather_nrf52832", "Adafruit", "Feather nRF52832", "NRF52832_FEATHER",
|
||||
"0x239A", [])
|
||||
make_board("feather52840", "feather_nrf52840_express", "Adafruit", "Feather nRF52840 Express", "NRF52840_FEATHER",
|
||||
"0x239A", ["0x8029", "0x0029", "0x002A", "0x802A"])
|
||||
# ------------------------------
|
||||
# Adafruit Boards
|
||||
# ------------------------------
|
||||
|
||||
make_board("feather52840sense", "feather_nrf52840_sense", "Adafruit", "Feather nRF52840 Sense", "NRF52840_FEATHER_SENSE",
|
||||
"0x239A", ["0x8087", "0x0087", "0x0088", "0x8088"])
|
||||
adafruit_boards_list = [
|
||||
["feather52832", "feather_nrf52832", "Adafruit", "Feather nRF52832", "NRF52832_FEATHER",
|
||||
"0x239A", []],
|
||||
|
||||
make_board("itsybitsy52840", "itsybitsy_nrf52840_express", "Adafruit", "ItsyBitsy nRF52840 Express", "NRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY",
|
||||
"0x239A", ["0x8051", "0x0051", "0x0052", "0x8052"])
|
||||
["feather52840", "feather_nrf52840_express", "Adafruit", "Feather nRF52840 Express", "NRF52840_FEATHER",
|
||||
"0x239A", ["0x8029", "0x0029", "0x002A", "0x802A"]],
|
||||
|
||||
make_board("cplaynrf52840", "circuitplayground_nrf52840", "Adafruit", "Circuit Playground Bluefruit", "NRF52840_CIRCUITPLAY",
|
||||
"0x239A", ["0x8045", "0x0045", "0x8046"])
|
||||
["feather52840sense", "feather_nrf52840_sense", "Adafruit", "Feather nRF52840 Sense", "NRF52840_FEATHER_SENSE",
|
||||
"0x239A", ["0x8087", "0x0087", "0x0088", "0x8088"]],
|
||||
|
||||
make_board("cluenrf52840", "clue_nrf52840", "Adafruit", "CLUE", "NRF52840_CLUE",
|
||||
"0x239A", ["0x8071", "0x0071", "0x8072"])
|
||||
["itsybitsy52840", "itsybitsy_nrf52840_express", "Adafruit", "ItsyBitsy nRF52840 Express", "NRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY",
|
||||
"0x239A", ["0x8051", "0x0051", "0x0052", "0x8052"]],
|
||||
|
||||
make_board("ledglasses_nrf52840", "ledglasses_nrf52840", "Adafruit", "LED Glasses Driver nRF52840", "NRF52840_LED_GLASSES",
|
||||
"0x239A", ["0x810D", "0x010D", "0x810E"])
|
||||
["cplaynrf52840", "circuitplayground_nrf52840", "Adafruit", "Circuit Playground Bluefruit", "NRF52840_CIRCUITPLAY",
|
||||
"0x239A", ["0x8045", "0x0045", "0x8046"]],
|
||||
|
||||
make_board("mdbt50qrx", "raytac_mdbt50q_rx", "Raytac", "nRF52840 Dongle", "MDBT50Q_RX",
|
||||
"0x239A", ["0x810B", "0x010B", "0x810C"])
|
||||
["cluenrf52840", "clue_nrf52840", "Adafruit", "CLUE", "NRF52840_CLUE",
|
||||
"0x239A", ["0x8071", "0x0071", "0x8072"]],
|
||||
|
||||
make_board("metro52840", "metro_nrf52840_express", "Adafruit", "Metro nRF52840 Express", "NRF52840_METRO",
|
||||
"0x239A", ["0x803F", "0x003F", "0x0040", "0x8040"])
|
||||
["ledglasses_nrf52840", "ledglasses_nrf52840", "Adafruit", "LED Glasses Driver nRF52840", "NRF52840_LED_GLASSES",
|
||||
"0x239A", ["0x810D", "0x010D", "0x810E"]],
|
||||
|
||||
["mdbt50qrx", "raytac_mdbt50q_rx", "Raytac", "nRF52840 Dongle", "MDBT50Q_RX",
|
||||
"0x239A", ["0x810B", "0x010B", "0x810C"]],
|
||||
|
||||
["metro52840", "metro_nrf52840_express", "Adafruit", "Metro nRF52840 Express", "NRF52840_METRO",
|
||||
"0x239A", ["0x803F", "0x003F", "0x0040", "0x8040"]],
|
||||
]
|
||||
|
||||
for b in adafruit_boards_list:
|
||||
make_board(*b)
|
||||
|
||||
# ------------------------------
|
||||
# 3rd Party Boards
|
||||
# ------------------------------
|
||||
|
||||
print()
|
||||
print()
|
||||
print("# -------------------------------------------------------")
|
||||
print("#")
|
||||
print("# Boards that aren't made by Adafruit")
|
||||
print("#")
|
||||
print("# and are not officially supported")
|
||||
print("# -------------------------------------------------------")
|
||||
|
||||
make_board("pca10056", "pca10056", "Nordic", "nRF52840 DK", "NRF52840_PCA10056",
|
||||
"0x239A", ["0x8029", "0x0029"])
|
||||
thirdparty_boards_list = [
|
||||
["pca10056", "pca10056", "Nordic", "nRF52840 DK", "NRF52840_PCA10056",
|
||||
"0x239A", ["0x8029", "0x0029"]],
|
||||
|
||||
make_board("particle_xenon", "particle_xenon", "Particle", "Xenon", "PARTICLE_XENON",
|
||||
"0x239A", ["0x8029", "0x0029"])
|
||||
["particle_xenon", "particle_xenon", "Particle", "Xenon", "PARTICLE_XENON",
|
||||
"0x239A", ["0x8029", "0x0029"]],
|
||||
]
|
||||
|
||||
for b in thirdparty_boards_list:
|
||||
make_board(*b)
|
||||
+31
-21
@@ -1,7 +1,6 @@
|
||||
import os
|
||||
import shutil
|
||||
import urllib.request
|
||||
import zipfile
|
||||
from multiprocessing import Pool
|
||||
|
||||
# Get all variants
|
||||
all_variant = []
|
||||
@@ -11,7 +10,7 @@ for entry in os.scandir("variants"):
|
||||
all_variant.sort()
|
||||
|
||||
# Detect version in platform.txt
|
||||
version = '';
|
||||
version = ''
|
||||
with open('platform.txt') as pf:
|
||||
platform_txt = pf.read()
|
||||
e = '{build.variant}_bootloader-'
|
||||
@@ -19,25 +18,36 @@ with open('platform.txt') as pf:
|
||||
v2 = platform_txt.index('_', v1)
|
||||
version = platform_txt[v1:v2]
|
||||
|
||||
print('version {}'.format(version))
|
||||
print(f'version {version}')
|
||||
|
||||
for variant in all_variant:
|
||||
|
||||
# Download a variant's bootloader
|
||||
def download_variant(variant):
|
||||
# Download from bootloader release
|
||||
name = '{}_bootloader-{}.zip'.format(variant, version)
|
||||
url = 'https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases/download/{}/{}'.format(version, name)
|
||||
print("Downloading", name)
|
||||
urllib.request.urlretrieve(url, name)
|
||||
|
||||
# remove existing bootloader
|
||||
shutil.rmtree('bootloader/{}'.format(variant), ignore_errors=True)
|
||||
|
||||
# unzip
|
||||
with zipfile.ZipFile(name, "r") as zip_ref:
|
||||
zip_ref.extractall("bootloader/{}".format(variant))
|
||||
|
||||
# Remove update.uf2 for 832
|
||||
sd_version = '6.1.1'
|
||||
sd_name = 's140'
|
||||
if variant == 'feather_nrf52832':
|
||||
os.remove("bootloader/{}/update-{}_nosd.uf2".format(variant, name[:-4]))
|
||||
sd_name = 's132'
|
||||
|
||||
# remove zip file
|
||||
os.remove(name)
|
||||
f_zip = f'{variant}_bootloader-{version}_{sd_name}_{sd_version}.zip'
|
||||
f_hex = f'{variant}_bootloader-{version}_{sd_name}_{sd_version}.hex'
|
||||
f_uf2 = f'update-{variant}_bootloader-{version}_nosd.uf2'
|
||||
url_prefix = f'https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases/download/{version}/'
|
||||
|
||||
# remove existing bootloader files
|
||||
for item in os.listdir(f'bootloader/{variant}'):
|
||||
os.remove(os.path.join(f'bootloader/{variant}', item))
|
||||
|
||||
print(f"Downloading {f_zip}")
|
||||
urllib.request.urlretrieve(url_prefix + f_zip, f'bootloader/{variant}/{f_zip}')
|
||||
|
||||
print(f"Downloading {f_hex}")
|
||||
urllib.request.urlretrieve(url_prefix + f_hex, f'bootloader/{variant}/{f_hex}')
|
||||
|
||||
if sd_name != 's132':
|
||||
print(f"Downloading {f_uf2}")
|
||||
urllib.request.urlretrieve(url_prefix + f_uf2, f'bootloader/{variant}/{f_uf2}')
|
||||
|
||||
if __name__ == "__main__":
|
||||
with Pool() as p:
|
||||
p.map(download_variant, all_variant)
|
||||
Reference in new issue
Block a user