├── .github └── workflows │ └── examples.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── boards ├── 96b_nitrogen.json ├── adafruit_clue_nrf52840.json ├── adafruit_cplaynrf52840.json ├── adafruit_feather_nrf52832.json ├── adafruit_feather_nrf52840.json ├── adafruit_feather_nrf52840_sense.json ├── adafruit_itsybitsy_nrf52840.json ├── adafruit_ledglasses_nrf52840.json ├── adafruit_metro_nrf52840.json ├── bbcmicrobit_v2.json ├── bluey.json ├── calliopemini_v3.json ├── delta_dfbm_nq620.json ├── dwm1001_dev.json ├── electronut_blip.json ├── electronut_papyr.json ├── hackaBLE.json ├── holyiot_yj16019.json ├── laird_bl652_dvk.json ├── laird_bl653_dvk.json ├── laird_bl654_dvk.json ├── laird_pinnacle_100_dvk.json ├── nano33ble.json ├── nicla_sense_me.json ├── nrf52832_mdk.json ├── nrf52833_dk.json ├── nrf52840_dk.json ├── nrf52840_dk_adafruit.json ├── nrf52840_mdk.json ├── nrf52_dk.json ├── particle_argon.json ├── particle_boron.json ├── particle_xenon.json ├── raytac_mdbt50q_rx.json ├── redbear_blenano2.json ├── redbear_blend2.json ├── reel_board.json ├── reel_board_v2.json ├── ruuvitag.json ├── sdt52832b.json ├── stct_nrf52_minidev.json ├── thingy_52.json ├── ublox_bmd345eval_nrf52840.json ├── ublox_evk_nina_b1.json └── vbluno52.json ├── builder ├── frameworks │ ├── _bare.py │ ├── arduino.py │ ├── mbed.py │ └── zephyr.py └── main.py ├── examples ├── arduino-ble-led │ ├── .gitignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ └── led.cpp │ └── test │ │ └── README ├── arduino-blink │ ├── .gitignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ └── Blink.cpp │ └── test │ │ └── README ├── arduino-bluefruit-bleuart │ ├── .gitignore │ ├── .skiptest │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ └── main.cpp │ └── test │ │ └── README ├── arduino-nina-b1-generic-example │ ├── LICENSE │ ├── README.md │ ├── extras │ │ └── Screenshot_20190328-130832_u-blox BLE.jpg │ ├── platformio.ini │ └── src │ │ └── main.cpp ├── arduino-serial-plotter │ ├── .gitignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ └── main.cpp │ └── test │ │ └── README ├── mbed-rtos-ble-battery │ ├── .gitignore │ ├── .mbedignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── mbed_app.json │ ├── platformio.ini │ ├── src │ │ ├── main.cpp │ │ └── pretty_printer.h │ └── test │ │ └── README ├── mbed-rtos-blink-baremetal │ ├── .gitignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── mbed_app.json │ ├── platformio.ini │ ├── src │ │ └── main.cpp │ └── test │ │ └── README ├── mbed-rtos-nfc │ ├── .gitignore │ ├── .mbedignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ ├── SmartPoster.cpp │ │ ├── SmartPoster.h │ │ └── main.cpp │ └── test │ │ └── README ├── zephyr-ble-beacon │ ├── .gitignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ └── main.c │ ├── test │ │ └── README │ └── zephyr │ │ ├── CMakeLists.txt │ │ └── prj.conf ├── zephyr-blink │ ├── .gitignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ └── main.c │ ├── test │ │ └── README │ └── zephyr │ │ ├── CMakeLists.txt │ │ └── prj.conf ├── zephyr-net-echo-client │ ├── .gitignore │ ├── README.md │ ├── include │ │ └── README │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ ├── ca_certificate.h │ │ ├── common.h │ │ ├── dummy_psk.h │ │ ├── echo-apps-cert.der │ │ ├── echo-client.c │ │ └── udp.c │ ├── test │ │ └── README │ └── zephyr │ │ ├── CMakeLists.txt │ │ ├── Kconfig │ │ ├── README.md │ │ ├── boards │ │ ├── atsamr21_xpro.conf │ │ ├── qemu_cortext_m3.conf │ │ └── qemu_x86.conf │ │ ├── docker-test.sh │ │ ├── overlay-6locan.conf │ │ ├── overlay-802154-subg.conf │ │ ├── overlay-802154.conf │ │ ├── overlay-bt.conf │ │ ├── overlay-cc2520.conf │ │ ├── overlay-debug.conf │ │ ├── overlay-e1000.conf │ │ ├── overlay-linux.conf │ │ ├── overlay-log.conf │ │ ├── overlay-max-stacks.conf │ │ ├── overlay-ot.conf │ │ ├── overlay-qemu_802154.conf │ │ ├── overlay-qemu_cortex_m3_eth.conf │ │ ├── overlay-socks5.conf │ │ ├── overlay-tls.conf │ │ ├── overlay-vlan.conf │ │ ├── prj.conf │ │ └── sample.yaml └── zephyr-subsys-nvs │ ├── .gitignore │ ├── README.md │ ├── include │ └── README │ ├── lib │ └── README │ ├── platformio.ini │ ├── src │ └── main.c │ ├── test │ └── README │ └── zephyr │ ├── CMakeLists.txt │ └── prj.conf ├── misc └── svd │ ├── nrf52.svd │ └── nrf52840.svd ├── platform.json └── platform.py /.github/workflows/examples.yml: -------------------------------------------------------------------------------- 1 | name: Examples 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | os: [ubuntu-latest, windows-latest, macos-13] 11 | example: 12 | - "examples/arduino-blink" 13 | - "examples/arduino-ble-led" 14 | - "examples/arduino-bluefruit-bleuart" 15 | - "examples/arduino-nina-b1-generic-example" 16 | - "examples/arduino-serial-plotter" 17 | - "examples/mbed-rtos-ble-battery" 18 | - "examples/mbed-rtos-blink-baremetal" 19 | - "examples/mbed-rtos-nfc" 20 | - "examples/zephyr-ble-beacon" 21 | - "examples/zephyr-blink" 22 | - "examples/zephyr-net-echo-client" 23 | - "examples/zephyr-subsys-nvs" 24 | runs-on: ${{ matrix.os }} 25 | steps: 26 | - uses: actions/checkout@v3 27 | with: 28 | submodules: "recursive" 29 | - name: Set up Python 3 30 | uses: actions/setup-python@v3 31 | with: 32 | python-version: "3.9" 33 | - name: Install dependencies 34 | run: | 35 | pip install -U https://github.com/platformio/platformio/archive/develop.zip 36 | pip3 install adafruit-nrfutil 37 | pio pkg install --global --platform symlink://. 38 | - name: Build examples 39 | run: | 40 | pio run -d ${{ matrix.example }} 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .piolibdeps 3 | .pio 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "builder/frameworks/arduino"] 2 | path = builder/frameworks/arduino 3 | url = https://github.com/platformio/builder-framework-arduino-nrf5.git 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nordic nRF52: development platform for [PlatformIO](https://platformio.org) 2 | 3 | [![Build Status](https://github.com/platformio/platform-nordicnrf52/workflows/Examples/badge.svg)](https://github.com/platformio/platform-nordicnrf52/actions) 4 | 5 | The nRF52 Series are built for speed to carry out increasingly complex tasks in the shortest possible time and return to sleep, conserving precious battery power. They have a Cortex-M4F processor which makes them quite capable Bluetooth Smart SoCs. 6 | 7 | * [Home](https://registry.platformio.org/platforms/platformio/nordicnrf52) (home page in the PlatformIO Registry) 8 | * [Documentation](https://docs.platformio.org/page/platforms/nordicnrf52.html) (advanced usage, packages, boards, frameworks, etc.) 9 | 10 | # Usage 11 | 12 | 1. [Install PlatformIO](https://platformio.org) 13 | 2. Create PlatformIO project and configure a platform option in [platformio.ini](https://docs.platformio.org/page/projectconf.html) file: 14 | 15 | ## Stable version 16 | 17 | ```ini 18 | [env:stable] 19 | platform = nordicnrf52 20 | board = ... 21 | ... 22 | ``` 23 | 24 | ## Development version 25 | 26 | ```ini 27 | [env:development] 28 | platform = https://github.com/platformio/platform-nordicnrf52.git 29 | board = ... 30 | ... 31 | ``` 32 | 33 | # Configuration 34 | 35 | Please navigate to [documentation](https://docs.platformio.org/page/platforms/nordicnrf52.html). 36 | -------------------------------------------------------------------------------- /boards/96b_nitrogen.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52832" 6 | }, 7 | "connectivity": [ 8 | "bluetooth" 9 | ], 10 | "debug": { 11 | "jlink_device": "nRF52832_xxAA", 12 | "svd_path": "nrf52.svd" 13 | }, 14 | "frameworks": [ 15 | "zephyr" 16 | ], 17 | "name": "96Boards Nitrogen", 18 | "upload": { 19 | "maximum_ram_size": 65536, 20 | "maximum_size": 524288, 21 | "protocol": "jlink", 22 | "protocols": [ 23 | "jlink", 24 | "nrfjprog", 25 | "stlink", 26 | "blackmagic" 27 | ] 28 | }, 29 | "url": "https://www.96boards.org/product/nitrogen/", 30 | "vendor": "96Boards" 31 | } 32 | -------------------------------------------------------------------------------- /boards/adafruit_clue_nrf52840.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52840_s140_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52840_CLUE -DNRF52840_XXAA", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x8071" 14 | ], 15 | [ 16 | "0x239A", 17 | "0x0071" 18 | ], 19 | [ 20 | "0x239A", 21 | "0x8072" 22 | ] 23 | ], 24 | "usb_product": "CLUE nRF52840", 25 | "mcu": "nrf52840", 26 | "variant": "clue_nrf52840", 27 | "bsp": { 28 | "name": "adafruit" 29 | }, 30 | "softdevice": { 31 | "sd_flags": "-DS140", 32 | "sd_name": "s140", 33 | "sd_version": "6.1.1", 34 | "sd_fwid": "0x00B6" 35 | }, 36 | "bootloader": { 37 | "settings_addr": "0xFF000" 38 | } 39 | }, 40 | "connectivity": [ 41 | "bluetooth" 42 | ], 43 | "debug": { 44 | "jlink_device": "nRF52840_xxAA", 45 | "svd_path": "nrf52840.svd" 46 | }, 47 | "frameworks": [ 48 | "arduino" 49 | ], 50 | "name": "Adafruit CLUE nRF52840", 51 | "upload": { 52 | "maximum_ram_size": 248832, 53 | "maximum_size": 815104, 54 | "speed": 115200, 55 | "protocol": "nrfutil", 56 | "protocols": [ 57 | "jlink", 58 | "nrfjprog", 59 | "nrfutil", 60 | "stlink", 61 | "cmsis-dap", 62 | "blackmagic" 63 | ], 64 | "use_1200bps_touch": true, 65 | "require_upload_port": true, 66 | "wait_for_upload_port": true 67 | }, 68 | "url": "https://www.adafruit.com/product/4500", 69 | "vendor": "Adafruit" 70 | } 71 | -------------------------------------------------------------------------------- /boards/adafruit_cplaynrf52840.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52840_s140_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52840_CIRCUITPLAY -DNRF52840_XXAA -DNRF52840_CIRCUITPLAY", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x8045" 14 | ], 15 | [ 16 | "0x239A", 17 | "0x0045" 18 | ], 19 | [ 20 | "0x239A", 21 | "0x8046" 22 | ] 23 | ], 24 | "usb_product": "Circuit Playground Bluefruit", 25 | "mcu": "nrf52840", 26 | "variant": "circuitplayground_nrf52840", 27 | "bsp": { 28 | "name": "adafruit" 29 | }, 30 | "softdevice": { 31 | "sd_flags": "-DS140", 32 | "sd_name": "s140", 33 | "sd_version": "6.1.1", 34 | "sd_fwid": "0x00B6" 35 | }, 36 | "bootloader": { 37 | "settings_addr": "0xFF000" 38 | } 39 | }, 40 | "connectivity": [ 41 | "bluetooth" 42 | ], 43 | "debug": { 44 | "jlink_device": "nRF52840_xxAA", 45 | "svd_path": "nrf52840.svd" 46 | }, 47 | "frameworks": [ 48 | "arduino" 49 | ], 50 | "name": "Circuit Playground Bluefruit", 51 | "upload": { 52 | "maximum_ram_size": 248832, 53 | "maximum_size": 815104, 54 | "speed": 115200, 55 | "protocol": "nrfutil", 56 | "protocols": [ 57 | "jlink", 58 | "nrfjprog", 59 | "nrfutil", 60 | "stlink", 61 | "cmsis-dap", 62 | "blackmagic" 63 | ], 64 | "use_1200bps_touch": true, 65 | "require_upload_port": true, 66 | "wait_for_upload_port": true 67 | }, 68 | "url": "https://www.adafruit.com/product/4333", 69 | "vendor": "Adafruit" 70 | } 71 | -------------------------------------------------------------------------------- /boards/adafruit_feather_nrf52832.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52832_s132_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DNRF52832_XXAA -DNRF52", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x8029" 14 | ], 15 | [ 16 | "0x239A", 17 | "0x0029" 18 | ], 19 | [ 20 | "0x239A", 21 | "0x002A" 22 | ], 23 | [ 24 | "0x239A", 25 | "0x802A" 26 | ] 27 | ], 28 | "usb_product": "Feather nRF52832 Express", 29 | "mcu": "nrf52832", 30 | "variant": "feather_nrf52832", 31 | "bsp": { 32 | "name": "adafruit" 33 | }, 34 | "softdevice": { 35 | "sd_flags": "-DS132", 36 | "sd_name": "s132", 37 | "sd_version": "6.1.1", 38 | "sd_fwid": "0x00B7" 39 | }, 40 | "zephyr": { 41 | "variant": "nrf52_adafruit_feather" 42 | } 43 | }, 44 | "connectivity": [ 45 | "bluetooth" 46 | ], 47 | "debug": { 48 | "jlink_device": "nRF52832_xxAA", 49 | "svd_path": "nrf52.svd" 50 | }, 51 | "frameworks": [ 52 | "arduino", 53 | "zephyr" 54 | ], 55 | "name": "Adafruit Bluefruit nRF52832 Feather", 56 | "upload": { 57 | "maximum_ram_size": 65536, 58 | "maximum_size": 524288, 59 | "require_upload_port": true, 60 | "speed": 115200, 61 | "protocol": "nrfutil", 62 | "protocols": [ 63 | "jlink", 64 | "nrfjprog", 65 | "nrfutil", 66 | "stlink", 67 | "cmsis-dap", 68 | "blackmagic" 69 | ] 70 | }, 71 | "url": "https://www.adafruit.com/product/3406", 72 | "vendor": "Adafruit" 73 | } 74 | -------------------------------------------------------------------------------- /boards/adafruit_feather_nrf52840.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52840_s140_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x8029" 14 | ], 15 | [ 16 | "0x239A", 17 | "0x0029" 18 | ], 19 | [ 20 | "0x239A", 21 | "0x002A" 22 | ], 23 | [ 24 | "0x239A", 25 | "0x802A" 26 | ] 27 | ], 28 | "usb_product": "Feather nRF52840 Express", 29 | "mcu": "nrf52840", 30 | "variant": "feather_nrf52840_express", 31 | "bsp": { 32 | "name": "adafruit" 33 | }, 34 | "softdevice": { 35 | "sd_flags": "-DS140", 36 | "sd_name": "s140", 37 | "sd_version": "6.1.1", 38 | "sd_fwid": "0x00B6" 39 | }, 40 | "bootloader": { 41 | "settings_addr": "0xFF000" 42 | } 43 | }, 44 | "connectivity": [ 45 | "bluetooth" 46 | ], 47 | "debug": { 48 | "jlink_device": "nRF52840_xxAA", 49 | "svd_path": "nrf52840.svd" 50 | }, 51 | "frameworks": [ 52 | "arduino", 53 | "zephyr" 54 | ], 55 | "name": "Adafruit Feather nRF52840 Express", 56 | "upload": { 57 | "maximum_ram_size": 248832, 58 | "maximum_size": 815104, 59 | "speed": 115200, 60 | "protocol": "nrfutil", 61 | "protocols": [ 62 | "jlink", 63 | "nrfjprog", 64 | "nrfutil", 65 | "stlink", 66 | "cmsis-dap", 67 | "blackmagic" 68 | ], 69 | "use_1200bps_touch": true, 70 | "require_upload_port": true, 71 | "wait_for_upload_port": true 72 | }, 73 | "url": "https://www.adafruit.com/product/4062", 74 | "vendor": "Adafruit" 75 | } 76 | -------------------------------------------------------------------------------- /boards/adafruit_feather_nrf52840_sense.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52840_s140_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52840_FEATHER_SENSE -DNRF52840_XXAA", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x8087" 14 | ], 15 | [ 16 | "0x239A", 17 | "0x0087" 18 | ], 19 | [ 20 | "0x239A", 21 | "0x0088" 22 | ], 23 | [ 24 | "0x239A", 25 | "0x8088" 26 | ] 27 | ], 28 | "usb_product": "Feather Bluefruit Sense", 29 | "mcu": "nrf52840", 30 | "variant": "feather_nrf52840_sense", 31 | "bsp": { 32 | "name": "adafruit" 33 | }, 34 | "softdevice": { 35 | "sd_flags": "-DS140", 36 | "sd_name": "s140", 37 | "sd_version": "6.1.1", 38 | "sd_fwid": "0x00B6" 39 | }, 40 | "bootloader": { 41 | "settings_addr": "0xFF000" 42 | } 43 | }, 44 | "connectivity": [ 45 | "bluetooth" 46 | ], 47 | "debug": { 48 | "jlink_device": "nRF52840_xxAA", 49 | "svd_path": "nrf52840.svd" 50 | }, 51 | "frameworks": [ 52 | "arduino" 53 | ], 54 | "name": "Adafruit Feather Bluefruit Sense", 55 | "upload": { 56 | "maximum_ram_size": 248832, 57 | "maximum_size": 815104, 58 | "speed": 115200, 59 | "protocol": "nrfutil", 60 | "protocols": [ 61 | "jlink", 62 | "nrfjprog", 63 | "nrfutil", 64 | "stlink", 65 | "cmsis-dap", 66 | "blackmagic" 67 | ], 68 | "use_1200bps_touch": true, 69 | "require_upload_port": true, 70 | "wait_for_upload_port": true 71 | }, 72 | "url": "https://www.adafruit.com/product/4516", 73 | "vendor": "Adafruit" 74 | } 75 | -------------------------------------------------------------------------------- /boards/adafruit_itsybitsy_nrf52840.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52840_s140_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52840_ITSYBITSY -DNRF52840_XXAA -DARDUINO_NRF52_ITSYBITSY", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x8051" 14 | ], 15 | [ 16 | "0x239A", 17 | "0x0051" 18 | ], 19 | [ 20 | "0x239A", 21 | "0x0052" 22 | ], 23 | [ 24 | "0x239A", 25 | "0x8052" 26 | ] 27 | ], 28 | "usb_product": "ItsyBitsy nRF52840 Express", 29 | "mcu": "nrf52840", 30 | "variant": "itsybitsy_nrf52840_express", 31 | "bsp": { 32 | "name": "adafruit" 33 | }, 34 | "softdevice": { 35 | "sd_flags": "-DS140", 36 | "sd_name": "s140", 37 | "sd_version": "6.1.1", 38 | "sd_fwid": "0x00B6" 39 | }, 40 | "bootloader": { 41 | "settings_addr": "0xFF000" 42 | } 43 | }, 44 | "connectivity": [ 45 | "bluetooth" 46 | ], 47 | "debug": { 48 | "jlink_device": "nRF52840_xxAA", 49 | "svd_path": "nrf52840.svd" 50 | }, 51 | "frameworks": [ 52 | "arduino" 53 | ], 54 | "name": "ItsyBitsy nRF52840 Express", 55 | "upload": { 56 | "maximum_ram_size": 248832, 57 | "maximum_size": 815104, 58 | "speed": 115200, 59 | "protocol": "nrfutil", 60 | "protocols": [ 61 | "jlink", 62 | "nrfjprog", 63 | "nrfutil", 64 | "stlink", 65 | "cmsis-dap", 66 | "blackmagic" 67 | ], 68 | "use_1200bps_touch": true, 69 | "require_upload_port": true, 70 | "wait_for_upload_port": true 71 | }, 72 | "url": "https://www.adafruit.com/product/4062", 73 | "vendor": "Adafruit" 74 | } 75 | -------------------------------------------------------------------------------- /boards/adafruit_ledglasses_nrf52840.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52840_s140_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52840_LED_GLASSES -DNRF52840_XXAA", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x810D" 14 | ], 15 | [ 16 | "0x239A", 17 | "0x0029" 18 | ], 19 | [ 20 | "0x239A", 21 | "0x010D" 22 | ], 23 | [ 24 | "0x239A", 25 | "0x810E" 26 | ] 27 | ], 28 | "usb_product": "Adafruit LED Glasses", 29 | "mcu": "nrf52840", 30 | "variant": "ledglasses_nrf52840", 31 | "bsp": { 32 | "name": "adafruit" 33 | }, 34 | "softdevice": { 35 | "sd_flags": "-DS140", 36 | "sd_name": "s140", 37 | "sd_version": "6.1.1", 38 | "sd_fwid": "0x00B6" 39 | }, 40 | "bootloader": { 41 | "settings_addr": "0xFF000" 42 | } 43 | }, 44 | "connectivity": [ 45 | "bluetooth" 46 | ], 47 | "debug": { 48 | "jlink_device": "nRF52840_xxAA", 49 | "svd_path": "nrf52840.svd" 50 | }, 51 | "frameworks": [ 52 | "arduino", 53 | "zephyr" 54 | ], 55 | "name": "Adafruit LED Glasses Driver nRF52840", 56 | "upload": { 57 | "maximum_ram_size": 237568, 58 | "maximum_size": 815104, 59 | "speed": 115200, 60 | "protocol": "nrfutil", 61 | "protocols": [ 62 | "jlink", 63 | "nrfjprog", 64 | "nrfutil", 65 | "stlink", 66 | "cmsis-dap", 67 | "blackmagic" 68 | ], 69 | "use_1200bps_touch": true, 70 | "require_upload_port": true, 71 | "wait_for_upload_port": true 72 | }, 73 | "url": "https://www.adafruit.com/product/5217", 74 | "vendor": "Adafruit" 75 | } 76 | -------------------------------------------------------------------------------- /boards/adafruit_metro_nrf52840.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52840_s140_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52840_FEATHER -DARDUINO_NRF52840_METRO -DNRF52840_XXAA", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x803F" 14 | ], 15 | [ 16 | "0x239A", 17 | "0x003F" 18 | ], 19 | [ 20 | "0x239A", 21 | "0x0040" 22 | ], 23 | [ 24 | "0x239A", 25 | "0x8040" 26 | ] 27 | ], 28 | "usb_product": "Metro nRF52840 Express", 29 | "mcu": "nrf52840", 30 | "variant": "metro_nrf52840_express", 31 | "bsp": { 32 | "name": "adafruit" 33 | }, 34 | "softdevice": { 35 | "sd_flags": "-DS140", 36 | "sd_name": "s140", 37 | "sd_version": "6.1.1", 38 | "sd_fwid": "0x00B6" 39 | }, 40 | "bootloader": { 41 | "settings_addr": "0xFF000" 42 | } 43 | }, 44 | "connectivity": [ 45 | "bluetooth" 46 | ], 47 | "debug": { 48 | "jlink_device": "nRF52840_xxAA", 49 | "svd_path": "nrf52840.svd" 50 | }, 51 | "frameworks": [ 52 | "arduino" 53 | ], 54 | "name": "Metro nRF52840 Express", 55 | "upload": { 56 | "maximum_ram_size": 248832, 57 | "maximum_size": 815104, 58 | "speed": 115200, 59 | "protocol": "nrfutil", 60 | "protocols": [ 61 | "jlink", 62 | "nrfjprog", 63 | "nrfutil", 64 | "stlink", 65 | "cmsis-dap", 66 | "blackmagic" 67 | ], 68 | "use_1200bps_touch": true, 69 | "require_upload_port": true, 70 | "wait_for_upload_port": true 71 | }, 72 | "url": "https://www.adafruit.com/product/4062", 73 | "vendor": "Adafruit" 74 | } 75 | -------------------------------------------------------------------------------- /boards/bbcmicrobit_v2.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52833_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_BBC_MICROBIT_V2 -DNRF52833_XXAA -DUSE_LFSYNT", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52833", 11 | "variant": "BBCmicrobitV2", 12 | "zephyr": { 13 | "variant": "bbc_microbit_v2" 14 | } 15 | }, 16 | "connectivity": [ 17 | "bluetooth" 18 | ], 19 | "debug": { 20 | "onboard_tools": [ 21 | "cmsis-dap" 22 | ], 23 | "svd_path": "nrf52.svd", 24 | "openocd_extra_args": [ 25 | "-c", 26 | "transport select swd;" 27 | ], 28 | "jlink_device": "nRF52833_xxAA" 29 | }, 30 | "frameworks": [ 31 | "arduino", 32 | "zephyr" 33 | ], 34 | "name": "BBC micro:bit V2", 35 | "upload": { 36 | "maximum_ram_size": 131072, 37 | "maximum_size": 524288, 38 | "protocol": "cmsis-dap", 39 | "protocols": [ 40 | "jlink", 41 | "nrfjprog", 42 | "stlink", 43 | "blackmagic", 44 | "cmsis-dap", 45 | "mbed" 46 | ] 47 | }, 48 | "url": "https://microbit.org/new-microbit/", 49 | "vendor": "BBC" 50 | } 51 | -------------------------------------------------------------------------------- /boards/bluey.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_ELECTRONUT_BLUEY", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52832", 11 | "variant": "bluey" 12 | }, 13 | "connectivity": [ 14 | "bluetooth" 15 | ], 16 | "debug": { 17 | "jlink_device": "nRF52832_xxAA", 18 | "svd_path": "nrf52.svd" 19 | }, 20 | "frameworks": [ 21 | "arduino" 22 | ], 23 | "name": "Bluey nRF52832 IoT", 24 | "upload": { 25 | "maximum_ram_size": 65536, 26 | "maximum_size": 524288, 27 | "protocol": "jlink", 28 | "protocols": [ 29 | "jlink", 30 | "nrfjprog", 31 | "stlink", 32 | "cmsis-dap", 33 | "blackmagic" 34 | ] 35 | }, 36 | "url": "https://electronut.in/portfolio/bluey/", 37 | "vendor": "Electronut Labs" 38 | } 39 | -------------------------------------------------------------------------------- /boards/calliopemini_v3.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "nrf52833_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DNRF52833_XXAA -DARDUINO_CALLIOPE_MINI_V3 -DUSE_LFSYNT", 9 | "f_cpu": "64000000", 10 | "hwids": [ 11 | [ 12 | "0x0D28", 13 | "0x0204" 14 | ] 15 | ], 16 | "mcu": "nrf52833", 17 | "usb_product": "CalliopeMiniV3", 18 | "variant": "CalliopeminiV3" 19 | }, 20 | "debug": { 21 | "svd_path": "nrf52.svd", 22 | "openocd_extra_args": [ 23 | "-c", 24 | "transport select swd;" 25 | ], 26 | "jlink_device": "nRF52833_xxAA" 27 | }, 28 | "frameworks": [ 29 | "arduino" 30 | ], 31 | "name": "Calliope Mini v3", 32 | "upload": { 33 | "maximum_ram_size": 131072, 34 | "maximum_size": 524288, 35 | "protocol": "cmsis-dap", 36 | "protocols": [ 37 | "blackmagic", 38 | "cmsis-dap", 39 | "jlink", 40 | "stlink" 41 | ] 42 | }, 43 | "url": "https://calliope.cc", 44 | "vendor": "Calliope" 45 | } 46 | -------------------------------------------------------------------------------- /boards/delta_dfbm_nq620.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_GENERIC", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52832", 11 | "variant": "Generic" 12 | }, 13 | "connectivity": [ 14 | "bluetooth" 15 | ], 16 | "debug": { 17 | "jlink_device": "nRF52832_xxAA", 18 | "onboard_tools": [ 19 | "cmsis-dap" 20 | ], 21 | "svd_path": "nrf52.svd" 22 | }, 23 | "frameworks": [ 24 | "arduino" 25 | ], 26 | "name": "Delta DFBM-NQ620", 27 | "upload": { 28 | "maximum_ram_size": 65536, 29 | "maximum_size": 524288, 30 | "protocol": "cmsis-dap", 31 | "protocols": [ 32 | "jlink", 33 | "nrfjprog", 34 | "blackmagic", 35 | "cmsis-dap", 36 | "stlink", 37 | "mbed" 38 | ] 39 | }, 40 | "url": "https://developer.mbed.org/platforms/Delta-DFBM-NQ620/", 41 | "vendor": "Delta" 42 | } 43 | -------------------------------------------------------------------------------- /boards/dwm1001_dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_DWM1001_DEV", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52832", 11 | "variant": "DWM1001-DEV" 12 | 13 | }, 14 | "connectivity": [ 15 | "bluetooth" 16 | ], 17 | "debug": { 18 | "default_tools": [ 19 | "jlink" 20 | ], 21 | "jlink_device": "nRF52832_xxAA", 22 | "onboard_tools": [ 23 | "jlink" 24 | ], 25 | "svd_path": "nrf52.svd" 26 | }, 27 | "frameworks": [ 28 | "arduino" 29 | ], 30 | "name": "decaWave DWM1001 Module Development Board", 31 | "upload": { 32 | "maximum_ram_size": 65536, 33 | "maximum_size": 524288, 34 | "protocol": "jlink", 35 | "protocols": [ 36 | "jlink", 37 | "nrfjprog", 38 | "stlink", 39 | "blackmagic", 40 | "cmsis-dap", 41 | "mbed" 42 | ] 43 | }, 44 | "url": "https://www.decawave.com/product/dwm1001-development-board/", 45 | "vendor": "decaWave" 46 | } 47 | -------------------------------------------------------------------------------- /boards/electronut_blip.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52840", 6 | "zephyr": { 7 | "variant": "nrf52840_blip" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth" 12 | ], 13 | "debug": { 14 | "default_tools": [ 15 | "blackmagic" 16 | ], 17 | "jlink_device": "nRF52840_xxAA", 18 | "onboard_tools": [ 19 | "blackmagic" 20 | ], 21 | "svd_path": "nrf52840.svd" 22 | }, 23 | "frameworks": [ 24 | "zephyr" 25 | ], 26 | "name": "ElectronutLabs Blip", 27 | "upload": { 28 | "maximum_ram_size": 262144, 29 | "maximum_size": 1048576, 30 | "protocol": "blackmagic", 31 | "protocols": [ 32 | "jlink", 33 | "nrfjprog", 34 | "stlink", 35 | "blackmagic", 36 | "cmsis-dap" 37 | ] 38 | }, 39 | "url": "https://github.com/electronut/ElectronutLabs-blip", 40 | "vendor": "ElectronutLabs" 41 | } 42 | -------------------------------------------------------------------------------- /boards/electronut_papyr.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52840", 6 | "zephyr": { 7 | "variant": "nrf52840_papyr" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth" 12 | ], 13 | "debug": { 14 | "default_tools": [ 15 | "blackmagic" 16 | ], 17 | "jlink_device": "nRF52840_xxAA", 18 | "onboard_tools": [ 19 | "blackmagic" 20 | ], 21 | "svd_path": "nrf52840.svd" 22 | }, 23 | "frameworks": [ 24 | "zephyr" 25 | ], 26 | "name": "ElectronutLabs Papyr", 27 | "upload": { 28 | "maximum_ram_size": 262144, 29 | "maximum_size": 1048576, 30 | "protocol": "blackmagic", 31 | "protocols": [ 32 | "jlink", 33 | "nrfjprog", 34 | "stlink", 35 | "blackmagic", 36 | "cmsis-dap" 37 | ] 38 | }, 39 | "url": "https://docs.electronut.in/papyr", 40 | "vendor": "ElectronutLabs" 41 | } 42 | -------------------------------------------------------------------------------- /boards/hackaBLE.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_ELECTRONUT_HACKABLE", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52832", 11 | "variant": "hackaBLE" 12 | }, 13 | "connectivity": [ 14 | "bluetooth" 15 | ], 16 | "debug": { 17 | "jlink_device": "nRF52832_xxAA", 18 | "svd_path": "nrf52.svd" 19 | }, 20 | "frameworks": [ 21 | "arduino" 22 | ], 23 | "name": "hackaBLE", 24 | "upload": { 25 | "maximum_ram_size": 65536, 26 | "maximum_size": 524288, 27 | "protocol": "jlink", 28 | "protocols": [ 29 | "jlink", 30 | "nrfjprog", 31 | "stlink", 32 | "cmsis-dap", 33 | "blackmagic" 34 | ] 35 | }, 36 | "url": "https://electronut.in/portfolio/hackaBLE/", 37 | "vendor": "Electronut Labs" 38 | } 39 | -------------------------------------------------------------------------------- /boards/holyiot_yj16019.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52832" 6 | }, 7 | "connectivity": [ 8 | "bluetooth" 9 | ], 10 | "debug": { 11 | "jlink_device": "nRF52832_xxAA", 12 | "svd_path": "nrf52.svd" 13 | }, 14 | "frameworks": [ 15 | "zephyr" 16 | ], 17 | "name": "Holyiot YJ-16019", 18 | "upload": { 19 | "maximum_ram_size": 65536, 20 | "maximum_size": 524288, 21 | "protocol": "jlink", 22 | "protocols": [ 23 | "jlink", 24 | "nrfjprog", 25 | "stlink", 26 | "blackmagic", 27 | "cmsis-dap" 28 | ] 29 | }, 30 | "url": "http://www.holyiot.com/eacp_view.asp?id=306", 31 | "vendor": "Holyiot" 32 | } 33 | -------------------------------------------------------------------------------- /boards/laird_bl652_dvk.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52832", 6 | "zephyr": { 7 | "variant": "bl652_dvk" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth" 12 | ], 13 | "debug": { 14 | "default_tools": [ 15 | "jlink" 16 | ], 17 | "jlink_device": "nRF52832_xxAA", 18 | "onboard_tools": [ 19 | "cmsis-dap", 20 | "jlink" 21 | ], 22 | "svd_path": "nrf52.svd" 23 | }, 24 | "frameworks": [ 25 | "zephyr" 26 | ], 27 | "name": "BL652 Development Kit", 28 | "upload": { 29 | "maximum_ram_size": 65536, 30 | "maximum_size": 524288, 31 | "protocol": "jlink", 32 | "protocols": [ 33 | "jlink", 34 | "nrfjprog", 35 | "stlink", 36 | "blackmagic", 37 | "cmsis-dap", 38 | "mbed" 39 | ] 40 | }, 41 | "url": "https://www.lairdconnect.com/wireless-modules/bluetooth-modules/bluetooth-5-modules/bl652-series-bluetooth-v5-nfc", 42 | "vendor": "Laird Connectivity" 43 | } 44 | -------------------------------------------------------------------------------- /boards/laird_bl653_dvk.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52833", 6 | "zephyr": { 7 | "variant": "bl653_dvk" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth" 12 | ], 13 | "debug": { 14 | "default_tools": [ 15 | "jlink" 16 | ], 17 | "jlink_device": "nRF52833_xxAA", 18 | "onboard_tools": [ 19 | "cmsis-dap", 20 | "jlink" 21 | ], 22 | "svd_path": "nrf52833.svd" 23 | }, 24 | "frameworks": [ 25 | "zephyr" 26 | ], 27 | "name": "BL653 Development Kit", 28 | "upload": { 29 | "maximum_ram_size": 131072, 30 | "maximum_size": 524288, 31 | "protocol": "jlink", 32 | "protocols": [ 33 | "jlink", 34 | "nrfjprog", 35 | "stlink", 36 | "blackmagic", 37 | "cmsis-dap", 38 | "mbed" 39 | ] 40 | }, 41 | "url": "https://www.lairdconnect.com/wireless-modules/bluetooth-modules/bluetooth-5-modules/bl653-series-bluetooth-51-802154-nfc-module", 42 | "vendor": "Laird Connectivity" 43 | } 44 | -------------------------------------------------------------------------------- /boards/laird_bl654_dvk.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52840", 6 | "zephyr": { 7 | "variant": "bl654_dvk" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth" 12 | ], 13 | "debug": { 14 | "default_tools": [ 15 | "jlink" 16 | ], 17 | "jlink_device": "nRF52840_xxAA", 18 | "onboard_tools": [ 19 | "cmsis-dap", 20 | "jlink" 21 | ], 22 | "svd_path": "nrf52840.svd" 23 | }, 24 | "frameworks": [ 25 | "zephyr" 26 | ], 27 | "name": "BL654 Development Kit", 28 | "upload": { 29 | "maximum_ram_size": 262144, 30 | "maximum_size": 1048576, 31 | "protocol": "jlink", 32 | "protocols": [ 33 | "jlink", 34 | "nrfjprog", 35 | "stlink", 36 | "blackmagic", 37 | "cmsis-dap", 38 | "mbed" 39 | ] 40 | }, 41 | "url": "https://www.lairdconnect.com/wireless-modules/bluetooth-modules/bluetooth-5-modules/bl654-series-bluetooth-module-nfc", 42 | "vendor": "Laird Connectivity" 43 | } 44 | -------------------------------------------------------------------------------- /boards/laird_pinnacle_100_dvk.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52840", 6 | "zephyr": { 7 | "variant": "pinnacle_100_dvk" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth" 12 | ], 13 | "debug": { 14 | "jlink_device": "nRF52840_xxAA", 15 | "svd_path": "nrf52840.svd" 16 | }, 17 | "frameworks": [ 18 | "zephyr" 19 | ], 20 | "name": "Laird Connectivity Pinnacle 100 DVK", 21 | "upload": { 22 | "maximum_ram_size": 262144, 23 | "maximum_size": 1048576, 24 | "protocol": "jlink", 25 | "protocols": [ 26 | "jlink", 27 | "nrfjprog", 28 | "stlink", 29 | "blackmagic", 30 | "cmsis-dap", 31 | "mbed" 32 | ] 33 | }, 34 | "url": "https://www.lairdconnect.com/wireless-modules/cellular-solutions/pinnacle-100-cellular-modem", 35 | "vendor": "Laird Connectivity" 36 | } 37 | -------------------------------------------------------------------------------- /boards/nano33ble.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "linker_script.ld" 5 | }, 6 | "core": "arduino", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_ARDUINO_NANO33BLE -DARDUINO_ARCH_NRF52840", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x2341", 13 | "0x005a" 14 | ], 15 | [ 16 | "0x2341", 17 | "0x805a" 18 | ] 19 | ], 20 | "mcu": "nrf52840", 21 | "variant": "ARDUINO_NANO33BLE" 22 | }, 23 | "connectivity": [ 24 | "bluetooth" 25 | ], 26 | "debug": { 27 | "jlink_device": "nRF52840_xxAA", 28 | "openocd_target": "nrf52.cfg", 29 | "svd_path": "nrf52840.svd" 30 | }, 31 | "frameworks": [ 32 | "arduino" 33 | ], 34 | "name": "Arduino Nano 33 BLE", 35 | "upload": { 36 | "maximum_ram_size": 262144, 37 | "maximum_size": 983040, 38 | "protocol": "sam-ba", 39 | "protocols": [ 40 | "jlink", 41 | "nrfjprog", 42 | "nrfutil", 43 | "cmsis-dap", 44 | "sam-ba", 45 | "blackmagic" 46 | ], 47 | "use_1200bps_touch": true, 48 | "require_upload_port": true, 49 | "wait_for_upload_port": true 50 | }, 51 | "url": "https://store.arduino.cc/arduino-nano-33-ble", 52 | "vendor": "Arduino" 53 | } 54 | -------------------------------------------------------------------------------- /boards/nicla_sense_me.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "linker_script.ld" 5 | }, 6 | "core": "arduino", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NICLA -DARDUINO_ARCH_NRF52832", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x2341", 13 | "0x0060" 14 | ] 15 | ], 16 | "mcu": "nrf52832", 17 | "variant": "NICLA" 18 | }, 19 | "connectivity": [ 20 | "bluetooth" 21 | ], 22 | "debug": { 23 | "default_tools": [ 24 | "cmsis-dap" 25 | ], 26 | "jlink_device": "nRF52832_xxAA", 27 | "onboard_tools": [ 28 | "cmsis-dap" 29 | ], 30 | "svd_path": "nrf52.svd", 31 | "openocd_target": "nrf52.cfg", 32 | "openocd_extra_args": [ 33 | "-c", 34 | "transport select swd;" 35 | ] 36 | }, 37 | "frameworks": [ 38 | "arduino" 39 | ], 40 | "name": "Arduino Nicla Sense ME", 41 | "upload": { 42 | "maximum_ram_size": 64288, 43 | "maximum_size": 527616, 44 | "protocol": "cmsis-dap", 45 | "protocols": [ 46 | "jlink", 47 | "nrfjprog", 48 | "nrfutil", 49 | "cmsis-dap", 50 | "sam-ba", 51 | "blackmagic" 52 | ], 53 | "use_1200bps_touch": false, 54 | "require_upload_port": true 55 | }, 56 | "url": "https://docs.arduino.cc/hardware/nicla-sense-me", 57 | "vendor": "Arduino" 58 | } 59 | -------------------------------------------------------------------------------- /boards/nrf52832_mdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52832" 6 | }, 7 | "connectivity": [ 8 | "bluetooth" 9 | ], 10 | "debug": { 11 | "default_tools": [ 12 | "cmsis-dap" 13 | ], 14 | "jlink_device": "nRF52832_xxAA", 15 | "onboard_tools": [ 16 | "cmsis-dap" 17 | ], 18 | "svd_path": "nrf52.svd" 19 | }, 20 | "frameworks": [ 21 | "zephyr" 22 | ], 23 | "name": "Makerdiary nRF52832-MDK", 24 | "upload": { 25 | "maximum_ram_size": 65536, 26 | "maximum_size": 524288, 27 | "protocol": "cmsis-dap", 28 | "protocols": [ 29 | "jlink", 30 | "nrfjprog", 31 | "stlink", 32 | "blackmagic", 33 | "cmsis-dap", 34 | "mbed" 35 | ] 36 | }, 37 | "url": "https://wiki.makerdiary.com/nrf52832-mdk/", 38 | "vendor": "Makerdiary" 39 | } 40 | -------------------------------------------------------------------------------- /boards/nrf52833_dk.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52833", 6 | "zephyr": { 7 | "variant": "nrf52833dk_nrf52833" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth" 12 | ], 13 | "debug": { 14 | "default_tools": [ 15 | "jlink" 16 | ], 17 | "jlink_device": "nRF52833_xxAA", 18 | "onboard_tools": [ 19 | "cmsis-dap", 20 | "jlink" 21 | ], 22 | "svd_path": "nrf52833.svd" 23 | }, 24 | "frameworks": [ 25 | "zephyr" 26 | ], 27 | "name": "Nordic nRF52833-DK", 28 | "upload": { 29 | "maximum_ram_size": 131072, 30 | "maximum_size": 524288, 31 | "protocol": "jlink", 32 | "protocols": [ 33 | "jlink", 34 | "nrfjprog", 35 | "stlink", 36 | "blackmagic", 37 | "cmsis-dap", 38 | "mbed" 39 | ] 40 | }, 41 | "url": "https://www.nordicsemi.com/Products/Development-hardware/nrf52833-dk", 42 | "vendor": "Nordic" 43 | } 44 | -------------------------------------------------------------------------------- /boards/nrf52840_dk.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52_DK", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52840", 11 | "variant": "nRF52DK", 12 | "zephyr": { 13 | "variant": "nrf52840dk_nrf52840" 14 | } 15 | }, 16 | "connectivity": [ 17 | "bluetooth" 18 | ], 19 | "debug": { 20 | "default_tools": [ 21 | "jlink" 22 | ], 23 | "jlink_device": "nRF52840_xxAA", 24 | "onboard_tools": [ 25 | "cmsis-dap", 26 | "jlink" 27 | ], 28 | "svd_path": "nrf52840.svd" 29 | }, 30 | "frameworks": [ 31 | "arduino", 32 | "mbed", 33 | "zephyr" 34 | ], 35 | "name": "Nordic nRF52840-DK", 36 | "upload": { 37 | "maximum_ram_size": 262144, 38 | "maximum_size": 1048576, 39 | "protocol": "jlink", 40 | "protocols": [ 41 | "jlink", 42 | "nrfjprog", 43 | "stlink", 44 | "blackmagic", 45 | "cmsis-dap", 46 | "mbed" 47 | ] 48 | }, 49 | "url": "https://os.mbed.com/platforms/Nordic-nRF52840-DK/", 50 | "vendor": "Nordic" 51 | } 52 | -------------------------------------------------------------------------------- /boards/nrf52840_dk_adafruit.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52840_s140_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52840_PCA10056 -DNRF52840_XXAA", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x8029" 14 | ] 15 | ], 16 | "usb_product": "NRF52 DK", 17 | "mcu": "nrf52840", 18 | "variant": "pca10056", 19 | "bsp": { 20 | "name": "adafruit" 21 | }, 22 | "softdevice": { 23 | "sd_flags": "-DS140", 24 | "sd_name": "s140", 25 | "sd_version": "6.1.1", 26 | "sd_fwid": "0x00B6" 27 | }, 28 | "bootloader": { 29 | "settings_addr": "0xFF000" 30 | } 31 | }, 32 | "connectivity": [ 33 | "bluetooth" 34 | ], 35 | "debug": { 36 | "jlink_device": "nRF52840_xxAA", 37 | "onboard_tools": [ 38 | "jlink" 39 | ], 40 | "svd_path": "nrf52840.svd" 41 | }, 42 | "frameworks": [ 43 | "arduino" 44 | ], 45 | "name": "Nordic nRF52840-DK (Adafruit BSP)", 46 | "upload": { 47 | "maximum_ram_size": 248832, 48 | "maximum_size": 815104, 49 | "require_upload_port": true, 50 | "speed": 115200, 51 | "protocol": "jlink", 52 | "protocols": [ 53 | "jlink", 54 | "nrfjprog", 55 | "stlink", 56 | "cmsis-dap", 57 | "blackmagic" 58 | ] 59 | }, 60 | "url": "https://os.mbed.com/platforms/Nordic-nRF52840-DK/", 61 | "vendor": "Nordic" 62 | } 63 | -------------------------------------------------------------------------------- /boards/nrf52840_mdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52840" 6 | }, 7 | "connectivity": [ 8 | "bluetooth" 9 | ], 10 | "debug": { 11 | "default_tools": [ 12 | "cmsis-dap" 13 | ], 14 | "jlink_device": "nRF52840_xxAA", 15 | "onboard_tools": [ 16 | "cmsis-dap" 17 | ], 18 | "svd_path": "nrf52840.svd" 19 | }, 20 | "frameworks": [ 21 | "zephyr" 22 | ], 23 | "name": "Makerdiary nRF52840-MDK", 24 | "upload": { 25 | "maximum_ram_size": 262144, 26 | "maximum_size": 1048576, 27 | "protocol": "cmsis-dap", 28 | "protocols": [ 29 | "jlink", 30 | "nrfjprog", 31 | "stlink", 32 | "blackmagic", 33 | "cmsis-dap", 34 | "mbed" 35 | ] 36 | }, 37 | "url": "https://wiki.makerdiary.com/nrf52840-mdk", 38 | "vendor": "Makerdiary" 39 | } 40 | -------------------------------------------------------------------------------- /boards/nrf52_dk.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52_DK", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52832", 11 | "variant": "nRF52DK", 12 | "zephyr": { 13 | "variant": "nrf52dk_nrf52832" 14 | } 15 | }, 16 | "connectivity": [ 17 | "bluetooth" 18 | ], 19 | "debug": { 20 | "default_tools": [ 21 | "jlink" 22 | ], 23 | "jlink_device": "nRF52832_xxAA", 24 | "onboard_tools": [ 25 | "cmsis-dap", 26 | "jlink" 27 | ], 28 | "svd_path": "nrf52.svd" 29 | }, 30 | "frameworks": [ 31 | "arduino", 32 | "mbed", 33 | "zephyr" 34 | ], 35 | "name": "Nordic nRF52-DK", 36 | "upload": { 37 | "maximum_ram_size": 65536, 38 | "maximum_size": 524288, 39 | "protocol": "jlink", 40 | "protocols": [ 41 | "jlink", 42 | "nrfjprog", 43 | "stlink", 44 | "blackmagic", 45 | "cmsis-dap", 46 | "mbed" 47 | ] 48 | }, 49 | "url": "https://developer.mbed.org/platforms/Nordic-nRF52-DK/", 50 | "vendor": "Nordic" 51 | } 52 | -------------------------------------------------------------------------------- /boards/particle_argon.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52840" 6 | }, 7 | "connectivity": [ 8 | "bluetooth" 9 | ], 10 | "debug": { 11 | "jlink_device": "nRF52840_xxAA", 12 | "svd_path": "nrf52840.svd" 13 | }, 14 | "frameworks": [ 15 | "zephyr" 16 | ], 17 | "name": "Particle Argon", 18 | "upload": { 19 | "maximum_ram_size": 248832, 20 | "maximum_size": 815104, 21 | "require_upload_port": true, 22 | "speed": 115200, 23 | "protocol": "nrfutil", 24 | "protocols": [ 25 | "jlink", 26 | "nrfjprog", 27 | "nrfutil", 28 | "cmsis-dap", 29 | "blackmagic" 30 | ] 31 | }, 32 | "url": "https://docs.particle.io/argon", 33 | "vendor": "Particle" 34 | } 35 | -------------------------------------------------------------------------------- /boards/particle_boron.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52840" 6 | }, 7 | "connectivity": [ 8 | "bluetooth" 9 | ], 10 | "debug": { 11 | "jlink_device": "nRF52840_xxAA", 12 | "svd_path": "nrf52840.svd" 13 | }, 14 | "frameworks": [ 15 | "zephyr" 16 | ], 17 | "name": "Particle Boron", 18 | "upload": { 19 | "maximum_ram_size": 248832, 20 | "maximum_size": 815104, 21 | "require_upload_port": true, 22 | "speed": 115200, 23 | "protocol": "nrfutil", 24 | "protocols": [ 25 | "jlink", 26 | "nrfjprog", 27 | "nrfutil", 28 | "cmsis-dap", 29 | "blackmagic" 30 | ] 31 | }, 32 | "url": "https://docs.particle.io/boron", 33 | "vendor": "Particle" 34 | } 35 | -------------------------------------------------------------------------------- /boards/particle_xenon.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52840_s140_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA -DNRF52840_XXAA", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x8029" 14 | ] 15 | ], 16 | "usb_product": "Particle Xenon", 17 | "mcu": "nrf52840", 18 | "variant": "particle_xenon", 19 | "bsp": { 20 | "name": "adafruit" 21 | }, 22 | "softdevice": { 23 | "sd_flags": "-DS140", 24 | "sd_name": "s140", 25 | "sd_version": "6.1.1", 26 | "sd_fwid": "0x00B6" 27 | }, 28 | "bootloader": { 29 | "settings_addr": "0xFF000" 30 | } 31 | }, 32 | "connectivity": [ 33 | "bluetooth" 34 | ], 35 | "debug": { 36 | "jlink_device": "nRF52840_xxAA", 37 | "svd_path": "nrf52840.svd" 38 | }, 39 | "frameworks": [ 40 | "arduino", 41 | "zephyr" 42 | ], 43 | "name": "Particle Xenon", 44 | "upload": { 45 | "maximum_ram_size": 248832, 46 | "maximum_size": 815104, 47 | "require_upload_port": true, 48 | "speed": 115200, 49 | "protocol": "nrfutil", 50 | "protocols": [ 51 | "jlink", 52 | "nrfjprog", 53 | "nrfutil", 54 | "stlink", 55 | "cmsis-dap", 56 | "blackmagic" 57 | ] 58 | }, 59 | "url": "https://docs.particle.io/xenon", 60 | "vendor": "Particle" 61 | } 62 | -------------------------------------------------------------------------------- /boards/raytac_mdbt50q_rx.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52840_s140_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_MDBT50Q_RX -DNRF52840_XXAA", 9 | "f_cpu": "64000000L", 10 | "hwids": [ 11 | [ 12 | "0x239A", 13 | "0x810B" 14 | ], 15 | [ 16 | "0x239A", 17 | "0x010B" 18 | ], 19 | [ 20 | "0x239A", 21 | "0x810C" 22 | ] 23 | ], 24 | "usb_product": "Raytac MDBT50Q - RX", 25 | "mcu": "nrf52840", 26 | "variant": "raytac_mdbt50q_rx", 27 | "bsp": { 28 | "name": "adafruit" 29 | }, 30 | "softdevice": { 31 | "sd_flags": "-DS140", 32 | "sd_name": "s140", 33 | "sd_version": "6.1.1", 34 | "sd_fwid": "0x00B6" 35 | }, 36 | "bootloader": { 37 | "settings_addr": "0xFF000" 38 | } 39 | }, 40 | "connectivity": [ 41 | "bluetooth" 42 | ], 43 | "debug": { 44 | "jlink_device": "nRF52840_xxAA", 45 | "svd_path": "nrf52840.svd" 46 | }, 47 | "frameworks": [ 48 | "arduino" 49 | ], 50 | "name": "Raytac MDBT50Q-RX Dongle", 51 | "upload": { 52 | "maximum_ram_size": 248832, 53 | "maximum_size": 815104, 54 | "speed": 115200, 55 | "protocol": "nrfutil", 56 | "protocols": [ 57 | "jlink", 58 | "nrfjprog", 59 | "nrfutil", 60 | "stlink", 61 | "cmsis-dap", 62 | "blackmagic" 63 | ], 64 | "use_1200bps_touch": true, 65 | "require_upload_port": true, 66 | "wait_for_upload_port": true 67 | }, 68 | "url": "https://www.raytac.com/product/ins.php?index_id=89", 69 | "vendor": "Raytac" 70 | } 71 | -------------------------------------------------------------------------------- /boards/redbear_blenano2.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_RB_BLE_NANO_2", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52832", 11 | "variant": "RedBear_BLENano2", 12 | "zephyr": { 13 | "variant": "nrf52_blenano2" 14 | } 15 | }, 16 | "connectivity": [ 17 | "bluetooth" 18 | ], 19 | "debug": { 20 | "jlink_device": "nRF52832_xxAA", 21 | "onboard_tools": [ 22 | "cmsis-dap" 23 | ], 24 | "svd_path": "nrf52.svd" 25 | }, 26 | "frameworks": [ 27 | "arduino", 28 | "zephyr" 29 | ], 30 | "name": "RedBearLab BLE Nano 2", 31 | "upload": { 32 | "maximum_ram_size": 65536, 33 | "maximum_size": 524288, 34 | "protocol": "cmsis-dap", 35 | "protocols": [ 36 | "jlink", 37 | "nrfjprog", 38 | "stlink", 39 | "blackmagic", 40 | "cmsis-dap" 41 | ] 42 | }, 43 | "url": "https://redbear.cc/product/ble-nano-2-soldered.html", 44 | "vendor": "RedBearLab" 45 | } 46 | -------------------------------------------------------------------------------- /boards/redbear_blend2.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_RB_BLEND_2", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52832", 11 | "variant": "RedBear_Blend2" 12 | }, 13 | "connectivity": [ 14 | "bluetooth" 15 | ], 16 | "debug": { 17 | "jlink_device": "nRF52832_xxAA", 18 | "onboard_tools": [ 19 | "cmsis-dap" 20 | ], 21 | "svd_path": "nrf52.svd" 22 | }, 23 | "frameworks": [ 24 | "arduino" 25 | ], 26 | "name": "RedBearLab Blend 2", 27 | "upload": { 28 | "maximum_ram_size": 65536, 29 | "maximum_size": 524288, 30 | "protocol": "cmsis-dap", 31 | "protocols": [ 32 | "jlink", 33 | "nrfjprog", 34 | "stlink", 35 | "blackmagic", 36 | "cmsis-dap" 37 | ] 38 | }, 39 | "url": "https://redbear.cc/product/ble/blend-2.html", 40 | "vendor": "RedBearLab" 41 | } 42 | -------------------------------------------------------------------------------- /boards/reel_board.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52840", 6 | "hwids": [ 7 | [ 8 | "0x0D28", 9 | "0x0204" 10 | ] 11 | ], 12 | "zephyr": { 13 | "variant": "reel_board" 14 | } 15 | }, 16 | "connectivity": [ 17 | "bluetooth" 18 | ], 19 | "debug": { 20 | "jlink_device": "nRF52840_xxAA", 21 | "onboard_tools": [ 22 | "cmsis-dap" 23 | ], 24 | "svd_path": "nrf52840.svd" 25 | }, 26 | "frameworks": [ 27 | "zephyr" 28 | ], 29 | "name": "PHYTEC reel board", 30 | "upload": { 31 | "maximum_ram_size": 262144, 32 | "maximum_size": 1048576, 33 | "protocol": "cmsis-dap", 34 | "protocols": [ 35 | "jlink", 36 | "nrfjprog", 37 | "blackmagic", 38 | "cmsis-dap", 39 | "stlink", 40 | "mbed" 41 | ] 42 | }, 43 | "url": "https://www.phytec.eu/reelboard", 44 | "vendor": "PHYTEC" 45 | } 46 | -------------------------------------------------------------------------------- /boards/reel_board_v2.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52840", 6 | "hwids": [ 7 | [ 8 | "0x0D28", 9 | "0x0204" 10 | ] 11 | ], 12 | "zephyr": { 13 | "variant": "reel_board_v2" 14 | } 15 | }, 16 | "connectivity": [ 17 | "bluetooth" 18 | ], 19 | "debug": { 20 | "jlink_device": "nRF52840_xxAA", 21 | "onboard_tools": [ 22 | "cmsis-dap" 23 | ], 24 | "svd_path": "nrf52840.svd" 25 | }, 26 | "frameworks": [ 27 | "zephyr" 28 | ], 29 | "name": "PHYTEC reel board v2", 30 | "upload": { 31 | "maximum_ram_size": 262144, 32 | "maximum_size": 1048576, 33 | "protocol": "cmsis-dap", 34 | "protocols": [ 35 | "jlink", 36 | "nrfjprog", 37 | "blackmagic", 38 | "cmsis-dap", 39 | "stlink", 40 | "mbed" 41 | ] 42 | }, 43 | "url": "https://www.phytec.eu/reelboard", 44 | "vendor": "PHYTEC" 45 | } 46 | -------------------------------------------------------------------------------- /boards/ruuvitag.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52832", 6 | "zephyr": { 7 | "variant": "ruuvi_ruuvitag" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth" 12 | ], 13 | "debug": { 14 | "jlink_device": "nRF52832_xxAA", 15 | "svd_path": "nrf52.svd" 16 | }, 17 | "frameworks": [ 18 | "zephyr" 19 | ], 20 | "name": "Ruuvi Tag", 21 | "upload": { 22 | "maximum_ram_size": 65536, 23 | "maximum_size": 524288, 24 | "protocol": "jlink", 25 | "protocols": [ 26 | "jlink", 27 | "nrfjprog", 28 | "stlink", 29 | "blackmagic", 30 | "cmsis-dap", 31 | "mbed" 32 | ] 33 | }, 34 | "url": "https://ruuvi.com/", 35 | "vendor": "Ruuvi" 36 | } 37 | -------------------------------------------------------------------------------- /boards/sdt52832b.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "cpu": "cortex-m4", 7 | "extra_flags": "-DARDUINO_NRF52_DK", 8 | "f_cpu": "64000000L", 9 | "mcu": "nrf52832" 10 | }, 11 | "connectivity": [ 12 | "bluetooth" 13 | ], 14 | "debug": { 15 | "jlink_device": "nRF52832_xxAA", 16 | "svd_path": "nrf52.svd" 17 | }, 18 | "frameworks": [ 19 | "mbed" 20 | ], 21 | "name": "SDT52832B", 22 | "upload": { 23 | "maximum_ram_size": 65536, 24 | "maximum_size": 524288, 25 | "protocol": "mbed", 26 | "protocols": [ 27 | "jlink", 28 | "nrfjprog", 29 | "stlink", 30 | "blackmagic", 31 | "cmsis-dap", 32 | "mbed" 33 | ] 34 | }, 35 | "url": "https://os.mbed.com/platforms/SDT52832B/", 36 | "vendor": "Sigma Delta Technologies" 37 | } 38 | -------------------------------------------------------------------------------- /boards/stct_nrf52_minidev.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_STCT_NRF52_minidev", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52832", 11 | "variant": "Taida_Century_nRF52_minidev" 12 | }, 13 | "connectivity": [ 14 | "bluetooth" 15 | ], 16 | "debug": { 17 | "jlink_device": "nRF52832_xxAA", 18 | "svd_path": "nrf52.svd" 19 | }, 20 | "frameworks": [ 21 | "arduino" 22 | ], 23 | "name": "Taida Century nRF52 mini board", 24 | "upload": { 25 | "maximum_ram_size": 65536, 26 | "maximum_size": 524288, 27 | "protocol": "jlink", 28 | "protocols": [ 29 | "jlink", 30 | "nrfjprog", 31 | "stlink", 32 | "cmsis-dap", 33 | "blackmagic" 34 | ] 35 | }, 36 | "url": "http://taida-century.com/en/index.asp", 37 | "vendor": "Taida Century" 38 | } 39 | -------------------------------------------------------------------------------- /boards/thingy_52.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52832", 6 | "zephyr": { 7 | "variant": "thingy52_nrf52832" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth" 12 | ], 13 | "debug": { 14 | "jlink_device": "nRF52832_xxAA", 15 | "svd_path": "nrf52.svd" 16 | }, 17 | "frameworks": [ 18 | "zephyr" 19 | ], 20 | "name": "Nordic Thingy:52 (nRF52-PCA20020)", 21 | "upload": { 22 | "maximum_ram_size": 65536, 23 | "maximum_size": 524288, 24 | "protocol": "jlink", 25 | "protocols": [ 26 | "jlink", 27 | "nrfjprog", 28 | "stlink", 29 | "blackmagic", 30 | "cmsis-dap" 31 | ] 32 | }, 33 | "url": "https://www.nordicsemi.com/Software-and-Tools/Prototyping-platforms/Nordic-Thingy-52", 34 | "vendor": "Nordic" 35 | } 36 | -------------------------------------------------------------------------------- /boards/ublox_bmd345eval_nrf52840.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52840", 6 | "zephyr": { 7 | "variant": "ubx_bmd345eval_nrf52840" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth", 12 | "nfc" 13 | ], 14 | "debug": { 15 | "default_tools": [ 16 | "jlink" 17 | ], 18 | "jlink_device": "nRF52840_xxAA", 19 | "onboard_tools": [ 20 | "cmsis-dap", 21 | "jlink" 22 | ], 23 | "svd_path": "nrf52840.svd" 24 | }, 25 | "frameworks": [ 26 | "zephyr" 27 | ], 28 | "name": "u-blox BMD-345-EVAL", 29 | "upload": { 30 | "maximum_ram_size": 262144, 31 | "maximum_size": 1048576, 32 | "protocol": "jlink", 33 | "protocols": [ 34 | "blackmagic", 35 | "cmsis-dap", 36 | "jlink", 37 | "nrfjprog", 38 | "mbed", 39 | "stlink" 40 | ] 41 | }, 42 | "url": "https://www.u-blox.com/en/product/bmd-34-series-open-cpu", 43 | "vendor": "u-blox" 44 | } 45 | -------------------------------------------------------------------------------- /boards/ublox_evk_nina_b1.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "nrf52_xxaa.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DARDUINO_GENERIC", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52832", 11 | "variant": "Generic" 12 | }, 13 | "connectivity": [ 14 | "bluetooth", 15 | "nfc" 16 | ], 17 | "debug": { 18 | "jlink_device": "nRF52832_xxAA", 19 | "onboard_tools": [ 20 | "jlink" 21 | ], 22 | "svd_path": "nrf52.svd" 23 | }, 24 | "frameworks": [ 25 | "arduino" 26 | ], 27 | "name": "u-blox EVK-NINA-B1", 28 | "upload": { 29 | "maximum_ram_size": 65536, 30 | "maximum_size": 524288, 31 | "protocol": "jlink", 32 | "protocols": [ 33 | "jlink", 34 | "nrfjprog", 35 | "stlink", 36 | "blackmagic", 37 | "cmsis-dap", 38 | "mbed" 39 | ] 40 | }, 41 | "url": "https://os.mbed.com/platforms/u-blox-EVK-NINA-B1/", 42 | "vendor": "u-blox" 43 | } 44 | -------------------------------------------------------------------------------- /boards/vbluno52.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "cpu": "cortex-m4", 4 | "f_cpu": "64000000L", 5 | "mcu": "nrf52832", 6 | "zephyr": { 7 | "variant": "nrf52_vbluno52" 8 | } 9 | }, 10 | "connectivity": [ 11 | "bluetooth" 12 | ], 13 | "debug": { 14 | "default_tools": [ 15 | "cmsis-dap" 16 | ], 17 | "jlink_device": "nRF52832_xxAA", 18 | "onboard_tools": [ 19 | "cmsis-dap" 20 | ], 21 | "svd_path": "nrf52.svd" 22 | }, 23 | "frameworks": [ 24 | "zephyr" 25 | ], 26 | "name": "VNG VBLUno52", 27 | "upload": { 28 | "maximum_ram_size": 65536, 29 | "maximum_size": 524288, 30 | "protocol": "cmsis-dap", 31 | "protocols": [ 32 | "jlink", 33 | "nrfjprog", 34 | "stlink", 35 | "blackmagic", 36 | "cmsis-dap" 37 | ] 38 | }, 39 | "url": "https://vngiotlab.github.io/", 40 | "vendor": "VNG" 41 | } 42 | -------------------------------------------------------------------------------- /builder/frameworks/_bare.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014-present PlatformIO 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # 16 | # Default flags for bare-metal programming (without any framework layers) 17 | # 18 | 19 | from SCons.Script import DefaultEnvironment 20 | 21 | env = DefaultEnvironment() 22 | 23 | env.Append( 24 | ASFLAGS=[ 25 | "-mthumb", 26 | ], 27 | ASPPFLAGS=[ 28 | "-x", "assembler-with-cpp", 29 | ], 30 | 31 | CCFLAGS=[ 32 | "-Os", # optimize for size 33 | "-ffunction-sections", # place each function in its own section 34 | "-fdata-sections", 35 | "-Wall", 36 | "-mthumb", 37 | "-nostdlib" 38 | ], 39 | 40 | CXXFLAGS=[ 41 | "-fno-rtti", 42 | "-fno-exceptions" 43 | ], 44 | 45 | CPPDEFINES=[ 46 | ("F_CPU", "$BOARD_F_CPU") 47 | ], 48 | 49 | LINKFLAGS=[ 50 | "-Os", 51 | "-Wl,--gc-sections,--relax", 52 | "-mthumb", 53 | "--specs=nano.specs", 54 | "--specs=nosys.specs" 55 | ], 56 | 57 | LIBS=["c", "gcc", "m", "stdc++", "nosys"] 58 | ) 59 | 60 | if "BOARD" in env: 61 | env.Append( 62 | ASFLAGS=[ 63 | "-mcpu=%s" % env.BoardConfig().get("build.cpu") 64 | ], 65 | CCFLAGS=[ 66 | "-mcpu=%s" % env.BoardConfig().get("build.cpu") 67 | ], 68 | LINKFLAGS=[ 69 | "-mcpu=%s" % env.BoardConfig().get("build.cpu") 70 | ] 71 | ) 72 | -------------------------------------------------------------------------------- /builder/frameworks/arduino.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014-present PlatformIO 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | Arduino 17 | 18 | Arduino Wiring-based Framework allows writing cross-platform software to 19 | control devices attached to a wide range of Arduino boards to create all 20 | kinds of creative coding, interactive objects, spaces or physical experiences. 21 | """ 22 | 23 | from SCons.Script import DefaultEnvironment 24 | 25 | env = DefaultEnvironment() 26 | board = env.BoardConfig() 27 | 28 | if board.get("build.bsp.name", "nrf5") == "adafruit": 29 | env.SConscript("arduino/adafruit.py") 30 | else: 31 | env.SConscript("arduino/nrf5.py") 32 | -------------------------------------------------------------------------------- /builder/frameworks/mbed.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014-present PlatformIO 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | mbed 16 | 17 | The mbed framework The mbed SDK has been designed to provide enough 18 | hardware abstraction to be intuitive and concise, yet powerful enough to 19 | build complex projects. It is built on the low-level ARM CMSIS APIs, 20 | allowing you to code down to the metal if needed. In addition to RTOS, 21 | USB and Networking libraries, a cookbook of hundreds of reusable 22 | peripheral and module libraries have been built on top of the SDK by 23 | the mbed Developer Community. 24 | 25 | http://mbed.org/ 26 | """ 27 | 28 | from os.path import join 29 | 30 | from SCons.Script import Import, SConscript 31 | 32 | Import("env") 33 | 34 | # https://github.com/platformio/builder-framework-mbed.git 35 | SConscript( 36 | join(env.PioPlatform().get_package_dir("framework-mbed"), "platformio", 37 | "platformio-build.py")) 38 | -------------------------------------------------------------------------------- /builder/frameworks/zephyr.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019-present PlatformIO 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | The Zephyr Project is a scalable real-time operating system (RTOS) supporting multiple 16 | hardware architectures, optimized for resource constrained devices, and built with 17 | safety and security in mind. 18 | 19 | https://github.com/zephyrproject-rtos/zephyr 20 | """ 21 | 22 | from os.path import join 23 | 24 | from SCons.Script import Import, SConscript 25 | 26 | Import("env") 27 | 28 | SConscript( 29 | join(env.PioPlatform().get_package_dir("framework-zephyr"), "scripts", 30 | "platformio", "platformio-build.py"), exports="env") 31 | -------------------------------------------------------------------------------- /examples/arduino-ble-led/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/arduino-ble-led/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd platform-nordicnrf52/examples/arduino-ble-led 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Clean build files 20 | $ pio run --target clean 21 | ``` 22 | -------------------------------------------------------------------------------- /examples/arduino-ble-led/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/arduino-ble-led/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/arduino-ble-led/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env] 11 | lib_deps = sandeepmistry/BLEPeripheral @ ^0.4.0 12 | lib_compat_mode = soft 13 | build_flags = -DNRF52_S132 14 | 15 | [env:nrf52_dk] 16 | platform = nordicnrf52 17 | framework = arduino 18 | board = nrf52_dk 19 | 20 | [env:redbear_blenano2] 21 | platform = nordicnrf52 22 | framework = arduino 23 | board = redbear_blenano2 24 | 25 | [env:stct_nrf52_minidev] 26 | platform = nordicnrf52 27 | framework = arduino 28 | board = stct_nrf52_minidev 29 | -------------------------------------------------------------------------------- /examples/arduino-ble-led/src/led.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Sandeep Mistry. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #include 5 | // Import libraries (BLEPeripheral depends on SPI) 6 | #include 7 | #include 8 | 9 | // LED pin 10 | #define LED_PIN LED_BUILTIN 11 | 12 | //custom boards may override default pin definitions with BLEPeripheral(PIN_REQ, PIN_RDY, PIN_RST) 13 | BLEPeripheral blePeripheral = BLEPeripheral(); 14 | 15 | // create service 16 | BLEService ledService = BLEService("19b10000e8f2537e4f6cd104768a1214"); 17 | 18 | // create switch characteristic 19 | BLECharCharacteristic switchCharacteristic = BLECharCharacteristic("19b10001e8f2537e4f6cd104768a1214", BLERead | BLEWrite); 20 | 21 | void setup() { 22 | Serial.begin(9600); 23 | #if defined (__AVR_ATmega32U4__) 24 | delay(5000); //5 seconds delay for enabling to see the start up comments on the serial board 25 | #endif 26 | 27 | // set LED pin to output mode 28 | pinMode(LED_PIN, OUTPUT); 29 | 30 | // set advertised local name and service UUID 31 | blePeripheral.setLocalName("LED"); 32 | blePeripheral.setAdvertisedServiceUuid(ledService.uuid()); 33 | 34 | // add service and characteristic 35 | blePeripheral.addAttribute(ledService); 36 | blePeripheral.addAttribute(switchCharacteristic); 37 | 38 | // begin initialization 39 | blePeripheral.begin(); 40 | 41 | Serial.println(F("BLE LED Peripheral")); 42 | } 43 | 44 | void loop() { 45 | BLECentral central = blePeripheral.central(); 46 | 47 | if (central) { 48 | // central connected to peripheral 49 | Serial.print(F("Connected to central: ")); 50 | Serial.println(central.address()); 51 | 52 | while (central.connected()) { 53 | // central still connected to peripheral 54 | if (switchCharacteristic.written()) { 55 | // central wrote new value to characteristic, update LED 56 | if (switchCharacteristic.value()) { 57 | Serial.println(F("LED on")); 58 | digitalWrite(LED_PIN, HIGH); 59 | } else { 60 | Serial.println(F("LED off")); 61 | digitalWrite(LED_PIN, LOW); 62 | } 63 | } 64 | } 65 | 66 | // central disconnected 67 | Serial.print(F("Disconnected from central: ")); 68 | Serial.println(central.address()); 69 | } 70 | } -------------------------------------------------------------------------------- /examples/arduino-ble-led/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/arduino-blink/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/arduino-blink/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd platform-nordicnrf52/examples/arduino-blink 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Clean build files 20 | $ pio run --target clean 21 | ``` 22 | -------------------------------------------------------------------------------- /examples/arduino-blink/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/arduino-blink/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/arduino-blink/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:bbcmicrobit_v2] 11 | platform = nordicnrf52 12 | framework = arduino 13 | board = bbcmicrobit_v2 14 | 15 | [env:calliopemini_v3] 16 | platform = nordicnrf52 17 | framework = arduino 18 | board = calliopemini_v3 19 | 20 | [env:nrf52_dk] 21 | platform = nordicnrf52 22 | framework = arduino 23 | board = nrf52_dk 24 | 25 | [env:delta_dfbm_nq620] 26 | platform = nordicnrf52 27 | framework = arduino 28 | board = delta_dfbm_nq620 29 | 30 | [env:redbear_blenano2] 31 | platform = nordicnrf52 32 | framework = arduino 33 | board = redbear_blenano2 34 | 35 | [env:redbear_blend2] 36 | platform = nordicnrf52 37 | framework = arduino 38 | board = redbear_blend2 39 | build_flags = -DNRF52_S132 40 | 41 | [env:stct_nrf52_minidev] 42 | platform = nordicnrf52 43 | framework = arduino 44 | board = stct_nrf52_minidev 45 | build_flags = -DNRF52_S132 46 | -------------------------------------------------------------------------------- /examples/arduino-blink/src/Blink.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Blink 3 | * Turns on an LED on for one second, 4 | * then off for one second, repeatedly. 5 | */ 6 | 7 | #include 8 | 9 | void setup() 10 | { 11 | // initialize LED digital pin as an output. 12 | pinMode(LED_BUILTIN, OUTPUT); 13 | } 14 | 15 | void loop() 16 | { 17 | // turn the LED on (HIGH is the voltage level) 18 | digitalWrite(LED_BUILTIN, HIGH); 19 | // wait for a second 20 | delay(100); 21 | // turn the LED off by making the voltage LOW 22 | digitalWrite(LED_BUILTIN, LOW); 23 | // wait for a second 24 | delay(100); 25 | } 26 | -------------------------------------------------------------------------------- /examples/arduino-blink/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/arduino-bluefruit-bleuart/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .pio 3 | .vscode -------------------------------------------------------------------------------- /examples/arduino-bluefruit-bleuart/.skiptest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/platformio/platform-nordicnrf52/51d75648d87315deb3cc22d80f2bc0e0dee6eee8/examples/arduino-bluefruit-bleuart/.skiptest -------------------------------------------------------------------------------- /examples/arduino-bluefruit-bleuart/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/arduino-bluefruit-bleuart/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/arduino-bluefruit-bleuart/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:adafruit_feather_nrf52832] 12 | platform = nordicnrf52 13 | framework = arduino 14 | board = adafruit_feather_nrf52832 15 | monitor_speed = 115200 16 | 17 | [env:adafruit_feather_nrf52840] 18 | platform = nordicnrf52 19 | framework = arduino 20 | board = adafruit_feather_nrf52840 21 | monitor_speed = 115200 22 | 23 | [env:nrf52840_dk_adafruit] 24 | platform = nordicnrf52 25 | framework = arduino 26 | board = nrf52840_dk_adafruit 27 | monitor_speed = 115200 28 | [env:adafruit_metro_nrf52840] 29 | platform = nordicnrf52 30 | framework = arduino 31 | board = adafruit_metro_nrf52840 32 | monitor_speed = 115200 33 | 34 | [env:adafruit_cplaynrf52840] 35 | platform = nordicnrf52 36 | framework = arduino 37 | board = adafruit_cplaynrf52840 38 | monitor_speed = 115200 39 | 40 | [env:particle_xenon] 41 | platform = nordicnrf52 42 | framework = arduino 43 | board = particle_xenon 44 | monitor_speed = 115200 45 | 46 | [env:adafruit_ledglasses_nrf52840] 47 | platform = nordicnrf52 48 | framework = arduino 49 | board = adafruit_ledglasses_nrf52840 50 | monitor_speed = 115200 51 | -------------------------------------------------------------------------------- /examples/arduino-bluefruit-bleuart/src/main.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | This is an example for our nRF52 based Bluefruit LE modules 3 | 4 | Pick one up today in the adafruit shop! 5 | 6 | Adafruit invests time and resources providing this open source code, 7 | please support Adafruit and open-source hardware by purchasing 8 | products from Adafruit! 9 | 10 | MIT license, check LICENSE for more information 11 | All text above, and the splash screen below must be included in 12 | any redistribution 13 | *********************************************************************/ 14 | #include 15 | 16 | // BLE Service 17 | BLEDfu bledfu; // OTA DFU service 18 | BLEDis bledis; // device information 19 | BLEUart bleuart; // uart over ble 20 | BLEBas blebas; // battery 21 | 22 | static void startAdv(void); 23 | static void connect_callback(uint16_t conn_handle); 24 | static void disconnect_callback(uint16_t conn_handle, uint8_t reason); 25 | 26 | void setup() 27 | { 28 | Serial.begin(115200); 29 | while ( !Serial ) delay(10); // for nrf52840 with native usb 30 | 31 | Serial.println("Bluefruit52 BLEUART Example"); 32 | Serial.println("---------------------------\n"); 33 | 34 | // Setup the BLE LED to be enabled on CONNECT 35 | // Note: This is actually the default behaviour, but provided 36 | // here in case you want to control this LED manually via PIN 19 37 | Bluefruit.autoConnLed(true); 38 | 39 | // Config the peripheral connection with maximum bandwidth 40 | // more SRAM required by SoftDevice 41 | // Note: All config***() function must be called before begin() 42 | Bluefruit.configPrphBandwidth(BANDWIDTH_MAX); 43 | 44 | Bluefruit.begin(); 45 | Bluefruit.setTxPower(4); // Check bluefruit.h for supported values 46 | Bluefruit.setName("Bluefruit52"); 47 | //Bluefruit.setName(getMcuUniqueID()); // useful testing with multiple central connections 48 | Bluefruit.Periph.setConnectCallback(connect_callback); 49 | Bluefruit.Periph.setDisconnectCallback(disconnect_callback); 50 | 51 | // To be consistent OTA DFU should be added first if it exists 52 | bledfu.begin(); 53 | 54 | // Configure and Start Device Information Service 55 | bledis.setManufacturer("Adafruit Industries"); 56 | bledis.setModel("Bluefruit Feather52"); 57 | bledis.begin(); 58 | 59 | // Configure and Start BLE Uart Service 60 | bleuart.begin(); 61 | 62 | // Start BLE Battery Service 63 | blebas.begin(); 64 | blebas.write(100); 65 | 66 | // Set up and start advertising 67 | startAdv(); 68 | 69 | Serial.println("Please use Adafruit's Bluefruit LE app to connect in UART mode"); 70 | Serial.println("Once connected, enter character(s) that you wish to send"); 71 | } 72 | 73 | void startAdv(void) 74 | { 75 | // Advertising packet 76 | Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); 77 | Bluefruit.Advertising.addTxPower(); 78 | 79 | // Include bleuart 128-bit uuid 80 | Bluefruit.Advertising.addService(bleuart); 81 | 82 | // Secondary Scan Response packet (optional) 83 | // Since there is no room for 'Name' in Advertising packet 84 | Bluefruit.ScanResponse.addName(); 85 | 86 | /* Start Advertising 87 | * - Enable auto advertising if disconnected 88 | * - Interval: fast mode = 20 ms, slow mode = 152.5 ms 89 | * - Timeout for fast mode is 30 seconds 90 | * - Start(timeout) with timeout = 0 will advertise forever (until connected) 91 | * 92 | * For recommended advertising interval 93 | * https://developer.apple.com/library/content/qa/qa1931/_index.html 94 | */ 95 | Bluefruit.Advertising.restartOnDisconnect(true); 96 | Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms 97 | Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode 98 | Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds 99 | } 100 | 101 | void loop() 102 | { 103 | // Forward data from HW Serial to BLEUART 104 | while (Serial.available()) 105 | { 106 | // Delay to wait for enough input, since we have a limited transmission buffer 107 | delay(2); 108 | 109 | uint8_t buf[64]; 110 | int count = Serial.readBytes(buf, sizeof(buf)); 111 | bleuart.write( buf, count ); 112 | } 113 | 114 | // Forward from BLEUART to HW Serial 115 | while ( bleuart.available() ) 116 | { 117 | uint8_t ch; 118 | ch = (uint8_t) bleuart.read(); 119 | Serial.write(ch); 120 | } 121 | } 122 | 123 | // callback invoked when central connects 124 | void connect_callback(uint16_t conn_handle) 125 | { 126 | // Get the reference to current connection 127 | BLEConnection* connection = Bluefruit.Connection(conn_handle); 128 | 129 | char central_name[32] = { 0 }; 130 | connection->getPeerName(central_name, sizeof(central_name)); 131 | 132 | Serial.print("Connected to "); 133 | Serial.println(central_name); 134 | } 135 | 136 | /** 137 | * Callback invoked when a connection is dropped 138 | * @param conn_handle connection where this event happens 139 | * @param reason is a BLE_HCI_STATUS_CODE which can be found in ble_hci.h 140 | */ 141 | void disconnect_callback(uint16_t conn_handle, uint8_t reason) 142 | { 143 | (void) conn_handle; 144 | (void) reason; 145 | 146 | Serial.println(); 147 | Serial.println("Disconnected"); 148 | } 149 | -------------------------------------------------------------------------------- /examples/arduino-bluefruit-bleuart/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/arduino-nina-b1-generic-example/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/arduino-nina-b1-generic-example/README.md: -------------------------------------------------------------------------------- 1 | # Arduino-u-blox-NINA-B1 2 | 3 | u-blox NINA-B1 Arduino example + SHT31 temperature and humidity + Bluetooth BLE 4 | 5 | [![GitHub version](https://img.shields.io/github/release/ldab/Arduino-u-blox-NINA-B1.svg)](https://github.com/ldab/Arduino-u-blox-NINA-B1/releases/latest) 6 | [![Build Status](https://travis-ci.org/ldab/Arduino-u-blox-NINA-B1.svg?branch=master)](https://travis-ci.org/ldab/Arduino-u-blox-NINA-B1) 7 | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/ldab/Arduino-u-blox-NINA-B1/blob/master/LICENSE) 8 | 9 | [![GitHub last commit](https://img.shields.io/github/last-commit/ldab/Arduino-u-blox-NINA-B1.svg?style=social)](https://github.com/ldab/Arduino-u-blox-NINA-B1) 10 | 11 | [![EVK-NINA-B1](https://www.u-blox.com/sites/default/files/styles/product_full/public/products/EVK-NINA-B1_2D-medium_RGB-CI.png)](https://www.u-blox.com/en/product/nina-b1-series) 12 | 13 | ## How to build PlatformIO based project 14 | 15 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 16 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 17 | 3. Extract ZIP archive 18 | 4. Run these commands: 19 | 20 | ``` 21 | # Change directory to example 22 | > cd platform-nordicnrf52/examples/Arduino-u-blox-NINA-B1 23 | 24 | # Build project 25 | > platformio run 26 | 27 | # Upload firmware 28 | > platformio run --target upload 29 | 30 | # Build specific environment 31 | > platformio run -e nina_b1 32 | 33 | # Upload firmware for the specific environment 34 | > platformio run -e nina_b1 --target upload 35 | 36 | # Clean build files 37 | > platformio run --target clean 38 | ``` 39 | 40 | ## Why? 41 | 42 | This example tries to implement some key functions and key PIN atributes in order to get you started with using Arduino and the NRF52832 BLE board u-blox NINA-B1. 43 | 44 | Timer functionas are implemented intead of `delay()` and the PINs have been re-mapped on the `#define` section 45 | 46 | ## Bluetooth iOS and Android app 47 | 48 | You can download the sample Bluetooth low energy app - BLE App straight from u-blox wesite: [https://www.u-blox.com/en/product/bluetooth-ios-and-android-app](https://www.u-blox.com/en/product/bluetooth-ios-and-android-app) 49 | 50 | ![App example](https://raw.githubusercontent.com/ldab/Arduino-u-blox-NINA-B1/master/extras/Screenshot_20190328-130832_u-blox%20BLE.jpg) 51 | 52 | ## fatal error: ble_gatts.h: No such file or directory 53 | 54 | The arduino-nRF5x core **REQUIRES** a SoftDevice in order to successfully use this library. Please see [Flashing a SoftDevice](https://github.com/sandeepmistry/arduino-nRF5#selecting-a-softdevice). 55 | 56 | On PlatformIO and when using this example you don't need to do anything special as the `build_flags = -DNRF52_S132` has already been included on `platform.ini` file. 57 | 58 | SoftDevices contain the BLE stack and housekeeping, and must be downloaded once before a sketch using BLE can be loaded. The SD consumes ~5k of Ram + some extra based on actual BLE configuration. 59 | 60 | * SoftDevice S132 v2.0.1 supports nRF52 in peripheral and central role. It is 112k in size. 61 | 62 | ## Credits 63 | 64 | Github Shields and Badges created with [Shields.io](https://github.com/badges/shields/) 65 | 66 | Sandeep Mistry's [Arduino BLE library](https://github.com/sandeepmistry/arduino-BLEPeripheral) 67 | 68 | Adafruit [SHT31 Library](https://www.adafruit.com/product/2857) 69 | 70 | u-blox NINA-B1 blueprint example [GitHub](https://github.com/u-blox/blueprint-B200-NINA-B1) 71 | 72 | u-blox official mBed [library](https://os.mbed.com/platforms/u-blox-EVK-NINA-B1/) 73 | -------------------------------------------------------------------------------- /examples/arduino-nina-b1-generic-example/extras/Screenshot_20190328-130832_u-blox BLE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/platformio/platform-nordicnrf52/51d75648d87315deb3cc22d80f2bc0e0dee6eee8/examples/arduino-nina-b1-generic-example/extras/Screenshot_20190328-130832_u-blox BLE.jpg -------------------------------------------------------------------------------- /examples/arduino-nina-b1-generic-example/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:nina_b1] 12 | platform = nordicnrf52 13 | board = ublox_evk_nina_b1 14 | framework = arduino 15 | 16 | build_flags = -DNRF52_S132 17 | 18 | lib_compat_mode = soft 19 | lib_deps = 20 | SPI 21 | adafruit/Adafruit SHT31 Library @ ^2.0.0 22 | sstaub/Ticker @ ^3.2.0 23 | sandeepmistry/BLEPeripheral @ ^0.4.0 24 | 25 | monitor_speed = 115200 26 | 27 | # upload_protocol = blackmagic 28 | -------------------------------------------------------------------------------- /examples/arduino-serial-plotter/.gitignore: -------------------------------------------------------------------------------- 1 | .pio -------------------------------------------------------------------------------- /examples/arduino-serial-plotter/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd platform-nordicnrf52/examples/arduino-serial-plotter 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Clean build files 20 | $ pio run --target clean 21 | ``` 22 | -------------------------------------------------------------------------------- /examples/arduino-serial-plotter/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/arduino-serial-plotter/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/arduino-serial-plotter/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:nano33ble] 11 | platform = nordicnrf52 12 | framework = arduino 13 | board = nano33ble 14 | -------------------------------------------------------------------------------- /examples/arduino-serial-plotter/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This example reads audio data from the on-board PDM microphones, and prints 3 | out the samples to the Serial console. The Serial Plotter built into the 4 | Arduino IDE can be used to plot the audio data (Tools -> Serial Plotter) 5 | 6 | Circuit: 7 | - Arduino Nano 33 BLE board 8 | 9 | This example code is in the public domain. 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | // buffer to read samples into, each sample is 16-bits 16 | short sampleBuffer[256]; 17 | 18 | void onPDMdata(); 19 | 20 | // number of samples read 21 | volatile int samplesRead; 22 | 23 | void setup() { 24 | Serial.begin(9600); 25 | while (!Serial); 26 | 27 | // configure the data receive callback 28 | PDM.onReceive(onPDMdata); 29 | 30 | // optionally set the gain, defaults to 20 31 | // PDM.setGain(30); 32 | 33 | // initialize PDM with: 34 | // - one channel (mono mode) 35 | // - a 16 kHz sample rate 36 | if (!PDM.begin(1, 16000)) { 37 | Serial.println("Failed to start PDM!"); 38 | while (1); 39 | } 40 | } 41 | 42 | void loop() { 43 | // wait for samples to be read 44 | if (samplesRead) { 45 | 46 | // print samples to the serial monitor or plotter 47 | for (int i = 0; i < samplesRead; i++) { 48 | Serial.println(sampleBuffer[i]); 49 | } 50 | 51 | // clear the read count 52 | samplesRead = 0; 53 | } 54 | } 55 | 56 | void onPDMdata() { 57 | // query the number of bytes available 58 | int bytesAvailable = PDM.available(); 59 | 60 | // read into the sample buffer 61 | PDM.read(sampleBuffer, bytesAvailable); 62 | 63 | // 16-bit, 2 bytes per sample 64 | samplesRead = bytesAvailable / 2; 65 | } -------------------------------------------------------------------------------- /examples/arduino-serial-plotter/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/mbed-rtos-ble-battery/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/mbed-rtos-ble-battery/.mbedignore: -------------------------------------------------------------------------------- 1 | mbed-os/connectivity/cellular/* 2 | mbed-os/connectivity/libraries/* 3 | mbed-os/connectivity/drivers/* 4 | mbed-os/connectivity/lorawan/* 5 | mbed-os/connectivity/lwipstack/* 6 | mbed-os/connectivity/mbedtls/* 7 | mbed-os/connectivity/nanostack/* 8 | mbed-os/connectivity/netsocket/* 9 | mbed-os/features/* 10 | mbed-os/storage/* 11 | -------------------------------------------------------------------------------- /examples/mbed-rtos-ble-battery/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd platform-nordicnrf52/examples/mbed-legacy-examples/mbed-rtos-ble-battery 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e nrf52_dk 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e nrf52_dk --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/mbed-rtos-ble-battery/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/mbed-rtos-ble-battery/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/mbed-rtos-ble-battery/mbed_app.json: -------------------------------------------------------------------------------- 1 | { 2 | "target_overrides": { 3 | "*": { 4 | "platform.stdio-baud-rate": 115200, 5 | "mbed-trace.enable": false, 6 | "mbed-trace.max-level": "TRACE_LEVEL_DEBUG", 7 | "cordio.trace-hci-packets": false, 8 | "cordio.trace-cordio-wsf-traces": false, 9 | "ble.trace-human-readable-enums": false 10 | }, 11 | "K64F": { 12 | "target.components_add": ["BlueNRG_MS"], 13 | "target.features_add": ["BLE"], 14 | "target.extra_labels_add": ["CORDIO"] 15 | }, 16 | "NUCLEO_F401RE": { 17 | "target.components_add": ["BlueNRG_MS"], 18 | "target.features_add": ["BLE"], 19 | "target.extra_labels_add": ["CORDIO"] 20 | }, 21 | "NRF52840_DK": { 22 | "target.features_add": ["BLE"] 23 | }, 24 | "NRF52_DK": { 25 | "target.features_add": ["BLE"] 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/mbed-rtos-ble-battery/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:nrf52_dk] 11 | platform = nordicnrf52 12 | framework = mbed 13 | board = nrf52_dk 14 | 15 | [env:nrf52840_dk] 16 | platform = nordicnrf52 17 | framework = mbed 18 | board = nrf52840_dk 19 | -------------------------------------------------------------------------------- /examples/mbed-rtos-ble-battery/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2019 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "ble/BLE.h" 19 | #include "ble/Gap.h" 20 | #include "pretty_printer.h" 21 | #include "mbed-trace/mbed_trace.h" 22 | 23 | const static char DEVICE_NAME[] = "BATTERY"; 24 | 25 | using namespace std::literals::chrono_literals; 26 | 27 | static events::EventQueue event_queue(/* event count */ 16 * EVENTS_EVENT_SIZE); 28 | 29 | class BatteryDemo : ble::Gap::EventHandler { 30 | public: 31 | BatteryDemo(BLE &ble, events::EventQueue &event_queue) : 32 | _ble(ble), 33 | _event_queue(event_queue), 34 | _battery_level(50), 35 | _adv_data_builder(_adv_buffer) 36 | { 37 | } 38 | 39 | void start() 40 | { 41 | /* mbed will call on_init_complete when when ble is ready */ 42 | _ble.init(this, &BatteryDemo::on_init_complete); 43 | 44 | /* this will never return */ 45 | _event_queue.dispatch_forever(); 46 | } 47 | 48 | private: 49 | /** Callback triggered when the ble initialization process has finished */ 50 | void on_init_complete(BLE::InitializationCompleteCallbackContext *params) 51 | { 52 | if (params->error != BLE_ERROR_NONE) { 53 | print_error(params->error, "Ble initialization failed."); 54 | return; 55 | } 56 | 57 | print_mac_address(); 58 | 59 | start_advertising(); 60 | } 61 | 62 | void start_advertising() 63 | { 64 | /* create advertising parameters and payload */ 65 | 66 | ble::AdvertisingParameters adv_parameters( 67 | /* you cannot connect to this device, you can only read its advertising data, 68 | * scannable means that the device has extra advertising data that the peer can receive if it 69 | * "scans" it which means it is using active scanning (it sends a scan request) */ 70 | ble::advertising_type_t::SCANNABLE_UNDIRECTED, 71 | ble::adv_interval_t(ble::millisecond_t(1000)) 72 | ); 73 | 74 | /* when advertising you can optionally add extra data that is only sent 75 | * if the central requests it by doing active scanning (sending scan requests), 76 | * in this example we set this payload first because we want to later reuse 77 | * the same _adv_data_builder builder for payload updates */ 78 | 79 | const uint8_t _vendor_specific_data[4] = { 0xAD, 0xDE, 0xBE, 0xEF }; 80 | _adv_data_builder.setManufacturerSpecificData(_vendor_specific_data); 81 | 82 | _ble.gap().setAdvertisingScanResponse( 83 | ble::LEGACY_ADVERTISING_HANDLE, 84 | _adv_data_builder.getAdvertisingData() 85 | ); 86 | 87 | /* now we set the advertising payload that gets sent during advertising without any scan requests */ 88 | 89 | _adv_data_builder.clear(); 90 | _adv_data_builder.setFlags(); 91 | _adv_data_builder.setName(DEVICE_NAME); 92 | 93 | /* we add the battery level as part of the payload so it's visible to any device that scans, 94 | * this part of the payload will be updated periodically without affecting the rest of the payload */ 95 | _adv_data_builder.setServiceData(GattService::UUID_BATTERY_SERVICE, {&_battery_level, 1}); 96 | 97 | /* setup advertising */ 98 | 99 | ble_error_t error = _ble.gap().setAdvertisingParameters( 100 | ble::LEGACY_ADVERTISING_HANDLE, 101 | adv_parameters 102 | ); 103 | 104 | if (error) { 105 | print_error(error, "_ble.gap().setAdvertisingParameters() failed"); 106 | return; 107 | } 108 | 109 | error = _ble.gap().setAdvertisingPayload( 110 | ble::LEGACY_ADVERTISING_HANDLE, 111 | _adv_data_builder.getAdvertisingData() 112 | ); 113 | 114 | if (error) { 115 | print_error(error, "_ble.gap().setAdvertisingPayload() failed"); 116 | return; 117 | } 118 | 119 | /* start advertising */ 120 | 121 | error = _ble.gap().startAdvertising(ble::LEGACY_ADVERTISING_HANDLE); 122 | 123 | if (error) { 124 | print_error(error, "_ble.gap().startAdvertising() failed"); 125 | return; 126 | } 127 | 128 | /* we simulate battery discharging by updating it every second */ 129 | _event_queue.call_every( 130 | 1000ms, 131 | [this]() { 132 | update_battery_level(); 133 | } 134 | ); 135 | } 136 | 137 | void update_battery_level() 138 | { 139 | if (_battery_level-- == 10) { 140 | _battery_level = 100; 141 | } 142 | 143 | /* update the payload with the new value of the bettery level, the rest of the payload remains the same */ 144 | ble_error_t error = _adv_data_builder.setServiceData(GattService::UUID_BATTERY_SERVICE, make_Span(&_battery_level, 1)); 145 | 146 | if (error) { 147 | print_error(error, "_adv_data_builder.setServiceData() failed"); 148 | return; 149 | } 150 | 151 | /* set the new payload, we don't need to stop advertising */ 152 | error = _ble.gap().setAdvertisingPayload( 153 | ble::LEGACY_ADVERTISING_HANDLE, 154 | _adv_data_builder.getAdvertisingData() 155 | ); 156 | 157 | if (error) { 158 | print_error(error, "_ble.gap().setAdvertisingPayload() failed"); 159 | return; 160 | } 161 | } 162 | 163 | private: 164 | BLE &_ble; 165 | events::EventQueue &_event_queue; 166 | 167 | uint8_t _battery_level; 168 | 169 | uint8_t _adv_buffer[ble::LEGACY_ADVERTISING_MAX_SIZE]; 170 | ble::AdvertisingDataBuilder _adv_data_builder; 171 | }; 172 | 173 | /* Schedule processing of events from the BLE middleware in the event queue. */ 174 | void schedule_ble_events(BLE::OnEventsToProcessCallbackContext *context) 175 | { 176 | event_queue.call(Callback(&context->ble, &BLE::processEvents)); 177 | } 178 | 179 | int main() 180 | { 181 | mbed_trace_init(); 182 | 183 | BLE &ble = BLE::Instance(); 184 | ble.onEventsToProcess(schedule_ble_events); 185 | 186 | BatteryDemo demo(ble, event_queue); 187 | demo.start(); 188 | 189 | return 0; 190 | } 191 | -------------------------------------------------------------------------------- /examples/mbed-rtos-ble-battery/src/pretty_printer.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2018 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "ble/BLE.h" 19 | 20 | inline void print_error(ble_error_t error, const char* msg) 21 | { 22 | printf("%s: ", msg); 23 | switch(error) { 24 | case BLE_ERROR_NONE: 25 | printf("BLE_ERROR_NONE: No error"); 26 | break; 27 | case BLE_ERROR_BUFFER_OVERFLOW: 28 | printf("BLE_ERROR_BUFFER_OVERFLOW: The requested action would cause a buffer overflow and has been aborted"); 29 | break; 30 | case BLE_ERROR_NOT_IMPLEMENTED: 31 | printf("BLE_ERROR_NOT_IMPLEMENTED: Requested a feature that isn't yet implement or isn't supported by the target HW"); 32 | break; 33 | case BLE_ERROR_PARAM_OUT_OF_RANGE: 34 | printf("BLE_ERROR_PARAM_OUT_OF_RANGE: One of the supplied parameters is outside the valid range"); 35 | break; 36 | case BLE_ERROR_INVALID_PARAM: 37 | printf("BLE_ERROR_INVALID_PARAM: One of the supplied parameters is invalid"); 38 | break; 39 | case BLE_STACK_BUSY: 40 | printf("BLE_STACK_BUSY: The stack is busy"); 41 | break; 42 | case BLE_ERROR_INVALID_STATE: 43 | printf("BLE_ERROR_INVALID_STATE: Invalid state"); 44 | break; 45 | case BLE_ERROR_NO_MEM: 46 | printf("BLE_ERROR_NO_MEM: Out of Memory"); 47 | break; 48 | case BLE_ERROR_OPERATION_NOT_PERMITTED: 49 | printf("BLE_ERROR_OPERATION_NOT_PERMITTED"); 50 | break; 51 | case BLE_ERROR_INITIALIZATION_INCOMPLETE: 52 | printf("BLE_ERROR_INITIALIZATION_INCOMPLETE"); 53 | break; 54 | case BLE_ERROR_ALREADY_INITIALIZED: 55 | printf("BLE_ERROR_ALREADY_INITIALIZED"); 56 | break; 57 | case BLE_ERROR_UNSPECIFIED: 58 | printf("BLE_ERROR_UNSPECIFIED: Unknown error"); 59 | break; 60 | case BLE_ERROR_INTERNAL_STACK_FAILURE: 61 | printf("BLE_ERROR_INTERNAL_STACK_FAILURE: internal stack failure"); 62 | break; 63 | case BLE_ERROR_NOT_FOUND: 64 | printf("BLE_ERROR_NOT_FOUND"); 65 | break; 66 | default: 67 | printf("Unknown error"); 68 | } 69 | printf("\r\n"); 70 | } 71 | 72 | /** print device address to the terminal */ 73 | inline void print_address(const ble::address_t &addr) 74 | { 75 | printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n", 76 | addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]); 77 | } 78 | 79 | inline void print_mac_address() 80 | { 81 | /* Print out device MAC address to the console*/ 82 | ble::own_address_type_t addr_type; 83 | ble::address_t address; 84 | BLE::Instance().gap().getAddress(addr_type, address); 85 | printf("DEVICE MAC ADDRESS: "); 86 | print_address(address); 87 | } 88 | 89 | inline const char* phy_to_string(ble::phy_t phy) { 90 | switch(phy.value()) { 91 | case ble::phy_t::LE_1M: 92 | return "LE 1M"; 93 | case ble::phy_t::LE_2M: 94 | return "LE 2M"; 95 | case ble::phy_t::LE_CODED: 96 | return "LE coded"; 97 | default: 98 | return "invalid PHY"; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /examples/mbed-rtos-ble-battery/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/mbed-rtos-blink-baremetal/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/mbed-rtos-blink-baremetal/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd platform-nordicnrf52/examples/mbed-rtos-blink-baremetal 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e nrf52_dk 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e nrf52_dk --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/mbed-rtos-blink-baremetal/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/mbed-rtos-blink-baremetal/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/mbed-rtos-blink-baremetal/mbed_app.json: -------------------------------------------------------------------------------- 1 | { 2 | "requires": ["bare-metal"], 3 | "target_overrides": { 4 | "*": { 5 | "target.c_lib": "small", 6 | "target.printf_lib": "minimal-printf", 7 | "platform.minimal-printf-enable-floating-point": false, 8 | "platform.stdio-minimal-console-only": true 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/mbed-rtos-blink-baremetal/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:nrf52_dk] 11 | platform = nordicnrf52 12 | framework = mbed 13 | board = nrf52_dk 14 | 15 | [env:nrf52840_dk] 16 | platform = nordicnrf52 17 | framework = mbed 18 | board = nrf52840_dk 19 | -------------------------------------------------------------------------------- /examples/mbed-rtos-blink-baremetal/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2019 ARM Limited 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | #include "mbed.h" 7 | 8 | #define WAIT_TIME_MS 500 9 | DigitalOut led1(LED1); 10 | 11 | int main() 12 | { 13 | printf("This is the bare metal blinky example running on Mbed OS %d.%d.%d.\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); 14 | 15 | while (true) 16 | { 17 | led1 = !led1; 18 | thread_sleep_for(WAIT_TIME_MS); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/mbed-rtos-blink-baremetal/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/mbed-rtos-nfc/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /examples/mbed-rtos-nfc/.mbedignore: -------------------------------------------------------------------------------- 1 | mbed-os/connectivity/cellular/* 2 | mbed-os/connectivity/FEATURE_BLE/* 3 | mbed-os/connectivity/libraries/* 4 | mbed-os/connectivity/lorawan/* 5 | mbed-os/connectivity/lwipstack/* 6 | mbed-os/connectivity/mbedtls/* 7 | mbed-os/connectivity/nanostack/* 8 | mbed-os/connectivity/netsocket/* 9 | mbed-os/features/* 10 | mbed-os/storage/* 11 | -------------------------------------------------------------------------------- /examples/mbed-rtos-nfc/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd platform-nordicnrf52/examples/mbed-rtos-nfc 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e nrf52_dk 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e nrf52_dk --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/mbed-rtos-nfc/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/mbed-rtos-nfc/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/mbed-rtos-nfc/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:nrf52_dk] 11 | platform = nordicnrf52 12 | framework = mbed 13 | board = nrf52_dk 14 | 15 | [env:nrf52840_dk] 16 | platform = nordicnrf52 17 | framework = mbed 18 | board = nrf52840_dk 19 | -------------------------------------------------------------------------------- /examples/mbed-rtos-nfc/src/SmartPoster.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2018-2018 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SMARTPOSTER_H_ 18 | #define SMARTPOSTER_H_ 19 | 20 | #include "nfc/ndef/common/Text.h" 21 | #include "nfc/ndef/common/URI.h" 22 | #include "nfc/ndef/common/Mime.h" 23 | #include "nfc/ndef/MessageBuilder.h" 24 | 25 | /** 26 | * Smart poster object. 27 | * 28 | * A smart poster is one of the basic use case of NFC. It encapsulates a URI to 29 | * a resource and meta-data of the resource. 30 | * 31 | * Meta-data are optional, they can be: 32 | * - title: name of the resource 33 | * - icon: image/media associated to the resource 34 | * - action: Action the peer should execute upon reception of the smart poster 35 | * - size: The size of the resource. 36 | * - type: Mime type of the resource. 37 | * 38 | * @note It obeys to value semantic and can be copied around. 39 | */ 40 | class SmartPoster { 41 | public: 42 | typedef mbed::nfc::ndef::common::Mime Mime; 43 | typedef mbed::nfc::ndef::common::Text Text; 44 | typedef mbed::nfc::ndef::common::URI URI; 45 | typedef mbed::nfc::ndef::MessageBuilder MessageBuilder; 46 | 47 | /** 48 | * Type of actions that should be executed upon smart poster reception. 49 | */ 50 | enum action_t { 51 | EXECUTE,//!< EXECUTE 52 | SAVE, //!< SAVE 53 | EDIT //!< EDIT 54 | }; 55 | 56 | /** 57 | * Construct a smart poster. 58 | * 59 | * @param uri The URI to the resource. 60 | */ 61 | SmartPoster(const URI &uri); 62 | 63 | /** 64 | * Set the title of the resource. 65 | * 66 | * @param text The title of the resource to set. 67 | */ 68 | void set_title(const Text &text); 69 | 70 | /** 71 | * Set the icon of the resource. 72 | * 73 | * @param icon The icon to set. 74 | */ 75 | void set_icon(const Mime &icon); 76 | 77 | /** 78 | * Set the action to trigger upon smart poster reception. 79 | * 80 | * @param action The action to do upon reception. 81 | */ 82 | void set_action(action_t action); 83 | 84 | /** 85 | * Set the size of the resource. 86 | * 87 | * @param size The size of the resource. 88 | */ 89 | void set_resource_size(uint32_t size); 90 | 91 | /** 92 | * Set the type of the resource. 93 | * 94 | * @param resource_type The type of the resource pointed by the URI. 95 | */ 96 | void set_resource_type(mbed::Span &resource_type); 97 | 98 | /** 99 | * Append the smart poster as a ndef record. 100 | * 101 | * @param ndef_builder The message builder where the record is appended. 102 | * @param is_last_record Indicates if this message is the last one. 103 | * 104 | * @return true if the message has been appended to the builder or false 105 | * otherwise. 106 | */ 107 | bool append_record(MessageBuilder &ndef_builder, bool is_last_record) const; 108 | 109 | private: 110 | void append_uri(MessageBuilder &builder) const; 111 | size_t get_uri_record_size() const; 112 | 113 | void append_title(MessageBuilder &builder) const; 114 | size_t get_title_record_size() const; 115 | 116 | void append_icon(MessageBuilder &builder) const; 117 | size_t get_icon_record_size() const; 118 | 119 | void append_action(MessageBuilder &builder) const; 120 | size_t get_action_record_size() const; 121 | 122 | void append_resource_size(MessageBuilder &builder) const; 123 | size_t get_resource_size_record_size() const; 124 | 125 | void append_type(MessageBuilder &builder) const; 126 | size_t get_type_record_size() const; 127 | 128 | URI _uri; 129 | Text _title; 130 | Mime _icon; 131 | action_t _action; 132 | uint32_t _resource_size; 133 | Text _type; 134 | 135 | bool _action_set:1; 136 | bool _resource_size_set:1; 137 | }; 138 | 139 | 140 | #endif /* SMARTPOSTER_H_ */ 141 | -------------------------------------------------------------------------------- /examples/mbed-rtos-nfc/src/main.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2018-2018 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "events/EventQueue.h" 20 | 21 | #include "nfc/controllers/PN512Driver.h" 22 | #include "nfc/controllers/PN512SPITransportDriver.h" 23 | #include "nfc/NFCRemoteInitiator.h" 24 | #include "nfc/NFCController.h" 25 | 26 | #include "nfc/ndef/MessageBuilder.h" 27 | #include "nfc/ndef/common/util.h" 28 | 29 | #include "SmartPoster.h" 30 | 31 | using events::EventQueue; 32 | 33 | using mbed::Span; 34 | using mbed::nfc::NFCRemoteInitiator; 35 | using mbed::nfc::NFCController; 36 | using mbed::nfc::nfc_rf_protocols_bitmask_t; 37 | using mbed::nfc::ndef::MessageBuilder; 38 | using mbed::nfc::ndef::common::Text; 39 | using mbed::nfc::ndef::common::URI; 40 | using mbed::nfc::ndef::common::span_from_cstr; 41 | 42 | /** 43 | * Manage the NFC discovery process and the local device operating in target mode. 44 | * 45 | * When a remote initiator has been discovered, it connects to it then reply 46 | * to its ndef message request with a smart poster message that contains: 47 | * - A URI: https://www.mbed.com 48 | * - A title: mbed website 49 | * - An action: EXECUTE which opens the browser of the peer with the URI 50 | * transmitted. 51 | */ 52 | class NFCProcess : NFCRemoteInitiator::Delegate, NFCController::Delegate { 53 | public: 54 | /** 55 | * Construct a new NFCProcess objects. 56 | * 57 | * This function construct the NFC controller and wires it with the PN512 58 | * driver. 59 | * 60 | * @param queue The event queue that will be used by the NFCController. 61 | */ 62 | NFCProcess(events::EventQueue &queue) : 63 | _pn512_transport(D11, D12, D13, D10, A1, A0), 64 | _pn512_driver(&_pn512_transport), 65 | _queue(queue), 66 | _ndef_buffer(), 67 | _nfc_controller(&_pn512_driver, &queue, _ndef_buffer) 68 | { } 69 | 70 | /** 71 | * Initialise and configure the NFC controller. 72 | * 73 | * @return NFC_OK in case of success or a meaningful error code in case of 74 | * failure. 75 | */ 76 | nfc_err_t init() 77 | { 78 | nfc_err_t err = _nfc_controller.initialize(); 79 | if (err) { 80 | return err; 81 | } 82 | 83 | // register callbacks 84 | _nfc_controller.set_delegate(this); 85 | 86 | nfc_rf_protocols_bitmask_t protocols = { 0 }; 87 | protocols.target_iso_dep = 1; 88 | return _nfc_controller.configure_rf_protocols(protocols); 89 | } 90 | 91 | /** 92 | * Start the discovery of peers. 93 | * 94 | * @return NFC_OK in case of success or a meaningful error code in case of 95 | * failure. 96 | */ 97 | nfc_err_t start_discovery() 98 | { 99 | return _nfc_controller.start_discovery(); 100 | } 101 | 102 | private: 103 | /* ------------------------------------------------------------------------ 104 | * Implementation of NFCRemoteInitiator::Delegate 105 | */ 106 | virtual void on_connected() { } 107 | 108 | virtual void on_disconnected() 109 | { 110 | // reset the state of the remote initiator 111 | _nfc_remote_initiator->set_delegate(NULL); 112 | _nfc_remote_initiator.reset(); 113 | 114 | // restart peer discovery 115 | _nfc_controller.start_discovery(); 116 | } 117 | 118 | virtual void parse_ndef_message(const Span &buffer) { } 119 | 120 | virtual size_t build_ndef_message(const Span &buffer) 121 | { 122 | // build the smart poster object we want to send 123 | SmartPoster smart_poster( 124 | URI(URI::HTTPS_WWW, span_from_cstr("mbed.com")) 125 | ); 126 | smart_poster.set_title( 127 | Text(Text::UTF8, span_from_cstr("en-US"), span_from_cstr("mbed website")) 128 | ); 129 | smart_poster.set_action(SmartPoster::EXECUTE); 130 | 131 | // serialize the smart poster into an ndef message operating on the 132 | // buffer in input. 133 | MessageBuilder builder(buffer); 134 | smart_poster.append_record(builder, /* last ? */ true); 135 | 136 | return builder.get_message().size(); 137 | } 138 | 139 | /* ------------------------------------------------------------------------ 140 | * Implementation of NFCController::Delegate 141 | */ 142 | virtual void on_discovery_terminated(nfc_discovery_terminated_reason_t reason) 143 | { 144 | if(reason != nfc_discovery_terminated_completed) { 145 | _nfc_controller.start_discovery(); 146 | } 147 | } 148 | 149 | virtual void on_nfc_initiator_discovered(const SharedPtr &nfc_initiator) 150 | { 151 | // setup the local remote initiator 152 | _nfc_remote_initiator = nfc_initiator; 153 | _nfc_remote_initiator->set_delegate(this); 154 | _nfc_remote_initiator->connect(); 155 | } 156 | 157 | mbed::nfc::PN512SPITransportDriver _pn512_transport; 158 | mbed::nfc::PN512Driver _pn512_driver; 159 | EventQueue& _queue; 160 | uint8_t _ndef_buffer[1024]; 161 | NFCController _nfc_controller; 162 | SharedPtr _nfc_remote_initiator; 163 | }; 164 | 165 | int main() 166 | { 167 | events::EventQueue queue; 168 | NFCProcess nfc_process(queue); 169 | 170 | nfc_err_t ret = nfc_process.init(); 171 | printf("Initialize: ret = %u\r\n", ret); 172 | 173 | ret = nfc_process.start_discovery(); 174 | printf("Start Discovery: ret = %u\r\n", ret); 175 | 176 | queue.dispatch_forever(); 177 | 178 | return 0; 179 | } -------------------------------------------------------------------------------- /examples/mbed-rtos-nfc/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/zephyr-ble-beacon/.gitignore: -------------------------------------------------------------------------------- 1 | .pio -------------------------------------------------------------------------------- /examples/zephyr-ble-beacon/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd platform-nordicnrf52/examples/zephyr-ble-beacon 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e nrf52_dk 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e nrf52_dk --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/zephyr-ble-beacon/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/zephyr-ble-beacon/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/zephyr-ble-beacon/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:nrf52840_dk] 11 | platform = nordicnrf52 12 | framework = zephyr 13 | board = nrf52840_dk 14 | monitor_speed = 115200 15 | 16 | [env:particle_xenon] 17 | platform = nordicnrf52 18 | framework = zephyr 19 | board = particle_xenon 20 | monitor_speed = 115200 21 | -------------------------------------------------------------------------------- /examples/zephyr-ble-beacon/src/main.c: -------------------------------------------------------------------------------- 1 | /* main.c - Application main entry point */ 2 | 3 | /* 4 | * Copyright (c) 2015-2016 Intel Corporation 5 | * 6 | * SPDX-License-Identifier: Apache-2.0 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | #define DEVICE_NAME CONFIG_BT_DEVICE_NAME 18 | #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) 19 | 20 | /* 21 | * Set Advertisement data. Based on the Eddystone specification: 22 | * https://github.com/google/eddystone/blob/master/protocol-specification.md 23 | * https://github.com/google/eddystone/tree/master/eddystone-url 24 | */ 25 | static const struct bt_data ad[] = { 26 | BT_DATA_BYTES(BT_DATA_FLAGS, BT_LE_AD_NO_BREDR), 27 | BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0xaa, 0xfe), 28 | BT_DATA_BYTES(BT_DATA_SVC_DATA16, 29 | 0xaa, 0xfe, /* Eddystone UUID */ 30 | 0x10, /* Eddystone-URL frame type */ 31 | 0x00, /* Calibrated Tx power at 0m */ 32 | 0x00, /* URL Scheme Prefix http://www. */ 33 | 'z', 'e', 'p', 'h', 'y', 'r', 34 | 'p', 'r', 'o', 'j', 'e', 'c', 't', 35 | 0x08) /* .org */ 36 | }; 37 | 38 | /* Set Scan Response data */ 39 | static const struct bt_data sd[] = { 40 | BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN), 41 | }; 42 | 43 | static void bt_ready(int err) 44 | { 45 | char addr_s[BT_ADDR_LE_STR_LEN]; 46 | bt_addr_le_t addr = {0}; 47 | size_t count = 1; 48 | 49 | if (err) { 50 | printk("Bluetooth init failed (err %d)\n", err); 51 | return; 52 | } 53 | 54 | printk("Bluetooth initialized\n"); 55 | 56 | /* Start advertising */ 57 | err = bt_le_adv_start(BT_LE_ADV_NCONN_IDENTITY, ad, ARRAY_SIZE(ad), 58 | sd, ARRAY_SIZE(sd)); 59 | if (err) { 60 | printk("Advertising failed to start (err %d)\n", err); 61 | return; 62 | } 63 | 64 | 65 | /* For connectable advertising you would use 66 | * bt_le_oob_get_local(). For non-connectable non-identity 67 | * advertising an non-resolvable private address is used; 68 | * there is no API to retrieve that. 69 | */ 70 | 71 | bt_id_get(&addr, &count); 72 | bt_addr_le_to_str(&addr, addr_s, sizeof(addr_s)); 73 | 74 | printk("Beacon started, advertising as %s\n", addr_s); 75 | } 76 | 77 | void main(void) 78 | { 79 | int err; 80 | 81 | printk("Starting Beacon Demo\n"); 82 | 83 | /* Initialize the Bluetooth Subsystem */ 84 | err = bt_enable(bt_ready); 85 | if (err) { 86 | printk("Bluetooth init failed (err %d)\n", err); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /examples/zephyr-ble-beacon/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/zephyr-ble-beacon/zephyr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.13.1) 4 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 5 | project(beacon) 6 | 7 | target_sources(app PRIVATE ../src/main.c) 8 | -------------------------------------------------------------------------------- /examples/zephyr-ble-beacon/zephyr/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=y 2 | CONFIG_BT_DEBUG_LOG=y 3 | CONFIG_BT_DEVICE_NAME="Test beacon" 4 | -------------------------------------------------------------------------------- /examples/zephyr-blink/.gitignore: -------------------------------------------------------------------------------- 1 | .pio -------------------------------------------------------------------------------- /examples/zephyr-blink/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd platform-nordicnrf52/examples/zephyr-blink 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e nrf52_dk 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e nrf52_dk --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/zephyr-blink/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/zephyr-blink/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/zephyr-blink/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:adafruit_feather_nrf52832] 11 | platform = nordicnrf52 12 | framework = zephyr 13 | board = adafruit_feather_nrf52832 14 | 15 | [env:nrf52_dk] 16 | platform = nordicnrf52 17 | framework = zephyr 18 | board = nrf52_dk 19 | 20 | [env:nrf52840_dk] 21 | platform = nordicnrf52 22 | framework = zephyr 23 | board = nrf52840_dk 24 | 25 | [env:particle_xenon] 26 | platform = nordicnrf52 27 | framework = zephyr 28 | board = particle_xenon 29 | -------------------------------------------------------------------------------- /examples/zephyr-blink/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /* 1000 msec = 1 sec */ 13 | #define SLEEP_TIME_MS 1000 14 | 15 | /* The devicetree node identifier for the "led0" alias. */ 16 | #define LED0_NODE DT_ALIAS(led0) 17 | 18 | #if DT_NODE_HAS_STATUS(LED0_NODE, okay) 19 | #define LED0 DT_GPIO_LABEL(LED0_NODE, gpios) 20 | #define PIN DT_GPIO_PIN(LED0_NODE, gpios) 21 | #define FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios) 22 | #else 23 | /* A build error here means your board isn't set up to blink an LED. */ 24 | #error "Unsupported board: led0 devicetree alias is not defined" 25 | #define LED0 "" 26 | #define PIN 0 27 | #define FLAGS 0 28 | #endif 29 | 30 | void main(void) 31 | { 32 | const struct device *dev; 33 | bool led_is_on = true; 34 | int ret; 35 | 36 | dev = device_get_binding(LED0); 37 | if (dev == NULL) { 38 | return; 39 | } 40 | 41 | ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS); 42 | if (ret < 0) { 43 | return; 44 | } 45 | 46 | while (1) { 47 | gpio_pin_set(dev, PIN, (int)led_is_on); 48 | led_is_on = !led_is_on; 49 | k_msleep(SLEEP_TIME_MS); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /examples/zephyr-blink/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/zephyr-blink/zephyr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.13.1) 4 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 5 | project(blinky) 6 | 7 | target_sources(app PRIVATE ../src/main.c) 8 | -------------------------------------------------------------------------------- /examples/zephyr-blink/zephyr/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_GPIO=y 2 | CONFIG_SERIAL=n 3 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/.gitignore: -------------------------------------------------------------------------------- 1 | .pio -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd platform-nordicnrf52/examples/zephyr-net-echo-client 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Clean build files 20 | $ pio run --target clean 21 | ``` 22 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:nrf52840_dk] 11 | platform = nordicnrf52 12 | framework = zephyr 13 | board = nrf52840_dk 14 | build_type = debug 15 | board_build.embed_files = 16 | src/echo-apps-cert.der -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/src/ca_certificate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __CA_CERTIFICATE_H__ 8 | #define __CA_CERTIFICATE_H__ 9 | 10 | #define CA_CERTIFICATE_TAG 1 11 | #define PSK_TAG 2 12 | 13 | #define TLS_PEER_HOSTNAME "localhost" 14 | 15 | /* This is the same cert as what is found in net-tools/echo-apps-cert.pem file 16 | */ 17 | static const unsigned char ca_certificate[] = { 18 | #include "echo-apps-cert.der.inc" 19 | }; 20 | 21 | #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) 22 | #include CONFIG_NET_SAMPLE_PSK_HEADER_FILE 23 | #endif 24 | 25 | #endif /* __CA_CERTIFICATE_H__ */ 26 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/src/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Intel Corporation. 3 | * Copyright (c) 2018 Nordic Semiconductor ASA. 4 | * 5 | * SPDX-License-Identifier: Apache-2.0 6 | */ 7 | 8 | /* Value of 0 will cause the IP stack to select next free port */ 9 | #define MY_PORT 0 10 | 11 | #define PEER_PORT 4242 12 | 13 | #if defined(CONFIG_USERSPACE) 14 | #include 15 | extern struct k_mem_partition app_partition; 16 | extern struct k_mem_domain app_domain; 17 | #define APP_BMEM K_APP_BMEM(app_partition) 18 | #define APP_DMEM K_APP_DMEM(app_partition) 19 | #else 20 | #define APP_BMEM 21 | #define APP_DMEM 22 | #endif 23 | 24 | #if IS_ENABLED(CONFIG_NET_TC_THREAD_PREEMPTIVE) 25 | #define THREAD_PRIORITY K_PRIO_PREEMPT(8) 26 | #else 27 | #define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1) 28 | #endif 29 | 30 | struct data { 31 | const char *proto; 32 | 33 | struct { 34 | int sock; 35 | /* Work controlling udp data sending */ 36 | struct k_work_delayable recv; 37 | struct k_work_delayable transmit; 38 | uint32_t expecting; 39 | uint32_t counter; 40 | uint32_t mtu; 41 | } udp; 42 | 43 | struct { 44 | int sock; 45 | uint32_t expecting; 46 | uint32_t received; 47 | uint32_t counter; 48 | } tcp; 49 | }; 50 | 51 | struct configs { 52 | struct data ipv4; 53 | struct data ipv6; 54 | }; 55 | 56 | #if !defined(CONFIG_NET_CONFIG_PEER_IPV4_ADDR) 57 | #define CONFIG_NET_CONFIG_PEER_IPV4_ADDR "" 58 | #endif 59 | 60 | #if !defined(CONFIG_NET_CONFIG_PEER_IPV6_ADDR) 61 | #define CONFIG_NET_CONFIG_PEER_IPV6_ADDR "" 62 | #endif 63 | 64 | extern const char lorem_ipsum[]; 65 | extern const int ipsum_len; 66 | extern struct configs conf; 67 | 68 | int start_udp(void); 69 | int process_udp(void); 70 | void stop_udp(void); 71 | 72 | int start_tcp(void); 73 | int process_tcp(void); 74 | void stop_tcp(void); 75 | 76 | #if defined(CONFIG_NET_VLAN) 77 | int init_vlan(void); 78 | #else 79 | static inline int init_vlan(void) 80 | { 81 | return 0; 82 | } 83 | #endif 84 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/src/dummy_psk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __DUMMY_PSK_H__ 8 | #define __DUMMY_PSK_H__ 9 | 10 | static const unsigned char psk[] = {0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 11 | 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; 12 | static const char psk_id[] = "PSK_identity"; 13 | 14 | #endif /* __DUMMY_PSK_H__ */ 15 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/src/echo-apps-cert.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/platformio/platform-nordicnrf52/51d75648d87315deb3cc22d80f2bc0e0dee6eee8/examples/zephyr-net-echo-client/src/echo-apps-cert.der -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/src/udp.c: -------------------------------------------------------------------------------- 1 | /* udp.c - UDP specific code for echo client */ 2 | 3 | /* 4 | * Copyright (c) 2017 Intel Corporation. 5 | * Copyright (c) 2018 Nordic Semiconductor ASA. 6 | * 7 | * SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | #include 11 | LOG_MODULE_DECLARE(net_echo_client_sample, LOG_LEVEL_DBG); 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include "common.h" 22 | #include "ca_certificate.h" 23 | 24 | #define RECV_BUF_SIZE 1280 25 | #define UDP_SLEEP K_MSEC(150) 26 | #define UDP_WAIT K_SECONDS(10) 27 | 28 | static APP_BMEM char recv_buf[RECV_BUF_SIZE]; 29 | 30 | static int send_udp_data(struct data *data) 31 | { 32 | int ret; 33 | 34 | do { 35 | data->udp.expecting = sys_rand32_get() % ipsum_len; 36 | } while (data->udp.expecting == 0U || 37 | data->udp.expecting > data->udp.mtu); 38 | 39 | ret = send(data->udp.sock, lorem_ipsum, data->udp.expecting, 0); 40 | 41 | LOG_DBG("%s UDP: Sent %d bytes", data->proto, data->udp.expecting); 42 | 43 | k_work_reschedule(&data->udp.recv, UDP_WAIT); 44 | 45 | return ret < 0 ? -EIO : 0; 46 | } 47 | 48 | static int compare_udp_data(struct data *data, const char *buf, uint32_t received) 49 | { 50 | if (received != data->udp.expecting) { 51 | LOG_ERR("Invalid amount of data received: UDP %s", data->proto); 52 | return -EIO; 53 | } 54 | 55 | if (memcmp(buf, lorem_ipsum, received) != 0) { 56 | LOG_ERR("Invalid data received: UDP %s", data->proto); 57 | return -EIO; 58 | } 59 | 60 | return 0; 61 | } 62 | 63 | static void wait_reply(struct k_work *work) 64 | { 65 | /* This means that we did not receive response in time. */ 66 | struct data *data = CONTAINER_OF(work, struct data, udp.recv); 67 | 68 | LOG_ERR("UDP %s: Data packet not received", data->proto); 69 | 70 | /* Send a new packet at this point */ 71 | send_udp_data(data); 72 | } 73 | 74 | static void wait_transmit(struct k_work *work) 75 | { 76 | struct data *data = CONTAINER_OF(work, struct data, udp.transmit); 77 | 78 | send_udp_data(data); 79 | } 80 | 81 | static int start_udp_proto(struct data *data, struct sockaddr *addr, 82 | socklen_t addrlen) 83 | { 84 | int ret; 85 | 86 | k_work_init_delayable(&data->udp.recv, wait_reply); 87 | k_work_init_delayable(&data->udp.transmit, wait_transmit); 88 | 89 | #if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS) 90 | data->udp.sock = socket(addr->sa_family, SOCK_DGRAM, IPPROTO_DTLS_1_2); 91 | #else 92 | data->udp.sock = socket(addr->sa_family, SOCK_DGRAM, IPPROTO_UDP); 93 | #endif 94 | if (data->udp.sock < 0) { 95 | LOG_ERR("Failed to create UDP socket (%s): %d", data->proto, 96 | errno); 97 | return -errno; 98 | } 99 | 100 | #if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS) 101 | sec_tag_t sec_tag_list[] = { 102 | CA_CERTIFICATE_TAG, 103 | #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) 104 | PSK_TAG, 105 | #endif 106 | }; 107 | 108 | ret = setsockopt(data->udp.sock, SOL_TLS, TLS_SEC_TAG_LIST, 109 | sec_tag_list, sizeof(sec_tag_list)); 110 | if (ret < 0) { 111 | LOG_ERR("Failed to set TLS_SEC_TAG_LIST option (%s): %d", 112 | data->proto, errno); 113 | ret = -errno; 114 | } 115 | 116 | ret = setsockopt(data->udp.sock, SOL_TLS, TLS_HOSTNAME, 117 | TLS_PEER_HOSTNAME, sizeof(TLS_PEER_HOSTNAME)); 118 | if (ret < 0) { 119 | LOG_ERR("Failed to set TLS_HOSTNAME option (%s): %d", 120 | data->proto, errno); 121 | ret = -errno; 122 | } 123 | #endif 124 | 125 | /* Call connect so we can use send and recv. */ 126 | ret = connect(data->udp.sock, addr, addrlen); 127 | if (ret < 0) { 128 | LOG_ERR("Cannot connect to UDP remote (%s): %d", data->proto, 129 | errno); 130 | ret = -errno; 131 | } 132 | 133 | return ret; 134 | } 135 | 136 | static int process_udp_proto(struct data *data) 137 | { 138 | int ret, received; 139 | 140 | received = recv(data->udp.sock, recv_buf, sizeof(recv_buf), 141 | MSG_DONTWAIT); 142 | 143 | if (received == 0) { 144 | return -EIO; 145 | } 146 | if (received < 0) { 147 | if (errno == EAGAIN || errno == EWOULDBLOCK) { 148 | ret = 0; 149 | } else { 150 | ret = -errno; 151 | } 152 | return ret; 153 | } 154 | 155 | ret = compare_udp_data(data, recv_buf, received); 156 | if (ret != 0) { 157 | LOG_WRN("%s UDP: Received and compared %d bytes, data " 158 | "mismatch", data->proto, received); 159 | return 0; 160 | } 161 | 162 | /* Correct response received */ 163 | LOG_DBG("%s UDP: Received and compared %d bytes, all ok", 164 | data->proto, received); 165 | 166 | if (++data->udp.counter % 1000 == 0U) { 167 | LOG_INF("%s UDP: Exchanged %u packets", data->proto, 168 | data->udp.counter); 169 | } 170 | 171 | k_work_cancel_delayable(&data->udp.recv); 172 | 173 | /* Do not flood the link if we have also TCP configured */ 174 | if (IS_ENABLED(CONFIG_NET_TCP)) { 175 | k_work_reschedule(&data->udp.transmit, UDP_SLEEP); 176 | ret = 0; 177 | } else { 178 | ret = send_udp_data(data); 179 | } 180 | 181 | return ret; 182 | } 183 | 184 | int start_udp(void) 185 | { 186 | int ret = 0; 187 | struct sockaddr_in addr4; 188 | struct sockaddr_in6 addr6; 189 | 190 | if (IS_ENABLED(CONFIG_NET_IPV6)) { 191 | addr6.sin6_family = AF_INET6; 192 | addr6.sin6_port = htons(PEER_PORT); 193 | inet_pton(AF_INET6, CONFIG_NET_CONFIG_PEER_IPV6_ADDR, 194 | &addr6.sin6_addr); 195 | 196 | ret = start_udp_proto(&conf.ipv6, (struct sockaddr *)&addr6, 197 | sizeof(addr6)); 198 | if (ret < 0) { 199 | return ret; 200 | } 201 | } 202 | 203 | if (IS_ENABLED(CONFIG_NET_IPV4)) { 204 | addr4.sin_family = AF_INET; 205 | addr4.sin_port = htons(PEER_PORT); 206 | inet_pton(AF_INET, CONFIG_NET_CONFIG_PEER_IPV4_ADDR, 207 | &addr4.sin_addr); 208 | 209 | ret = start_udp_proto(&conf.ipv4, (struct sockaddr *)&addr4, 210 | sizeof(addr4)); 211 | if (ret < 0) { 212 | return ret; 213 | } 214 | } 215 | 216 | if (IS_ENABLED(CONFIG_NET_IPV6)) { 217 | ret = send_udp_data(&conf.ipv6); 218 | if (ret < 0) { 219 | return ret; 220 | } 221 | } 222 | 223 | if (IS_ENABLED(CONFIG_NET_IPV4)) { 224 | ret = send_udp_data(&conf.ipv4); 225 | } 226 | 227 | return ret; 228 | } 229 | 230 | int process_udp(void) 231 | { 232 | int ret = 0; 233 | 234 | if (IS_ENABLED(CONFIG_NET_IPV6)) { 235 | ret = process_udp_proto(&conf.ipv6); 236 | if (ret < 0) { 237 | return ret; 238 | } 239 | } 240 | 241 | if (IS_ENABLED(CONFIG_NET_IPV4)) { 242 | ret = process_udp_proto(&conf.ipv4); 243 | if (ret < 0) { 244 | return ret; 245 | } 246 | } 247 | 248 | return ret; 249 | } 250 | 251 | void stop_udp(void) 252 | { 253 | if (IS_ENABLED(CONFIG_NET_IPV6)) { 254 | k_work_cancel_delayable(&conf.ipv6.udp.recv); 255 | k_work_cancel_delayable(&conf.ipv6.udp.transmit); 256 | 257 | if (conf.ipv6.udp.sock >= 0) { 258 | (void)close(conf.ipv6.udp.sock); 259 | } 260 | } 261 | 262 | if (IS_ENABLED(CONFIG_NET_IPV4)) { 263 | k_work_cancel_delayable(&conf.ipv4.udp.recv); 264 | k_work_cancel_delayable(&conf.ipv4.udp.transmit); 265 | 266 | if (conf.ipv4.udp.sock >= 0) { 267 | (void)close(conf.ipv4.udp.sock); 268 | } 269 | } 270 | } 271 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.13.1) 4 | 5 | set (CONF_FILE "prj.conf overlay-ot.conf") 6 | 7 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 8 | project(sockets_echo_client) 9 | 10 | if(CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED AND 11 | (CONFIG_NET_SAMPLE_PSK_HEADER_FILE STREQUAL "dummy_psk.h")) 12 | add_custom_target(development_psk 13 | COMMAND ${CMAKE_COMMAND} -E echo "----------------------------------------------------------" 14 | COMMAND ${CMAKE_COMMAND} -E echo "--- WARNING: Using dummy PSK! Only suitable for ---" 15 | COMMAND ${CMAKE_COMMAND} -E echo "--- development. Set NET_SAMPLE_PSK_HEADER_FILE to use ---" 16 | COMMAND ${CMAKE_COMMAND} -E echo "--- own pre-shared key. ---" 17 | COMMAND ${CMAKE_COMMAND} -E echo "----------------------------------------------------------" 18 | ) 19 | add_dependencies(app development_psk) 20 | endif() 21 | 22 | target_sources( app PRIVATE ../src/echo-client.c) 23 | target_sources_ifdef(CONFIG_NET_UDP app PRIVATE ../src/udp.c) 24 | target_sources_ifdef(CONFIG_NET_TCP app PRIVATE ../src/tcp.c) 25 | target_sources_ifdef(CONFIG_NET_VLAN app PRIVATE ../src/vlan.c) 26 | 27 | include($ENV{ZEPHYR_BASE}/samples/net/common/common.cmake) 28 | 29 | set(gen_dir ${ZEPHYR_BINARY_DIR}/include/generated/) 30 | 31 | generate_inc_file_for_target( 32 | app 33 | ../src/echo-apps-cert.der 34 | ${gen_dir}/echo-apps-cert.der.inc 35 | ) 36 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/Kconfig: -------------------------------------------------------------------------------- 1 | # Private config options for echo-client sample app 2 | 3 | # Copyright (c) 2018 Intel Corporation 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | mainmenu "Networking echo-client sample application" 7 | 8 | config NET_SAMPLE_IFACE2_MY_IPV6_ADDR 9 | string "My IPv6 address for second interface" 10 | help 11 | The value depends on your network setup. 12 | 13 | config NET_SAMPLE_IFACE2_MY_IPV4_ADDR 14 | string "My IPv4 address for second interface" 15 | help 16 | The value depends on your network setup. 17 | 18 | config NET_SAMPLE_IFACE2_VLAN_TAG 19 | int "VLAN tag for second interface" 20 | default 100 21 | range 0 4094 22 | depends on NET_VLAN 23 | help 24 | Set VLAN (virtual LAN) tag (id) that is used in the sample 25 | application. 26 | 27 | config NET_SAMPLE_IFACE3_MY_IPV6_ADDR 28 | string "My IPv6 address for third interface" 29 | help 30 | The value depends on your network setup. 31 | 32 | config NET_SAMPLE_IFACE3_MY_IPV4_ADDR 33 | string "My IPv4 address for third interface" 34 | help 35 | The value depends on your network setup. 36 | 37 | config NET_SAMPLE_IFACE3_VLAN_TAG 38 | int "VLAN tag for third interface" 39 | default 200 40 | range 0 4094 41 | depends on NET_VLAN 42 | help 43 | Set VLAN (virtual LAN) tag (id) that is used in the sample 44 | application. 45 | 46 | config NET_SAMPLE_PSK_HEADER_FILE 47 | string "Header file containing PSK" 48 | default "dummy_psk.h" 49 | depends on MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 50 | help 51 | Name of a header file containing a 52 | pre-shared key. 53 | 54 | config NET_SAMPLE_SEND_ITERATIONS 55 | int "Send sample data this many times" 56 | default 0 57 | help 58 | Send sample data this many times before exiting. A value of 59 | zero means that the sample application is run forever. 60 | 61 | source "Kconfig.zephyr" 62 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/README.md: -------------------------------------------------------------------------------- 1 | .. _sockets-echo-client-sample: 2 | 3 | Socket Echo Client 4 | ################## 5 | 6 | Overview 7 | ******** 8 | 9 | The echo-client sample application for Zephyr implements a UDP/TCP client 10 | that will send IPv4 or IPv6 packets, wait for the data to be sent back, 11 | and then verify it matches the data that was sent. 12 | 13 | The source code for this sample application can be found at: 14 | :zephyr_file:`samples/net/sockets/echo_client`. 15 | 16 | Requirements 17 | ************ 18 | 19 | - :ref:`networking_with_host` 20 | 21 | Building and Running 22 | ******************** 23 | 24 | There are multiple ways to use this application. One of the most common 25 | usage scenario is to run echo-client application inside QEMU. This is 26 | described in :ref:`networking_with_qemu`. 27 | 28 | There are configuration files for different boards and setups in the 29 | echo-client directory: 30 | 31 | - :file:`prj.conf` 32 | Generic config file, normally you should use this. 33 | 34 | - :file:`overlay-ot.conf` 35 | This overlay config enables support for OpenThread. 36 | 37 | - :file:`overlay-802154.conf` 38 | This overlay config enables support for native IEEE 802.15.4 connectivity. 39 | Note, that by default IEEE 802.15.4 L2 uses unacknowledged communication. To 40 | improve connection reliability, acknowledgments can be enabled with shell 41 | command: ``ieee802154 ack set``. 42 | 43 | - :file:`overlay-bt.conf` 44 | This overlay config enables support for Bluetooth IPSP connectivity. 45 | 46 | - :file:`overlay-qemu_802154.conf` 47 | This overlay config enables support for two QEMU's when simulating 48 | IEEE 802.15.4 network that are connected together. 49 | 50 | - :file:`overlay-tls.conf` 51 | This overlay config enables support for TLS. 52 | 53 | Build echo-client sample application like this: 54 | 55 | .. zephyr-app-commands:: 56 | :zephyr-app: samples/net/sockets/echo_client 57 | :board: 58 | :conf: 59 | :goals: build 60 | :compact: 61 | 62 | Example building for the nrf52840dk_nrf52840 with OpenThread support: 63 | 64 | .. zephyr-app-commands:: 65 | :zephyr-app: samples/net/sockets/echo_client 66 | :host-os: unix 67 | :board: nrf52840dk_nrf52840 68 | :conf: "prj.conf overlay-ot.conf" 69 | :goals: run 70 | :compact: 71 | 72 | Example building for the IEEE 802.15.4 RF2XX transceiver: 73 | 74 | .. zephyr-app-commands:: 75 | :zephyr-app: samples/net/sockets/echo_client 76 | :host-os: unix 77 | :board: [atsamr21_xpro | sam4s_xplained | sam_v71_xult] 78 | :gen-args: -DOVERLAY_CONFIG=overlay-802154.conf 79 | :goals: build flash 80 | :compact: 81 | 82 | In a terminal window you can check if communication is happen: 83 | 84 | .. code-block:: console 85 | 86 | $ minicom -D /dev/ttyACM1 87 | 88 | 89 | 90 | Enabling TLS support 91 | ==================== 92 | 93 | Enable TLS support in the sample by building the project with the 94 | ``overlay-tls.conf`` overlay file enabled, for example, using these commands: 95 | 96 | .. zephyr-app-commands:: 97 | :zephyr-app: samples/net/sockets/echo_client 98 | :board: qemu_x86 99 | :conf: "prj.conf overlay-tls.conf" 100 | :goals: build 101 | :compact: 102 | 103 | An alternative way is to specify ``-DOVERLAY_CONFIG=overlay-tls.conf`` when 104 | running ``west build`` or ``cmake``. 105 | 106 | The certificate and private key used by the sample can be found in the sample's 107 | ``src`` directory. The default certificates used by Socket Echo Client and 108 | :ref:`sockets-echo-server-sample` enable establishing a secure connection 109 | between the samples. 110 | 111 | SOCKS5 proxy support 112 | ==================== 113 | 114 | It is also possible to connect to the echo-server through a SOCKS5 proxy. 115 | To enable it, use ``-DOVERLAY_CONFIG=overlay-socks5.conf`` when running ``west 116 | build`` or ``cmake``. 117 | 118 | By default, to make the testing easier, the proxy is expected to run on the 119 | same host as the echo-server in Linux host. 120 | 121 | To start a proxy server, for example a builtin SOCKS server support in ssh 122 | can be used (-D option). Use the following command to run it on your host 123 | with the default port: 124 | 125 | For IPv4 proxy server: 126 | 127 | .. code-block: console 128 | 129 | $ ssh -N -D 0.0.0.0:1080 localhost 130 | 131 | For IPv6 proxy server: 132 | 133 | .. code-block: console 134 | 135 | $ ssh -N -D [::]:1080 localhost 136 | 137 | Run both commands if you are testing IPv4 and IPv6. 138 | 139 | To connect to a proxy server that is not running under the same IP as the 140 | echo-server or uses a different port number, modify the following values 141 | in echo_client/src/tcp.c. 142 | 143 | .. code-block:: c 144 | 145 | #define SOCKS5_PROXY_V4_ADDR IPV4_ADDR 146 | #define SOCKS5_PROXY_V6_ADDR IPV6_ADDR 147 | #define SOCKS5_PROXY_PORT 1080 148 | 149 | Running echo-server in Linux Host 150 | ================================= 151 | 152 | There is one useful testing scenario that can be used with Linux host. 153 | Here echo-client is run in QEMU and echo-server is run in Linux host. 154 | 155 | To use QEMU for testing, follow the :ref:`networking_with_qemu` guide. 156 | 157 | In a terminal window: 158 | 159 | .. code-block:: console 160 | 161 | $ sudo ./echo-server -i tap0 162 | 163 | Run echo-client application in QEMU: 164 | 165 | .. zephyr-app-commands:: 166 | :zephyr-app: samples/net/sockets/echo_client 167 | :host-os: unix 168 | :board: qemu_x86 169 | :conf: "prj.conf overlay-linux.conf" 170 | :goals: run 171 | :compact: 172 | 173 | Note that echo-server must be running in the Linux host terminal window 174 | before you start the echo-client application in QEMU. 175 | Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`. 176 | 177 | You can verify TLS communication with a Linux host as well. See 178 | https://github.com/zephyrproject-rtos/net-tools documentation for information 179 | on how to test TLS with Linux host samples. 180 | 181 | See the :ref:`sockets-echo-server-sample` documentation for an alternate 182 | way of running, with the echo-client on the Linux host and the echo-server 183 | in QEMU. 184 | ``` 185 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/boards/atsamr21_xpro.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020-2021, Gerson Fernando Budke 3 | # Copyright (c) 2019, Benjamin Valentin 4 | # 5 | # SPDX-License-Identifier: Apache-2.0 6 | # 7 | 8 | CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="RF2XX_0" 9 | 10 | # Reduced buffers to fit into SAMR21 SoC 11 | CONFIG_CPLUSPLUS=n 12 | 13 | CONFIG_NET_PKT_RX_COUNT=6 14 | CONFIG_NET_PKT_TX_COUNT=6 15 | CONFIG_NET_BUF_RX_COUNT=6 16 | CONFIG_NET_BUF_TX_COUNT=6 17 | CONFIG_NET_MAX_CONTEXTS=4 18 | CONFIG_NET_MAX_CONN=1 19 | CONFIG_NET_MAX_ROUTES=1 20 | CONFIG_NET_MAX_NEXTHOPS=1 21 | 22 | CONFIG_SHELL_STACK_SIZE=768 23 | CONFIG_SHELL_CMD_BUFF_SIZE=64 24 | CONFIG_SHELL_ARGC_MAX=6 25 | CONFIG_SHELL_HISTORY_BUFFER=64 26 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/boards/qemu_cortext_m3.conf: -------------------------------------------------------------------------------- 1 | # The addresses are selected so that qemu<->qemu connectivity works ok. 2 | # For linux<->qemu connectivity, create a new conf file and swap the 3 | # addresses (so that peer address is ending to 2). 4 | CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::2" 5 | CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::1" 6 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.2" 7 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.1" 8 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/boards/qemu_x86.conf: -------------------------------------------------------------------------------- 1 | # The addresses are selected so that qemu<->qemu connectivity works ok. 2 | # For linux<->qemu connectivity, create a new conf file and swap the 3 | # addresses (so that peer address is ending to 2). 4 | CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::2" 5 | CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::1" 6 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.2" 7 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.1" 8 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/docker-test.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | if [ -z "$RUNNING_FROM_MAIN_SCRIPT" ]; then 5 | echo "Do not run this script directly!" 6 | echo "Run $ZEPHYR_BASE/scripts/net/run-sample-tests.sh instead." 7 | exit 1 8 | fi 9 | 10 | start_configuration "--ip=192.0.2.1 --ip6=2001:db8::1" || return $? 11 | start_docker "/net-tools/echo-server -i eth0" || return $? 12 | 13 | start_zephyr "$overlay" "-DCONFIG_NET_SAMPLE_SEND_ITERATIONS=10" 14 | 15 | wait_zephyr 16 | result=$? 17 | 18 | stop_docker 19 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-6locan.conf: -------------------------------------------------------------------------------- 1 | CONFIG_CAN=y 2 | CONFIG_CAN_NET=y 3 | CONFIG_CAN_MAX_FILTER=8 4 | CONFIG_NET_L2_CANBUS=y 5 | CONFIG_NET_L2_CANBUS_BS=8 6 | CONFIG_NET_L2_CANBUS_STMIN=0 7 | CONFIG_NET_IPV4=n 8 | CONFIG_NET_IPV6=y 9 | CONFIG_NET_CONFIG_NEED_IPV6=y 10 | CONFIG_NET_CONFIG_NEED_IPV4=n 11 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="" 12 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" 13 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-802154-subg.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=n 2 | 3 | # Disable TCP and IPv4 (TCP disabled to avoid heavy traffic) 4 | CONFIG_NET_TCP=n 5 | CONFIG_NET_IPV4=n 6 | 7 | CONFIG_NET_CONFIG_NEED_IPV6=y 8 | CONFIG_NET_CONFIG_NEED_IPV4=n 9 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="" 10 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" 11 | CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::2" 12 | CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::1" 13 | 14 | CONFIG_NET_L2_IEEE802154=y 15 | CONFIG_NET_L2_IEEE802154_SHELL=y 16 | CONFIG_NET_L2_IEEE802154_LOG_LEVEL_INF=y 17 | 18 | CONFIG_NET_CONFIG_IEEE802154_CHANNEL=1 19 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-802154.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=n 2 | 3 | # Disable TCP and IPv4 (TCP disabled to avoid heavy traffic) 4 | CONFIG_NET_TCP=n 5 | CONFIG_NET_IPV4=n 6 | 7 | CONFIG_NET_CONFIG_NEED_IPV6=y 8 | CONFIG_NET_CONFIG_NEED_IPV4=n 9 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="" 10 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" 11 | CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::2" 12 | CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::1" 13 | 14 | CONFIG_NET_L2_IEEE802154=y 15 | CONFIG_NET_L2_IEEE802154_SHELL=y 16 | CONFIG_NET_L2_IEEE802154_LOG_LEVEL_INF=y 17 | 18 | CONFIG_NET_CONFIG_IEEE802154_CHANNEL=26 19 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-bt.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=y 2 | CONFIG_BT_DEBUG_LOG=y 3 | CONFIG_BT_SMP=y 4 | CONFIG_BT_PERIPHERAL=y 5 | CONFIG_BT_CENTRAL=y 6 | CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y 7 | CONFIG_BT_DEVICE_NAME="Zephyr Echo Client" 8 | CONFIG_NET_L2_BT=y 9 | CONFIG_NET_IPV4=n 10 | CONFIG_NET_IPV6=y 11 | CONFIG_NET_CONFIG_BT_NODE=y 12 | CONFIG_NET_CONFIG_NEED_IPV6=y 13 | CONFIG_NET_CONFIG_NEED_IPV4=n 14 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="" 15 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" 16 | CONFIG_NET_BUF_RX_COUNT=64 17 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-cc2520.conf: -------------------------------------------------------------------------------- 1 | CONFIG_NET_L2_IEEE802154=y 2 | 3 | CONFIG_IEEE802154_CC2520=y 4 | 5 | CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="cc2520" 6 | 7 | CONFIG_NET_IPV4=n 8 | CONFIG_NET_CONFIG_NEED_IPV4=n 9 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="" 10 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" 11 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-debug.conf: -------------------------------------------------------------------------------- 1 | CONFIG_NO_OPTIMIZATIONS=y 2 | CONFIG_DEBUG=y 3 | 4 | CONFIG_ASSERT=y 5 | 6 | CONFIG_STACK_SENTINEL=y 7 | CONFIG_STACK_CANARIES=y 8 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-e1000.conf: -------------------------------------------------------------------------------- 1 | CONFIG_PCIE=y 2 | CONFIG_ETH_E1000=y 3 | 4 | CONFIG_NET_L2_ETHERNET=y 5 | CONFIG_NET_QEMU_ETHERNET=y 6 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-linux.conf: -------------------------------------------------------------------------------- 1 | # Include this overlay when the echo-server is running on Linux and 2 | # echo-client is running on Qemu. 3 | CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1" 4 | CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2" 5 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1" 6 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2" 7 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-log.conf: -------------------------------------------------------------------------------- 1 | CONFIG_LOG=y 2 | CONFIG_LOG_MODE_IMMEDIATE=y 3 | CONFIG_LOG_BACKEND_SHOW_COLOR=n 4 | 5 | CONFIG_LOG_BUFFER_SIZE=1024 6 | CONFIG_LOG_STRDUP_BUF_COUNT=2048 7 | 8 | CONFIG_NET_LOG=y 9 | 10 | CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=y 11 | CONFIG_NET_CONN_LOG_LEVEL_DBG=y 12 | CONFIG_NET_CONTEXT_LOG_LEVEL_DBG=y 13 | 14 | CONFIG_NET_TCP_LOG_LEVEL_DBG=y 15 | 16 | #CONFIG_NET_IF_LOG_LEVEL_DBG=y 17 | #CONFIG_NET_L2_ETHERNET_LOG_LEVEL_DBG=y 18 | 19 | #CONFIG_SLIP_LOG_LEVEL_DBG=y 20 | 21 | #CONFIG_ETHERNET_LOG_LEVEL_DBG=y 22 | #CONFIG_ETH_E1000_VERBOSE_DEBUG=y 23 | 24 | #CONFIG_NET_PKT_LOG_LEVEL_DBG=y 25 | 26 | #CONFIG_NET_BUF_LOG=y 27 | #CONFIG_NET_BUF_LOG_LEVEL_DBG=y 28 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-max-stacks.conf: -------------------------------------------------------------------------------- 1 | CONFIG_NET_MGMT_EVENT_STACK_SIZE=65535 2 | CONFIG_PRIVILEGED_STACK_SIZE=65535 3 | CONFIG_NET_TX_STACK_SIZE=65535 4 | CONFIG_NET_RX_STACK_SIZE=65535 5 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=65535 6 | CONFIG_MAIN_STACK_SIZE=65535 7 | CONFIG_IDLE_STACK_SIZE=65535 8 | CONFIG_ISR_STACK_SIZE=65535 9 | CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=65535 10 | CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE=65535 11 | CONFIG_SHELL_STACK_SIZE=65535 12 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-ot.conf: -------------------------------------------------------------------------------- 1 | CONFIG_NEWLIB_LIBC=y 2 | 3 | # Disable TCP and IPv4 (TCP disabled to avoid heavy traffic) 4 | CONFIG_NET_TCP=n 5 | CONFIG_NET_IPV4=n 6 | 7 | CONFIG_NET_IPV6_NBR_CACHE=n 8 | CONFIG_NET_IPV6_MLD=n 9 | CONFIG_NET_CONFIG_NEED_IPV4=n 10 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="" 11 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" 12 | 13 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 14 | 15 | # Enable OpenThread shell 16 | CONFIG_SHELL=y 17 | CONFIG_OPENTHREAD_SHELL=y 18 | CONFIG_SHELL_STACK_SIZE=3072 19 | 20 | CONFIG_NET_L2_OPENTHREAD=y 21 | 22 | CONFIG_OPENTHREAD_DEBUG=y 23 | CONFIG_OPENTHREAD_L2_DEBUG=y 24 | CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF=y 25 | 26 | CONFIG_OPENTHREAD_CHANNEL=26 27 | CONFIG_OPENTHREAD_NETWORKKEY="00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff" 28 | 29 | CONFIG_NET_CONFIG_MY_IPV6_ADDR="fdde:ad00:beef::1" 30 | CONFIG_NET_CONFIG_PEER_IPV6_ADDR="fdde:ad00:beef::2" 31 | 32 | # mbedTLS tweaks 33 | CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=768 34 | 35 | # A sample configuration to enable Thread Joiner, uncomment if needed 36 | #CONFIG_OPENTHREAD_JOINER=y 37 | #CONFIG_OPENTHREAD_JOINER_AUTOSTART=y 38 | 39 | # Enable diagnostic module, uncomment if needed 40 | #CONFIG_OPENTHREAD_DIAG=y 41 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-qemu_802154.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=n 2 | 3 | # Disable TCP and IPv4 (TCP disabled to avoid heavy traffic) 4 | CONFIG_NET_TCP=n 5 | CONFIG_NET_IPV4=n 6 | 7 | # Disabling Ethernet 8 | CONFIG_NET_SLIP_TAP=n 9 | # Enable UART PIPE 802.15.4 driver 10 | CONFIG_IEEE802154_UPIPE=y 11 | CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154_UPIPE" 12 | 13 | CONFIG_NET_CONFIG_NEED_IPV6=y 14 | CONFIG_NET_CONFIG_NEED_IPV4=n 15 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="" 16 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" 17 | 18 | CONFIG_NET_L2_IEEE802154=y 19 | CONFIG_NET_L2_IEEE802154_SHELL=y 20 | CONFIG_NET_L2_IEEE802154_LOG_LEVEL_INF=y 21 | 22 | CONFIG_NET_CONFIG_IEEE802154_CHANNEL=26 23 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-qemu_cortex_m3_eth.conf: -------------------------------------------------------------------------------- 1 | # Select Stellaris Ethernet 2 | CONFIG_NET_SLIP_TAP=n 3 | CONFIG_SLIP=n 4 | CONFIG_NET_L2_ETHERNET=y 5 | CONFIG_ETH_STELLARIS=y 6 | 7 | # Network Application Options 8 | CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::2" 9 | CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::1" 10 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.2" 11 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.1" 12 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-socks5.conf: -------------------------------------------------------------------------------- 1 | CONFIG_SOCKS=y 2 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-tls.conf: -------------------------------------------------------------------------------- 1 | CONFIG_MAIN_STACK_SIZE=4096 2 | CONFIG_NET_BUF_RX_COUNT=100 3 | CONFIG_NET_BUF_TX_COUNT=100 4 | 5 | # TLS configuration 6 | CONFIG_MBEDTLS=y 7 | CONFIG_MBEDTLS_BUILTIN=y 8 | CONFIG_MBEDTLS_ENABLE_HEAP=y 9 | CONFIG_MBEDTLS_HEAP_SIZE=60000 10 | CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=2048 11 | 12 | CONFIG_NET_SOCKETS_SOCKOPT_TLS=y 13 | CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=4 14 | CONFIG_NET_SOCKETS_ENABLE_DTLS=y 15 | CONFIG_POSIX_MAX_FDS=8 16 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/overlay-vlan.conf: -------------------------------------------------------------------------------- 1 | CONFIG_NET_VLAN=y 2 | 3 | # We have one non-vlan interface and two VLAN interfaces 4 | CONFIG_NET_VLAN_COUNT=3 5 | 6 | # There will be three network interfaces. Note that the addresses are 7 | # selected so that our address ends to .1 and the peer one to .2 8 | 9 | # First ethernet interface will use these settings 10 | CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1" 11 | CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2" 12 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1" 13 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2" 14 | 15 | # Second ethernet interface will have these settings 16 | CONFIG_NET_SAMPLE_IFACE2_MY_IPV6_ADDR="2001:db8:100::1" 17 | # TEST-NET-2 from RFC 5737 18 | CONFIG_NET_SAMPLE_IFACE2_MY_IPV4_ADDR="198.51.100.1" 19 | # VLAN tag for the second interface 20 | CONFIG_NET_SAMPLE_IFACE2_VLAN_TAG=100 21 | 22 | # Settings for the third network interface 23 | CONFIG_NET_SAMPLE_IFACE3_MY_IPV6_ADDR="2001:db8:200::1" 24 | # TEST-NET-3 from RFC 5737 25 | CONFIG_NET_SAMPLE_IFACE3_MY_IPV4_ADDR="203.0.113.1" 26 | # VLAN tag for the second interface 27 | CONFIG_NET_SAMPLE_IFACE3_VLAN_TAG=200 28 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/prj.conf: -------------------------------------------------------------------------------- 1 | # Generic networking options 2 | CONFIG_NETWORKING=y 3 | CONFIG_NET_UDP=y 4 | CONFIG_NET_TCP=y 5 | CONFIG_NET_IPV6=y 6 | CONFIG_NET_IPV4=y 7 | CONFIG_NET_SOCKETS=y 8 | CONFIG_NET_SOCKETS_POSIX_NAMES=y 9 | CONFIG_NET_SOCKETS_POLL_MAX=4 10 | CONFIG_NET_CONNECTION_MANAGER=y 11 | 12 | # Kernel options 13 | CONFIG_MAIN_STACK_SIZE=2048 14 | CONFIG_ENTROPY_GENERATOR=y 15 | CONFIG_TEST_RANDOM_GENERATOR=y 16 | CONFIG_INIT_STACKS=y 17 | 18 | # Logging 19 | CONFIG_NET_LOG=y 20 | CONFIG_LOG=y 21 | CONFIG_NET_STATISTICS=y 22 | CONFIG_PRINTK=y 23 | 24 | # Network buffers 25 | CONFIG_NET_PKT_RX_COUNT=16 26 | CONFIG_NET_PKT_TX_COUNT=16 27 | CONFIG_NET_BUF_RX_COUNT=80 28 | CONFIG_NET_BUF_TX_COUNT=80 29 | CONFIG_NET_CONTEXT_NET_PKT_POOL=y 30 | 31 | # IP address options 32 | CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3 33 | CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4 34 | CONFIG_NET_MAX_CONTEXTS=10 35 | 36 | # Network shell 37 | CONFIG_NET_SHELL=y 38 | 39 | # The addresses are selected so that qemu<->qemu connectivity works ok. 40 | # For linux<->qemu connectivity, create a new conf file and swap the 41 | # addresses (so that peer address is ending to 2). 42 | CONFIG_NET_CONFIG_SETTINGS=y 43 | CONFIG_NET_CONFIG_NEED_IPV6=y 44 | CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::2" 45 | CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::1" 46 | CONFIG_NET_CONFIG_NEED_IPV4=y 47 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.2" 48 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.1" 49 | CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 50 | -------------------------------------------------------------------------------- /examples/zephyr-net-echo-client/zephyr/sample.yaml: -------------------------------------------------------------------------------- 1 | common: 2 | harness: net 3 | tags: net socket 4 | depends_on: netif 5 | min_flash: 140 6 | sample: 7 | description: Test network sockets using a client/server 8 | sample 9 | name: Socket Echo Client 10 | tests: 11 | sample.net.sockets.echo_client: 12 | platform_allow: qemu_x86 frdm_k64f sam_e70_xplained 13 | qemu_cortex_m3 frdm_kw41z 14 | sample.net.sockets.echo_client.802154: 15 | extra_args: OVERLAY_CONFIG="overlay-qemu_802154.conf" 16 | platform_allow: qemu_x86 17 | sample.net.sockets.echo_server.802154.rf2xx: 18 | extra_args: OVERLAY_CONFIG="overlay-802154.conf" 19 | platform_allow: atsamr21_xpro 20 | sample.net.sockets.echo_server.802154.rf2xx.xplained: 21 | extra_args: SHIELD=atmel_rf2xx_xplained OVERLAY_CONFIG="overlay-802154.conf" 22 | platform_allow: sam4s_xplained 23 | sample.net.sockets.echo_server.802154.rf2xx.xpro: 24 | extra_args: SHIELD=atmel_rf2xx_xpro OVERLAY_CONFIG="overlay-802154.conf" 25 | platform_allow: sam4e_xpro sam_v71_xult 26 | sample.net.sockets.echo_server.802154.rf2xx.legacy: 27 | extra_args: SHIELD=atmel_rf2xx_legacy OVERLAY_CONFIG="overlay-802154.conf" 28 | platform_allow: sam4e_xpro sam_v71_xult 29 | sample.net.sockets.echo_server.802154.rf2xx.arduino: 30 | extra_args: SHIELD=atmel_rf2xx_arduino OVERLAY_CONFIG="overlay-802154.conf" 31 | platform_allow: sam_v71_xult frdm_k64f nucleo_f767zi 32 | sample.net.sockets.echo_server.802154.rf2xx.mikrobus: 33 | extra_args: SHIELD=atmel_rf2xx_mikrobus OVERLAY_CONFIG="overlay-802154.conf" 34 | platform_allow: lpcxpresso55s69_ns 35 | sample.net.sockets.echo_client.bt: 36 | extra_args: OVERLAY_CONFIG="overlay-bt.conf" 37 | platform_allow: qemu_x86 38 | tags: bluetooth 39 | sample.net.sockets.echo_client.mcr20a: 40 | extra_args: SHIELD=frdm_cr20a OVERLAY_CONFIG=overlay-802154.conf 41 | platform_allow: frdm_k64f 42 | sample.net.sockets.echo_client.nrf_802154: 43 | extra_args: OVERLAY_CONFIG="overlay-802154.conf" 44 | platform_allow: nrf52840dk_nrf52840 45 | sample.net.sockets.echo_client.nrf_openthread: 46 | extra_args: OVERLAY_CONFIG="overlay-ot.conf" 47 | slow: true 48 | tags: net openthread 49 | platform_allow: nrf52840dk_nrf52840 50 | filter: TOOLCHAIN_HAS_NEWLIB == 1 51 | sample.net.sockets.echo_client.kw41z_openthread: 52 | extra_args: OVERLAY_CONFIG="overlay-ot.conf" 53 | slow: true 54 | tags: net openthread 55 | platform_allow: frdm_kw41z 56 | filter: TOOLCHAIN_HAS_NEWLIB == 1 57 | sample.net.sockets.echo_client.userspace: 58 | extra_args: CONFIG_USERSPACE=y OVERLAY_CONFIG="overlay-e1000.conf" 59 | platform_allow: qemu_x86 60 | -------------------------------------------------------------------------------- /examples/zephyr-subsys-nvs/.gitignore: -------------------------------------------------------------------------------- 1 | .pio -------------------------------------------------------------------------------- /examples/zephyr-subsys-nvs/README.md: -------------------------------------------------------------------------------- 1 | How to build PlatformIO based project 2 | ===================================== 3 | 4 | 1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) 5 | 2. Download [development platform with examples](https://github.com/platformio/platform-nordicnrf52/archive/develop.zip) 6 | 3. Extract ZIP archive 7 | 4. Run these commands: 8 | 9 | ```shell 10 | # Change directory to example 11 | $ cd platform-nordicnrf52/examples/zephyr-subsys-nvs 12 | 13 | # Build project 14 | $ pio run 15 | 16 | # Upload firmware 17 | $ pio run --target upload 18 | 19 | # Build specific environment 20 | $ pio run -e nrf52_dk 21 | 22 | # Upload firmware for the specific environment 23 | $ pio run -e nrf52_dk --target upload 24 | 25 | # Clean build files 26 | $ pio run --target clean 27 | ``` 28 | -------------------------------------------------------------------------------- /examples/zephyr-subsys-nvs/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /examples/zephyr-subsys-nvs/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /examples/zephyr-subsys-nvs/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; https://docs.platformio.org/page/projectconf.html 9 | 10 | [env:adafruit_feather_nrf52832] 11 | platform = nordicnrf52 12 | framework = zephyr 13 | board = adafruit_feather_nrf52832 14 | monitor_speed = 115200 15 | 16 | [env:nrf52_dk] 17 | platform = nordicnrf52 18 | framework = zephyr 19 | board = nrf52_dk 20 | monitor_speed = 115200 21 | -------------------------------------------------------------------------------- /examples/zephyr-subsys-nvs/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /examples/zephyr-subsys-nvs/zephyr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.13.1) 4 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 5 | project(nvs) 6 | 7 | 8 | target_sources(app PRIVATE ../src/main.c) 9 | target_include_directories(app PRIVATE $ENV{ZEPHYR_BASE}/subsys/fs/nvs) 10 | -------------------------------------------------------------------------------- /examples/zephyr-subsys-nvs/zephyr/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_FLASH=y 2 | CONFIG_FLASH_PAGE_LAYOUT=y 3 | 4 | CONFIG_NVS=y 5 | CONFIG_LOG=y 6 | CONFIG_NVS_LOG_LEVEL_DBG=y 7 | CONFIG_REBOOT=y 8 | CONFIG_MPU_ALLOW_FLASH_WRITE=y 9 | -------------------------------------------------------------------------------- /platform.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nordicnrf52", 3 | "title": "Nordic nRF52", 4 | "description": "The nRF52 Series are built for speed to carry out increasingly complex tasks in the shortest possible time and return to sleep, conserving precious battery power. They have a Cortex-M4F processor which makes them quite capable Bluetooth Smart SoCs.", 5 | "homepage": "https://www.nordicsemi.com/Products/nRF52-Series-SoC", 6 | "license": "Apache-2.0", 7 | "keywords": [ 8 | "dev-platform", 9 | "ARM", 10 | "Cortex-M", 11 | "Nordic Semiconductor", 12 | "nRF52" 13 | ], 14 | "engines": { 15 | "platformio": "^6" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/platformio/platform-nordicnrf52.git" 20 | }, 21 | "version": "10.9.0", 22 | "frameworks": { 23 | "arduino": { 24 | "package": "framework-arduinonordicnrf5", 25 | "script": "builder/frameworks/arduino.py" 26 | }, 27 | "mbed": { 28 | "package": "framework-mbed", 29 | "script": "builder/frameworks/mbed.py" 30 | }, 31 | "zephyr": { 32 | "package": "framework-zephyr", 33 | "script": "builder/frameworks/zephyr.py" 34 | } 35 | }, 36 | "packages": { 37 | "toolchain-gccarmnoneeabi": { 38 | "type": "toolchain", 39 | "owner": "platformio", 40 | "version": ">=1.60301.0,<1.80000.0", 41 | "optionalVersions": [ 42 | "~1.70201.0", 43 | "~1.80201.0", 44 | "~1.90201.0" 45 | ] 46 | }, 47 | "framework-mbed": { 48 | "type": "framework", 49 | "optional": true, 50 | "owner": "platformio", 51 | "version": "~6.61700.0" 52 | }, 53 | "framework-arduinoadafruitnrf52": { 54 | "type": "framework", 55 | "optional": true, 56 | "owner": "platformio", 57 | "version": "~1.10601.0" 58 | }, 59 | "framework-arduinonordicnrf5": { 60 | "type": "framework", 61 | "optional": true, 62 | "owner": "platformio", 63 | "version": "~1.800.0" 64 | }, 65 | "framework-arduino-mbed": { 66 | "type": "framework", 67 | "optional": true, 68 | "owner": "platformio", 69 | "version": "~4.3.1" 70 | }, 71 | "framework-cmsis": { 72 | "type": "framework", 73 | "optional": true, 74 | "owner": "platformio", 75 | "version": "~2.50700.0" 76 | }, 77 | "framework-zephyr": { 78 | "type": "framework", 79 | "optional": true, 80 | "owner": "platformio", 81 | "version": "~2.20701.0" 82 | }, 83 | "tool-adafruit-nrfutil": { 84 | "owner": "platformio", 85 | "optional": true, 86 | "version": "~1.503.0" 87 | }, 88 | "tool-sreccat": { 89 | "owner": "platformio", 90 | "version": "~1.164.0" 91 | }, 92 | "tool-openocd": { 93 | "type": "uploader", 94 | "optional": true, 95 | "owner": "platformio", 96 | "version": "~3.1200.0" 97 | }, 98 | "tool-nrfjprog": { 99 | "type": "uploader", 100 | "optional": true, 101 | "owner": "platformio", 102 | "version": "~1.90702.0" 103 | }, 104 | "tool-jlink": { 105 | "type": "uploader", 106 | "optional": true, 107 | "owner": "platformio", 108 | "version": "^1.63208.0" 109 | }, 110 | "tool-bossac-nordicnrf52": { 111 | "type": "uploader", 112 | "optional": true, 113 | "owner": "platformio", 114 | "version": "~1.10901.0" 115 | }, 116 | "tool-cmake": { 117 | "optional": true, 118 | "owner": "platformio", 119 | "version": "~3.21.0" 120 | }, 121 | "tool-dtc": { 122 | "optional": true, 123 | "owner": "platformio", 124 | "version": "~1.4.7" 125 | }, 126 | "tool-ninja": { 127 | "optional": true, 128 | "owner": "platformio", 129 | "version": "^1.7.0" 130 | }, 131 | "tool-gperf": { 132 | "optional": true, 133 | "owner": "platformio", 134 | "version": "^3.0.0" 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /platform.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014-present PlatformIO 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import json 16 | import os 17 | import sys 18 | 19 | from platformio.public import PlatformBase 20 | 21 | 22 | IS_WINDOWS = sys.platform.startswith("win") 23 | 24 | class Nordicnrf52Platform(PlatformBase): 25 | 26 | def is_embedded(self): 27 | return True 28 | 29 | def configure_default_packages(self, variables, targets): 30 | upload_protocol = "" 31 | board = variables.get("board") 32 | frameworks = variables.get("pioframework", []) 33 | if board: 34 | upload_protocol = variables.get( 35 | "upload_protocol", 36 | self.board_config(board).get("upload.protocol", "")) 37 | 38 | if self.board_config(board).get("build.bsp.name", 39 | "nrf5") == "adafruit": 40 | self.frameworks["arduino"][ 41 | "package"] = "framework-arduinoadafruitnrf52" 42 | self.packages["framework-cmsis"]["optional"] = False 43 | self.packages["tool-adafruit-nrfutil"]["optional"] = False 44 | 45 | if "mbed" in frameworks: 46 | self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.90201.0" 47 | 48 | if "zephyr" in frameworks: 49 | for p in self.packages: 50 | if p in ("tool-cmake", "tool-dtc", "tool-ninja"): 51 | self.packages[p]["optional"] = False 52 | self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.80201.0" 53 | if not IS_WINDOWS: 54 | self.packages["tool-gperf"]["optional"] = False 55 | 56 | if board in ("nano33ble", "nicla_sense_me"): 57 | self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.70201.0" 58 | self.frameworks["arduino"]["package"] = "framework-arduino-mbed" 59 | self.frameworks["arduino"][ 60 | "script" 61 | ] = "builder/frameworks/arduino/mbed-core/arduino-core-mbed.py" 62 | 63 | if set(["bootloader", "erase"]) & set(targets): 64 | self.packages["tool-nrfjprog"]["optional"] = False 65 | elif (upload_protocol and upload_protocol != "nrfjprog" 66 | and "tool-nrfjprog" in self.packages): 67 | del self.packages["tool-nrfjprog"] 68 | 69 | # configure J-LINK tool 70 | jlink_conds = [ 71 | "jlink" in variables.get(option, "") 72 | for option in ("upload_protocol", "debug_tool") 73 | ] 74 | if board: 75 | board_config = self.board_config(board) 76 | jlink_conds.extend([ 77 | "jlink" in board_config.get(key, "") 78 | for key in ("debug.default_tools", "upload.protocol") 79 | ]) 80 | jlink_pkgname = "tool-jlink" 81 | if not any(jlink_conds) and jlink_pkgname in self.packages: 82 | del self.packages[jlink_pkgname] 83 | 84 | return super().configure_default_packages(variables, targets) 85 | 86 | def get_boards(self, id_=None): 87 | result = super().get_boards(id_) 88 | if not result: 89 | return result 90 | if id_: 91 | return self._add_default_debug_tools(result) 92 | else: 93 | for key, value in result.items(): 94 | result[key] = self._add_default_debug_tools(result[key]) 95 | return result 96 | 97 | def _add_default_debug_tools(self, board): 98 | debug = board.manifest.get("debug", {}) 99 | upload_protocols = board.manifest.get("upload", {}).get( 100 | "protocols", []) 101 | if "tools" not in debug: 102 | debug["tools"] = {} 103 | 104 | # J-Link / ST-Link / BlackMagic Probe 105 | for link in ("blackmagic", "jlink", "stlink", "cmsis-dap"): 106 | if link not in upload_protocols or link in debug['tools']: 107 | continue 108 | 109 | if link == "blackmagic": 110 | debug["tools"]["blackmagic"] = { 111 | "hwids": [["0x1d50", "0x6018"]], 112 | "require_debug_port": True 113 | } 114 | 115 | elif link == "jlink": 116 | assert debug.get("jlink_device"), ( 117 | "Missed J-Link Device ID for %s" % board.id) 118 | debug["tools"][link] = { 119 | "server": { 120 | "package": "tool-jlink", 121 | "arguments": [ 122 | "-singlerun", 123 | "-if", "SWD", 124 | "-select", "USB", 125 | "-device", debug.get("jlink_device"), 126 | "-port", "2331" 127 | ], 128 | "executable": ("JLinkGDBServerCL.exe" 129 | if IS_WINDOWS else 130 | "JLinkGDBServer") 131 | } 132 | } 133 | 134 | else: 135 | server_args = [ 136 | "-s", "$PACKAGE_DIR/openocd/scripts", 137 | "-f", "interface/%s.cfg" % link 138 | ] 139 | if link == "stlink": 140 | server_args.extend([ 141 | "-c", 142 | "transport select hla_swd; set WORKAREASIZE 0x4000" 143 | ]) 144 | server_args.extend(["-f", "target/nrf52.cfg"]) 145 | debug["tools"][link] = { 146 | "server": { 147 | "package": "tool-openocd", 148 | "executable": "bin/openocd", 149 | "arguments": server_args 150 | } 151 | } 152 | server_args.extend(debug.get("openocd_extra_args", [])) 153 | 154 | debug["tools"][link]["onboard"] = link in debug.get("onboard_tools", []) 155 | debug["tools"][link]["default"] = link in debug.get("default_tools", []) 156 | 157 | board.manifest['debug'] = debug 158 | return board 159 | 160 | def configure_debug_session(self, debug_config): 161 | if debug_config.speed: 162 | server_executable = (debug_config.server or {}).get("executable", "").lower() 163 | if "openocd" in server_executable: 164 | debug_config.server["arguments"].extend( 165 | ["-c", "adapter speed %s" % debug_config.speed] 166 | ) 167 | elif "jlink" in server_executable: 168 | debug_config.server["arguments"].extend( 169 | ["-speed", debug_config.speed] 170 | ) 171 | --------------------------------------------------------------------------------