├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── config ├── custom_board.h └── nrf52832_mdk.h ├── docs ├── CONTRIBUTING.md ├── LICENSE.md ├── cn │ ├── CONTRIBUTING.md │ ├── LICENSE.md │ ├── about.md │ ├── daplink │ │ └── index.md │ ├── espruino │ │ └── index.md │ ├── getting-started │ │ ├── images │ │ │ └── daplink_disk_win.png │ │ └── index.md │ ├── how-to-buy.md │ ├── index.md │ ├── jerryscript │ │ └── index.md │ ├── mbedos │ │ └── index.md │ ├── mesh │ │ └── index.md │ ├── micropython │ │ └── index.md │ ├── mynewt │ │ └── index.md │ ├── nrf5-sdk │ │ └── index.md │ └── zephyr │ │ └── index.md ├── daplink │ ├── images │ │ ├── building_daplink_keil.png │ │ ├── daplink-website-logo-link.png │ │ └── daplink_diagram.png │ └── index.md ├── espruino │ ├── images │ │ ├── espruino-logo.png │ │ ├── espruino_example_blinky.png │ │ ├── espruino_web_ide_connected.png │ │ ├── espruino_web_ide_connecting.png │ │ ├── espruino_web_ide_pairing.png │ │ ├── espruino_web_ide_ui.png │ │ ├── flashing_espruino_using_daplink.png │ │ └── web_bluetooth_secure_dfu.png │ └── index.md ├── getting-started │ ├── images │ │ ├── connecting_nrf52832-mdk.jpg │ │ ├── drag-n-drop_programming.png │ │ ├── nrf_connect_blinky.jpg │ │ ├── programming_using_pyocd.png │ │ ├── putty_configuration.png │ │ ├── putty_messages.png │ │ ├── screen_messages_macos.png │ │ └── screen_messages_ubuntu.png │ └── index.md ├── hardware │ ├── nRF52832-MDK_3D_STEP_V1.0.step │ ├── nRF52832-MDK_3D_STEP_V1.1.step │ ├── nRF52832-MDK_3D_STEP_V2.0.step │ ├── nRF52832-MDK_PCB_V1.0.pdf │ ├── nRF52832-MDK_PCB_V1.1.pdf │ ├── nRF52832-MDK_PCB_V2.0.pdf │ ├── nRF52832-MDK_SCH_V1.0.pdf │ ├── nRF52832-MDK_SCH_V1.1.pdf │ ├── nRF52832-MDK_SCH_V2.0.pdf │ ├── nRF52832-MDK_V1_Pinout.pdf │ └── nRF52832-MDK_V2_Pinout.pdf ├── how-to-buy.md ├── images │ ├── daplink_diagram.png │ ├── favicon.png │ ├── logo.svg │ ├── makerdiary-store-logo.png │ ├── nrf52832-mdk-v1-n-v2.jpg │ ├── nrf52832_mdk_docs.png │ ├── nrf52832_mdk_v1_image.jpg │ ├── nrf52832_mdk_v1_pinout.jpeg │ ├── nrf52832_mdk_v2_image.jpg │ ├── nrf52832_mdk_v2_pinout.jpeg │ ├── nrf52832_soc.png │ ├── seeed_logo_2018_horizontal.png │ ├── taobao-logo.png │ ├── tindie-logo.png │ └── wxzwxd-logo.png ├── index.md ├── jerryscript │ ├── images │ │ ├── jerryscript-logo.png │ │ └── jerryscript_for_zephyr_repl.png │ └── index.md ├── mbedos │ ├── images │ │ ├── mbed-os-example-ble-battery.jpg │ │ ├── mbed-os-example-blinky-bash.png │ │ ├── mbed-os-example-blinky-demo.gif │ │ └── mbedos-logo.png │ └── index.md ├── mesh │ ├── images │ │ ├── building_my_light_switch_client.png │ │ ├── flashing_my_light_switch_client.png │ │ ├── generating_build_files.png │ │ ├── mesh-network_topology.png │ │ ├── mesh_icon_small.png │ │ ├── my_light_switch_client_log_info.png │ │ └── nrf-mesh-app-screenshot.jpg │ └── index.md ├── micropython │ ├── images │ │ ├── flashing_micropython_using_daplink.png │ │ ├── micropython-logo.jpeg │ │ ├── micropython_ble_repl.png │ │ └── micropython_repl_help.png │ └── index.md ├── mynewt │ ├── images │ │ ├── loading_mynewt_image.png │ │ ├── mynewt-logo.png │ │ └── mynewt_example_blinky.gif │ └── index.md ├── nrf5-sdk │ ├── images │ │ ├── SDK-icon_small.png │ │ ├── arm-none-eabi-gcc_version.png │ │ ├── blinky_example.gif │ │ └── gnu-make_version.png │ └── index.md └── zephyr │ ├── images │ ├── hello_world_ninja_building.png │ └── zephyr-logo.png │ └── index.md ├── examples ├── mbedos5 │ ├── README.md │ ├── mbed-os-example-ble │ │ ├── BLE_BatteryLevel │ │ │ ├── .mbedls-mock │ │ │ ├── .mbedls-mock.lock │ │ │ ├── hex │ │ │ │ └── BLE_BatteryLevel.hex │ │ │ ├── main.cpp │ │ │ ├── mbed-os.lib │ │ │ └── module.json │ │ ├── BLE_Beacon │ │ │ ├── .mbedls-mock │ │ │ ├── .mbedls-mock.lock │ │ │ ├── hex │ │ │ │ └── BLE_Beacon.hex │ │ │ ├── main.cpp │ │ │ ├── mbed-os.lib │ │ │ └── module.json │ │ ├── BLE_Button │ │ │ ├── .mbedls-mock │ │ │ ├── .mbedls-mock.lock │ │ │ ├── ButtonService.h │ │ │ ├── hex │ │ │ │ └── BLE_Button.hex │ │ │ ├── main.cpp │ │ │ ├── mbed-os.lib │ │ │ ├── mbed_app.json │ │ │ └── module.json │ │ ├── BLE_GAPButton │ │ │ ├── .mbedls-mock │ │ │ ├── .mbedls-mock.lock │ │ │ ├── hex │ │ │ │ └── BLE_GAPButton.hex │ │ │ ├── main.cpp │ │ │ ├── mbed-os.lib │ │ │ ├── mbed_app.json │ │ │ └── module.json │ │ ├── BLE_HeartRate │ │ │ ├── .mbedls-mock │ │ │ ├── .mbedls-mock.lock │ │ │ ├── hex │ │ │ │ └── BLE_HeartRate.hex │ │ │ ├── main.cpp │ │ │ ├── mbed-os.lib │ │ │ └── module.json │ │ ├── BLE_LED │ │ │ ├── .mbedls-mock │ │ │ ├── .mbedls-mock.lock │ │ │ ├── LEDService.h │ │ │ ├── hex │ │ │ │ └── BLE_LED.hex │ │ │ ├── main.cpp │ │ │ ├── mbed-os.lib │ │ │ └── module.json │ │ ├── BLE_LEDBlinker │ │ │ ├── .mbedls-mock │ │ │ ├── .mbedls-mock.lock │ │ │ ├── hex │ │ │ │ └── BLE_LEDBlinker.hex │ │ │ ├── main.cpp │ │ │ ├── mbed-os.lib │ │ │ └── module.json │ │ └── BLE_Thermometer │ │ │ ├── .mbedls-mock │ │ │ ├── .mbedls-mock.lock │ │ │ ├── hex │ │ │ └── BLE_Thermometer.hex │ │ │ ├── main.cpp │ │ │ ├── mbed-os.lib │ │ │ └── module.json │ ├── mbed-os-example-blinky │ │ ├── .mbedls-mock │ │ ├── .mbedls-mock.lock │ │ ├── hex │ │ │ └── mbed-os-example-blinky.hex │ │ ├── main.cpp │ │ ├── mbed-os.lib │ │ ├── mbed_app.json │ │ └── stats_report.h │ └── mbed-os-example-i2c-scanner │ │ ├── .mbedls-mock │ │ ├── .mbedls-mock.lock │ │ ├── hex │ │ └── mbed-os-example-i2c-scanner.hex │ │ ├── main.cpp │ │ └── mbed-os.lib ├── mynewt │ └── blinky │ │ ├── .gitignore │ │ ├── .rat-excludes │ │ ├── LICENSE │ │ ├── NOTICE │ │ ├── README.md │ │ ├── apps │ │ └── blinky │ │ │ ├── pkg.yml │ │ │ └── src │ │ │ └── main.c │ │ ├── project.yml │ │ └── targets │ │ ├── my_blinky_sim │ │ ├── pkg.yml │ │ └── target.yml │ │ ├── nrf52_blinky │ │ ├── pkg.yml │ │ └── target.yml │ │ ├── nrf52_boot │ │ ├── pkg.yml │ │ └── target.yml │ │ └── unittest │ │ ├── pkg.yml │ │ └── target.yml ├── nrf5-sdk │ ├── ble_app_beacon │ │ ├── armgcc │ │ │ ├── Makefile │ │ │ └── ble_app_beacon_gcc_nrf52.ld │ │ ├── config │ │ │ └── sdk_config.h │ │ ├── hex │ │ │ └── ble_app_beacon_nrf52832_mdk_s132.hex │ │ └── main.c │ ├── ble_app_blinky │ │ ├── armgcc │ │ │ ├── Makefile │ │ │ └── ble_app_blinky_gcc_nrf52.ld │ │ ├── config │ │ │ └── sdk_config.h │ │ ├── hex │ │ │ └── ble_app_blinky_nrf52832_mdk_s132.hex │ │ └── main.c │ ├── ble_app_cli │ │ ├── armgcc │ │ │ ├── Makefile │ │ │ └── ble_app_cli_gcc_nrf52.ld │ │ ├── cli_adc_cmds.c │ │ ├── cli_bsp_cmds.c │ │ ├── cli_gpio_cmds.c │ │ ├── config │ │ │ └── sdk_config.h │ │ ├── hex │ │ │ └── ble_app_cli_nrf52832_mdk_s132.hex │ │ └── main.c │ ├── ble_app_eddystone │ │ ├── armgcc │ │ │ ├── Makefile │ │ │ └── ble_app_eddystone_gcc_nrf52.ld │ │ ├── config │ │ │ └── sdk_config.h │ │ ├── es_app_config.h │ │ ├── hex │ │ │ └── ble_app_eddystone_nrf52832_mdk_s132.hex │ │ └── main.c │ ├── ble_app_hrs │ │ ├── armgcc │ │ │ ├── Makefile │ │ │ └── ble_app_hrs_gcc_nrf52.ld │ │ ├── config │ │ │ └── sdk_config.h │ │ ├── hex │ │ │ └── ble_app_hrs_nrf52832_mdk_s132.hex │ │ └── main.c │ ├── blinky │ │ ├── README.md │ │ ├── armgcc │ │ │ ├── Makefile │ │ │ └── blinky_gcc_nrf52.ld │ │ ├── config │ │ │ └── sdk_config.h │ │ ├── hex │ │ │ └── blinky_nrf52832_mdk.hex │ │ └── main.c │ ├── flash_fds │ │ ├── armgcc │ │ │ ├── Makefile │ │ │ └── flash_fds_example_gcc_nrf52.ld │ │ ├── cli.c │ │ ├── config │ │ │ └── sdk_config.h │ │ ├── fds_example.h │ │ ├── hex │ │ │ └── flash_fds_example_nrf52832_mdk.hex │ │ └── main.c │ ├── nfc_url_record │ │ ├── armgcc │ │ │ ├── Makefile │ │ │ └── nfc_url_record_gcc_nrf52.ld │ │ ├── config │ │ │ └── sdk_config.h │ │ ├── hex │ │ │ └── nfc_url_record_nrf52832_mdk.hex │ │ └── main.c │ └── saadc │ │ ├── armgcc │ │ ├── Makefile │ │ └── saadc_gcc_nrf52.ld │ │ ├── config │ │ └── sdk_config.h │ │ ├── hex │ │ └── saadc_nrf52832_mdk.hex │ │ └── main.c └── zephyr │ ├── README.md │ ├── blink_led │ ├── CMakeLists.txt │ ├── README.rst │ ├── prj.conf │ ├── prj_nrf52832_mdk.conf │ ├── prj_nrf52840_mdk.conf │ ├── prj_nrf52840_pca10056.conf │ ├── sample.yaml │ └── src │ │ └── main.c │ ├── blinky │ ├── CMakeLists.txt │ ├── README.rst │ ├── prj.conf │ ├── sample.yaml │ └── src │ │ └── main.c │ ├── bluetooth │ ├── beacon │ │ ├── CMakeLists.txt │ │ ├── README.rst │ │ ├── prj.conf │ │ ├── sample.yaml │ │ └── src │ │ │ └── main.c │ ├── eddystone │ │ ├── CMakeLists.txt │ │ ├── README.rst │ │ ├── prj.conf │ │ ├── sample.yaml │ │ └── src │ │ │ └── main.c │ ├── gatt │ │ ├── bas.c │ │ ├── bas.h │ │ ├── cts.c │ │ ├── cts.h │ │ ├── dis.c │ │ ├── dis.h │ │ ├── hog.c │ │ ├── hog.h │ │ ├── hrs.c │ │ ├── hrs.h │ │ ├── ipss.c │ │ └── ipss.h │ └── peripheral_hr │ │ ├── CMakeLists.txt │ │ ├── README.rst │ │ ├── prj.conf │ │ ├── sample.yaml │ │ └── src │ │ └── main.c │ ├── button │ ├── CMakeLists.txt │ ├── README.rst │ ├── prj.conf │ ├── sample.yaml │ └── src │ │ └── main.c │ ├── fade_led │ ├── CMakeLists.txt │ ├── README.rst │ ├── prj.conf │ ├── sample.yaml │ └── src │ │ └── main.c │ ├── hello_world │ ├── CMakeLists.txt │ ├── README.rst │ ├── prj.conf │ ├── sample.yaml │ └── src │ │ └── main.c │ └── threads │ ├── CMakeLists.txt │ ├── README.rst │ ├── prj.conf │ ├── sample.yaml │ └── src │ └── main.c ├── firmware ├── daplink │ ├── README.md │ ├── lpc11u35_nrf52832_mdk_if_crc_0244.bin │ ├── lpc11u35_nrf52832_mdk_if_crc_0245.bin │ ├── lpc11u35_nrf52832_mdk_if_crc_0251.bin │ └── lpc11u35_nrf52832_mdk_if_crc_0253.bin ├── espruino │ ├── espruino_1v96.3727_nrf52832_mdk.hex │ └── espruino_1v96.3727_nrf52832_mdk.zip ├── jerryscript │ └── jerryscript_v1.0_for_zephyr.hex └── micropython │ └── micropython-v1.8.1-3702-gf163a64eb.hex ├── mkdocs.yml ├── nrf_sdks └── README.md └── tools ├── cmsisconfig ├── CMSIS_Configuration_Wizard.jar ├── LICENSE.txt └── README.TXT └── mergehex ├── Linux-i386 ├── mergehex ├── mergehex.h └── mergehex_release_notes.txt └── OSX ├── mergehex ├── mergehex.h └── mergehex_release_notes.txt /.gitignore: -------------------------------------------------------------------------------- 1 | nrf_sdks/* 2 | !nrf_sdks/nRF5-SDK-for-Mesh 3 | !nrf_sdks/README.md 4 | .DS_Store/* 5 | _build/ 6 | build/ 7 | 8 | BUILD/ 9 | mbed-os/ 10 | 11 | site 12 | 13 | mkdocs-material/* 14 | material/* 15 | 16 | .idea 17 | .build 18 | .mbed 19 | projectfiles 20 | *.py* -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "nrf_sdks/nRF5-SDK-for-Mesh"] 2 | path = nrf_sdks/nRF5-SDK-for-Mesh 3 | url = https://github.com/makerdiary/nRF5-SDK-for-Mesh.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 [makerdiary.co](https://makerdiary.co/) 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 | -------------------------------------------------------------------------------- /config/custom_board.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | #ifndef CUSTOM_BOARD_H 41 | #define CUSTOM_BOARD_H 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #if defined NRF52832_MDK 48 | #include "nrf52832_mdk.h" 49 | #else 50 | #error "Board is not defined" 51 | #endif 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif // CUSTOM_BOARD_H 58 | -------------------------------------------------------------------------------- /config/nrf52832_mdk.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2018 makerdiary 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following 14 | * disclaimer in the documentation and/or other materials provided 15 | * with the distribution. 16 | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | */ 30 | #ifndef NRF52832_MDK_H 31 | #define NRF52832_MDK_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #include "nrf_gpio.h" 38 | 39 | // LEDs definitions for nRF52832-MDK 40 | #define LEDS_NUMBER 3 41 | 42 | #define LED_START 22 43 | #define LED_1 22 44 | #define LED_2 23 45 | #define LED_3 24 46 | #define LED_STOP 24 47 | 48 | #define LEDS_ACTIVE_STATE 0 49 | 50 | #define LEDS_INV_MASK LEDS_MASK 51 | 52 | #define LEDS_LIST { LED_1, LED_2, LED_3 } 53 | 54 | #define BSP_LED_0 LED_1 55 | #define BSP_LED_1 LED_2 56 | #define BSP_LED_2 LED_3 57 | 58 | #define BUTTONS_NUMBER 4 59 | #define BUTTON_1 27 // Connect Grove-Button at Base Dock Grove Port#1 60 | #define BUTTON_2 29 // Connect Grove-Button at Base Dock Grove Port#2 61 | #define BUTTON_3 31 // Connect Grove-Button at Base Dock Grove Port#3 62 | #define BUTTON_4 3 // Connect Grove-Button at Base Dock Grove Port#4 63 | 64 | #define BUTTON_PULL NRF_GPIO_PIN_PULLDOWN 65 | 66 | #define BUTTONS_ACTIVE_STATE 1 67 | 68 | #define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4} 69 | 70 | #define BSP_BUTTON_0 BUTTON_1 71 | #define BSP_BUTTON_1 BUTTON_2 72 | #define BSP_BUTTON_2 BUTTON_3 73 | #define BSP_BUTTON_3 BUTTON_4 74 | 75 | 76 | #define RX_PIN_NUMBER 19 77 | #define TX_PIN_NUMBER 20 78 | #define HWFC false 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif // NRF52832_MDK_H 85 | -------------------------------------------------------------------------------- /docs/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | Interested in contributing to the nRF52832-MDK project? Want to report a bug? Before you do, please read the following guidelines. 3 | 4 | ## Got a question or problem? 5 | 6 | For quick questions there's no need to open an issue as you can comment at the bottom of the corresponding 7 | page. 8 | 9 | ## Found a bug? 10 | 11 | If you found a bug in the source code, you can help us by submitting an issue to the [issue tracker](https://github.com/makerdiary/nrf52832-mdk/issues) in our GitHub repository. Even better, you can submit a Pull Request with a fix. 12 | 13 | ## Missing a feature? 14 | 15 | You can request a new feature by submitting an issue to our GitHub Repository. Be sure that it is of use for everyone. 16 | 17 | -------------------------------------------------------------------------------- /docs/LICENSE.md: -------------------------------------------------------------------------------- 1 | **MIT License** 2 | 3 | Copyright (c) 2018 [makerdiary.com](https://makerdiary.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/cn/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | 如果你对 nRF52832-MDK 项目感兴趣,欢迎加入我们,一起做出有趣的东西。 3 | 4 | ## 任何疑问 5 | 6 | 如果有任何需要快速解答的疑问,可以直接在对应页面下方的评论窗口反馈。 7 | 8 | ## 提交 Bug 9 | 10 | 如果你发现某些 Bug,可以通过 [issue tracker](https://github.com/makerdiary/nrf52832-mdk/issues) 提交给我们,一起让这个项目变得更好。 11 | 12 | ## 增加新功能 13 | 14 | 如果你觉得可以增加一些有趣的新功能、新案例,可以在 GitHub 创建 Issue,向更多人分享你的想法。 15 | 16 | 17 | -------------------------------------------------------------------------------- /docs/cn/LICENSE.md: -------------------------------------------------------------------------------- 1 | **MIT License** 2 | 3 | Copyright (c) 2018 [makerdiary.com](https://makerdiary.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /docs/cn/about.md: -------------------------------------------------------------------------------- 1 | # 订阅更多 2 | 3 | 你可以通过以下方式订阅、关注我们,一起交流、学习、成长: 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/cn/daplink/index.md: -------------------------------------------------------------------------------- 1 | # Arm Mbed DAPLink
Arm Mbed 开源的 Cortex 芯片调试工具 2 | 3 | [![](../../daplink/images/daplink-website-logo-link.png)](https://github.com/ARMmbed/DAPLink) 4 | 5 | ## 简介 6 | 7 | DAPLink 是 Arm Mbed 开源的、针对 Cortex-M 芯片的调试工具,其目的是通过 Cortex 调试器来实现代码下载到目标设备。 8 | 9 | DAPLink 有三个主要特性: 10 | 11 | * HID 接口实现,基于 CMSIS-DAP 调试协议,HID 接口允许常用的工具链来对设备进行编程及调试,目前支持的工具链包括 MDK、IAR 及 pyOCD; 12 | * 拖放编程支持,通过将 固件拖放到 USB 磁盘内即实现编程 13 | * 实现 USB 串口通信功能。 14 | 15 | 了解更多信息,可以访问 [Arm Mbed DAPLink 官网](https://armmbed.github.io/DAPLink/)。 16 | 17 | ## 功能框图 18 | 19 | 以下是 DAPLink 的功能框图,使用 Cortex-M0 内核的 LPC11U35 实现: 20 | 21 | ![](../../daplink/images/daplink_diagram.png) 22 | 23 | ## 如何更新 DAPLink 固件? 24 | 25 | DAPLink 会不断优化以及增加新的功能,你可以通过更新固件来获得这些新功能,按照以下步骤可完成更新: 26 | 27 | 1. 按下 RESET 按键,连接到 PC,DAPLink 将进入 Bootloader 模式,系统出现名为 `CRP DISABLD` 的可移动磁盘; 28 | 2. 删除 `CRP DISABLD` 可移动磁盘中的 `firmware.bin` 文件; 29 | 3. 下载[最新的 DAPLink 固件](https://github.com/makerdiary/nrf52832-mdk/tree/master/firmware/daplink) 30 | 4. 将固件直接拷贝到 `CRP DISABLD` 可移动磁盘; 31 | 5. 拷贝完成后,重新拔插板子,即可完成更新,新版本号从 *DAPLink* 磁盘中描述文件中获得。 32 | 33 | ## 如何编译 DAPLink? 34 | 35 | 你也可以自己编译 DAPLink,以下内容将做简单介绍: 36 | 37 | ### 安装依赖工具 38 | 39 | 提前安装好以下需要用到的第三方工具: 40 | 41 | * [Python 2, 2.7.9+](https://www.python.org/downloads/) 42 | * [Git](https://git-scm.com/downloads) 43 | * [Keil MDK-ARM](https://www.keil.com/download/product/) 44 | 45 | ### 下载源码 46 | 47 | 从 Arm Mbed 官方仓库克隆 DAPLink 源码: 48 | 49 | ``` sh 50 | $ git clone https://github.com/ARMmbed/DAPLink 51 | $ cd DAPLink 52 | $ pip install virtualenv 53 | $ virtualenv venv 54 | ``` 55 | 56 | ### 创建编译环境 57 | 58 | 使用 Python 虚拟环境,安装依赖工具,并生成 Keil 工程: 59 | 60 | ``` sh 61 | $ ./venv/Scripts/activate 62 | $ pip install -r requirements.txt 63 | $ progen generate -t uvision 64 | $ ./venv/Scripts/deactivate 65 | ``` 66 | 67 | ### 编译 DAPLink 68 | 69 | 在 `projectfiles/uvision/` 目录打开 Keil 工程,直接点击编译按钮即可。 70 | 71 | ![](../../daplink/images/building_daplink_keil.png) 72 | 73 | ## 参考资源 74 | 75 | * [Arm Mbed DAPLink 仓库](https://github.com/ARMmbed/DAPLink) 76 | 77 | ## 问题反馈 78 | 79 | 如果在开发过程遇到任何问题,可以通过 [GitHub Issue](https://github.com/makerdiary/nrf52832-mdk/issues) 反馈。 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /docs/cn/getting-started/images/daplink_disk_win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/cn/getting-started/images/daplink_disk_win.png -------------------------------------------------------------------------------- /docs/cn/getting-started/index.md: -------------------------------------------------------------------------------- 1 | # nRF52832-MDK 快速入门指南 2 | 3 | !!! success "感谢使用 nRF52832-MDK!" 4 | 本指南将指引你如何快速开始 nRF52832-MDK 开发,整个过程大概需要 20 分钟。 5 | 6 | ## 第一步:连接 nRF52832-MDK 7 | 8 | 使用 Micro USB 数据线,将 nRF52832-MDK 连接至 PC,绿色电源指示灯将常亮,另外的绿色 LED 常亮表示蓝牙正在广播: 9 | 10 | ![](../../getting-started/images/connecting_nrf52832-mdk.jpg) 11 | 12 | 打开 PC 的资源浏览器,nRF52832-MDK 将被识别成一个名为 **DAPLINK** 的可移动磁盘设备: 13 | 14 | ![](images/daplink_disk_win.png) 15 | 16 | ## 第二步:配置串口终端 17 | 18 | ### Windows 19 | 20 | 在 Windows 环境下可能需要安装串口驱动,[点击下载](http://os.mbed.com/media/downloads/drivers/mbedWinSerial_16466.exe)并安装驱动。 21 | 22 | !!! tip "提示" 23 | 对于 Windows 10 以上系统,系统会自动安装驱动。 24 | 25 | 串口工具建议使用免费的 [PuTTY](https://www.chiark.greenend.org.uk/~sgtatham/putty/),相关设置如下,串口号可以在 *设备管理器* 中查看: 26 | 27 | ![](../../getting-started/images/putty_configuration.png) 28 | 29 | ![](../../getting-started/images/putty_messages.png) 30 | 31 | ### macOS 32 | 33 | macOS 用户可直接使用系统内置的终端工具 `screen`, 具体命令如下: 34 | 35 | ``` sh 36 | $ screen /dev/cu.usbmodem1412 115200 37 | ``` 38 | 39 | !!! tip "小技巧" 40 | 可以在终端先输入 `screen /dev/cu.usb`,然后按下 tab,设备名称将自动补齐。 41 | 42 | 按下 Ctrl + A,再按下 K,在窗口底部会出现提示符 `[y/n]`,输入 y 即可退出串口终端。 43 | 44 | ![](../../getting-started/images/screen_messages_macos.png) 45 | 46 | ### Linux 47 | 48 | 在 Linux 环境下同样可以使用 `screen` 工具,这里以 Ubuntu 16.04 为例: 49 | 50 | ``` sh 51 | $ sudo apt-get install screen 52 | ``` 53 | 54 | ``` sh 55 | $ sudo screen /dev/ttyACM0 115200 56 | ``` 57 | 58 | ![](../../getting-started/images/screen_messages_ubuntu.png) 59 | 60 | 61 | ## 第三步:使用 nRF Connect 62 | 63 | 1. 从 App Store 或 Google Play 下载 *nRF Connect* 应用; 64 | 2. 打开 app,扫描设备,你将看到名为 *nRF52832-MDK* 的设备正在广播,连接该设备; 65 | 3. 蓝色 LED 亮、绿色 LED 灭,表明设备从广播态进入连接态,同时可以观察到该设备能够提供的服务; 66 | 4. 先后对 *Nordic Blinky LED* 属性 (0x1525) 写入 `01` 、`00`,可观察到 LED 的状态变化。 67 | 68 | [![](../../getting-started/images/nrf_connect_blinky.jpg)](../../getting-started/images/nrf_connect_blinky.jpg) 69 | 70 | !!! tip "提示" 71 | 该演示 demo 源码位于 `./nrf52832-mdk/examples/nrf5-sdk/ble_app_blinky`。 72 | 73 | ## 如何下载固件? 74 | 75 | nRF52832-MDK 板上集成了 DAPLink 多功能调试器,可用于下载固件、调试代码、输出调试信息。目前支持以下两种下载方式: 76 | 77 | * [“拖放”下载](#_4) 78 | * [使用 pyOCD 下载](#pyocd) 79 | 80 | ### “拖放”下载 81 | 82 | 将 nRF52832-MDK 连接到 PC,系统会自动识别到 **DAPLINK** 可移动磁盘,直接把 `.hex` 固件拖放到该磁盘即可开始下载,等待下载完成.... 83 | 84 | ![](../../getting-started/images/drag-n-drop_programming.png) 85 | 86 | 下载完成后,按下复位按钮便可运行新固件。 87 | 88 | ### 使用 pyOCD 89 | 90 | [pyOCD](https://github.com/mbedmicro/pyOCD) 是一个开源、跨平台的 python 库,支持 Linux, macOS, Windows 系统,可对 ARM Cortex-M 系列 MCU 进行编程和调试,甚至可以利用其提供的 API 实现更复杂的功能。 91 | 92 | 可以通过 [pip](https://pip.pypa.io/en/stable/index.html) 安装最新稳定版: 93 | 94 | ``` sh 95 | $ pip install --pre -U pyocd 96 | ``` 97 | 98 | 或者,可以尝试安装最新开发版本,体验一些正在开发中的新功能: 99 | 100 | ``` sh 101 | $ pip install --pre -U https://github.com/mbedmicro/pyOCD/archive/master.zip 102 | ``` 103 | 104 | !!! note "注意" 105 | 有的系统(例如 Ubuntu )可能会因为权限问题导致无法正常使用 pyOCD,需要在安装命令前增加 `sudo -H` 进行全局安装。 106 | 107 | 通过以下命令可完成固件下载、擦除: 108 | 109 | ``` sh 110 | # -se 表示只擦除需要用到的区域 111 | $ pyocd-flashtool -t nrf52 -se your-hex-file.hex 112 | 113 | # 如果需要整片擦除,可以使用 -ce 参数 114 | $ pyocd-flashtool -t nrf52 -ce your-hex-file.hex 115 | 116 | # 如果只是想擦除,不编程,可以不带hex文件参数 117 | $ pyocd-flashtool -t nrf52 -ce 118 | ``` 119 | 120 | ![](../../getting-started/images/programming_using_pyocd.png) 121 | 122 | ## 下载项目源码 123 | 124 | nRF52832-MDK 的所有示例代码及文档托管在 GitHub [makerdiary/nrf52832-mdk](https://github.com/makerdiary/nrf52832-mdk) 仓库,你可以自由下载或克隆到你的工作目录下使用: 125 | 126 | ``` sh 127 | $ git clone https://github.com/makerdiary/nrf52832-mdk.git 128 | ``` 129 | 130 | ## 问题反馈 131 | 132 | 如果在开发过程遇到任何问题,可以通过 [GitHub Issue](https://github.com/makerdiary/nrf52832-mdk/issues) 反馈。 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /docs/cn/how-to-buy.md: -------------------------------------------------------------------------------- 1 | # 如何购买 nRF52832-MDK? 2 | 3 | ## 购买渠道 4 | 5 | 你可以通过以下购买渠道获得 nRF52832-MDK 相关硬件: 6 | 7 | [![Taobao](../../images/taobao-logo.png)](https://zaowubang.taobao.com/category-1347611684.htm?spm=a1z10.1-c-s.w4010-18605444712.9.39be796cJVdvk7&search=y&parentCatId=769990253&parentCatName=%CE%EF%C1%AA%CD%F8%D3%B2%BC%FE&catName=nRF52832-MDK#bd) 8 | 9 | 10 | 11 | ## 批量&定制化 12 | 如果你有批量或者定制化需求,可以直接联系我们! 13 | 14 | -------------------------------------------------------------------------------- /docs/cn/index.md: -------------------------------------------------------------------------------- 1 | # nRF52832-MDK
开源、面向物联网应用的开发套件 2 | 3 | !!! note "提示" 4 | 目前 nRF52832-MDK 有两个硬件版本可用: 5 | 6 | * **V1**: 带有 Micro USB 接口且排针焊接在板上 7 | * **V2**: 配排针但不焊在板上、无需数据线即可与 PC 连接 8 | 9 | nRF52832-MDK 是一款完全开源、基于 Nordic 新一代高性能低功耗蓝牙系统级芯片 [nRF52832](http://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF52832)、面向物联网嵌入式应用的开发套件。 10 | 11 | nRF52832-MDK 提供丰富的硬件资源,集成多功能调试工具,可以玩转多种开源软件框架(如:nRF5 SDK, Mesh, Mbed OS 5, Zephyr, Mynewt, JerryScript, Espruino, MicroPython 等等)。 12 | 13 | nRF52832-MDK 支持跨平台开发,并且提供丰富的在线文档及示例,希望带来全新的开发体验。 14 | 15 | ![产品图片](../images/nrf52832_mdk_v1_image.jpg) 16 | 17 | ![产品图片](../images/nrf52832_mdk_v2_image.jpg) 18 | 19 | ## 硬件规格 20 | 21 | * Nordic 高性能低功耗蓝牙 SoC nRF52832 22 | 23 | * ARM® Cortex™-M4F 内核 24 | * 512kB Flash + 64kB RAM 25 | * 支持低功耗蓝牙(BLE), ANT, 2.4GHz 26 | * 支持 NFC™-A 标签 27 | 28 | * 板载 DAPLink 多功能调试工具: 29 | 30 | * MSC - 支持“拖放”方式下载固件 31 | * CDC - 提供虚拟串口工具 32 | * HID - 兼容 CMSIS-DAP 仿真功能 33 | 34 | * 拥有多达 24 个可编程 GPIO 35 | 36 | * 提供复位按钮,可更新 DAPLink 固件 37 | 38 | * 可编程 RGB LED 39 | 40 | * 2.4GHz 晶片天线,在有限的空间内提供出色的 RF 性能 41 | 42 | * 3.3V 稳压器,高效率、低静态电流、可输出 1A 峰值电流 43 | 44 | * VBUS & VIN 电源路径管理 45 | 46 | * 标准引脚间距,可直接安装在面包板上 47 | 48 | * 尺寸小巧 48mm x 18mm x 13mm (已焊排针)、63mm x 18mm x 4mm(不焊排针) 49 | 50 | ## 引脚位置图 51 | 52 | [![](../images/nrf52832_mdk_v1_pinout.jpeg)](../images/nrf52832_mdk_v1_pinout.jpeg) 53 | 54 | [![](../images/nrf52832_mdk_v2_pinout.jpeg)](../images/nrf52832_mdk_v2_pinout.jpeg) 55 | 56 | ## nRF52832 SoC 57 | 58 | nRF52832 SoC 是 Nordic Semiconductor 新一代高性能的低功耗蓝牙系统级芯片,ARM® Cortex™-M4F 内核,512kB Flash + 64kB RAM,支持 BLE, ANT, 2.4GHz 协议栈。 59 | 60 | 61 | 62 | ![](../images/nrf52832_soc.png) 63 | 64 | ## 多功能调试器 65 | 66 | nRF52832-MDK 集成了多功能调试器 DAPLink,即插即用,支持“拖放”方式下载固件、串口调试、CMSIS-DAP 仿真调试。 67 | 68 | 69 | 70 | ![](../images/daplink_diagram.png) 71 | 72 | ## 开源软件框架 73 | 74 | nRF52832-MDK 可以用来玩转多种开源软件框架: 75 | 76 | | 开源框架 | 简介 | 77 | | ---------- | ----- | 78 | | [nRF5 SDK](http://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF5-SDK) | Nordic 官方提供的 SDK | 79 | | [nRF5 SDK for Mesh](http://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF5-SDK-for-Mesh) | Nordic 官方提供的低功耗蓝牙 Mesh 网络 SDK | 80 | | [Mbed OS 5](https://os.mbed.com/) | Arm 开源的物联网实时操作系统 | 81 | | [Zephyr](https://www.zephyrproject.org/) | Linux 基金会开源的物联网实时操作系统 | 82 | | [Mynewt](https://mynewt.apache.org/) | Apache 开源模块化的实时操作系统,专门为内存和存储都极其有限而又要以极低功耗运行非常长时间的物联网设备设计 | 83 | | [JerryScript](https://github.com/jerryscript-project/jerryscript) | 三星开源的面向物联网的轻量级 JavaScript 引擎 | 84 | | [Espruino](https://github.com/espruino/Espruino) | 运行在内存和存储都极其有限的 MCU 上的 JavaScrupt 引擎 | 85 | | [MicroPython](https://github.com/micropython/micropython) | 面向嵌入式设备的轻量级 Python | 86 | | [Web Bluetooth](https://github.com/WebBluetoothCG/web-bluetooth) | 基于 Web 的低功耗蓝牙 API | 87 | | [Eddystone](https://github.com/google/eddystone) | Google 开源的 Beacon 协议 | 88 | | .... | | 89 | 90 | 91 | ## 在线文档 92 | 93 | nRF52832-MDK 提供优秀的在线文档,使用 [MkDocs](http://www.mkdocs.org/) 生成文档,并托管在 [GitHub](https://github.com/makerdiary/nrf52832-mdk/) 上。 94 | 95 | ![文档图片](../images/nrf52832_mdk_docs.png) 96 | 97 | ## 相关资源 98 | 99 | | 版本 | 设计文档 | 100 | | -------- | --------- | 101 | | V2.0 | [nRF52832-MDK V2.0 Schematic](../hardware/nRF52832-MDK_SCH_V2.0.pdf)
[nRF52832-MDK V2.0 PCB](../hardware/nRF52832-MDK_PCB_V2.0.pdf)
[nRF52832-MDK V2.0 3D STEP](../hardware/nRF52832-MDK_3D_STEP_V2.0.step)| 102 | | V1.1 | [nRF52832-MDK V1.1 Schematic](../hardware/nRF52832-MDK_SCH_V1.1.pdf)
[nRF52832-MDK V1.1 PCB]()
[nRF52832-MDK V1.1 3D STEP](../hardware/nRF52832-MDK_3D_STEP_V1.1.step)| 103 | | V1.0 | [nRF52832-MDK V1.0 Schematic](../hardware/nRF52832-MDK_SCH_V1.0.pdf)
[nRF52832-MDK V1.0 PCB](../hardware/nRF52832-MDK_PCB_V1.0.pdf)
[nRF52832-MDK V1.0 3D STEP](../hardware/nRF52832-MDK_3D_STEP_V1.0.step)| 104 | 105 | ## 问题反馈 106 | 107 | 如果在开发过程遇到任何问题,可以通过 [GitHub Issue](https://github.com/makerdiary/nrf52832-mdk/issues) 反馈。 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /docs/cn/jerryscript/index.md: -------------------------------------------------------------------------------- 1 | # JerryScript
开源、面向小型嵌入式设备的 JavaScript 引擎 2 | 3 | [![](../../jerryscript/images/jerryscript-logo.png)](https://github.com/jerryscript-project/jerryscript) 4 | 5 | ## 简介 6 | 7 | JerryScript 是三星开源的一个非常轻量的 JavaScript 引擎,主要面向资源受限的物联网设备,可在 小于 64KB RAM 64KB 和 200KB ROM 的微控制器上运行。 8 | 9 | JavaScript 是现在非常流行的编程语言之一,大量前端开发者对它非常熟悉,将物联网设备和 web 生态系统相互配合,对于构建物联网生态系统来说是个明智的选择,这也正是三星开发 JerryScript 的初衷。 10 | 11 | 另一方面,JavaScript 在嵌入式设备开发中是非常便利的。它支持异步函数回调和异步 I/O,这对基于事件驱动的硬件编程是非常有用的。 12 | 13 | JerryScript 具备以下关键特性: 14 | 15 | * 完全兼容 ECMAScript 5.1 16 | * 若采用 ARM Thumb-2 指令集编译,仅需 160KB 空间 17 | * 注重内存优化,减少内存消耗 18 | * 使用 C99 编写,可移植性强 19 | * 为预编译 JavaScript 源码提供快照支持 20 | * 提供成熟的 C API,调用方便 21 | 22 | 了解更多细节,可以访问 [JerryScript 官方仓库](https://github.com/jerryscript-project/jerryscript)。 23 | 24 | ## 快速入门 25 | 26 | 以下内容将介绍如何快速编译、运行 JerryScript。 27 | 28 | ### 搭建编译环境 29 | 30 | 编译 JerryScript 引擎之前,需要配置好开发环境,安装以下工具: 31 | 32 | * `gcc` 或 其他 C99 编译器 (本地或交叉编译器,例如:arm-none-eabi) 33 | * `cmake` >= `2.8.12.2` 34 | * `bash` >= `4.3.11` 35 | * `cppcheck` >= `1.61` 36 | * `vera++` >= `1.2.1` 37 | * `python` >= `2.7.6` 38 | 39 | 另外确保以下命令行工具可用: 40 | 41 | * `awk` 42 | * `bc` 43 | * `find` 44 | * `sed` 45 | 46 | 从官方仓库克隆 JerryScript 源码: 47 | 48 | ``` sh 49 | $ git clone https://github.com/jerryscript-project/jerryscript.git 50 | ``` 51 | 52 | ### 基于 Zephyr 编译 JerryScript 53 | 54 | 这里我们基于 Zephyr 来编译 JerryScript 引擎,你也可以基于 Arm Mbed OS 进行编译。 55 | 56 | Zephyr 开发环境配置请参考:[搭建 Zephyr 开发环境](../zephyr)。 57 | 58 | 配置 Zephyr 环境变量: 59 | 60 | ``` sh 61 | $ cd zephyr 62 | $ source zephyr-env.sh 63 | ``` 64 | 65 | ### 编译运行 JerryScript 66 | 67 | 接下来,你可以开始编译下载 JerryScript 引擎: 68 | 69 | ``` sh 70 | $ cd jerryscript 71 | $ make -f ./targets/zephyr/Makefile.zephyr BOARD=nrf52832_mdk flash 72 | ``` 73 | 74 | 打开串口工具,JerryScript 将以 REPL 模式运行: 75 | 76 | ``` sh 77 | ***** BOOTING ZEPHYR OS v1.10.99 - BUILD: Mar 2 2018 22:19:04 ***** 78 | JerryScript build: Mar 2 2018 22:19:03 79 | JerryScript API 1.0 80 | Zephyr version 1.10.99 81 | js> 82 | ``` 83 | 84 | 尝试运行下面比较简单的脚本: 85 | 86 | ``` js 87 | js> var test=0; for (t=100; t<1000; t++) test+=t; print ('Hi JS World! '+test); 88 | Hi JS World! 494550 89 | undefined 90 | ``` 91 | 92 | 或者更复杂的: 93 | 94 | ``` js 95 | js> function hello(t) {t=t*10;return t}; print("result"+hello(10.5)); 96 | result105 97 | undefined 98 | ``` 99 | 100 | ![](../../jerryscript/images/jerryscript_for_zephyr_repl.png) 101 | 102 | !!! tip "提示" 103 | 我们提供预编译好的固件 `jerryscript_v1.0_for_zephyr.hex`, 该固件位于 `./nrf52832-mdk/firmware/jerryscript/` 目录。 104 | 105 | ## 更多示例 106 | 107 | JerryScript 引擎目前还没有直接支持 nRF5 SoC,相信在社区开发者的努力下,很快会完成这部分移植工作。 108 | 109 | 目前 Intel 基于 Zephyr 已经做大量移植工作,这个项目就是 [Zephyr.js](https://github.com/intel/zephyr.js),对 Arduino 101 支持比较好,对于 nRF52 还有一些功能需要添加,你可以保持关注,更多功能会逐渐加入。 110 | 111 | ## 参考资源 112 | 113 | * [JerryScript 官方仓库](https://github.com/jerryscript-project/jerryscript) 114 | * [zephyr.js 官方仓库](https://github.com/intel/zephyr.js) 115 | 116 | 117 | ## 问题反馈 118 | 119 | 如果在开发过程遇到任何问题,可以通过 [GitHub Issue](https://github.com/makerdiary/nrf52832-mdk/issues) 反馈。 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /docs/cn/mbedos/index.md: -------------------------------------------------------------------------------- 1 | # Arm Mbed OS
Arm 开源、面向物联网小型设备的实时操作系统 2 | 3 | [![](../../mbedos/images/mbedos-logo.png)](https://os.mbed.com/) 4 | 5 | ## 简介 6 | 7 | Arm Mbed OS 是 Arm 专门为物联网设备而设计的开源嵌入式操作系统,主要面向 ARM Cortex-M 系列微控制器,非常适合涉及智能城市、智能家庭和穿戴式设备等领域的应用程序。 8 | 9 | 相比于其他嵌入式操作系统,Arm Mbed OS 的主要优势在于: 10 | 11 | * 安全性:提供 mbed TLS 和 mbed uVisor 安全机制 12 | * 连接性:支持多种协议栈,包括 Bluetooth LE, Wi-Fi, 6LoWPAN, Thread, Lora等等 13 | * 完整的工具链支持:提供在线 IDE, mbed CLI 以及 第三方 IDE 14 | * 良好的社区生态 15 | 16 | 了解更多内容,可以直接访问 [Mbed OS 开发者网站](https://os.mbed.com/). 17 | 18 | ## 使用 Arm Mbed CLI 19 | 20 | Arm 为 Mbed OS 提供了离线开发工具 Mbed CLI,该工具支持跨平台,可以运行在 Windows,Linux 和 macOS 平台上。 21 | 22 | ### 安装 Mbed CLI 23 | 24 | 在 Windows 上,最简单的方法是使用 [Mbed CLI Windows .exe 安装包](https://mbed-media.mbed.com/filer_public/50/38/5038849b-16a8-42f3-be7a-43d98c7a3af3/mbed_installer_v043.exe)。 25 | 26 | 在 Linux 和 macOS系统,可以使用 `pip` 进行安装: 27 | 28 | ``` sh 29 | $ pip install mbed-cli 30 | ``` 31 | 32 | 安装完成后,可以使用 `mbed help` 验证是否正确安装。 33 | 34 | ### 设置开发环境 35 | 36 | 接着,需要添加工具链路径配置: 37 | 38 | ``` sh 39 | $ mbed config -G GCC_ARM_PATH "" 40 | [mbed] now set as global GCC_ARM_PATH 41 | 42 | $ mbed config --list 43 | [mbed] Global config: 44 | GCC_ARM_PATH= 45 | ``` 46 | 47 | ## 编译运行第一个示例 48 | 49 | 现在可以开始尝试编译第一个示例,这里以 `mbed-os-example-blinky` 为例: 50 | 51 | 打开命令行终端,切换到示例目录: 52 | 53 | ``` sh 54 | $ cd ./nrf52832-mdk/examples/mbedos5/mbed-os-example-blinky/ 55 | ``` 56 | 57 | 为该示例添加 Mbed OS 库: 58 | 59 | ``` sh 60 | mbed-os-example-blinky$ mbed config root . 61 | mbed-os-example-blinky$ mbed add https://github.com/makerdiary/mbed-os.git 62 | ``` 63 | 64 | 使用 `mbed compile` 进行编译: 65 | 66 | ``` sh 67 | mbed-os-example-blinky$ mbed compile --target NRF52832_MDK --toolchain GCC_ARM --flash 68 | ``` 69 | 70 | 增加 `--flash` 参数,将会在编译完成后自动将固件下载到 nRF52832-MDK 硬件上。 71 | 72 | 如果 `mbed detect` 无法检测到板子,可以运行以下命令添加: 73 | 74 | ``` sh 75 | $ mbedls --mock=1024:nRF52832_MDK 76 | ``` 77 | 78 | !!! tip "提示" 79 | 你也可以参考前面的内容 “[如何下载固件?](../getting-started/#_2)” 下载固件。 80 | 81 | ![](../../mbedos/images/mbed-os-example-blinky-bash.png) 82 | 83 | 观察运行结果: 84 | 85 | ![](../../mbedos/images/mbed-os-example-blinky-demo.gif) 86 | 87 | 88 | ## 低功耗蓝牙示例 89 | 90 | Mbed OS 对低功耗蓝牙支持非常友好,这里提供一些低功耗蓝牙示例: 91 | 92 | ``` sh 93 | ./nrf52832-mdk/examples/mbedos5/mbed-os-example-ble 94 | ├── BLE_BatteryLevel 95 | ├── BLE_Beacon 96 | ├── BLE_Button 97 | ├── BLE_EddystoneObserver 98 | ├── BLE_EddystoneService 99 | ├── BLE_GAPButton 100 | ├── BLE_HeartRate 101 | ├── BLE_LED 102 | ├── BLE_LEDBlinker 103 | ├── BLE_Thermometer 104 | └── README.md 105 | ``` 106 | 107 | 可以切换到示例目录,例如,`BLE_BatteryLevel`: 108 | 109 | ``` sh 110 | $ cd BLE_BatteryLevel 111 | ``` 112 | 113 | 添加 Mbed OS 库: 114 | 115 | ``` sh 116 | BLE_BatteryLevel$ mbed add https://github.com/makerdiary/mbed-os.git 117 | ``` 118 | 119 | 编译下载: 120 | 121 | ``` sh 122 | BLE_BatteryLevel$ mbed compile --target NRF52832_MDK --toolchain GCC_ARM --flash 123 | ``` 124 | 125 | 打开 **nRF Connect** app,找到名为 `BATTERY` 的设备,连接设备,可发现 UUID 为 `0x180F` 的电池服务,该服务包含 UUID 为 `0x2A19` 的 `Battery level` 属性。 126 | 127 | [![](../../mbedos/images/mbed-os-example-ble-battery.jpg)](../../mbedos/images/mbed-os-example-ble-battery.jpg) 128 | 129 | 其他低功耗蓝牙示例使用方法类似,你可以自行验证。 130 | 131 | ## 更多示例 132 | 133 | 我们会不定期增加更多有趣的示例到 [nrf52832-mdk](https://github.com/makerdiary/nrf52832-mdk) 仓库中,敬请关注! 134 | 135 | ## 参考资源 136 | 137 | * [Arm Mbed OS 开发者网站](https://os.mbed.com/) 138 | * [Mbed OS 文档中心](https://os.mbed.com/docs/) 139 | * [ARMmbed/mbed-os 仓库](https://github.com/ARMmbed/mbed-os) 140 | 141 | ## 问题反馈 142 | 143 | 如果在开发过程遇到任何问题,可以通过 [GitHub Issue](https://github.com/makerdiary/nrf52832-mdk/issues) 反馈。 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/cn/micropython/index.md: -------------------------------------------------------------------------------- 1 | # MicoPython
面向嵌入式设备的轻量级 Python 2 | 3 | [![](../../micropython/images/micropython-logo.jpeg)](https://github.com/micropython/micropython) 4 | 5 | ## 简介 6 | 7 | MicroPython 是⼀个 Python 3 的精简、⾼效实现,包含 Python 标准库的⼀⼩部分,并经过优化,可以运⾏在微控制器和受限环境中运⾏。 8 | 9 | MicroPython 包含了诸如交互式提⽰,任意精度整数、闭包、列表解析、⽣成器、异常处理等⾼级功能。然⽽,它⾜够紧凑,适合并能运⾏在只有 256k 代码空间和 16K RAM 的硬件上。 10 | 11 | MicroPython 旨在尽可能与普通 Python 兼容,从⽽轻松将代码从桌⾯传输到微控制器或嵌⼊式系统。 12 | 13 | 引用 MicroPhthon 社区的一段话: 14 | 15 | ``` markdown 16 | Code, 17 | Hack it, 18 | Less is more, 19 | Keep it simple, 20 | Small is beautiful, 21 | Be brave! Break things! Learn and have fun! 22 | Express yourself with MicroPython. 23 | Happy hacking! :-) 24 | ``` 25 | 26 | 了解更多信息,可以访问 [MicroPython 官方网站](http://micropython.org/)。 27 | 28 | ## 快速入门 29 | 30 | 下面内容我们简单介绍如何在 nRF52832-MDK 上运行 MicroPython。 31 | 32 | ### 下载 MicroPython 固件 33 | 34 | 我们已经提供一个简单的 MicroPython 固件,位于 `./nrf52832-mdk/firmware/micropython/` 目录下。 35 | 36 | 连接板子,直接将 `.hex` 固件拖到 *DAPLINK* 可移动磁盘中: 37 | 38 | ![](../../micropython/images/flashing_micropython_using_daplink.png) 39 | 40 | 下载完成,按下 RESET 按钮,MicroPython 将以 REPL 模式运行。 41 | 42 | ### 运行第一行代码 43 | 44 | 使用串口工具,打开设备,波特率为 `115200`: 45 | 46 | ``` sh 47 | $ screen /dev/cu.usbmodem1412 115200 48 | ``` 49 | 50 | 试着运行一些 Python 代码: 51 | 52 | ``` python 53 | >>> print('hello micropython!') 54 | ``` 55 | 56 | 输入 `help()` 可以获取一些有用的帮助信息: 57 | 58 | ![](../../micropython/images/micropython_repl_help.png) 59 | 60 | ### Blink LED 示例 61 | 62 | MicroPython 固件已经提供一些可以操作外设的 API,这里我们可以 Blink LED 为例: 63 | 64 | ``` python 65 | from machine import Pin 66 | import time 67 | 68 | led = Pin('PA22', Pin.OUT) 69 | 70 | for i in range(0, 10): 71 | led.value(1) 72 | time.sleep_ms(500) 73 | led.value(0) 74 | time.sleep_ms(500) 75 | 76 | print('Done!') 77 | ``` 78 | 79 | 观察绿色 LED 是否闪烁。 80 | 81 | 这就是整个使用过程,可以参考官方 API 文档,体验更多功能。 82 | 83 | ## 如何编译 MicroPython? 84 | 85 | 以下内容将介绍如何自己动手编译 MicroPython。 86 | 87 | ### 搭建开发环境 88 | 89 | 首先,下载安装 GNU Arm Embedded toolchains,并确保添加到系统环境变量: 90 | 91 | ``` sh 92 | /gcc-arm-none-eabi-6-2017-q2-update/bin 93 | ``` 94 | 95 | 验证是否正确安装: 96 | 97 | ``` sh 98 | $ arm-none-eabi-gcc --version 99 | ``` 100 | 101 | !!! note "注意" 102 | 最新版 GNU Arm Embedded toolchains 可能无法正常工作,可以自行尝试。 103 | 104 | ### 编译并下载 MicroPython 105 | 106 | 从我们的仓库克隆支持 nRF52832-MDK 的 MicroPython 仓库,并编译 MicroPython 标准库: 107 | 108 | ``` sh 109 | $ git clone https://github.com/makerdiary/micropython.git 110 | $ cd micropython 111 | $ git submodule update --init 112 | $ make -C mpy-cross 113 | ``` 114 | 115 | 切换到 `nrf` 目录,下载 低功耗蓝牙协议栈: 116 | 117 | ``` sh 118 | micropython$ cd nrf 119 | nrf$ ./drivers/bluetooth/download_ble_stack.sh 120 | ``` 121 | 122 | 接着,可以为 nRF52832-MDK 编译并下载固件: 123 | 124 | ``` sh 125 | $ make BOARD=nrf52832_mdk SD=s132 sd FLASHER=pyocd 126 | ``` 127 | 128 | ### 项目状态 129 | 130 | 目前,这部分工作还处于 beta 阶段,部分 API 可能会变更,你也可以参与到这个项目中来,尽管折腾吧。 131 | 132 | ## 参考资源 133 | 134 | * [MicroPython 官方网站](http://micropython.org/) 135 | * [MicroPython 文档](http://docs.micropython.org/en/latest/pyboard/index.html) 136 | * [MicroPython 官方仓库](https://github.com/micropython/micropython) 137 | * [makerdiary/MicroPython](https://github.com/makerdiary/micropython) 138 | 139 | ## 问题反馈 140 | 141 | 如果在开发过程遇到任何问题,可以通过 [GitHub Issue](https://github.com/makerdiary/nrf52832-mdk/issues) 反馈。 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /docs/daplink/images/building_daplink_keil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/daplink/images/building_daplink_keil.png -------------------------------------------------------------------------------- /docs/daplink/images/daplink-website-logo-link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/daplink/images/daplink-website-logo-link.png -------------------------------------------------------------------------------- /docs/daplink/images/daplink_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/daplink/images/daplink_diagram.png -------------------------------------------------------------------------------- /docs/espruino/images/espruino-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/espruino/images/espruino-logo.png -------------------------------------------------------------------------------- /docs/espruino/images/espruino_example_blinky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/espruino/images/espruino_example_blinky.png -------------------------------------------------------------------------------- /docs/espruino/images/espruino_web_ide_connected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/espruino/images/espruino_web_ide_connected.png -------------------------------------------------------------------------------- /docs/espruino/images/espruino_web_ide_connecting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/espruino/images/espruino_web_ide_connecting.png -------------------------------------------------------------------------------- /docs/espruino/images/espruino_web_ide_pairing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/espruino/images/espruino_web_ide_pairing.png -------------------------------------------------------------------------------- /docs/espruino/images/espruino_web_ide_ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/espruino/images/espruino_web_ide_ui.png -------------------------------------------------------------------------------- /docs/espruino/images/flashing_espruino_using_daplink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/espruino/images/flashing_espruino_using_daplink.png -------------------------------------------------------------------------------- /docs/espruino/images/web_bluetooth_secure_dfu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/espruino/images/web_bluetooth_secure_dfu.png -------------------------------------------------------------------------------- /docs/getting-started/images/connecting_nrf52832-mdk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/getting-started/images/connecting_nrf52832-mdk.jpg -------------------------------------------------------------------------------- /docs/getting-started/images/drag-n-drop_programming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/getting-started/images/drag-n-drop_programming.png -------------------------------------------------------------------------------- /docs/getting-started/images/nrf_connect_blinky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/getting-started/images/nrf_connect_blinky.jpg -------------------------------------------------------------------------------- /docs/getting-started/images/programming_using_pyocd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/getting-started/images/programming_using_pyocd.png -------------------------------------------------------------------------------- /docs/getting-started/images/putty_configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/getting-started/images/putty_configuration.png -------------------------------------------------------------------------------- /docs/getting-started/images/putty_messages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/getting-started/images/putty_messages.png -------------------------------------------------------------------------------- /docs/getting-started/images/screen_messages_macos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/getting-started/images/screen_messages_macos.png -------------------------------------------------------------------------------- /docs/getting-started/images/screen_messages_ubuntu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/getting-started/images/screen_messages_ubuntu.png -------------------------------------------------------------------------------- /docs/hardware/nRF52832-MDK_PCB_V1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/hardware/nRF52832-MDK_PCB_V1.0.pdf -------------------------------------------------------------------------------- /docs/hardware/nRF52832-MDK_PCB_V1.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/hardware/nRF52832-MDK_PCB_V1.1.pdf -------------------------------------------------------------------------------- /docs/hardware/nRF52832-MDK_PCB_V2.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/hardware/nRF52832-MDK_PCB_V2.0.pdf -------------------------------------------------------------------------------- /docs/hardware/nRF52832-MDK_SCH_V1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/hardware/nRF52832-MDK_SCH_V1.0.pdf -------------------------------------------------------------------------------- /docs/hardware/nRF52832-MDK_SCH_V1.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/hardware/nRF52832-MDK_SCH_V1.1.pdf -------------------------------------------------------------------------------- /docs/hardware/nRF52832-MDK_SCH_V2.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/hardware/nRF52832-MDK_SCH_V2.0.pdf -------------------------------------------------------------------------------- /docs/hardware/nRF52832-MDK_V1_Pinout.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/hardware/nRF52832-MDK_V1_Pinout.pdf -------------------------------------------------------------------------------- /docs/hardware/nRF52832-MDK_V2_Pinout.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/hardware/nRF52832-MDK_V2_Pinout.pdf -------------------------------------------------------------------------------- /docs/how-to-buy.md: -------------------------------------------------------------------------------- 1 | # How to Buy nRF52832-MDK 2 | 3 | ## Buy Online 4 | 5 | nRF52832-MDK is available on the following channels (click to go directly to the product): 6 | 7 | [![makerdiary store](images/makerdiary-store-logo.png)](https://store.makerdiary.com/collections/frontpage) 8 | 9 | [![SeeedStudio](images/seeed_logo_2018_horizontal.png)](https://www.seeedstudio.com/nRF52832-Micro-Development-Board-p-2992.html) 10 | 11 | [![Tindie](images/tindie-logo.png)](https://www.tindie.com/stores/Zelin/) 12 | 13 | [![Taobao](images/taobao-logo.png)](https://zaowubang.taobao.com/category-1347611684.htm?spm=a1z10.1-c-s.w4010-18605444712.9.39be796cJVdvk7&search=y&parentCatId=769990253&parentCatName=%CE%EF%C1%AA%CD%F8%D3%B2%BC%FE&catName=nRF52832-MDK#bd) 14 | 15 | 16 | ## Bulk & Customization 17 | 18 | We are ready to customize our electronics and firmware to better meet your solution's needs. Many of our platforms are prepared for customization. 19 | 20 | If you would like to do some serious business, [drop a line](mailto:zelin@makerdiary.co) and we'll reply before you know it. 21 | 22 | -------------------------------------------------------------------------------- /docs/images/daplink_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/daplink_diagram.png -------------------------------------------------------------------------------- /docs/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/favicon.png -------------------------------------------------------------------------------- /docs/images/logo.svg: -------------------------------------------------------------------------------- 1 | logo -------------------------------------------------------------------------------- /docs/images/makerdiary-store-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/makerdiary-store-logo.png -------------------------------------------------------------------------------- /docs/images/nrf52832-mdk-v1-n-v2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/nrf52832-mdk-v1-n-v2.jpg -------------------------------------------------------------------------------- /docs/images/nrf52832_mdk_docs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/nrf52832_mdk_docs.png -------------------------------------------------------------------------------- /docs/images/nrf52832_mdk_v1_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/nrf52832_mdk_v1_image.jpg -------------------------------------------------------------------------------- /docs/images/nrf52832_mdk_v1_pinout.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/nrf52832_mdk_v1_pinout.jpeg -------------------------------------------------------------------------------- /docs/images/nrf52832_mdk_v2_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/nrf52832_mdk_v2_image.jpg -------------------------------------------------------------------------------- /docs/images/nrf52832_mdk_v2_pinout.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/nrf52832_mdk_v2_pinout.jpeg -------------------------------------------------------------------------------- /docs/images/nrf52832_soc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/nrf52832_soc.png -------------------------------------------------------------------------------- /docs/images/seeed_logo_2018_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/seeed_logo_2018_horizontal.png -------------------------------------------------------------------------------- /docs/images/taobao-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/taobao-logo.png -------------------------------------------------------------------------------- /docs/images/tindie-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/tindie-logo.png -------------------------------------------------------------------------------- /docs/images/wxzwxd-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/images/wxzwxd-logo.png -------------------------------------------------------------------------------- /docs/jerryscript/images/jerryscript-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/jerryscript/images/jerryscript-logo.png -------------------------------------------------------------------------------- /docs/jerryscript/images/jerryscript_for_zephyr_repl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/jerryscript/images/jerryscript_for_zephyr_repl.png -------------------------------------------------------------------------------- /docs/mbedos/images/mbed-os-example-ble-battery.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mbedos/images/mbed-os-example-ble-battery.jpg -------------------------------------------------------------------------------- /docs/mbedos/images/mbed-os-example-blinky-bash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mbedos/images/mbed-os-example-blinky-bash.png -------------------------------------------------------------------------------- /docs/mbedos/images/mbed-os-example-blinky-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mbedos/images/mbed-os-example-blinky-demo.gif -------------------------------------------------------------------------------- /docs/mbedos/images/mbedos-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mbedos/images/mbedos-logo.png -------------------------------------------------------------------------------- /docs/mesh/images/building_my_light_switch_client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mesh/images/building_my_light_switch_client.png -------------------------------------------------------------------------------- /docs/mesh/images/flashing_my_light_switch_client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mesh/images/flashing_my_light_switch_client.png -------------------------------------------------------------------------------- /docs/mesh/images/generating_build_files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mesh/images/generating_build_files.png -------------------------------------------------------------------------------- /docs/mesh/images/mesh-network_topology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mesh/images/mesh-network_topology.png -------------------------------------------------------------------------------- /docs/mesh/images/mesh_icon_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mesh/images/mesh_icon_small.png -------------------------------------------------------------------------------- /docs/mesh/images/my_light_switch_client_log_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mesh/images/my_light_switch_client_log_info.png -------------------------------------------------------------------------------- /docs/mesh/images/nrf-mesh-app-screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mesh/images/nrf-mesh-app-screenshot.jpg -------------------------------------------------------------------------------- /docs/micropython/images/flashing_micropython_using_daplink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/micropython/images/flashing_micropython_using_daplink.png -------------------------------------------------------------------------------- /docs/micropython/images/micropython-logo.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/micropython/images/micropython-logo.jpeg -------------------------------------------------------------------------------- /docs/micropython/images/micropython_ble_repl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/micropython/images/micropython_ble_repl.png -------------------------------------------------------------------------------- /docs/micropython/images/micropython_repl_help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/micropython/images/micropython_repl_help.png -------------------------------------------------------------------------------- /docs/mynewt/images/loading_mynewt_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mynewt/images/loading_mynewt_image.png -------------------------------------------------------------------------------- /docs/mynewt/images/mynewt-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mynewt/images/mynewt-logo.png -------------------------------------------------------------------------------- /docs/mynewt/images/mynewt_example_blinky.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/mynewt/images/mynewt_example_blinky.gif -------------------------------------------------------------------------------- /docs/nrf5-sdk/images/SDK-icon_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/nrf5-sdk/images/SDK-icon_small.png -------------------------------------------------------------------------------- /docs/nrf5-sdk/images/arm-none-eabi-gcc_version.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/nrf5-sdk/images/arm-none-eabi-gcc_version.png -------------------------------------------------------------------------------- /docs/nrf5-sdk/images/blinky_example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/nrf5-sdk/images/blinky_example.gif -------------------------------------------------------------------------------- /docs/nrf5-sdk/images/gnu-make_version.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/nrf5-sdk/images/gnu-make_version.png -------------------------------------------------------------------------------- /docs/zephyr/images/hello_world_ninja_building.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/zephyr/images/hello_world_ninja_building.png -------------------------------------------------------------------------------- /docs/zephyr/images/zephyr-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/docs/zephyr/images/zephyr-logo.png -------------------------------------------------------------------------------- /examples/mbedos5/README.md: -------------------------------------------------------------------------------- 1 | # Getting started with mbed OS examples 2 | 3 | This guide reviews the steps required to get the examples working on nRF52832-MDK. 4 | 5 | ## Using Arm Mbed CLI 6 | 7 | In the Arm Mbed ecosystem, you have a choice in how you want to develop, Online and Offline. For offline development, Arm Mbed CLI is provided. Mbed CLI is compatible with Windows, Linux and OSX. This option provides more configuration options but also requires slightly more setup. 8 | 9 | The setup process for Arm Mbed CLI depends on your operating system. Please choose your host operating system. The setup instructions for each operating system walk you through how to install Mbed CLI locally. 10 | 11 | On Windows the easiest way to install Mbed CLI to run the [Mbed CLI Windows .exe installer](https://mbed-media.mbed.com/filer_public/50/38/5038849b-16a8-42f3-be7a-43d98c7a3af3/mbed_installer_v043.exe). 12 | 13 | On Linux and macOS, you can use Python and Pip: 14 | 15 | ``` sh 16 | $ pip install mbed-cli 17 | ``` 18 | 19 | You can ensure Mbed CLI installed correctly by running `mbed help` from your command-line. 20 | 21 | For any installed toolchain, be sure to add the Mbed CLI global configuration: 22 | 23 | ``` sh 24 | $ mbed config -G GCC_ARM_PATH "" 25 | [mbed] now set as global GCC_ARM_PATH 26 | 27 | $ mbed config --list 28 | [mbed] Global config: 29 | GCC_ARM_PATH= 30 | ``` 31 | 32 | !!! note 33 | You can also apply the same configuration to the IAR and ARM toolchains using `IAR_PATH` or `ARM_PATH`. 34 | 35 | ## Compile and program the board 36 | 37 | Now you can try to compile one of the examples. Will use the `mbed-os-example-blinky` example here to keep it simple. 38 | 39 | Open terminal and change directory to: 40 | 41 | ``` sh 42 | $ cd ./nrf52832-mdk/examples/mbedos5/mbed-os-example-blinky/ 43 | ``` 44 | 45 | Add mbed-os library to the example directory: 46 | 47 | ``` sh 48 | mbed-os-example-blinky$ mbed add https://github.com/makerdiary/mbed-os.git 49 | ``` 50 | 51 | Invoke `mbed compile`, and specify the name of your platform and your installed toolchain (GCC_ARM, ARM, IAR). For example, for the NRF52832_MDK platform and GNU Arm embedded toolchain: 52 | 53 | ``` sh 54 | mbed-os-example-blinky$ mbed compile --target NRF52832_MDK --toolchain GCC_ARM --flash 55 | ``` 56 | 57 | The `--flash` argument automatically flashes the compiled program onto your board if it is connected to your computer. You can add locally manufacturers id and platform name for nRF52832-MDK and see which boards are connected with `mbed detect`: 58 | 59 | ``` sh 60 | $ mbedls --mock=1024:nRF52832-MDK 61 | ``` 62 | 63 | ``` sh 64 | ... 65 | Compile [ 96.0%]: gpio_api.c 66 | Compile [ 96.3%]: lp_ticker.c 67 | Compile [ 96.6%]: pinmap.c 68 | Compile [ 96.9%]: nordic_critical.c 69 | Compile [ 97.2%]: port_api.c 70 | Compile [ 97.5%]: reloc_vector_table.c 71 | Compile [ 97.8%]: i2c_api.c 72 | Compile [ 98.2%]: rtc_api.c 73 | Compile [ 98.5%]: trng_api.c 74 | Compile [ 98.8%]: sleep.c 75 | Compile [ 99.1%]: serial_api.c 76 | Compile [ 99.4%]: us_ticker.c 77 | Compile [ 99.7%]: spi_api.c 78 | Compile [100.0%]: test_env.cpp 79 | Link: mbed-os-example-blinky 80 | Elf2Bin: mbed-os-example-blinky 81 | Text 39KB Data 2.62KB BSS 7.01KB ROM 41.6KB RAM 9.64KB 82 | ROM [||| ] 41.6KB/512KB 83 | RAM [||||||| ] 9.64KB/64KB 84 | Image: ./BUILD/NRF52832_MDK/GCC_ARM/mbed-os-example-blinky.hex 85 | [mbed] Detected "nRF52832-MDK" connected to "/Volumes/DAPLINK" and using com port "/dev/tty.usbmodem1412" 86 | ``` 87 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_BatteryLevel/.mbedls-mock: -------------------------------------------------------------------------------- 1 | {"daplink": {"1024": "nRF52832_MDK"}} -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_BatteryLevel/.mbedls-mock.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/examples/mbedos5/mbed-os-example-ble/BLE_BatteryLevel/.mbedls-mock.lock -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_BatteryLevel/main.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2014 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 19 | #include "ble/BLE.h" 20 | #include "ble/Gap.h" 21 | #include "ble/services/BatteryService.h" 22 | 23 | DigitalOut led1(LED1, 1); 24 | 25 | const static char DEVICE_NAME[] = "BATTERY"; 26 | static const uint16_t uuid16_list[] = {GattService::UUID_BATTERY_SERVICE}; 27 | 28 | static uint8_t batteryLevel = 50; 29 | static BatteryService* batteryServicePtr; 30 | 31 | static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE); 32 | 33 | void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) 34 | { 35 | BLE::Instance().gap().startAdvertising(); 36 | } 37 | 38 | void updateSensorValue() { 39 | batteryLevel++; 40 | if (batteryLevel > 100) { 41 | batteryLevel = 20; 42 | } 43 | 44 | batteryServicePtr->updateBatteryLevel(batteryLevel); 45 | } 46 | 47 | void blinkCallback(void) 48 | { 49 | led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */ 50 | 51 | BLE &ble = BLE::Instance(); 52 | if (ble.gap().getState().connected) { 53 | eventQueue.call(updateSensorValue); 54 | } 55 | } 56 | 57 | /** 58 | * This function is called when the ble initialization process has failled 59 | */ 60 | void onBleInitError(BLE &ble, ble_error_t error) 61 | { 62 | /* Initialization error handling should go here */ 63 | } 64 | 65 | void printMacAddress() 66 | { 67 | /* Print out device MAC address to the console*/ 68 | Gap::AddressType_t addr_type; 69 | Gap::Address_t address; 70 | BLE::Instance().gap().getAddress(&addr_type, address); 71 | printf("DEVICE MAC ADDRESS: "); 72 | for (int i = 5; i >= 1; i--){ 73 | printf("%02x:", address[i]); 74 | } 75 | printf("%02x\r\n", address[0]); 76 | } 77 | 78 | /** 79 | * Callback triggered when the ble initialization process has finished 80 | */ 81 | void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) 82 | { 83 | BLE& ble = params->ble; 84 | ble_error_t error = params->error; 85 | 86 | if (error != BLE_ERROR_NONE) { 87 | /* In case of error, forward the error handling to onBleInitError */ 88 | onBleInitError(ble, error); 89 | return; 90 | } 91 | 92 | /* Ensure that it is the default instance of BLE */ 93 | if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { 94 | return; 95 | } 96 | 97 | ble.gap().onDisconnection(disconnectionCallback); 98 | 99 | /* Setup primary service */ 100 | batteryServicePtr = new BatteryService(ble, batteryLevel); 101 | 102 | /* Setup advertising */ 103 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); 104 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *) uuid16_list, sizeof(uuid16_list)); 105 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *) DEVICE_NAME, sizeof(DEVICE_NAME)); 106 | ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); 107 | ble.gap().setAdvertisingInterval(1000); /* 1000ms */ 108 | ble.gap().startAdvertising(); 109 | 110 | printMacAddress(); 111 | } 112 | 113 | void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) { 114 | BLE &ble = BLE::Instance(); 115 | eventQueue.call(Callback(&ble, &BLE::processEvents)); 116 | } 117 | 118 | int main() 119 | { 120 | eventQueue.call_every(500, blinkCallback); 121 | 122 | BLE &ble = BLE::Instance(); 123 | ble.onEventsToProcess(scheduleBleEventsProcessing); 124 | ble.init(bleInitComplete); 125 | 126 | eventQueue.dispatch_forever(); 127 | 128 | return 0; 129 | } 130 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_BatteryLevel/mbed-os.lib: -------------------------------------------------------------------------------- 1 | /Users/jerrin/makerdiary/mbed-os/#33c8dceab1a49c64f3e20edcba5cae9e13f0194c 2 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_BatteryLevel/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ble-batterylevel", 3 | "version": "0.0.1", 4 | "description": "An example of creating and updating a simple GATT Service using the BLE_API", 5 | "licenses": [ 6 | { 7 | "url": "https://spdx.org/licenses/Apache-2.0", 8 | "type": "Apache-2.0" 9 | } 10 | ], 11 | "dependencies": { 12 | "ble": "^2.0.0" 13 | }, 14 | "targetDependencies": {}, 15 | "bin": "./" 16 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Beacon/.mbedls-mock: -------------------------------------------------------------------------------- 1 | {"daplink": {"1024": "nRF52832_MDK"}} -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Beacon/.mbedls-mock.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/examples/mbedos5/mbed-os-example-ble/BLE_Beacon/.mbedls-mock.lock -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Beacon/main.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2015 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 19 | #include "ble/BLE.h" 20 | #include "ble/services/iBeacon.h" 21 | 22 | static iBeacon* ibeaconPtr; 23 | 24 | static EventQueue eventQueue(/* event count */ 4 * EVENTS_EVENT_SIZE); 25 | 26 | /** 27 | * This function is called when the ble initialization process has failled 28 | */ 29 | void onBleInitError(BLE &ble, ble_error_t error) 30 | { 31 | /* Initialization error handling should go here */ 32 | } 33 | 34 | void printMacAddress() 35 | { 36 | /* Print out device MAC address to the console*/ 37 | Gap::AddressType_t addr_type; 38 | Gap::Address_t address; 39 | BLE::Instance().gap().getAddress(&addr_type, address); 40 | printf("DEVICE MAC ADDRESS: "); 41 | for (int i = 5; i >= 1; i--){ 42 | printf("%02x:", address[i]); 43 | } 44 | printf("%02x\r\n", address[0]); 45 | } 46 | 47 | /** 48 | * Callback triggered when the ble initialization process has finished 49 | */ 50 | void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) 51 | { 52 | BLE& ble = params->ble; 53 | ble_error_t error = params->error; 54 | 55 | if (error != BLE_ERROR_NONE) { 56 | /* In case of error, forward the error handling to onBleInitError */ 57 | onBleInitError(ble, error); 58 | return; 59 | } 60 | 61 | /* Ensure that it is the default instance of BLE */ 62 | if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { 63 | return; 64 | } 65 | 66 | /** 67 | * The Beacon payload has the following composition: 68 | * 128-Bit / 16byte UUID = E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 69 | * Major/Minor = 0x1122 / 0x3344 70 | * Tx Power = 0xC8 = 200, 2's compliment is 256-200 = (-56dB) 71 | * 72 | * Note: please remember to calibrate your beacons TX Power for more accurate results. 73 | */ 74 | static const uint8_t uuid[] = {0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4, 75 | 0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61}; 76 | uint16_t majorNumber = 1122; 77 | uint16_t minorNumber = 3344; 78 | uint16_t txPower = 0xC8; 79 | ibeaconPtr = new iBeacon(ble, uuid, majorNumber, minorNumber, txPower); 80 | 81 | ble.gap().setAdvertisingInterval(1000); /* 1000ms. */ 82 | ble.gap().startAdvertising(); 83 | 84 | printMacAddress(); 85 | } 86 | 87 | void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) { 88 | BLE &ble = BLE::Instance(); 89 | eventQueue.call(Callback(&ble, &BLE::processEvents)); 90 | } 91 | 92 | int main() 93 | { 94 | BLE &ble = BLE::Instance(); 95 | ble.onEventsToProcess(scheduleBleEventsProcessing); 96 | ble.init(bleInitComplete); 97 | 98 | eventQueue.dispatch_forever(); 99 | 100 | return 0; 101 | } 102 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Beacon/mbed-os.lib: -------------------------------------------------------------------------------- 1 | /Users/jerrin/makerdiary/mbed-os/#33c8dceab1a49c64f3e20edcba5cae9e13f0194c 2 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Beacon/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ble-beacon", 3 | "version": "0.0.1", 4 | "description": "BLE iBeacon example, building with mbed-cli", 5 | "licenses": [ 6 | { 7 | "url": "https://spdx.org/licenses/Apache-2.0", 8 | "type": "Apache-2.0" 9 | } 10 | ], 11 | "dependencies": { 12 | "ble": "^2.0.0" 13 | }, 14 | "targetDependencies": {}, 15 | "bin": "./" 16 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Button/.mbedls-mock: -------------------------------------------------------------------------------- 1 | {"daplink": {"1024": "nRF52832_MDK"}} -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Button/.mbedls-mock.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/examples/mbedos5/mbed-os-example-ble/BLE_Button/.mbedls-mock.lock -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Button/ButtonService.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 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 __BLE_BUTTON_SERVICE_H__ 18 | #define __BLE_BUTTON_SERVICE_H__ 19 | 20 | class ButtonService { 21 | public: 22 | const static uint16_t BUTTON_SERVICE_UUID = 0xA000; 23 | const static uint16_t BUTTON_STATE_CHARACTERISTIC_UUID = 0xA001; 24 | 25 | ButtonService(BLE &_ble, bool buttonPressedInitial) : 26 | ble(_ble), buttonState(BUTTON_STATE_CHARACTERISTIC_UUID, &buttonPressedInitial, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) 27 | { 28 | GattCharacteristic *charTable[] = {&buttonState}; 29 | GattService buttonService(ButtonService::BUTTON_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); 30 | ble.gattServer().addService(buttonService); 31 | } 32 | 33 | void updateButtonState(bool newState) { 34 | ble.gattServer().write(buttonState.getValueHandle(), (uint8_t *)&newState, sizeof(bool)); 35 | } 36 | 37 | private: 38 | BLE &ble; 39 | ReadOnlyGattCharacteristic buttonState; 40 | }; 41 | 42 | #endif /* #ifndef __BLE_BUTTON_SERVICE_H__ */ 43 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Button/main.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 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 | #include 17 | 18 | #include 19 | #include "ble/BLE.h" 20 | #include "ble/Gap.h" 21 | #include "ButtonService.h" 22 | 23 | DigitalOut led1(LED1, 1); 24 | InterruptIn button(BLE_BUTTON_PIN_NAME, PullDown); 25 | 26 | static EventQueue eventQueue(/* event count */ 10 * EVENTS_EVENT_SIZE); 27 | 28 | const static char DEVICE_NAME[] = "Button"; 29 | static const uint16_t uuid16_list[] = {ButtonService::BUTTON_SERVICE_UUID}; 30 | 31 | ButtonService *buttonServicePtr; 32 | 33 | void buttonPressedCallback(void) 34 | { 35 | eventQueue.call(Callback(buttonServicePtr, &ButtonService::updateButtonState), true); 36 | } 37 | 38 | void buttonReleasedCallback(void) 39 | { 40 | eventQueue.call(Callback(buttonServicePtr, &ButtonService::updateButtonState), false); 41 | } 42 | 43 | void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) 44 | { 45 | BLE::Instance().gap().startAdvertising(); // restart advertising 46 | } 47 | 48 | void blinkCallback(void) 49 | { 50 | led1 = !led1; /* Do blinky on LED1 to indicate system aliveness. */ 51 | } 52 | 53 | void onBleInitError(BLE &ble, ble_error_t error) 54 | { 55 | /* Initialization error handling should go here */ 56 | } 57 | 58 | void printMacAddress() 59 | { 60 | /* Print out device MAC address to the console*/ 61 | Gap::AddressType_t addr_type; 62 | Gap::Address_t address; 63 | BLE::Instance().gap().getAddress(&addr_type, address); 64 | printf("DEVICE MAC ADDRESS: "); 65 | for (int i = 5; i >= 1; i--){ 66 | printf("%02x:", address[i]); 67 | } 68 | printf("%02x\r\n", address[0]); 69 | } 70 | 71 | void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) 72 | { 73 | BLE& ble = params->ble; 74 | ble_error_t error = params->error; 75 | 76 | if (error != BLE_ERROR_NONE) { 77 | /* In case of error, forward the error handling to onBleInitError */ 78 | onBleInitError(ble, error); 79 | return; 80 | } 81 | 82 | /* Ensure that it is the default instance of BLE */ 83 | if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { 84 | return; 85 | } 86 | 87 | ble.gap().onDisconnection(disconnectionCallback); 88 | 89 | button.fall(buttonPressedCallback); 90 | button.rise(buttonReleasedCallback); 91 | 92 | /* Setup primary service. */ 93 | buttonServicePtr = new ButtonService(ble, false /* initial value for button pressed */); 94 | 95 | /* setup advertising */ 96 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); 97 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); 98 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); 99 | ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); 100 | ble.gap().setAdvertisingInterval(1000); /* 1000ms. */ 101 | ble.gap().startAdvertising(); 102 | 103 | printMacAddress(); 104 | } 105 | 106 | void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) { 107 | BLE &ble = BLE::Instance(); 108 | eventQueue.call(Callback(&ble, &BLE::processEvents)); 109 | } 110 | 111 | int main() 112 | { 113 | eventQueue.call_every(500, blinkCallback); 114 | 115 | BLE &ble = BLE::Instance(); 116 | ble.onEventsToProcess(scheduleBleEventsProcessing); 117 | ble.init(bleInitComplete); 118 | 119 | eventQueue.dispatch_forever(); 120 | 121 | return 0; 122 | } 123 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Button/mbed-os.lib: -------------------------------------------------------------------------------- 1 | /Users/jerrin/makerdiary/mbed-os/#33c8dceab1a49c64f3e20edcba5cae9e13f0194c 2 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Button/mbed_app.json: -------------------------------------------------------------------------------- 1 | { 2 | "config": { 3 | "ble_button_pin_name": { 4 | "help": "The pin name used as button in this application", 5 | "macro_name": "BLE_BUTTON_PIN_NAME", 6 | "required": true 7 | } 8 | }, 9 | "target_overrides": { 10 | "NRF52832_MDK": { 11 | "ble_button_pin_name": "BUTTON1" 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Button/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ble-button", 3 | "version": "0.0.1", 4 | "description": "The *input service template* demonstrates the use of a simple input (boolean values) from a read-only characteristic.", 5 | "licenses": [ 6 | { 7 | "url": "https://spdx.org/licenses/Apache-2.0", 8 | "type": "Apache-2.0" 9 | } 10 | ], 11 | "bin": "./", 12 | "dependencies": { 13 | "ble": "^2.0.0" 14 | } 15 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_GAPButton/.mbedls-mock: -------------------------------------------------------------------------------- 1 | {"daplink": {"1024": "nRF52832_MDK"}} -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_GAPButton/.mbedls-mock.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/examples/mbedos5/mbed-os-example-ble/BLE_GAPButton/.mbedls-mock.lock -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_GAPButton/mbed-os.lib: -------------------------------------------------------------------------------- 1 | /Users/jerrin/makerdiary/mbed-os/#33c8dceab1a49c64f3e20edcba5cae9e13f0194c 2 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_GAPButton/mbed_app.json: -------------------------------------------------------------------------------- 1 | { 2 | "config": { 3 | "ble_button_pin_name": { 4 | "help": "The pin name used as button in this application", 5 | "macro_name": "BLE_BUTTON_PIN_NAME", 6 | "required": true 7 | } 8 | }, 9 | "target_overrides": { 10 | "NRF52832_MDK": { 11 | "ble_button_pin_name": "BUTTON1" 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_GAPButton/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ble-gapbutton", 3 | "version": "0.0.1", 4 | "bin": "./", 5 | "description": "BLE button that uses gap advertisement to broadcast its state.", 6 | "author": "Liyou Zhou", 7 | "license": "Apache-2.0", 8 | "dependencies": { 9 | "mbed-drivers": "*", 10 | "ble": "^2.0.0" 11 | } 12 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_HeartRate/.mbedls-mock: -------------------------------------------------------------------------------- 1 | {"daplink": {"1024": "nRF52832_MDK"}} -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_HeartRate/.mbedls-mock.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/examples/mbedos5/mbed-os-example-ble/BLE_HeartRate/.mbedls-mock.lock -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_HeartRate/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* mbed Microcontroller Library 3 | * Copyright (c) 2006-2015 ARM Limited 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include "ble/BLE.h" 21 | #include "ble/Gap.h" 22 | #include "ble/services/HeartRateService.h" 23 | 24 | DigitalOut led1(LED1, 1); 25 | 26 | const static char DEVICE_NAME[] = "HRM"; 27 | static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE}; 28 | 29 | static uint8_t hrmCounter = 100; // init HRM to 100bps 30 | static HeartRateService *hrServicePtr; 31 | 32 | static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE); 33 | 34 | void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) 35 | { 36 | BLE::Instance().gap().startAdvertising(); // restart advertising 37 | } 38 | 39 | void updateSensorValue() { 40 | // Do blocking calls or whatever is necessary for sensor polling. 41 | // In our case, we simply update the HRM measurement. 42 | hrmCounter++; 43 | 44 | // 100 <= HRM bps <=175 45 | if (hrmCounter == 175) { 46 | hrmCounter = 100; 47 | } 48 | 49 | hrServicePtr->updateHeartRate(hrmCounter); 50 | } 51 | 52 | void periodicCallback(void) 53 | { 54 | led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */ 55 | 56 | if (BLE::Instance().getGapState().connected) { 57 | eventQueue.call(updateSensorValue); 58 | } 59 | } 60 | 61 | void onBleInitError(BLE &ble, ble_error_t error) 62 | { 63 | (void)ble; 64 | (void)error; 65 | /* Initialization error handling should go here */ 66 | } 67 | 68 | void printMacAddress() 69 | { 70 | /* Print out device MAC address to the console*/ 71 | Gap::AddressType_t addr_type; 72 | Gap::Address_t address; 73 | BLE::Instance().gap().getAddress(&addr_type, address); 74 | printf("DEVICE MAC ADDRESS: "); 75 | for (int i = 5; i >= 1; i--){ 76 | printf("%02x:", address[i]); 77 | } 78 | printf("%02x\r\n", address[0]); 79 | } 80 | 81 | void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) 82 | { 83 | BLE& ble = params->ble; 84 | ble_error_t error = params->error; 85 | 86 | if (error != BLE_ERROR_NONE) { 87 | onBleInitError(ble, error); 88 | return; 89 | } 90 | 91 | if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { 92 | return; 93 | } 94 | 95 | ble.gap().onDisconnection(disconnectionCallback); 96 | 97 | /* Setup primary service. */ 98 | hrServicePtr = new HeartRateService(ble, hrmCounter, HeartRateService::LOCATION_FINGER); 99 | 100 | /* Setup advertising. */ 101 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); 102 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); 103 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_HEART_RATE_SENSOR); 104 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); 105 | ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); 106 | ble.gap().setAdvertisingInterval(1000); /* 1000ms */ 107 | ble.gap().startAdvertising(); 108 | 109 | printMacAddress(); 110 | } 111 | 112 | void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) { 113 | BLE &ble = BLE::Instance(); 114 | eventQueue.call(Callback(&ble, &BLE::processEvents)); 115 | } 116 | 117 | int main() 118 | { 119 | eventQueue.call_every(500, periodicCallback); 120 | 121 | BLE &ble = BLE::Instance(); 122 | ble.onEventsToProcess(scheduleBleEventsProcessing); 123 | ble.init(bleInitComplete); 124 | 125 | eventQueue.dispatch_forever(); 126 | 127 | return 0; 128 | } 129 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_HeartRate/mbed-os.lib: -------------------------------------------------------------------------------- 1 | /Users/jerrin/makerdiary/mbed-os/#33c8dceab1a49c64f3e20edcba5cae9e13f0194c 2 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_HeartRate/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ble-heartrate", 3 | "version": "0.0.1", 4 | "description": "BLE Heartreate example, building with mbed-cli", 5 | "licenses": [ 6 | { 7 | "url": "https://spdx.org/licenses/Apache-2.0", 8 | "type": "Apache-2.0" 9 | } 10 | ], 11 | "dependencies": { 12 | "ble": "^2.0.0" 13 | }, 14 | "targetDependencies": {}, 15 | "bin": "./" 16 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_LED/.mbedls-mock: -------------------------------------------------------------------------------- 1 | {"daplink": {"1024": "nRF52832_MDK"}} -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_LED/.mbedls-mock.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/examples/mbedos5/mbed-os-example-ble/BLE_LED/.mbedls-mock.lock -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_LED/LEDService.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 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 __BLE_LED_SERVICE_H__ 18 | #define __BLE_LED_SERVICE_H__ 19 | 20 | class LEDService { 21 | public: 22 | const static uint16_t LED_SERVICE_UUID = 0xA000; 23 | const static uint16_t LED_STATE_CHARACTERISTIC_UUID = 0xA001; 24 | 25 | LEDService(BLEDevice &_ble, bool initialValueForLEDCharacteristic) : 26 | ble(_ble), ledState(LED_STATE_CHARACTERISTIC_UUID, &initialValueForLEDCharacteristic) 27 | { 28 | GattCharacteristic *charTable[] = {&ledState}; 29 | GattService ledService(LED_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); 30 | ble.addService(ledService); 31 | } 32 | 33 | GattAttribute::Handle_t getValueHandle() const 34 | { 35 | return ledState.getValueHandle(); 36 | } 37 | 38 | private: 39 | BLEDevice &ble; 40 | ReadWriteGattCharacteristic ledState; 41 | }; 42 | 43 | #endif /* #ifndef __BLE_LED_SERVICE_H__ */ 44 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_LED/mbed-os.lib: -------------------------------------------------------------------------------- 1 | /Users/jerrin/makerdiary/mbed-os/#33c8dceab1a49c64f3e20edcba5cae9e13f0194c 2 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_LED/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ble-led", 3 | "version": "0.0.1", 4 | "description": "A simple service that demonstrates the use of a read-write characteristic to control a LED", 5 | "licenses": [ 6 | { 7 | "url": "https://spdx.org/licenses/Apache-2.0", 8 | "type": "Apache-2.0" 9 | } 10 | ], 11 | "dependencies": { 12 | "ble": "^2.0.0" 13 | }, 14 | "targetDependencies": {}, 15 | "bin": "./" 16 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_LEDBlinker/.mbedls-mock: -------------------------------------------------------------------------------- 1 | {"daplink": {"1024": "nRF52832_MDK"}} -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_LEDBlinker/.mbedls-mock.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/examples/mbedos5/mbed-os-example-ble/BLE_LEDBlinker/.mbedls-mock.lock -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_LEDBlinker/mbed-os.lib: -------------------------------------------------------------------------------- 1 | /Users/jerrin/makerdiary/mbed-os/#33c8dceab1a49c64f3e20edcba5cae9e13f0194c 2 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_LEDBlinker/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ble-ledblinker", 3 | "version": "0.0.1", 4 | "description": "An initial demo showcasing the GattClient APIs. Drives an LED service exported by a BLE_LED peripheral. Shows scanning, connections, service-discovery, and reads/writes.", 5 | "licenses": [ 6 | { 7 | "url": "https://spdx.org/licenses/Apache-2.0", 8 | "type": "Apache-2.0" 9 | } 10 | ], 11 | "dependencies": { 12 | "ble": "^2.0.0" 13 | }, 14 | "bin": "./" 15 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Thermometer/.mbedls-mock: -------------------------------------------------------------------------------- 1 | {"daplink": {"1024": "nRF52832_MDK"}} -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Thermometer/.mbedls-mock.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/examples/mbedos5/mbed-os-example-ble/BLE_Thermometer/.mbedls-mock.lock -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Thermometer/main.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 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 "mbed.h" 19 | #include "ble/BLE.h" 20 | #include "ble/services/HealthThermometerService.h" 21 | 22 | DigitalOut led1(LED1, 1); 23 | 24 | const static char DEVICE_NAME[] = "Therm"; 25 | static const uint16_t uuid16_list[] = {GattService::UUID_HEALTH_THERMOMETER_SERVICE}; 26 | 27 | static float currentTemperature = 39.6; 28 | static HealthThermometerService *thermometerServicePtr; 29 | 30 | static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE); 31 | 32 | /* Restart Advertising on disconnection*/ 33 | void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *) 34 | { 35 | BLE::Instance().gap().startAdvertising(); 36 | } 37 | 38 | void updateSensorValue(void) { 39 | /* Do blocking calls or whatever is necessary for sensor polling. 40 | In our case, we simply update the Temperature measurement. */ 41 | currentTemperature = (currentTemperature + 0.1 > 43.0) ? 39.6 : currentTemperature + 0.1; 42 | thermometerServicePtr->updateTemperature(currentTemperature); 43 | } 44 | 45 | void periodicCallback(void) 46 | { 47 | led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */ 48 | 49 | if (BLE::Instance().gap().getState().connected) { 50 | eventQueue.call(updateSensorValue); 51 | } 52 | } 53 | 54 | void onBleInitError(BLE &ble, ble_error_t error) 55 | { 56 | /* Initialization error handling should go here */ 57 | } 58 | 59 | void printMacAddress() 60 | { 61 | /* Print out device MAC address to the console*/ 62 | Gap::AddressType_t addr_type; 63 | Gap::Address_t address; 64 | BLE::Instance().gap().getAddress(&addr_type, address); 65 | printf("DEVICE MAC ADDRESS: "); 66 | for (int i = 5; i >= 1; i--){ 67 | printf("%02x:", address[i]); 68 | } 69 | printf("%02x\r\n", address[0]); 70 | } 71 | 72 | void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) 73 | { 74 | BLE& ble = params->ble; 75 | ble_error_t error = params->error; 76 | 77 | if (error != BLE_ERROR_NONE) { 78 | onBleInitError(ble, error); 79 | return; 80 | } 81 | 82 | if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { 83 | return; 84 | } 85 | 86 | ble.gap().onDisconnection(disconnectionCallback); 87 | 88 | /* Setup primary service. */ 89 | thermometerServicePtr = new HealthThermometerService(ble, currentTemperature, HealthThermometerService::LOCATION_EAR); 90 | 91 | /* setup advertising */ 92 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); 93 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); 94 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::THERMOMETER_EAR); 95 | ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); 96 | ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); 97 | ble.gap().setAdvertisingInterval(1000); /* 1000ms */ 98 | ble.gap().startAdvertising(); 99 | 100 | printMacAddress(); 101 | } 102 | 103 | void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) { 104 | BLE &ble = BLE::Instance(); 105 | eventQueue.call(Callback(&ble, &BLE::processEvents)); 106 | } 107 | 108 | int main() 109 | { 110 | eventQueue.call_every(500, periodicCallback); 111 | 112 | BLE &ble = BLE::Instance(); 113 | ble.onEventsToProcess(scheduleBleEventsProcessing); 114 | ble.init(bleInitComplete); 115 | 116 | eventQueue.dispatch_forever(); 117 | 118 | return 0; 119 | } 120 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Thermometer/mbed-os.lib: -------------------------------------------------------------------------------- 1 | /Users/jerrin/makerdiary/mbed-os/#33c8dceab1a49c64f3e20edcba5cae9e13f0194c 2 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-ble/BLE_Thermometer/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ble-thermometer", 3 | "version": "0.0.1", 4 | "description": "This example demonstrates how to use the Health Thermometer Service. The Health Thermometer service reports two pieces of information, Temperature and Sensor Location.", 5 | "licenses": [ 6 | { 7 | "url": "https://spdx.org/licenses/Apache-2.0", 8 | "type": "Apache-2.0" 9 | } 10 | ], 11 | "dependencies": { 12 | "ble": "^2.0.0" 13 | }, 14 | "bin": "./" 15 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-blinky/.mbedls-mock: -------------------------------------------------------------------------------- 1 | {"daplink": {"1024": "nRF52832_MDK"}} -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-blinky/.mbedls-mock.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/examples/mbedos5/mbed-os-example-blinky/.mbedls-mock.lock -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-blinky/main.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2018 ARM Limited 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | #include "mbed.h" 7 | #include "stats_report.h" 8 | 9 | DigitalOut led1(LED1); 10 | 11 | // main() runs in its own thread in the OS 12 | int main() 13 | { 14 | SystemReport sys_state(500 /* Loop delay time in ms */); 15 | 16 | while (true) { 17 | // Blink LED and wait 0.5 seconds 18 | led1 = !led1; 19 | wait(0.5f); 20 | 21 | // Following the main thread wait, report on the current system status 22 | sys_state.report_state(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-blinky/mbed-os.lib: -------------------------------------------------------------------------------- 1 | /Users/jerrin/makerdiary/mbed-os/#f2d7e130df490330b4ecd8e464edea2542e0daa4 2 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-blinky/mbed_app.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "target_overrides": { 4 | "*": { 5 | "platform.stdio-baud-rate": 115200, 6 | "platform.stack-stats-enabled": true, 7 | "platform.heap-stats-enabled": true, 8 | "platform.cpu-stats-enabled": true, 9 | "platform.thread-stats-enabled": true, 10 | "platform.sys-stats-enabled": true 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-blinky/stats_report.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2018 ARM Limited 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | #ifndef STATS_REPORT_H 7 | #define STATS_REPORT 8 | 9 | #include "mbed.h" 10 | 11 | /** 12 | * System Reporting library. Provides runtime information on device: 13 | * - CPU sleep, idle, and wake times 14 | * - Heap and stack usage 15 | * - Thread information 16 | * - Static system information 17 | */ 18 | class SystemReport { 19 | mbed_stats_heap_t heap_stats; 20 | mbed_stats_cpu_t cpu_stats; 21 | mbed_stats_sys_t sys_stats; 22 | 23 | mbed_stats_thread_t *thread_stats; 24 | uint8_t thread_count; 25 | uint8_t max_thread_count; 26 | uint32_t sample_time_ms; 27 | 28 | public: 29 | /** 30 | * SystemReport - Sample rate in ms is required to handle the CPU percent awake logic 31 | */ 32 | SystemReport(uint32_t sample_rate) : max_thread_count(8), sample_time_ms(sample_rate) 33 | { 34 | thread_stats = new mbed_stats_thread_t[max_thread_count]; 35 | 36 | // Collect the static system information 37 | mbed_stats_sys_get(&sys_stats); 38 | 39 | printf("=============================== SYSTEM INFO ================================\r\n"); 40 | printf("Mbed OS Version: %ld \r\n", sys_stats.os_version); 41 | printf("CPU ID: 0x%lx \r\n", sys_stats.cpu_id); 42 | printf("Compiler ID: %d \r\n", sys_stats.compiler_id); 43 | printf("Compiler Version: %ld \r\n", sys_stats.compiler_version); 44 | } 45 | 46 | ~SystemReport(void) 47 | { 48 | free(thread_stats); 49 | } 50 | 51 | /** 52 | * Report on each Mbed OS Platform stats API 53 | */ 54 | void report_state(void) 55 | { 56 | report_cpu_stats(); 57 | report_heap_stats(); 58 | report_thread_stats(); 59 | 60 | // Clear next line to separate subsequent report logs 61 | printf("\r\n"); 62 | } 63 | 64 | /** 65 | * Report CPU idle and awake time in terms of percentage 66 | */ 67 | void report_cpu_stats(void) 68 | { 69 | static uint64_t prev_idle_time = 0; 70 | 71 | printf("================= CPU STATS =================\r\n"); 72 | 73 | // Collect and print cpu stats 74 | mbed_stats_cpu_get(&cpu_stats); 75 | 76 | uint64_t diff = (cpu_stats.idle_time - prev_idle_time); 77 | uint8_t idle = (diff * 100) / (sample_time_ms * 1000); // usec; 78 | uint8_t usage = 100 - ((diff * 100) / (sample_time_ms * 1000)); // usec;; 79 | prev_idle_time = cpu_stats.idle_time; 80 | 81 | printf("Idle: %d%% Usage: %d%% \r\n", idle, usage); 82 | } 83 | 84 | /** 85 | * Report current heap stats. Current heap refers to the current amount of 86 | * allocated heap. Max heap refers to the highest amount of heap allocated 87 | * since reset. 88 | */ 89 | void report_heap_stats(void) 90 | { 91 | printf("================ HEAP STATS =================\r\n"); 92 | 93 | // Collect and print heap stats 94 | mbed_stats_heap_get(&heap_stats); 95 | 96 | printf("Current heap: %lu\r\n", heap_stats.current_size); 97 | printf("Max heap size: %lu\r\n", heap_stats.max_size); 98 | } 99 | 100 | /** 101 | * Report active thread stats 102 | */ 103 | void report_thread_stats(void) 104 | { 105 | printf("================ THREAD STATS ===============\r\n"); 106 | 107 | // Collect and print running thread stats 108 | int count = mbed_stats_thread_get_each(thread_stats, max_thread_count); 109 | 110 | for (int i = 0; i < count; i++) { 111 | printf("ID: 0x%lx \r\n", thread_stats[i].id); 112 | printf("Name: %s \r\n", thread_stats[i].name); 113 | printf("State: %ld \r\n", thread_stats[i].state); 114 | printf("Priority: %ld \r\n", thread_stats[i].priority); 115 | printf("Stack Size: %ld \r\n", thread_stats[i].stack_size); 116 | printf("Stack Space: %ld \r\n", thread_stats[i].stack_space); 117 | } 118 | } 119 | }; 120 | 121 | #endif // STATS_REPORT_H -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-i2c-scanner/.mbedls-mock: -------------------------------------------------------------------------------- 1 | {"daplink": {"1024": "nRF52832_MDK"}} -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-i2c-scanner/.mbedls-mock.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/examples/mbedos5/mbed-os-example-i2c-scanner/.mbedls-mock.lock -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-i2c-scanner/main.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2018 ARM Limited 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | #include "mbed.h" 7 | 8 | /* Number of possible I2C addresses. */ 9 | #define I2C_ADDRESSES 255 10 | 11 | DigitalOut led1(LED1); 12 | 13 | I2C i2c(I2C_SDA0, I2C_SCL0); 14 | 15 | 16 | // main() runs in its own thread in the OS 17 | int main() 18 | { 19 | int address; 20 | char sample_data; 21 | bool detected_device = false; 22 | 23 | int rslt; 24 | 25 | for (address = 1; address <= I2C_ADDRESSES; address++) 26 | { 27 | rslt = i2c.read(address, &sample_data, sizeof(sample_data)); 28 | 29 | if(rslt == 0) //0 on success (ack) 30 | { 31 | detected_device = true; 32 | printf("I2C device detected at address 0x%x.\r\n", address); 33 | } 34 | } 35 | if (!detected_device) 36 | { 37 | printf("No device was found.\r\n"); 38 | } 39 | 40 | while (true) { 41 | // Blink LED and wait 0.5 seconds 42 | led1 = !led1; 43 | wait(0.5f); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /examples/mbedos5/mbed-os-example-i2c-scanner/mbed-os.lib: -------------------------------------------------------------------------------- 1 | /Users/jerrin/makerdiary/mbed-os/#9521a6288e9cf9b259752174cc7e0ec3f8c98932 2 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | .app.db 21 | .app 22 | bin 23 | obj 24 | tags 25 | .gdb_history 26 | .gdb_out 27 | .gdb_cmds 28 | *~ 29 | .DS_Store 30 | *.swp 31 | *.swo 32 | 33 | .repo.db 34 | repos 35 | project.state -------------------------------------------------------------------------------- /examples/mynewt/blinky/.rat-excludes: -------------------------------------------------------------------------------- 1 | # Can't easily add license to rat-excludes file. 2 | .rat-excludes 3 | 4 | # Temporary user files. 5 | .gdb_history 6 | .gdb_out 7 | tags 8 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/NOTICE: -------------------------------------------------------------------------------- 1 | Apache Mynewt 2 | Copyright 2015-2017 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | 7 | Portions of this software were developed at 8 | Runtime Inc, copyright 2015. 9 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/README.md: -------------------------------------------------------------------------------- 1 | 21 | 22 | # Apache Blinky 23 | 24 | ## Overview 25 | 26 | Apache Blinky is a skeleton for new Apache Mynewt projects. The user downloads 27 | this skeleton by issuing the "newt new" command (using Apache Newt). Apache 28 | blinky also contains an example app and target for use with Apache Mynewt to 29 | help you get started. 30 | 31 | ## Building 32 | 33 | Apache Blinky contains an example Apache Mynewt application called blinky. 34 | When executed on suitably equipped hardware, this application repeatedly blinks 35 | an LED. The below procedure describes how to build this application for the 36 | Apache Mynewt simulator. 37 | 38 | 1. Download and install Apache Newt. 39 | 40 | You will need to download the Apache Newt tool, as documented in the [Getting Started Guide](http://mynewt.apache.org/os/get_started/introduction/). 41 | 42 | 2. Download the Apache Mynewt Core package (executed from the blinky directory). 43 | 44 | ```no-highlight 45 | $ newt install 46 | ``` 47 | 48 | 3. Build the blinky app for the sim platform using the "my_blinky_sim" target 49 | (executed from the blinky directory). 50 | 51 | ```no-highlight 52 | $ newt build my_blinky_sim 53 | ``` 54 | 55 | The Apache Newt tool should indicate the location of the generated blinky 56 | executable. Since the simulator does not have an LED to blink, this version of 57 | blinky is not terribly exciting - a printed message indicating the current LED 58 | state. To learn how to build blinky for actual hardware, please see the 59 | [Getting Started Guide](http://mynewt.apache.org/os/get_started/introduction/). 60 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/apps/blinky/pkg.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | pkg.name: apps/blinky 21 | pkg.type: app 22 | pkg.description: Basic example application which blinks an LED. 23 | pkg.author: "Apache Mynewt " 24 | pkg.homepage: "http://mynewt.apache.org/" 25 | pkg.keywords: 26 | 27 | pkg.deps: 28 | - "@apache-mynewt-core/kernel/os" 29 | - "@apache-mynewt-core/hw/hal" 30 | - "@apache-mynewt-core/sys/console/stub" 31 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/apps/blinky/src/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "sysinit/sysinit.h" 24 | #include "os/os.h" 25 | #include "bsp/bsp.h" 26 | #include "hal/hal_gpio.h" 27 | #ifdef ARCH_sim 28 | #include "mcu/mcu_sim.h" 29 | #endif 30 | 31 | static volatile int g_task1_loops; 32 | 33 | /* For LED toggling */ 34 | int g_led_pin; 35 | 36 | /** 37 | * main 38 | * 39 | * The main task for the project. This function initializes packages, 40 | * and then blinks the BSP LED in a loop. 41 | * 42 | * @return int NOTE: this function should never return! 43 | */ 44 | int 45 | main(int argc, char **argv) 46 | { 47 | int rc; 48 | 49 | #ifdef ARCH_sim 50 | mcu_sim_parse_args(argc, argv); 51 | #endif 52 | 53 | sysinit(); 54 | 55 | g_led_pin = LED_BLINK_PIN; 56 | hal_gpio_init_out(g_led_pin, 1); 57 | 58 | while (1) { 59 | ++g_task1_loops; 60 | 61 | /* Wait one second */ 62 | os_time_delay(OS_TICKS_PER_SEC); 63 | 64 | /* Toggle the LED */ 65 | hal_gpio_toggle(g_led_pin); 66 | } 67 | assert(0); 68 | 69 | return rc; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/project.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | project.name: "blinky" 21 | 22 | project.repositories: 23 | - apache-mynewt-core 24 | - mynewt_nrf52832_mdk 25 | 26 | # Use github's distribution mechanism for core ASF libraries. 27 | # This provides mirroring automatically for us. 28 | # 29 | repository.apache-mynewt-core: 30 | type: github 31 | vers: 1-latest 32 | user: apache 33 | repo: mynewt-core 34 | 35 | # a special repo to hold hardware specific stuff for nRF52832-MDK 36 | repository.mynewt_nrf52832_mdk: 37 | type: github 38 | vers: 0-dev 39 | user: makerdiary 40 | repo: mynewt_nrf52832_mdk -------------------------------------------------------------------------------- /examples/mynewt/blinky/targets/my_blinky_sim/pkg.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | ### Package: targets/my_blinky_sim 21 | pkg.name: "targets/my_blinky_sim" 22 | pkg.type: "target" 23 | pkg.description: 24 | pkg.author: 25 | pkg.homepage: 26 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/targets/my_blinky_sim/target.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | ### Target: targets/my_blinky_sim 21 | target.app: "apps/blinky" 22 | target.bsp: "@apache-mynewt-core/hw/bsp/native" 23 | target.build_profile: "debug" 24 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/targets/nrf52_blinky/pkg.yml: -------------------------------------------------------------------------------- 1 | ### Package: targets/nrf52_blinky 2 | pkg.name: "targets/nrf52_blinky" 3 | pkg.type: "target" 4 | pkg.description: 5 | pkg.author: 6 | pkg.homepage: 7 | 8 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/targets/nrf52_blinky/target.yml: -------------------------------------------------------------------------------- 1 | ### Target: targets/nrf52_blinky 2 | target.app: "apps/blinky" 3 | target.bsp: "@mynewt_nrf52832_mdk/hw/bsp/nrf52832_mdk" 4 | target.build_profile: "debug" 5 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/targets/nrf52_boot/pkg.yml: -------------------------------------------------------------------------------- 1 | ### Package: targets/nrf52_boot 2 | pkg.name: "targets/nrf52_boot" 3 | pkg.type: "target" 4 | pkg.description: 5 | pkg.author: 6 | pkg.homepage: 7 | 8 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/targets/nrf52_boot/target.yml: -------------------------------------------------------------------------------- 1 | ### Target: targets/nrf52_boot 2 | target.app: "@apache-mynewt-core/apps/boot" 3 | target.bsp: "@mynewt_nrf52832_mdk/hw/bsp/nrf52832_mdk" 4 | target.build_profile: "optimized" 5 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/targets/unittest/pkg.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | ### Package: targets/unittest 21 | pkg.name: "targets/unittest" 22 | pkg.type: "target" 23 | pkg.description: "Used for unit tests by the \"newt test\" command." 24 | pkg.author: "Apache Mynewt " 25 | pkg.homepage: "http://mynewt.apache.org/" 26 | -------------------------------------------------------------------------------- /examples/mynewt/blinky/targets/unittest/target.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | ### Target: targets/unittest 21 | target.bsp: "@apache-mynewt-core/hw/bsp/native" 22 | target.build_profile: "debug" 23 | target.compiler: "@apache-mynewt-core/compiler/sim" 24 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/ble_app_beacon/armgcc/ble_app_beacon_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000 9 | RAM (rwx) : ORIGIN = 0x200018a8, LENGTH = 0xe758 10 | } 11 | 12 | SECTIONS 13 | { 14 | } 15 | 16 | SECTIONS 17 | { 18 | . = ALIGN(4); 19 | .mem_section_dummy_ram : 20 | { 21 | } 22 | .cli_sorted_cmd_ptrs : 23 | { 24 | PROVIDE(__start_cli_sorted_cmd_ptrs = .); 25 | KEEP(*(.cli_sorted_cmd_ptrs)) 26 | PROVIDE(__stop_cli_sorted_cmd_ptrs = .); 27 | } > RAM 28 | .fs_data : 29 | { 30 | PROVIDE(__start_fs_data = .); 31 | KEEP(*(.fs_data)) 32 | PROVIDE(__stop_fs_data = .); 33 | } > RAM 34 | .log_dynamic_data : 35 | { 36 | PROVIDE(__start_log_dynamic_data = .); 37 | KEEP(*(SORT(.log_dynamic_data*))) 38 | PROVIDE(__stop_log_dynamic_data = .); 39 | } > RAM 40 | .log_filter_data : 41 | { 42 | PROVIDE(__start_log_filter_data = .); 43 | KEEP(*(SORT(.log_filter_data*))) 44 | PROVIDE(__stop_log_filter_data = .); 45 | } > RAM 46 | 47 | } INSERT AFTER .data; 48 | 49 | SECTIONS 50 | { 51 | .mem_section_dummy_rom : 52 | { 53 | } 54 | .sdh_soc_observers : 55 | { 56 | PROVIDE(__start_sdh_soc_observers = .); 57 | KEEP(*(SORT(.sdh_soc_observers*))) 58 | PROVIDE(__stop_sdh_soc_observers = .); 59 | } > FLASH 60 | .sdh_ble_observers : 61 | { 62 | PROVIDE(__start_sdh_ble_observers = .); 63 | KEEP(*(SORT(.sdh_ble_observers*))) 64 | PROVIDE(__stop_sdh_ble_observers = .); 65 | } > FLASH 66 | .pwr_mgmt_data : 67 | { 68 | PROVIDE(__start_pwr_mgmt_data = .); 69 | KEEP(*(SORT(.pwr_mgmt_data*))) 70 | PROVIDE(__stop_pwr_mgmt_data = .); 71 | } > FLASH 72 | .sdh_stack_observers : 73 | { 74 | PROVIDE(__start_sdh_stack_observers = .); 75 | KEEP(*(SORT(.sdh_stack_observers*))) 76 | PROVIDE(__stop_sdh_stack_observers = .); 77 | } > FLASH 78 | .sdh_req_observers : 79 | { 80 | PROVIDE(__start_sdh_req_observers = .); 81 | KEEP(*(SORT(.sdh_req_observers*))) 82 | PROVIDE(__stop_sdh_req_observers = .); 83 | } > FLASH 84 | .sdh_state_observers : 85 | { 86 | PROVIDE(__start_sdh_state_observers = .); 87 | KEEP(*(SORT(.sdh_state_observers*))) 88 | PROVIDE(__stop_sdh_state_observers = .); 89 | } > FLASH 90 | .nrf_queue : 91 | { 92 | PROVIDE(__start_nrf_queue = .); 93 | KEEP(*(.nrf_queue)) 94 | PROVIDE(__stop_nrf_queue = .); 95 | } > FLASH 96 | .nrf_balloc : 97 | { 98 | PROVIDE(__start_nrf_balloc = .); 99 | KEEP(*(.nrf_balloc)) 100 | PROVIDE(__stop_nrf_balloc = .); 101 | } > FLASH 102 | .cli_command : 103 | { 104 | PROVIDE(__start_cli_command = .); 105 | KEEP(*(.cli_command)) 106 | PROVIDE(__stop_cli_command = .); 107 | } > FLASH 108 | .crypto_data : 109 | { 110 | PROVIDE(__start_crypto_data = .); 111 | KEEP(*(SORT(.crypto_data*))) 112 | PROVIDE(__stop_crypto_data = .); 113 | } > FLASH 114 | .log_const_data : 115 | { 116 | PROVIDE(__start_log_const_data = .); 117 | KEEP(*(SORT(.log_const_data*))) 118 | PROVIDE(__stop_log_const_data = .); 119 | } > FLASH 120 | .log_backends : 121 | { 122 | PROVIDE(__start_log_backends = .); 123 | KEEP(*(SORT(.log_backends*))) 124 | PROVIDE(__stop_log_backends = .); 125 | } > FLASH 126 | 127 | } INSERT AFTER .text 128 | 129 | INCLUDE "nrf_common.ld" 130 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/ble_app_blinky/armgcc/ble_app_blinky_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000 9 | RAM (rwx) : ORIGIN = 0x200022b8, LENGTH = 0xdd48 10 | } 11 | 12 | SECTIONS 13 | { 14 | } 15 | 16 | SECTIONS 17 | { 18 | . = ALIGN(4); 19 | .mem_section_dummy_ram : 20 | { 21 | } 22 | .cli_sorted_cmd_ptrs : 23 | { 24 | PROVIDE(__start_cli_sorted_cmd_ptrs = .); 25 | KEEP(*(.cli_sorted_cmd_ptrs)) 26 | PROVIDE(__stop_cli_sorted_cmd_ptrs = .); 27 | } > RAM 28 | .fs_data : 29 | { 30 | PROVIDE(__start_fs_data = .); 31 | KEEP(*(.fs_data)) 32 | PROVIDE(__stop_fs_data = .); 33 | } > RAM 34 | .log_dynamic_data : 35 | { 36 | PROVIDE(__start_log_dynamic_data = .); 37 | KEEP(*(SORT(.log_dynamic_data*))) 38 | PROVIDE(__stop_log_dynamic_data = .); 39 | } > RAM 40 | .log_filter_data : 41 | { 42 | PROVIDE(__start_log_filter_data = .); 43 | KEEP(*(SORT(.log_filter_data*))) 44 | PROVIDE(__stop_log_filter_data = .); 45 | } > RAM 46 | 47 | } INSERT AFTER .data; 48 | 49 | SECTIONS 50 | { 51 | .mem_section_dummy_rom : 52 | { 53 | } 54 | .sdh_soc_observers : 55 | { 56 | PROVIDE(__start_sdh_soc_observers = .); 57 | KEEP(*(SORT(.sdh_soc_observers*))) 58 | PROVIDE(__stop_sdh_soc_observers = .); 59 | } > FLASH 60 | .pwr_mgmt_data : 61 | { 62 | PROVIDE(__start_pwr_mgmt_data = .); 63 | KEEP(*(SORT(.pwr_mgmt_data*))) 64 | PROVIDE(__stop_pwr_mgmt_data = .); 65 | } > FLASH 66 | .sdh_ble_observers : 67 | { 68 | PROVIDE(__start_sdh_ble_observers = .); 69 | KEEP(*(SORT(.sdh_ble_observers*))) 70 | PROVIDE(__stop_sdh_ble_observers = .); 71 | } > FLASH 72 | .sdh_stack_observers : 73 | { 74 | PROVIDE(__start_sdh_stack_observers = .); 75 | KEEP(*(SORT(.sdh_stack_observers*))) 76 | PROVIDE(__stop_sdh_stack_observers = .); 77 | } > FLASH 78 | .sdh_req_observers : 79 | { 80 | PROVIDE(__start_sdh_req_observers = .); 81 | KEEP(*(SORT(.sdh_req_observers*))) 82 | PROVIDE(__stop_sdh_req_observers = .); 83 | } > FLASH 84 | .sdh_state_observers : 85 | { 86 | PROVIDE(__start_sdh_state_observers = .); 87 | KEEP(*(SORT(.sdh_state_observers*))) 88 | PROVIDE(__stop_sdh_state_observers = .); 89 | } > FLASH 90 | .nrf_queue : 91 | { 92 | PROVIDE(__start_nrf_queue = .); 93 | KEEP(*(.nrf_queue)) 94 | PROVIDE(__stop_nrf_queue = .); 95 | } > FLASH 96 | .nrf_balloc : 97 | { 98 | PROVIDE(__start_nrf_balloc = .); 99 | KEEP(*(.nrf_balloc)) 100 | PROVIDE(__stop_nrf_balloc = .); 101 | } > FLASH 102 | .cli_command : 103 | { 104 | PROVIDE(__start_cli_command = .); 105 | KEEP(*(.cli_command)) 106 | PROVIDE(__stop_cli_command = .); 107 | } > FLASH 108 | .crypto_data : 109 | { 110 | PROVIDE(__start_crypto_data = .); 111 | KEEP(*(SORT(.crypto_data*))) 112 | PROVIDE(__stop_crypto_data = .); 113 | } > FLASH 114 | .log_const_data : 115 | { 116 | PROVIDE(__start_log_const_data = .); 117 | KEEP(*(SORT(.log_const_data*))) 118 | PROVIDE(__stop_log_const_data = .); 119 | } > FLASH 120 | .log_backends : 121 | { 122 | PROVIDE(__start_log_backends = .); 123 | KEEP(*(SORT(.log_backends*))) 124 | PROVIDE(__stop_log_backends = .); 125 | } > FLASH 126 | 127 | } INSERT AFTER .text 128 | 129 | INCLUDE "nrf_common.ld" 130 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/ble_app_cli/armgcc/ble_app_cli_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000 9 | RAM (rwx) : ORIGIN = 0x20002f90, LENGTH = 0xd070 10 | } 11 | 12 | SECTIONS 13 | { 14 | } 15 | 16 | SECTIONS 17 | { 18 | . = ALIGN(4); 19 | .mem_section_dummy_ram : 20 | { 21 | } 22 | .cli_sorted_cmd_ptrs : 23 | { 24 | PROVIDE(__start_cli_sorted_cmd_ptrs = .); 25 | KEEP(*(.cli_sorted_cmd_ptrs)) 26 | PROVIDE(__stop_cli_sorted_cmd_ptrs = .); 27 | } > RAM 28 | .fs_data : 29 | { 30 | PROVIDE(__start_fs_data = .); 31 | KEEP(*(.fs_data)) 32 | PROVIDE(__stop_fs_data = .); 33 | } > RAM 34 | .log_dynamic_data : 35 | { 36 | PROVIDE(__start_log_dynamic_data = .); 37 | KEEP(*(SORT(.log_dynamic_data*))) 38 | PROVIDE(__stop_log_dynamic_data = .); 39 | } > RAM 40 | .log_filter_data : 41 | { 42 | PROVIDE(__start_log_filter_data = .); 43 | KEEP(*(SORT(.log_filter_data*))) 44 | PROVIDE(__stop_log_filter_data = .); 45 | } > RAM 46 | 47 | } INSERT AFTER .data; 48 | 49 | SECTIONS 50 | { 51 | .mem_section_dummy_rom : 52 | { 53 | } 54 | .sdh_soc_observers : 55 | { 56 | PROVIDE(__start_sdh_soc_observers = .); 57 | KEEP(*(SORT(.sdh_soc_observers*))) 58 | PROVIDE(__stop_sdh_soc_observers = .); 59 | } > FLASH 60 | .sdh_ble_observers : 61 | { 62 | PROVIDE(__start_sdh_ble_observers = .); 63 | KEEP(*(SORT(.sdh_ble_observers*))) 64 | PROVIDE(__stop_sdh_ble_observers = .); 65 | } > FLASH 66 | .pwr_mgmt_data : 67 | { 68 | PROVIDE(__start_pwr_mgmt_data = .); 69 | KEEP(*(SORT(.pwr_mgmt_data*))) 70 | PROVIDE(__stop_pwr_mgmt_data = .); 71 | } > FLASH 72 | .cli_command : 73 | { 74 | PROVIDE(__start_cli_command = .); 75 | KEEP(*(.cli_command)) 76 | PROVIDE(__stop_cli_command = .); 77 | } > FLASH 78 | .nrf_queue : 79 | { 80 | PROVIDE(__start_nrf_queue = .); 81 | KEEP(*(.nrf_queue)) 82 | PROVIDE(__stop_nrf_queue = .); 83 | } > FLASH 84 | .sdh_stack_observers : 85 | { 86 | PROVIDE(__start_sdh_stack_observers = .); 87 | KEEP(*(SORT(.sdh_stack_observers*))) 88 | PROVIDE(__stop_sdh_stack_observers = .); 89 | } > FLASH 90 | .sdh_req_observers : 91 | { 92 | PROVIDE(__start_sdh_req_observers = .); 93 | KEEP(*(SORT(.sdh_req_observers*))) 94 | PROVIDE(__stop_sdh_req_observers = .); 95 | } > FLASH 96 | .sdh_state_observers : 97 | { 98 | PROVIDE(__start_sdh_state_observers = .); 99 | KEEP(*(SORT(.sdh_state_observers*))) 100 | PROVIDE(__stop_sdh_state_observers = .); 101 | } > FLASH 102 | .nrf_balloc : 103 | { 104 | PROVIDE(__start_nrf_balloc = .); 105 | KEEP(*(.nrf_balloc)) 106 | PROVIDE(__stop_nrf_balloc = .); 107 | } > FLASH 108 | .crypto_data : 109 | { 110 | PROVIDE(__start_crypto_data = .); 111 | KEEP(*(SORT(.crypto_data*))) 112 | PROVIDE(__stop_crypto_data = .); 113 | } > FLASH 114 | .log_const_data : 115 | { 116 | PROVIDE(__start_log_const_data = .); 117 | KEEP(*(SORT(.log_const_data*))) 118 | PROVIDE(__stop_log_const_data = .); 119 | } > FLASH 120 | .log_backends : 121 | { 122 | PROVIDE(__start_log_backends = .); 123 | KEEP(*(SORT(.log_backends*))) 124 | PROVIDE(__stop_log_backends = .); 125 | } > FLASH 126 | 127 | } INSERT AFTER .text 128 | 129 | INCLUDE "nrf_common.ld" 130 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/ble_app_eddystone/armgcc/ble_app_eddystone_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000 9 | RAM (rwx) : ORIGIN = 0x200022b8, LENGTH = 0xdd48 10 | } 11 | 12 | SECTIONS 13 | { 14 | } 15 | 16 | SECTIONS 17 | { 18 | . = ALIGN(4); 19 | .mem_section_dummy_ram : 20 | { 21 | } 22 | .cli_sorted_cmd_ptrs : 23 | { 24 | PROVIDE(__start_cli_sorted_cmd_ptrs = .); 25 | KEEP(*(.cli_sorted_cmd_ptrs)) 26 | PROVIDE(__stop_cli_sorted_cmd_ptrs = .); 27 | } > RAM 28 | .fs_data : 29 | { 30 | PROVIDE(__start_fs_data = .); 31 | KEEP(*(.fs_data)) 32 | PROVIDE(__stop_fs_data = .); 33 | } > RAM 34 | .log_dynamic_data : 35 | { 36 | PROVIDE(__start_log_dynamic_data = .); 37 | KEEP(*(SORT(.log_dynamic_data*))) 38 | PROVIDE(__stop_log_dynamic_data = .); 39 | } > RAM 40 | .log_filter_data : 41 | { 42 | PROVIDE(__start_log_filter_data = .); 43 | KEEP(*(SORT(.log_filter_data*))) 44 | PROVIDE(__stop_log_filter_data = .); 45 | } > RAM 46 | 47 | } INSERT AFTER .data; 48 | 49 | SECTIONS 50 | { 51 | .mem_section_dummy_rom : 52 | { 53 | } 54 | .sdh_soc_observers : 55 | { 56 | PROVIDE(__start_sdh_soc_observers = .); 57 | KEEP(*(SORT(.sdh_soc_observers*))) 58 | PROVIDE(__stop_sdh_soc_observers = .); 59 | } > FLASH 60 | .sdh_ble_observers : 61 | { 62 | PROVIDE(__start_sdh_ble_observers = .); 63 | KEEP(*(SORT(.sdh_ble_observers*))) 64 | PROVIDE(__stop_sdh_ble_observers = .); 65 | } > FLASH 66 | .pwr_mgmt_data : 67 | { 68 | PROVIDE(__start_pwr_mgmt_data = .); 69 | KEEP(*(SORT(.pwr_mgmt_data*))) 70 | PROVIDE(__stop_pwr_mgmt_data = .); 71 | } > FLASH 72 | .nrf_queue : 73 | { 74 | PROVIDE(__start_nrf_queue = .); 75 | KEEP(*(.nrf_queue)) 76 | PROVIDE(__stop_nrf_queue = .); 77 | } > FLASH 78 | .sdh_stack_observers : 79 | { 80 | PROVIDE(__start_sdh_stack_observers = .); 81 | KEEP(*(SORT(.sdh_stack_observers*))) 82 | PROVIDE(__stop_sdh_stack_observers = .); 83 | } > FLASH 84 | .sdh_req_observers : 85 | { 86 | PROVIDE(__start_sdh_req_observers = .); 87 | KEEP(*(SORT(.sdh_req_observers*))) 88 | PROVIDE(__stop_sdh_req_observers = .); 89 | } > FLASH 90 | .sdh_state_observers : 91 | { 92 | PROVIDE(__start_sdh_state_observers = .); 93 | KEEP(*(SORT(.sdh_state_observers*))) 94 | PROVIDE(__stop_sdh_state_observers = .); 95 | } > FLASH 96 | .nrf_balloc : 97 | { 98 | PROVIDE(__start_nrf_balloc = .); 99 | KEEP(*(.nrf_balloc)) 100 | PROVIDE(__stop_nrf_balloc = .); 101 | } > FLASH 102 | .cli_command : 103 | { 104 | PROVIDE(__start_cli_command = .); 105 | KEEP(*(.cli_command)) 106 | PROVIDE(__stop_cli_command = .); 107 | } > FLASH 108 | .crypto_data : 109 | { 110 | PROVIDE(__start_crypto_data = .); 111 | KEEP(*(SORT(.crypto_data*))) 112 | PROVIDE(__stop_crypto_data = .); 113 | } > FLASH 114 | .log_const_data : 115 | { 116 | PROVIDE(__start_log_const_data = .); 117 | KEEP(*(SORT(.log_const_data*))) 118 | PROVIDE(__stop_log_const_data = .); 119 | } > FLASH 120 | .log_backends : 121 | { 122 | PROVIDE(__start_log_backends = .); 123 | KEEP(*(SORT(.log_backends*))) 124 | PROVIDE(__stop_log_backends = .); 125 | } > FLASH 126 | 127 | } INSERT AFTER .text 128 | 129 | INCLUDE "nrf_common.ld" 130 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/ble_app_hrs/armgcc/ble_app_hrs_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000 9 | RAM (rwx) : ORIGIN = 0x20002b90, LENGTH = 0xd470 10 | } 11 | 12 | SECTIONS 13 | { 14 | } 15 | 16 | SECTIONS 17 | { 18 | . = ALIGN(4); 19 | .mem_section_dummy_ram : 20 | { 21 | } 22 | .cli_sorted_cmd_ptrs : 23 | { 24 | PROVIDE(__start_cli_sorted_cmd_ptrs = .); 25 | KEEP(*(.cli_sorted_cmd_ptrs)) 26 | PROVIDE(__stop_cli_sorted_cmd_ptrs = .); 27 | } > RAM 28 | .fs_data : 29 | { 30 | PROVIDE(__start_fs_data = .); 31 | KEEP(*(.fs_data)) 32 | PROVIDE(__stop_fs_data = .); 33 | } > RAM 34 | .log_dynamic_data : 35 | { 36 | PROVIDE(__start_log_dynamic_data = .); 37 | KEEP(*(SORT(.log_dynamic_data*))) 38 | PROVIDE(__stop_log_dynamic_data = .); 39 | } > RAM 40 | .log_filter_data : 41 | { 42 | PROVIDE(__start_log_filter_data = .); 43 | KEEP(*(SORT(.log_filter_data*))) 44 | PROVIDE(__stop_log_filter_data = .); 45 | } > RAM 46 | 47 | } INSERT AFTER .data; 48 | 49 | SECTIONS 50 | { 51 | .mem_section_dummy_rom : 52 | { 53 | } 54 | .sdh_soc_observers : 55 | { 56 | PROVIDE(__start_sdh_soc_observers = .); 57 | KEEP(*(SORT(.sdh_soc_observers*))) 58 | PROVIDE(__stop_sdh_soc_observers = .); 59 | } > FLASH 60 | .sdh_ble_observers : 61 | { 62 | PROVIDE(__start_sdh_ble_observers = .); 63 | KEEP(*(SORT(.sdh_ble_observers*))) 64 | PROVIDE(__stop_sdh_ble_observers = .); 65 | } > FLASH 66 | .pwr_mgmt_data : 67 | { 68 | PROVIDE(__start_pwr_mgmt_data = .); 69 | KEEP(*(SORT(.pwr_mgmt_data*))) 70 | PROVIDE(__stop_pwr_mgmt_data = .); 71 | } > FLASH 72 | .nrf_queue : 73 | { 74 | PROVIDE(__start_nrf_queue = .); 75 | KEEP(*(.nrf_queue)) 76 | PROVIDE(__stop_nrf_queue = .); 77 | } > FLASH 78 | .sdh_stack_observers : 79 | { 80 | PROVIDE(__start_sdh_stack_observers = .); 81 | KEEP(*(SORT(.sdh_stack_observers*))) 82 | PROVIDE(__stop_sdh_stack_observers = .); 83 | } > FLASH 84 | .sdh_req_observers : 85 | { 86 | PROVIDE(__start_sdh_req_observers = .); 87 | KEEP(*(SORT(.sdh_req_observers*))) 88 | PROVIDE(__stop_sdh_req_observers = .); 89 | } > FLASH 90 | .sdh_state_observers : 91 | { 92 | PROVIDE(__start_sdh_state_observers = .); 93 | KEEP(*(SORT(.sdh_state_observers*))) 94 | PROVIDE(__stop_sdh_state_observers = .); 95 | } > FLASH 96 | .nrf_balloc : 97 | { 98 | PROVIDE(__start_nrf_balloc = .); 99 | KEEP(*(.nrf_balloc)) 100 | PROVIDE(__stop_nrf_balloc = .); 101 | } > FLASH 102 | .cli_command : 103 | { 104 | PROVIDE(__start_cli_command = .); 105 | KEEP(*(.cli_command)) 106 | PROVIDE(__stop_cli_command = .); 107 | } > FLASH 108 | .crypto_data : 109 | { 110 | PROVIDE(__start_crypto_data = .); 111 | KEEP(*(SORT(.crypto_data*))) 112 | PROVIDE(__stop_crypto_data = .); 113 | } > FLASH 114 | .log_const_data : 115 | { 116 | PROVIDE(__start_log_const_data = .); 117 | KEEP(*(SORT(.log_const_data*))) 118 | PROVIDE(__stop_log_const_data = .); 119 | } > FLASH 120 | .log_backends : 121 | { 122 | PROVIDE(__start_log_backends = .); 123 | KEEP(*(SORT(.log_backends*))) 124 | PROVIDE(__stop_log_backends = .); 125 | } > FLASH 126 | 127 | } INSERT AFTER .text 128 | 129 | INCLUDE "nrf_common.ld" 130 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/blinky/README.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | 3 | When the application starts, the GPIO pins(P22, P23, P24) are configured as outputs to drive the RGB LED. The application then loops while toggling the state of one of the LEDs every 500 milliseconds. 4 | 5 | 6 | ## Compile & Program 7 | 8 | ``` 9 | $ make flash 10 | ``` 11 | 12 | Observe that the LEDs are blinking. 13 | 14 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/blinky/armgcc/blinky_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | } 15 | 16 | SECTIONS 17 | { 18 | . = ALIGN(4); 19 | .mem_section_dummy_ram : 20 | { 21 | } 22 | .log_dynamic_data : 23 | { 24 | PROVIDE(__start_log_dynamic_data = .); 25 | KEEP(*(SORT(.log_dynamic_data*))) 26 | PROVIDE(__stop_log_dynamic_data = .); 27 | } > RAM 28 | .log_filter_data : 29 | { 30 | PROVIDE(__start_log_filter_data = .); 31 | KEEP(*(SORT(.log_filter_data*))) 32 | PROVIDE(__stop_log_filter_data = .); 33 | } > RAM 34 | 35 | } INSERT AFTER .data; 36 | 37 | SECTIONS 38 | { 39 | .mem_section_dummy_rom : 40 | { 41 | } 42 | .log_const_data : 43 | { 44 | PROVIDE(__start_log_const_data = .); 45 | KEEP(*(SORT(.log_const_data*))) 46 | PROVIDE(__stop_log_const_data = .); 47 | } > FLASH 48 | .log_backends : 49 | { 50 | PROVIDE(__start_log_backends = .); 51 | KEEP(*(SORT(.log_backends*))) 52 | PROVIDE(__stop_log_backends = .); 53 | } > FLASH 54 | .nrf_balloc : 55 | { 56 | PROVIDE(__start_nrf_balloc = .); 57 | KEEP(*(.nrf_balloc)) 58 | PROVIDE(__stop_nrf_balloc = .); 59 | } > FLASH 60 | 61 | } INSERT AFTER .text 62 | 63 | INCLUDE "nrf_common.ld" 64 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/blinky/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 - 2018, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | /** @file 41 | * 42 | * @defgroup blinky_example_main main.c 43 | * @{ 44 | * @ingroup blinky_example 45 | * @brief Blinky Example Application main file. 46 | * 47 | * This file contains the source code for a sample application to blink LEDs. 48 | * 49 | */ 50 | 51 | #include 52 | #include 53 | #include "nrf_delay.h" 54 | #include "boards.h" 55 | 56 | /** 57 | * @brief Function for application main entry. 58 | */ 59 | int main(void) 60 | { 61 | /* Configure board. */ 62 | bsp_board_init(BSP_INIT_LEDS); 63 | 64 | /* Toggle LEDs. */ 65 | while (true) 66 | { 67 | for (int i = 0; i < LEDS_NUMBER; i++) 68 | { 69 | bsp_board_led_invert(i); 70 | nrf_delay_ms(500); 71 | } 72 | } 73 | } 74 | 75 | /** 76 | *@} 77 | **/ 78 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/flash_fds/armgcc/flash_fds_example_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | } 15 | 16 | SECTIONS 17 | { 18 | . = ALIGN(4); 19 | .mem_section_dummy_ram : 20 | { 21 | } 22 | .cli_sorted_cmd_ptrs : 23 | { 24 | PROVIDE(__start_cli_sorted_cmd_ptrs = .); 25 | KEEP(*(.cli_sorted_cmd_ptrs)) 26 | PROVIDE(__stop_cli_sorted_cmd_ptrs = .); 27 | } > RAM 28 | .fs_data : 29 | { 30 | PROVIDE(__start_fs_data = .); 31 | KEEP(*(.fs_data)) 32 | PROVIDE(__stop_fs_data = .); 33 | } > RAM 34 | .log_dynamic_data : 35 | { 36 | PROVIDE(__start_log_dynamic_data = .); 37 | KEEP(*(SORT(.log_dynamic_data*))) 38 | PROVIDE(__stop_log_dynamic_data = .); 39 | } > RAM 40 | .log_filter_data : 41 | { 42 | PROVIDE(__start_log_filter_data = .); 43 | KEEP(*(SORT(.log_filter_data*))) 44 | PROVIDE(__stop_log_filter_data = .); 45 | } > RAM 46 | 47 | } INSERT AFTER .data; 48 | 49 | SECTIONS 50 | { 51 | .mem_section_dummy_rom : 52 | { 53 | } 54 | .cli_command : 55 | { 56 | PROVIDE(__start_cli_command = .); 57 | KEEP(*(.cli_command)) 58 | PROVIDE(__stop_cli_command = .); 59 | } > FLASH 60 | .pwr_mgmt_data : 61 | { 62 | PROVIDE(__start_pwr_mgmt_data = .); 63 | KEEP(*(SORT(.pwr_mgmt_data*))) 64 | PROVIDE(__stop_pwr_mgmt_data = .); 65 | } > FLASH 66 | .nrf_queue : 67 | { 68 | PROVIDE(__start_nrf_queue = .); 69 | KEEP(*(.nrf_queue)) 70 | PROVIDE(__stop_nrf_queue = .); 71 | } > FLASH 72 | .log_const_data : 73 | { 74 | PROVIDE(__start_log_const_data = .); 75 | KEEP(*(SORT(.log_const_data*))) 76 | PROVIDE(__stop_log_const_data = .); 77 | } > FLASH 78 | .log_backends : 79 | { 80 | PROVIDE(__start_log_backends = .); 81 | KEEP(*(SORT(.log_backends*))) 82 | PROVIDE(__stop_log_backends = .); 83 | } > FLASH 84 | .nrf_balloc : 85 | { 86 | PROVIDE(__start_nrf_balloc = .); 87 | KEEP(*(.nrf_balloc)) 88 | PROVIDE(__stop_nrf_balloc = .); 89 | } > FLASH 90 | 91 | } INSERT AFTER .text 92 | 93 | INCLUDE "nrf_common.ld" 94 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/flash_fds/fds_example.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | 41 | #ifndef FDS_EXAMPLE_H__ 42 | #define FDS_EXAMPLE_H__ 43 | 44 | #include 45 | 46 | /* File ID and Key used for the configuration record. */ 47 | 48 | #define CONFIG_FILE (0xF010) 49 | #define CONFIG_REC_KEY (0x7010) 50 | 51 | /* Colors used to print on the console. */ 52 | 53 | #define COLOR_GREEN "\033[1;32m" 54 | #define COLOR_YELLOW "\033[1;33m" 55 | #define COLOR_CYAN "\033[1;36m" 56 | 57 | /* Macros to print on the console using colors. */ 58 | 59 | #define NRF_LOG_CYAN(...) NRF_LOG_INFO(COLOR_CYAN __VA_ARGS__) 60 | #define NRF_LOG_YELLOW(...) NRF_LOG_INFO(COLOR_YELLOW __VA_ARGS__) 61 | #define NRF_LOG_GREEN(...) NRF_LOG_INFO(COLOR_GREEN __VA_ARGS__) 62 | 63 | 64 | /* A dummy structure to save in flash. */ 65 | typedef struct 66 | { 67 | uint32_t boot_count; 68 | char device_name[16]; 69 | bool config1_on; 70 | bool config2_on; 71 | } configuration_t; 72 | 73 | 74 | /* Defined in main.c */ 75 | 76 | void delete_all_begin(void); 77 | 78 | /* Defined in cli.c */ 79 | 80 | void cli_init(void); 81 | void cli_start(void); 82 | void cli_process(void); 83 | bool record_delete_next(void); 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/nfc_url_record/armgcc/nfc_url_record_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | } 15 | 16 | SECTIONS 17 | { 18 | . = ALIGN(4); 19 | .mem_section_dummy_ram : 20 | { 21 | } 22 | .log_dynamic_data : 23 | { 24 | PROVIDE(__start_log_dynamic_data = .); 25 | KEEP(*(SORT(.log_dynamic_data*))) 26 | PROVIDE(__stop_log_dynamic_data = .); 27 | } > RAM 28 | .log_filter_data : 29 | { 30 | PROVIDE(__start_log_filter_data = .); 31 | KEEP(*(SORT(.log_filter_data*))) 32 | PROVIDE(__stop_log_filter_data = .); 33 | } > RAM 34 | 35 | } INSERT AFTER .data; 36 | 37 | SECTIONS 38 | { 39 | .mem_section_dummy_rom : 40 | { 41 | } 42 | .log_const_data : 43 | { 44 | PROVIDE(__start_log_const_data = .); 45 | KEEP(*(SORT(.log_const_data*))) 46 | PROVIDE(__stop_log_const_data = .); 47 | } > FLASH 48 | .log_backends : 49 | { 50 | PROVIDE(__start_log_backends = .); 51 | KEEP(*(SORT(.log_backends*))) 52 | PROVIDE(__stop_log_backends = .); 53 | } > FLASH 54 | .nrf_balloc : 55 | { 56 | PROVIDE(__start_nrf_balloc = .); 57 | KEEP(*(.nrf_balloc)) 58 | PROVIDE(__stop_nrf_balloc = .); 59 | } > FLASH 60 | 61 | } INSERT AFTER .text 62 | 63 | INCLUDE "nrf_common.ld" 64 | -------------------------------------------------------------------------------- /examples/nrf5-sdk/saadc/armgcc/saadc_gcc_nrf52.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | SECTIONS 13 | { 14 | } 15 | 16 | SECTIONS 17 | { 18 | . = ALIGN(4); 19 | .mem_section_dummy_ram : 20 | { 21 | } 22 | .log_dynamic_data : 23 | { 24 | PROVIDE(__start_log_dynamic_data = .); 25 | KEEP(*(SORT(.log_dynamic_data*))) 26 | PROVIDE(__stop_log_dynamic_data = .); 27 | } > RAM 28 | .log_filter_data : 29 | { 30 | PROVIDE(__start_log_filter_data = .); 31 | KEEP(*(SORT(.log_filter_data*))) 32 | PROVIDE(__stop_log_filter_data = .); 33 | } > RAM 34 | 35 | } INSERT AFTER .data; 36 | 37 | SECTIONS 38 | { 39 | .mem_section_dummy_rom : 40 | { 41 | } 42 | .pwr_mgmt_data : 43 | { 44 | PROVIDE(__start_pwr_mgmt_data = .); 45 | KEEP(*(SORT(.pwr_mgmt_data*))) 46 | PROVIDE(__stop_pwr_mgmt_data = .); 47 | } > FLASH 48 | .log_const_data : 49 | { 50 | PROVIDE(__start_log_const_data = .); 51 | KEEP(*(SORT(.log_const_data*))) 52 | PROVIDE(__stop_log_const_data = .); 53 | } > FLASH 54 | .log_backends : 55 | { 56 | PROVIDE(__start_log_backends = .); 57 | KEEP(*(SORT(.log_backends*))) 58 | PROVIDE(__stop_log_backends = .); 59 | } > FLASH 60 | .nrf_balloc : 61 | { 62 | PROVIDE(__start_nrf_balloc = .); 63 | KEEP(*(.nrf_balloc)) 64 | PROVIDE(__stop_nrf_balloc = .); 65 | } > FLASH 66 | 67 | } INSERT AFTER .text 68 | 69 | INCLUDE "nrf_common.ld" 70 | -------------------------------------------------------------------------------- /examples/zephyr/blink_led/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 3 | project(NONE) 4 | 5 | target_sources(app PRIVATE src/main.c) 6 | -------------------------------------------------------------------------------- /examples/zephyr/blink_led/README.rst: -------------------------------------------------------------------------------- 1 | .. _blink-led-sample: 2 | 3 | PWM: Blink LED 4 | ############## 5 | 6 | Overview 7 | ******** 8 | 9 | This is a sample app which blinks a LED using PWM. 10 | 11 | The LED will start at a blinking frequency of 1 Hz. Every 4 seconds, 12 | the blinking frequency will double. When the blinking frequency 13 | reaches 64 Hz, the blinking frequency will be halved every 4 seconds 14 | until the blinking frequency reaches 1 Hz. This completes a whole 15 | blinking cycle. This faster-then-slower LED blinking cycle repeats forever. 16 | 17 | Wiring 18 | ****** 19 | 20 | Arduino 101 and Quark D2000 CRB 21 | =============================== 22 | You will need to connect the LED to ground and PWM0 via the shield. 23 | You may need a current limiting resistor. See your LED datasheet. 24 | 25 | Nucleo_F401RE, Nucleo_L476RG, STM32F4_DISCOVERY, Nucleo_F302R8 26 | ============================================================== 27 | Connect PWM2(PA0) to LED 28 | 29 | Nucleo_F103RB 30 | ============= 31 | Connect PWM1(PA8) to LED 32 | 33 | Hexiwear K64 34 | ============ 35 | No special board setup is necessary because there is an on-board RGB LED 36 | connected to the K64 PWM. 37 | 38 | nRF52840_PCA10056 39 | ================= 40 | No special board setup is necessary because there is an on-board LED connected. 41 | 42 | Building and Running 43 | ******************** 44 | 45 | This sample can be built for multiple boards, in this example we will build it 46 | for the arduino_101 board: 47 | 48 | .. zephyr-app-commands:: 49 | :zephyr-app: samples/basic/blink_led 50 | :board: arduino_101 51 | :goals: build flash 52 | :compact: 53 | 54 | After flashing the image to the board, the user LED on the board should start to 55 | blinking as discussed in overview 56 | 57 | -------------------------------------------------------------------------------- /examples/zephyr/blink_led/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_STDOUT_CONSOLE=y 2 | CONFIG_PRINTK=y 3 | CONFIG_PWM=y 4 | CONFIG_LOG=y 5 | CONFIG_PWM_LOG_LEVEL_DBG=y 6 | -------------------------------------------------------------------------------- /examples/zephyr/blink_led/prj_nrf52832_mdk.conf: -------------------------------------------------------------------------------- 1 | CONFIG_STDOUT_CONSOLE=y 2 | CONFIG_PRINTK=y 3 | CONFIG_PWM=y 4 | CONFIG_LOG=y 5 | CONFIG_PWM_LOG_LEVEL_DBG=y 6 | CONFIG_PWM_NRF5_SW_0_CLOCK_PRESCALER=9 7 | -------------------------------------------------------------------------------- /examples/zephyr/blink_led/prj_nrf52840_mdk.conf: -------------------------------------------------------------------------------- 1 | CONFIG_STDOUT_CONSOLE=y 2 | CONFIG_PRINTK=y 3 | CONFIG_PWM=y 4 | CONFIG_LOG=y 5 | CONFIG_PWM_LOG_LEVEL_DBG=y 6 | CONFIG_PWM_NRF5_SW_0_CLOCK_PRESCALER=9 7 | -------------------------------------------------------------------------------- /examples/zephyr/blink_led/prj_nrf52840_pca10056.conf: -------------------------------------------------------------------------------- 1 | CONFIG_PRINTK=y 2 | CONFIG_LOG=y 3 | CONFIG_PWM_LOG_LEVEL_DBG=y 4 | 5 | CONFIG_PWM=y 6 | CONFIG_PWM_NRF5_SW_0_CLOCK_PRESCALER=9 7 | -------------------------------------------------------------------------------- /examples/zephyr/blink_led/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | name: Blink LED (PWM based) 3 | tests: 4 | test: 5 | # FIXME: We should remove those and just rely on depends_on 6 | platform_whitelist: arduino_101 quark_d2000_crb 7 | nucleo_f103rb nucleo_f302r8 nucleo_f401re nucleo_l476rg stm32f4_disco 8 | hexiwear_k64 colibri_imx7d_m4 nrf52832_mdk nrf52840_mdk 9 | tags: drivers pwm 10 | depends_on: pwm 11 | -------------------------------------------------------------------------------- /examples/zephyr/blink_led/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /** 8 | * @file Sample app to demonstrate PWM. 9 | * 10 | * This app uses PWM[0]. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #if defined(CONFIG_SOC_STM32F401XE) || defined(CONFIG_SOC_STM32F412ZG) || \ 20 | defined(CONFIG_SOC_STM32F413XH) || defined(CONFIG_SOC_STM32L476XG) || \ 21 | defined(CONFIG_SOC_STM32F407XG) || defined(CONFIG_SOC_STM32F302X8) 22 | #define PWM_DRIVER CONFIG_PWM_STM32_2_DEV_NAME 23 | #define PWM_CHANNEL 1 24 | #elif CONFIG_SOC_STM32F103XB 25 | #define PWM_DRIVER CONFIG_PWM_STM32_1_DEV_NAME 26 | #define PWM_CHANNEL 1 27 | #elif defined(CONFIG_SOC_QUARK_SE_C1000) || defined(CONFIG_SOC_QUARK_D2000) 28 | #define PWM_DRIVER CONFIG_PWM_QMSI_DEV_NAME 29 | #define PWM_CHANNEL 0 30 | #elif defined(CONFIG_SOC_FAMILY_NRF) 31 | #define PWM_DRIVER CONFIG_PWM_NRF5_SW_0_DEV_NAME 32 | #define PWM_CHANNEL LED0_GPIO_PIN 33 | #elif defined(CONFIG_BOARD_HEXIWEAR_K64) 34 | #define PWM_DRIVER GREEN_PWM_NAME 35 | #define PWM_CHANNEL GREEN_PWM_CHANNEL 36 | #elif defined(CONFIG_BOARD_COLIBRI_IMX7D_M4) 37 | #define PWM_DRIVER PWM_1_LABEL 38 | #define PWM_CHANNEL 0 39 | #elif defined(CONFIG_SOC_FAMILY_NRF) 40 | #define PWM_DRIVER CONFIG_PWM_NRF5_SW_0_DEV_NAME 41 | #define PWM_CHANNEL LED0_GPIO_PIN 42 | #else 43 | #error "Choose supported PWM driver" 44 | #endif 45 | 46 | /* in micro second */ 47 | #define MIN_PERIOD (USEC_PER_SEC / 64) 48 | 49 | /* in micro second */ 50 | #define MAX_PERIOD USEC_PER_SEC 51 | 52 | void main(void) 53 | { 54 | struct device *pwm_dev; 55 | u32_t period = MAX_PERIOD; 56 | u8_t dir = 0; 57 | 58 | printk("PWM demo app-blink LED\n"); 59 | 60 | pwm_dev = device_get_binding(PWM_DRIVER); 61 | if (!pwm_dev) { 62 | printk("Cannot find %s!\n", PWM_DRIVER); 63 | return; 64 | } 65 | 66 | while (1) { 67 | if (pwm_pin_set_usec(pwm_dev, PWM_CHANNEL, 68 | period, period / 2)) { 69 | printk("pwm pin set fails\n"); 70 | return; 71 | } 72 | 73 | if (dir) { 74 | period *= 2; 75 | 76 | if (period > MAX_PERIOD) { 77 | dir = 0; 78 | period = MAX_PERIOD; 79 | } 80 | } else { 81 | period /= 2; 82 | 83 | if (period < MIN_PERIOD) { 84 | dir = 1; 85 | period = MIN_PERIOD; 86 | } 87 | } 88 | 89 | k_sleep(MSEC_PER_SEC * 4); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /examples/zephyr/blinky/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 3 | project(NONE) 4 | 5 | target_sources(app PRIVATE src/main.c) 6 | -------------------------------------------------------------------------------- /examples/zephyr/blinky/README.rst: -------------------------------------------------------------------------------- 1 | .. _blinky-sample: 2 | 3 | Blinky Application 4 | ################## 5 | 6 | Overview 7 | ******** 8 | 9 | The Blinky example shows how to configure GPIO pins as outputs which can also be 10 | used to drive LEDs on the hardware usually delivered as "User LEDs" on many of 11 | the supported boards in Zephyr. 12 | 13 | Requirements 14 | ************ 15 | 16 | The demo assumes that an LED is connected to one of GPIO lines. The 17 | sample code is configured to work on boards with user defined buttons and that 18 | have defined the LED0\_* variables in :file:`board.h`. 19 | 20 | The :file:`board.h` must define the following variables: 21 | 22 | - LED0_GPIO_NAME (or LED0_GPIO_CONTROLLER) 23 | - LED0_GPIO_PIN 24 | 25 | 26 | Building and Running 27 | ******************** 28 | 29 | This samples does not output anything to the console. It can be built and 30 | flashed to a board as follows: 31 | 32 | .. zephyr-app-commands:: 33 | :zephyr-app: samples/basic/blinky 34 | :board: arduino_101 35 | :goals: build flash 36 | :compact: 37 | 38 | After flashing the image to the board, the user LED on the board should start to 39 | blink. 40 | -------------------------------------------------------------------------------- /examples/zephyr/blinky/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_GPIO=y 2 | CONFIG_SERIAL=n 3 | -------------------------------------------------------------------------------- /examples/zephyr/blinky/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | name: Blinky Sample 3 | tests: 4 | test: 5 | tags: LED gpio 6 | depends_on: gpio 7 | -------------------------------------------------------------------------------- /examples/zephyr/blinky/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 | /* Change this if you have an LED connected to a custom port */ 13 | #ifndef LED0_GPIO_CONTROLLER 14 | #define LED0_GPIO_CONTROLLER LED0_GPIO_PORT 15 | #endif 16 | 17 | #define LED_PORT LED0_GPIO_CONTROLLER 18 | 19 | /* Change this if you have an LED connected to a custom pin */ 20 | #define LED LED0_GPIO_PIN 21 | 22 | /* 1000 msec = 1 sec */ 23 | #define SLEEP_TIME 1000 24 | 25 | void main(void) 26 | { 27 | int cnt = 0; 28 | struct device *dev; 29 | 30 | dev = device_get_binding(LED_PORT); 31 | /* Set LED pin as output */ 32 | gpio_pin_configure(dev, LED, GPIO_DIR_OUT); 33 | 34 | while (1) { 35 | /* Set pin to HIGH/LOW every 1 second */ 36 | gpio_pin_write(dev, LED, cnt % 2); 37 | cnt++; 38 | k_sleep(SLEEP_TIME); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/beacon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 3 | project(NONE) 4 | 5 | target_sources(app PRIVATE src/main.c) 6 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/beacon/README.rst: -------------------------------------------------------------------------------- 1 | .. _bluetooth-beacon-sample: 2 | 3 | Bluetooth: Beacon 4 | ################# 5 | 6 | Overview 7 | ******** 8 | 9 | A simple application demonstrating the BLE Broadcaster role functionality by 10 | advertising an Eddystone URL (the Zephyr website). 11 | 12 | 13 | 14 | Requirements 15 | ************ 16 | 17 | * BlueZ running on the host, or 18 | * A board with BLE support 19 | 20 | Building and Running 21 | ******************** 22 | 23 | This sample can be found under :file:`samples/bluetooth/beacon` in the 24 | Zephyr tree. 25 | 26 | See :ref:`bluetooth setup section ` for details. 27 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/beacon/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=y 2 | CONFIG_BT_DEBUG_LOG=y 3 | CONFIG_BT_DEVICE_NAME="Test beacon" 4 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/beacon/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | description: TBD 3 | name: TBD 4 | tests: 5 | test: 6 | harness: bluetooth 7 | platform_whitelist: qemu_cortex_m3 qemu_x86 nrf52_pca10040 8 | tags: bluetooth 9 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/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 | if (err) { 46 | printk("Bluetooth init failed (err %d)\n", err); 47 | return; 48 | } 49 | 50 | printk("Bluetooth initialized\n"); 51 | 52 | /* Start advertising */ 53 | err = bt_le_adv_start(BT_LE_ADV_NCONN, ad, ARRAY_SIZE(ad), 54 | sd, ARRAY_SIZE(sd)); 55 | if (err) { 56 | printk("Advertising failed to start (err %d)\n", err); 57 | return; 58 | } 59 | 60 | printk("Beacon started\n"); 61 | } 62 | 63 | void main(void) 64 | { 65 | int err; 66 | 67 | printk("Starting Beacon Demo\n"); 68 | 69 | /* Initialize the Bluetooth Subsystem */ 70 | err = bt_enable(bt_ready); 71 | if (err) { 72 | printk("Bluetooth init failed (err %d)\n", err); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/eddystone/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 3 | project(NONE) 4 | 5 | target_sources(app PRIVATE 6 | src/main.c 7 | ) 8 | 9 | zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth) 10 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/eddystone/README.rst: -------------------------------------------------------------------------------- 1 | .. _bluetooth-eddystone-sample: 2 | 3 | Bluetooth: Eddystone 4 | #################### 5 | 6 | Overview 7 | ******** 8 | Application demonstrating `Eddystone Configuration Service`_ 9 | 10 | The Eddystone Configuration Service runs as a GATT service on the beacon while 11 | it is connectable and allows configuration of the advertised data, the 12 | broadcast power levels, and the advertising intervals. It also forms part of 13 | the definition of how Eddystone-EID beacons are configured and registered with 14 | a trusted resolver. 15 | 16 | 17 | Requirements 18 | ************ 19 | 20 | * BlueZ running on the host, or 21 | * A board with BLE support 22 | 23 | Building and Running 24 | ******************** 25 | This sample can be found under :file:`samples/bluetooth/eddystone` in the 26 | Zephyr tree. 27 | 28 | See :ref:`bluetooth setup section ` for details. 29 | 30 | .. _Eddystone Configuration Service: https://github.com/google/eddystone/tree/master/configuration-service 31 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/eddystone/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=y 2 | CONFIG_BT_DEBUG_LOG=y 3 | CONFIG_BT_PERIPHERAL=y 4 | CONFIG_BT_DEVICE_NAME="Zephyr Eddystone" 5 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/eddystone/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | description: TBD 3 | name: TBD 4 | tests: 5 | test: 6 | harness: bluetooth 7 | platform_whitelist: qemu_cortex_m3 qemu_x86 8 | tags: bluetooth 9 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/bas.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief BAS Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | static struct bt_gatt_ccc_cfg blvl_ccc_cfg[BT_GATT_CCC_MAX] = {}; 26 | static u8_t simulate_blvl; 27 | static u8_t battery = 100; 28 | 29 | static void blvl_ccc_cfg_changed(const struct bt_gatt_attr *attr, 30 | u16_t value) 31 | { 32 | simulate_blvl = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0; 33 | } 34 | 35 | static ssize_t read_blvl(struct bt_conn *conn, const struct bt_gatt_attr *attr, 36 | void *buf, u16_t len, u16_t offset) 37 | { 38 | const char *value = attr->user_data; 39 | 40 | return bt_gatt_attr_read(conn, attr, buf, len, offset, value, 41 | sizeof(*value)); 42 | } 43 | 44 | /* Battery Service Declaration */ 45 | static struct bt_gatt_attr attrs[] = { 46 | BT_GATT_PRIMARY_SERVICE(BT_UUID_BAS), 47 | BT_GATT_CHARACTERISTIC(BT_UUID_BAS_BATTERY_LEVEL, 48 | BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, 49 | BT_GATT_PERM_READ, read_blvl, NULL, &battery), 50 | BT_GATT_CCC(blvl_ccc_cfg, blvl_ccc_cfg_changed), 51 | }; 52 | 53 | static struct bt_gatt_service bas_svc = BT_GATT_SERVICE(attrs); 54 | 55 | void bas_init(void) 56 | { 57 | bt_gatt_service_register(&bas_svc); 58 | } 59 | 60 | void bas_notify(void) 61 | { 62 | if (!simulate_blvl) { 63 | return; 64 | } 65 | 66 | battery--; 67 | if (!battery) { 68 | /* Software eco battery charger */ 69 | battery = 100; 70 | } 71 | 72 | bt_gatt_notify(NULL, &attrs[1], &battery, sizeof(battery)); 73 | } 74 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/bas.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief BAS Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void bas_init(void); 16 | void bas_notify(void); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/cts.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief CTS Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | static struct bt_gatt_ccc_cfg ct_ccc_cfg[BT_GATT_CCC_MAX] = {}; 26 | static u8_t ct[10]; 27 | static u8_t ct_update; 28 | 29 | static void ct_ccc_cfg_changed(const struct bt_gatt_attr *attr, u16_t value) 30 | { 31 | /* TODO: Handle value */ 32 | } 33 | 34 | static ssize_t read_ct(struct bt_conn *conn, const struct bt_gatt_attr *attr, 35 | void *buf, u16_t len, u16_t offset) 36 | { 37 | const char *value = attr->user_data; 38 | 39 | return bt_gatt_attr_read(conn, attr, buf, len, offset, value, 40 | sizeof(ct)); 41 | } 42 | 43 | static ssize_t write_ct(struct bt_conn *conn, const struct bt_gatt_attr *attr, 44 | const void *buf, u16_t len, u16_t offset, 45 | u8_t flags) 46 | { 47 | u8_t *value = attr->user_data; 48 | 49 | if (offset + len > sizeof(ct)) { 50 | return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); 51 | } 52 | 53 | memcpy(value + offset, buf, len); 54 | ct_update = 1; 55 | 56 | return len; 57 | } 58 | 59 | /* Current Time Service Declaration */ 60 | static struct bt_gatt_attr attrs[] = { 61 | BT_GATT_PRIMARY_SERVICE(BT_UUID_CTS), 62 | BT_GATT_CHARACTERISTIC(BT_UUID_CTS_CURRENT_TIME, BT_GATT_CHRC_READ | 63 | BT_GATT_CHRC_NOTIFY | BT_GATT_CHRC_WRITE, 64 | BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, 65 | read_ct, write_ct, ct), 66 | BT_GATT_CCC(ct_ccc_cfg, ct_ccc_cfg_changed), 67 | }; 68 | 69 | static struct bt_gatt_service cts_svc = BT_GATT_SERVICE(attrs); 70 | 71 | static void generate_current_time(u8_t *buf) 72 | { 73 | u16_t year; 74 | 75 | /* 'Exact Time 256' contains 'Day Date Time' which contains 76 | * 'Date Time' - characteristic contains fields for: 77 | * year, month, day, hours, minutes and seconds. 78 | */ 79 | 80 | year = sys_cpu_to_le16(2015); 81 | memcpy(buf, &year, 2); /* year */ 82 | buf[2] = 5; /* months starting from 1 */ 83 | buf[3] = 30; /* day */ 84 | buf[4] = 12; /* hours */ 85 | buf[5] = 45; /* minutes */ 86 | buf[6] = 30; /* seconds */ 87 | 88 | /* 'Day of Week' part of 'Day Date Time' */ 89 | buf[7] = 1; /* day of week starting from 1 */ 90 | 91 | /* 'Fractions 256 part of 'Exact Time 256' */ 92 | buf[8] = 0; 93 | 94 | /* Adjust reason */ 95 | buf[9] = 0; /* No update, change, etc */ 96 | } 97 | 98 | void cts_init(void) 99 | { 100 | /* Simulate current time for Current Time Service */ 101 | generate_current_time(ct); 102 | 103 | bt_gatt_service_register(&cts_svc); 104 | } 105 | 106 | void cts_notify(void) 107 | { /* Current Time Service updates only when time is changed */ 108 | if (!ct_update) { 109 | return; 110 | } 111 | 112 | ct_update = 0; 113 | bt_gatt_notify(NULL, &attrs[1], &ct, sizeof(ct)); 114 | } 115 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/cts.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief CTS Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void cts_init(void); 16 | void cts_notify(void); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/dis.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief DIS Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | static const char *dis_model; 26 | static const char *dis_manuf; 27 | 28 | static ssize_t read_model(struct bt_conn *conn, 29 | const struct bt_gatt_attr *attr, void *buf, 30 | u16_t len, u16_t offset) 31 | { 32 | return bt_gatt_attr_read(conn, attr, buf, len, offset, dis_model, 33 | strlen(dis_model)); 34 | } 35 | 36 | static ssize_t read_manuf(struct bt_conn *conn, 37 | const struct bt_gatt_attr *attr, void *buf, 38 | u16_t len, u16_t offset) 39 | { 40 | return bt_gatt_attr_read(conn, attr, buf, len, offset, dis_manuf, 41 | strlen(dis_manuf)); 42 | } 43 | 44 | /* Device Information Service Declaration */ 45 | static struct bt_gatt_attr attrs[] = { 46 | BT_GATT_PRIMARY_SERVICE(BT_UUID_DIS), 47 | BT_GATT_CHARACTERISTIC(BT_UUID_DIS_MODEL_NUMBER, BT_GATT_CHRC_READ, 48 | BT_GATT_PERM_READ, read_model, NULL, NULL), 49 | BT_GATT_CHARACTERISTIC(BT_UUID_DIS_MANUFACTURER_NAME, 50 | BT_GATT_CHRC_READ, BT_GATT_PERM_READ, 51 | read_manuf, NULL, NULL), 52 | }; 53 | 54 | static struct bt_gatt_service dis_svc = BT_GATT_SERVICE(attrs); 55 | 56 | void dis_init(const char *model, const char *manuf) 57 | { 58 | dis_model = model; 59 | dis_manuf = manuf; 60 | 61 | bt_gatt_service_register(&dis_svc); 62 | } 63 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/dis.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief DIS Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void dis_init(const char *model, const char *manuf); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/hog.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief HoG Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void hog_init(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/hrs.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief HRS Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | static struct bt_gatt_ccc_cfg hrmc_ccc_cfg[BT_GATT_CCC_MAX] = {}; 26 | static u8_t simulate_hrm; 27 | static u8_t heartrate = 90; 28 | static u8_t hrs_blsc; 29 | 30 | static void hrmc_ccc_cfg_changed(const struct bt_gatt_attr *attr, 31 | u16_t value) 32 | { 33 | simulate_hrm = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0; 34 | } 35 | 36 | static ssize_t read_blsc(struct bt_conn *conn, const struct bt_gatt_attr *attr, 37 | void *buf, u16_t len, u16_t offset) 38 | { 39 | return bt_gatt_attr_read(conn, attr, buf, len, offset, &hrs_blsc, 40 | sizeof(hrs_blsc)); 41 | } 42 | 43 | /* Heart Rate Service Declaration */ 44 | static struct bt_gatt_attr attrs[] = { 45 | BT_GATT_PRIMARY_SERVICE(BT_UUID_HRS), 46 | BT_GATT_CHARACTERISTIC(BT_UUID_HRS_MEASUREMENT, BT_GATT_CHRC_NOTIFY, 47 | BT_GATT_PERM_NONE, NULL, NULL, NULL), 48 | BT_GATT_CCC(hrmc_ccc_cfg, hrmc_ccc_cfg_changed), 49 | BT_GATT_CHARACTERISTIC(BT_UUID_HRS_BODY_SENSOR, BT_GATT_CHRC_READ, 50 | BT_GATT_PERM_READ, read_blsc, NULL, NULL), 51 | BT_GATT_CHARACTERISTIC(BT_UUID_HRS_CONTROL_POINT, BT_GATT_CHRC_WRITE, 52 | BT_GATT_PERM_NONE, NULL, NULL, NULL), 53 | }; 54 | 55 | static struct bt_gatt_service hrs_svc = BT_GATT_SERVICE(attrs); 56 | 57 | void hrs_init(u8_t blsc) 58 | { 59 | hrs_blsc = blsc; 60 | 61 | bt_gatt_service_register(&hrs_svc); 62 | } 63 | 64 | void hrs_notify(void) 65 | { 66 | static u8_t hrm[2]; 67 | 68 | /* Heartrate measurements simulation */ 69 | if (!simulate_hrm) { 70 | return; 71 | } 72 | 73 | heartrate++; 74 | if (heartrate == 160) { 75 | heartrate = 90; 76 | } 77 | 78 | hrm[0] = 0x06; /* uint8, sensor contact */ 79 | hrm[1] = heartrate; 80 | 81 | bt_gatt_notify(NULL, &attrs[1], &hrm, sizeof(hrm)); 82 | } 83 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/hrs.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief HRS Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void hrs_init(u8_t blsc); 16 | void hrs_notify(void); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/ipss.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief IP Support Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2015-2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #define UNKNOWN_APPEARANCE 0x0000 26 | 27 | static struct bt_gatt_attr attrs[] = { 28 | /* IP Support Service Declaration */ 29 | BT_GATT_PRIMARY_SERVICE(BT_UUID_IPSS), 30 | }; 31 | 32 | static struct bt_gatt_service ipss_svc = BT_GATT_SERVICE(attrs); 33 | 34 | static const struct bt_data ad[] = { 35 | BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), 36 | BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x20, 0x18), 37 | }; 38 | 39 | static void connected(struct bt_conn *conn, u8_t err) 40 | { 41 | if (err) { 42 | printk("Connection failed (err %u)\n", err); 43 | } else { 44 | printk("Connected\n"); 45 | } 46 | } 47 | 48 | static void disconnected(struct bt_conn *conn, u8_t reason) 49 | { 50 | printk("Disconnected (reason %u)\n", reason); 51 | } 52 | 53 | static struct bt_conn_cb conn_callbacks = { 54 | .connected = connected, 55 | .disconnected = disconnected, 56 | }; 57 | 58 | void ipss_init(void) 59 | { 60 | bt_gatt_service_register(&ipss_svc); 61 | 62 | bt_conn_cb_register(&conn_callbacks); 63 | } 64 | 65 | int ipss_advertise(void) 66 | { 67 | int err; 68 | 69 | err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0); 70 | if (err) { 71 | return err; 72 | } 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/gatt/ipss.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief IPSP Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2015-2016 Intel Corporation 7 | * 8 | * SPDX-License-Identifier: Apache-2.0 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | void ipss_init(void); 16 | int ipss_advertise(void); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/peripheral_hr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 3 | project(NONE) 4 | 5 | FILE(GLOB app_sources src/*.c) 6 | target_sources(app PRIVATE 7 | ${app_sources} 8 | ../gatt/hrs.c 9 | ../gatt/dis.c 10 | ../gatt/bas.c 11 | ) 12 | 13 | zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth) 14 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/peripheral_hr/README.rst: -------------------------------------------------------------------------------- 1 | .. _peripheral_hr: 2 | 3 | Bluetooth: Peripheral HR 4 | ######################## 5 | 6 | Overview 7 | ******** 8 | 9 | Similar to the :ref:`Peripheral ` sample, except that this 10 | application specifically exposes the HR (Heart Rate) GATT Service. Once a device 11 | connects it will generate dummy heart-rate values. 12 | 13 | 14 | Requirements 15 | ************ 16 | 17 | * BlueZ running on the host, or 18 | * A board with BLE support 19 | 20 | Building and Running 21 | ******************** 22 | 23 | This sample can be found under :file:`samples/bluetooth/peripheral_hr` in the 24 | Zephyr tree. 25 | 26 | See :ref:`bluetooth setup section ` for details. 27 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/peripheral_hr/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=y 2 | CONFIG_BT_DEBUG_LOG=y 3 | CONFIG_BT_SMP=y 4 | CONFIG_BT_PERIPHERAL=y 5 | CONFIG_BT_DEVICE_NAME="Zephyr Heartrate Sensor" 6 | CONFIG_BT_DEVICE_APPEARANCE=833 7 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/peripheral_hr/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | description: TBD 3 | name: TBD 4 | tests: 5 | test: 6 | harness: bluetooth 7 | platform_whitelist: qemu_cortex_m3 qemu_x86 8 | tags: bluetooth 9 | -------------------------------------------------------------------------------- /examples/zephyr/bluetooth/peripheral_hr/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 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | struct bt_conn *default_conn; 28 | 29 | static const struct bt_data ad[] = { 30 | BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), 31 | BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x0d, 0x18, 0x0f, 0x18, 0x05, 0x18), 32 | }; 33 | 34 | static void connected(struct bt_conn *conn, u8_t err) 35 | { 36 | if (err) { 37 | printk("Connection failed (err %u)\n", err); 38 | } else { 39 | default_conn = bt_conn_ref(conn); 40 | printk("Connected\n"); 41 | } 42 | } 43 | 44 | static void disconnected(struct bt_conn *conn, u8_t reason) 45 | { 46 | printk("Disconnected (reason %u)\n", reason); 47 | 48 | if (default_conn) { 49 | bt_conn_unref(default_conn); 50 | default_conn = NULL; 51 | } 52 | } 53 | 54 | static struct bt_conn_cb conn_callbacks = { 55 | .connected = connected, 56 | .disconnected = disconnected, 57 | }; 58 | 59 | static void bt_ready(int err) 60 | { 61 | if (err) { 62 | printk("Bluetooth init failed (err %d)\n", err); 63 | return; 64 | } 65 | 66 | printk("Bluetooth initialized\n"); 67 | 68 | hrs_init(0x01); 69 | bas_init(); 70 | dis_init(CONFIG_SOC, "Manufacturer"); 71 | 72 | err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0); 73 | if (err) { 74 | printk("Advertising failed to start (err %d)\n", err); 75 | return; 76 | } 77 | 78 | printk("Advertising successfully started\n"); 79 | } 80 | 81 | static void auth_cancel(struct bt_conn *conn) 82 | { 83 | char addr[BT_ADDR_LE_STR_LEN]; 84 | 85 | bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); 86 | 87 | printk("Pairing cancelled: %s\n", addr); 88 | } 89 | 90 | static struct bt_conn_auth_cb auth_cb_display = { 91 | .cancel = auth_cancel, 92 | }; 93 | 94 | void main(void) 95 | { 96 | int err; 97 | 98 | err = bt_enable(bt_ready); 99 | if (err) { 100 | printk("Bluetooth init failed (err %d)\n", err); 101 | return; 102 | } 103 | 104 | bt_conn_cb_register(&conn_callbacks); 105 | bt_conn_auth_cb_register(&auth_cb_display); 106 | 107 | /* Implement notification. At the moment there is no suitable way 108 | * of starting delayed work so we do it here 109 | */ 110 | while (1) { 111 | k_sleep(MSEC_PER_SEC); 112 | 113 | /* Heartrate measurements simulation */ 114 | hrs_notify(); 115 | 116 | /* Battery level simulation */ 117 | bas_notify(); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /examples/zephyr/button/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 3 | project(NONE) 4 | 5 | target_sources(app PRIVATE src/main.c) 6 | -------------------------------------------------------------------------------- /examples/zephyr/button/README.rst: -------------------------------------------------------------------------------- 1 | .. _button-sample: 2 | 3 | Button demo 4 | ########### 5 | 6 | Overview 7 | ******** 8 | 9 | A simple button demo showcasing the use of GPIO input with interrupts. 10 | 11 | Requirements 12 | ************ 13 | 14 | The demo assumes that a push button is connected to one of GPIO lines. The 15 | sample code is configured to work on boards with user defined buttons and that 16 | have defined the SW0_* variable in board.h 17 | 18 | To use this sample, you will require a board that defines the user switch in its 19 | header file. The :file:`board.h` must define the following variables: 20 | 21 | - SW0_GPIO_NAME (or SW0_GPIO_CONTROLLER) 22 | - SW0_GPIO_PIN 23 | 24 | The following boards currently define the above variables: 25 | 26 | - bbc_microbit 27 | - cc3220sf_launchxl 28 | - frdm_k64f 29 | - nrf51_pca10028 30 | - nrf52840_pca10056 31 | - nrf52_pca10040 32 | - nucleo_f103rb 33 | - :ref:`quark_d2000_devboard` 34 | - quark_se_c1000_devboard 35 | - quark_se_c1000_ss_devboard 36 | 37 | 38 | Building and Running 39 | ******************** 40 | 41 | This sample can be built for multiple boards, in this example we will build it 42 | for the nucleo_f103rb board: 43 | 44 | .. zephyr-app-commands:: 45 | :zephyr-app: samples/basic/button 46 | :board: nucleo_f103rb 47 | :goals: build 48 | :compact: 49 | 50 | After startup, the program looks up a predefined GPIO device, and configures the 51 | pin in input mode, enabling interrupt generation on falling edge. During each 52 | iteration of the main loop, the state of GPIO line is monitored and printed to 53 | the serial console. When the input button gets pressed, the interrupt handler 54 | will print an information about this event along with its timestamp. 55 | -------------------------------------------------------------------------------- /examples/zephyr/button/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_GPIO=y 2 | -------------------------------------------------------------------------------- /examples/zephyr/button/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | name: Button Sample 3 | tests: 4 | test: 5 | platform_whitelist: nucleo_f103rb quark_se_c1000_devboard 6 | tags: button gpio 7 | depends_on: gpio 8 | -------------------------------------------------------------------------------- /examples/zephyr/button/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Open-RnD Sp. z o.o. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | /* change this to use another GPIO port */ 15 | #ifndef SW0_GPIO_CONTROLLER 16 | #ifdef SW0_GPIO_NAME 17 | #define SW0_GPIO_CONTROLLER SW0_GPIO_NAME 18 | #else 19 | #error SW0_GPIO_NAME or SW0_GPIO_CONTROLLER needs to be set in board.h 20 | #endif 21 | #endif 22 | #define PORT SW0_GPIO_CONTROLLER 23 | 24 | /* change this to use another GPIO pin */ 25 | #ifdef SW0_GPIO_PIN 26 | #define PIN SW0_GPIO_PIN 27 | #else 28 | #error SW0_GPIO_PIN needs to be set in board.h 29 | #endif 30 | 31 | /* change to use another GPIO pin interrupt config */ 32 | #ifdef SW0_GPIO_FLAGS 33 | #define EDGE (SW0_GPIO_FLAGS | GPIO_INT_EDGE) 34 | #else 35 | /* 36 | * If SW0_GPIO_FLAGS not defined used default EDGE value. 37 | * Change this to use a different interrupt trigger 38 | */ 39 | #define EDGE (GPIO_INT_EDGE | GPIO_INT_ACTIVE_LOW) 40 | #endif 41 | 42 | /* change this to enable pull-up/pull-down */ 43 | #ifndef SW0_GPIO_FLAGS 44 | #ifdef SW0_GPIO_PIN_PUD 45 | #define SW0_GPIO_FLAGS SW0_GPIO_PIN_PUD 46 | #else 47 | #define SW0_GPIO_FLAGS 0 48 | #endif 49 | #endif 50 | #define PULL_UP SW0_GPIO_FLAGS 51 | 52 | /* Sleep time */ 53 | #define SLEEP_TIME 500 54 | 55 | 56 | void button_pressed(struct device *gpiob, struct gpio_callback *cb, 57 | u32_t pins) 58 | { 59 | printk("Button pressed at %d\n", k_cycle_get_32()); 60 | } 61 | 62 | static struct gpio_callback gpio_cb; 63 | 64 | void main(void) 65 | { 66 | struct device *gpiob; 67 | 68 | printk("Press the user defined button on the board\n"); 69 | gpiob = device_get_binding(PORT); 70 | if (!gpiob) { 71 | printk("error\n"); 72 | return; 73 | } 74 | 75 | gpio_pin_configure(gpiob, PIN, 76 | GPIO_DIR_IN | GPIO_INT | PULL_UP | EDGE); 77 | 78 | gpio_init_callback(&gpio_cb, button_pressed, BIT(PIN)); 79 | 80 | gpio_add_callback(gpiob, &gpio_cb); 81 | gpio_pin_enable_callback(gpiob, PIN); 82 | 83 | while (1) { 84 | u32_t val = 0; 85 | 86 | gpio_pin_read(gpiob, PIN, &val); 87 | k_sleep(SLEEP_TIME); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /examples/zephyr/fade_led/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 3 | project(NONE) 4 | 5 | target_sources(app PRIVATE src/main.c) 6 | -------------------------------------------------------------------------------- /examples/zephyr/fade_led/README.rst: -------------------------------------------------------------------------------- 1 | .. _fade-led-sample: 2 | 3 | PWM: Fade LED 4 | ############# 5 | 6 | Overview 7 | ******** 8 | 9 | This is a sample app which fades a LED using PWM. 10 | 11 | The LED will start from dark and increases its 12 | brightness gradually for 10 seconds. Then, the 13 | brightness reduces gradually for 10 seconds and 14 | finally the LED becomes dark again. The LED will 15 | repeat this cycle for ever. 16 | 17 | Wiring 18 | ****** 19 | 20 | Arduino 101 and Quark D2000 CRB 21 | =============================== 22 | You will need to connect the LED to ground and PWM0 via 23 | the shield. You may need a current limiting resistor. See 24 | your LED datasheet. 25 | 26 | Nucleo_F401RE and Nucleo_L476RG 27 | =============================== 28 | Connect PWM2(PA0) to LED 29 | 30 | Nucleo_F103RB 31 | ============= 32 | Connect PWM1(PA8) to LED 33 | 34 | Hexiwear K64 35 | ============ 36 | No special board setup is necessary because there is an on-board RGB LED 37 | connected to the K64 PWM. 38 | 39 | Building and Running 40 | ******************** 41 | 42 | This sample can be built for multiple boards, in this example we will build it 43 | for the arduino_101 board: 44 | 45 | .. zephyr-app-commands:: 46 | :zephyr-app: samples/basic/fade_led 47 | :board: arduino_101 48 | :goals: build flash 49 | :compact: 50 | -------------------------------------------------------------------------------- /examples/zephyr/fade_led/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_PRINTK=y 2 | CONFIG_PWM=y 3 | CONFIG_LOG=y 4 | CONFIG_PWM_LOG_LEVEL_DBG=y 5 | -------------------------------------------------------------------------------- /examples/zephyr/fade_led/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | name: Fade LED 3 | tests: 4 | test: 5 | # FIXME: We should remove those and just rely on depends_on 6 | platform_whitelist: arduino_101 quark_d2000_crb 7 | nucleo_f103rb nucleo_f401re nucleo_l476rg hexiwear_k64 8 | tags: drivers pwm 9 | depends_on: pwm 10 | -------------------------------------------------------------------------------- /examples/zephyr/fade_led/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /** 8 | * @file Sample app to demonstrate PWM. 9 | * 10 | * This app uses PWM[0]. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #if defined(CONFIG_SOC_STM32F401XE) || defined(CONFIG_SOC_STM32L476XG) 20 | #define PWM_DRIVER CONFIG_PWM_STM32_2_DEV_NAME 21 | #define PWM_CHANNEL 1 22 | #elif CONFIG_SOC_STM32F103XB 23 | #define PWM_DRIVER CONFIG_PWM_STM32_1_DEV_NAME 24 | #define PWM_CHANNEL 1 25 | #elif defined(CONFIG_SOC_QUARK_SE_C1000) || defined(CONFIG_SOC_QUARK_D2000) 26 | #define PWM_DRIVER CONFIG_PWM_QMSI_DEV_NAME 27 | #define PWM_CHANNEL 0 28 | #elif defined(CONFIG_SOC_FAMILY_NRF) 29 | #include 30 | #define PWM_DRIVER CONFIG_PWM_NRF5_SW_0_DEV_NAME 31 | #define PWM_CHANNEL LED0_GPIO_PIN 32 | #elif defined(CONFIG_BOARD_HEXIWEAR_K64) 33 | #define PWM_DRIVER GREEN_PWM_NAME 34 | #define PWM_CHANNEL GREEN_PWM_CHANNEL 35 | #elif defined(CONFIG_SOC_ESP32) 36 | #define PWM_DRIVER CONFIG_PWM_LED_ESP32_DEV_NAME_0 37 | #define PWM_CHANNEL 21 38 | #else 39 | #error "Choose supported PWM driver" 40 | #endif 41 | 42 | /* 43 | * 50 is flicker fusion threshold. Modulated light will be perceived 44 | * as steady by our eyes when blinking rate is at least 50. 45 | */ 46 | #define PERIOD (USEC_PER_SEC / 50) 47 | 48 | /* in micro second */ 49 | #define FADESTEP 2000 50 | 51 | void main(void) 52 | { 53 | struct device *pwm_dev; 54 | u32_t pulse_width = 0; 55 | u8_t dir = 0; 56 | 57 | printk("PWM demo app-fade LED\n"); 58 | 59 | pwm_dev = device_get_binding(PWM_DRIVER); 60 | if (!pwm_dev) { 61 | printk("Cannot find %s!\n", PWM_DRIVER); 62 | return; 63 | } 64 | 65 | while (1) { 66 | if (pwm_pin_set_usec(pwm_dev, PWM_CHANNEL, 67 | PERIOD, pulse_width)) { 68 | printk("pwm pin set fails\n"); 69 | return; 70 | } 71 | 72 | if (dir) { 73 | if (pulse_width < FADESTEP) { 74 | dir = 0; 75 | pulse_width = 0; 76 | } else { 77 | pulse_width -= FADESTEP; 78 | } 79 | } else { 80 | pulse_width += FADESTEP; 81 | 82 | if (pulse_width >= PERIOD) { 83 | dir = 1; 84 | pulse_width = PERIOD; 85 | } 86 | } 87 | 88 | k_sleep(MSEC_PER_SEC); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /examples/zephyr/hello_world/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 4 | project(NONE) 5 | 6 | target_sources(app PRIVATE src/main.c) 7 | -------------------------------------------------------------------------------- /examples/zephyr/hello_world/README.rst: -------------------------------------------------------------------------------- 1 | .. _hello_world: 2 | 3 | Hello World 4 | ########### 5 | 6 | Overview 7 | ******** 8 | A simple Hello World example that can be used with any supported board and 9 | prints 'Hello World' to the console. This application can be built into modes: 10 | 11 | * single thread 12 | * multi threading 13 | 14 | Building and Running 15 | ******************** 16 | 17 | This project outputs 'Hello World' to the console. It can be built and executed 18 | on QEMU as follows: 19 | 20 | .. zephyr-app-commands:: 21 | :zephyr-app: samples/hello_world 22 | :host-os: unix 23 | :board: qemu_x86 24 | :goals: run 25 | :compact: 26 | 27 | To build the single thread version, use the supplied configuration file for 28 | single thread: :file:`prj_single.conf`: 29 | 30 | .. zephyr-app-commands:: 31 | :zephyr-app: samples/hello_world 32 | :host-os: unix 33 | :board: qemu_x86 34 | :conf: prj_single.conf 35 | :goals: run 36 | :compact: 37 | 38 | Sample Output 39 | ============= 40 | 41 | .. code-block:: console 42 | 43 | Hello World! x86 44 | -------------------------------------------------------------------------------- /examples/zephyr/hello_world/prj.conf: -------------------------------------------------------------------------------- 1 | # nothing here 2 | -------------------------------------------------------------------------------- /examples/zephyr/hello_world/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | description: Hello World sample, the simplest Zephyr 3 | application 4 | name: hello world 5 | platforms: all 6 | common: 7 | tags: introduction 8 | harness: console 9 | harness_config: 10 | type: one_line 11 | regex: 12 | - "Hello World! (.*)" 13 | tests: 14 | sample.helloworld: 15 | tags: introduction 16 | -------------------------------------------------------------------------------- /examples/zephyr/hello_world/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014 Wind River Systems, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | void main(void) 11 | { 12 | printk("Hello World! %s\n", CONFIG_BOARD); 13 | } 14 | -------------------------------------------------------------------------------- /examples/zephyr/threads/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) 3 | project(NONE) 4 | 5 | target_sources(app PRIVATE src/main.c) 6 | -------------------------------------------------------------------------------- /examples/zephyr/threads/README.rst: -------------------------------------------------------------------------------- 1 | .. _96b_carbon_multi_thread_blinky: 2 | 3 | Basic Thread Example 4 | #################### 5 | 6 | Overview 7 | ******** 8 | 9 | This example demonstrates spawning of multiple threads using K_THREAD_DEFINE. 10 | 11 | The example works by spawning three threads. The first two threads control a 12 | separate LED. Both of these LEDs (USR1 and USR2) have their individual loop 13 | control and timing logic defined by separate functions. 14 | 15 | After either thread toggles its LED, it also pushes information into a 16 | FIFO identifying which thread toggled its LED and how many times it 17 | was done. 18 | 19 | The third thread, ``uart_out()``, uses printk (over the UART) to 20 | display the information that comes through the FIFO. 21 | 22 | - blink1() controls the USR1 LED that has a 100ms sleep cycle 23 | - blink2() controls the USR2 LED that has a 1000ms sleep cycle 24 | 25 | Each thread is then defined at compile time using K_THREAD_DEFINE. 26 | 27 | Building 28 | ******** 29 | 30 | .. zephyr-app-commands:: 31 | :zephyr-app: samples/basic/threads 32 | :board: 96b_carbon 33 | :goals: build flash 34 | :compact: 35 | -------------------------------------------------------------------------------- /examples/zephyr/threads/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_PRINTK=y 2 | CONFIG_HEAP_MEM_POOL_SIZE=256 3 | CONFIG_ASSERT=y 4 | -------------------------------------------------------------------------------- /examples/zephyr/threads/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | description: A basic demo to showcase multi-threading 3 | using K_THREAD_DEFINE 4 | name: Basic Thread Demo 5 | tests: 6 | test: 7 | platform_whitelist: 96b_carbon 8 | tags: kernel threads gpio 9 | depends_on: gpio 10 | -------------------------------------------------------------------------------- /examples/zephyr/threads/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Linaro Limited 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | /* size of stack area used by each thread */ 16 | #define STACKSIZE 1024 17 | 18 | /* scheduling priority used by each thread */ 19 | #define PRIORITY 7 20 | 21 | /* Change this if you have an LED connected to a custom port */ 22 | #ifndef LED0_GPIO_CONTROLLER 23 | #define LED0_GPIO_CONTROLLER LED0_GPIO_PORT 24 | #endif 25 | #ifndef LED1_GPIO_CONTROLLER 26 | #define LED1_GPIO_CONTROLLER LED1_GPIO_PORT 27 | #endif 28 | 29 | #define PORT0 LED0_GPIO_CONTROLLER 30 | #define PORT1 LED1_GPIO_CONTROLLER 31 | 32 | 33 | /* Change this if you have an LED connected to a custom pin */ 34 | #define LED0 LED0_GPIO_PIN 35 | #define LED1 LED1_GPIO_PIN 36 | 37 | struct printk_data_t { 38 | void *fifo_reserved; /* 1st word reserved for use by fifo */ 39 | u32_t led; 40 | u32_t cnt; 41 | }; 42 | 43 | K_FIFO_DEFINE(printk_fifo); 44 | 45 | void blink(const char *port, u32_t sleep_ms, u32_t led, u32_t id) 46 | { 47 | int cnt = 0; 48 | struct device *gpio_dev; 49 | 50 | gpio_dev = device_get_binding(port); 51 | __ASSERT_NO_MSG(gpio_dev != NULL); 52 | 53 | gpio_pin_configure(gpio_dev, led, GPIO_DIR_OUT); 54 | 55 | while (1) { 56 | gpio_pin_write(gpio_dev, led, cnt % 2); 57 | 58 | struct printk_data_t tx_data = { .led = id, .cnt = cnt }; 59 | 60 | size_t size = sizeof(struct printk_data_t); 61 | char *mem_ptr = k_malloc(size); 62 | __ASSERT_NO_MSG(mem_ptr != 0); 63 | 64 | memcpy(mem_ptr, &tx_data, size); 65 | 66 | k_fifo_put(&printk_fifo, mem_ptr); 67 | 68 | k_sleep(sleep_ms); 69 | cnt++; 70 | } 71 | } 72 | 73 | void blink1(void) 74 | { 75 | blink(PORT0, 100, LED0, 0); 76 | } 77 | 78 | void blink2(void) 79 | { 80 | blink(PORT1, 1000, LED1, 1); 81 | } 82 | 83 | void uart_out(void) 84 | { 85 | while (1) { 86 | struct printk_data_t *rx_data = k_fifo_get(&printk_fifo, K_FOREVER); 87 | printk("Toggle USR%d LED: Counter = %d\n", rx_data->led, rx_data->cnt); 88 | k_free(rx_data); 89 | } 90 | } 91 | 92 | K_THREAD_DEFINE(blink1_id, STACKSIZE, blink1, NULL, NULL, NULL, 93 | PRIORITY, 0, K_NO_WAIT); 94 | K_THREAD_DEFINE(blink2_id, STACKSIZE, blink2, NULL, NULL, NULL, 95 | PRIORITY, 0, K_NO_WAIT); 96 | K_THREAD_DEFINE(uart_out_id, STACKSIZE, uart_out, NULL, NULL, NULL, 97 | PRIORITY, 0, K_NO_WAIT); 98 | -------------------------------------------------------------------------------- /firmware/daplink/README.md: -------------------------------------------------------------------------------- 1 | ## How to Update DAPLINK Firmware 2 | 3 | To update the firmware on a device hold the reset button while attaching USB. The device will boot into bootloader mode. From there remove `firmware.bin` and then copy `lpc11u35_nrf52832_mdk_if_crc_xxxx.bin` onto the drive. Reconnect the board, if successful the device will leave bootloader mode and start running the new firmware. -------------------------------------------------------------------------------- /firmware/daplink/lpc11u35_nrf52832_mdk_if_crc_0244.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/firmware/daplink/lpc11u35_nrf52832_mdk_if_crc_0244.bin -------------------------------------------------------------------------------- /firmware/daplink/lpc11u35_nrf52832_mdk_if_crc_0245.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/firmware/daplink/lpc11u35_nrf52832_mdk_if_crc_0245.bin -------------------------------------------------------------------------------- /firmware/daplink/lpc11u35_nrf52832_mdk_if_crc_0251.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/firmware/daplink/lpc11u35_nrf52832_mdk_if_crc_0251.bin -------------------------------------------------------------------------------- /firmware/daplink/lpc11u35_nrf52832_mdk_if_crc_0253.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/firmware/daplink/lpc11u35_nrf52832_mdk_if_crc_0253.bin -------------------------------------------------------------------------------- /firmware/espruino/espruino_1v96.3727_nrf52832_mdk.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/firmware/espruino/espruino_1v96.3727_nrf52832_mdk.zip -------------------------------------------------------------------------------- /nrf_sdks/README.md: -------------------------------------------------------------------------------- 1 | ## Installing the nRF5 SDK 2 | 3 | Download the SDK package from [www.nordicsemi.com](https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK/). 4 | 5 | The latest version is `15.2.0`, it can be downloaded directly here: [nRF5_SDK_v15.2.0_9412b96](https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK/Download#infotabs) 6 | 7 | Extract the zip file into this directory. This should give you the following folder structure: 8 | 9 | ``` sh 10 | ./nrf52832-mdk/ 11 | ├── LICENSE 12 | ├── README.md 13 | ├── firmware 14 | ├── config 15 | ├── docs 16 | ├── examples 17 | ├── mkdocs.yml 18 | ├── nrf_sdks 19 | │   └── nRF5_SDK_v15.2.0_9412b96 20 | └── tools 21 | ``` 22 | 23 | Config the toolchain path in `makefile.windows` or `makefile.posix` depending on platform you are using. That is, the `.posix` should be edited if your are working on either Linux or macOS. These files are located in: 24 | 25 | ``` sh 26 | /components/toolchain/gcc 27 | ``` 28 | 29 | Open the file in a text editor and make sure that the `GNU_INSTALL_ROOT` variable is pointing to your GNU Arm Embedded Toolchain install directory. For example: 30 | 31 | ``` sh 32 | GNU_INSTALL_ROOT ?= $(HOME)/gcc-arm-none-eabi/gcc-arm-none-eabi-6-2017-q2-update/bin/ 33 | GNU_VERSION ?= 6.3.1 34 | GNU_PREFIX ?= arm-none-eabi 35 | ``` 36 | -------------------------------------------------------------------------------- /tools/cmsisconfig/CMSIS_Configuration_Wizard.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/tools/cmsisconfig/CMSIS_Configuration_Wizard.jar -------------------------------------------------------------------------------- /tools/cmsisconfig/README.TXT: -------------------------------------------------------------------------------- 1 | CMSIS Configuration Wizard v0.0.7 2 | 3 | http://helmpcb.com/software/cmsis-configuration-wizard 4 | https://sourceforge.net/projects/cmsisconfig/ 5 | 6 | The CMSIS Configuration Wizard allows users to easily configure ARM source files without using the Keil uVision IDE. The wizard parses the source file and generates a GUI, allowing the various parameters to be edited. 7 | 8 | Changelog: 9 | 10 | v0.0.7 (2017/08/11) 11 | - Added the ability to load a file directly from the command line. Simply pass the full file name as the first paramter to the program (e.g. java -jar CMSIS_Configuration_Wizard.jar /path/to/file). 12 | 13 | v0.0.6 (2012/04/20) 14 | - Fixed a bug where the program would throw an exception if a numeric option was outside of its range. The value is now automatically clamped to either the maximum or the minimum. 15 | 16 | v0.0.5 (2012/04/20) 17 | - Added support for assembler files. 18 | 19 | v0.0.4 (2012/04/20) 20 | - Modifed the filter in the file dialogs to allow both C source and header files. 21 | 22 | v0.0.3 (2012/04/20) 23 | - Modified the code for selection modifiers (e.g. ) so that they can accept both decimal and hexadecimal figures. 24 | 25 | v0.0.2 (2012/04/07) 26 | - Initial release. -------------------------------------------------------------------------------- /tools/mergehex/Linux-i386/mergehex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/tools/mergehex/Linux-i386/mergehex -------------------------------------------------------------------------------- /tools/mergehex/Linux-i386/mergehex.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | */ 11 | 12 | #ifndef MERGEHEX_H 13 | #define MERGEHEX_H 14 | 15 | //@TODO: Have the build system update this. 16 | #define major_version (9) 17 | #define minor_version (3) 18 | #define micro_version (1) 19 | 20 | enum MergehexErrorCodesType { 21 | 22 | Success = 0, // Requested operation (operations) were successfully completed. 23 | 24 | /* mergehex.exe or PC errors */ 25 | MergehexError = 1, // An error condition that should not occur has happened. 26 | // It is most probably a bug in mergehex.exe. 27 | MemoryAllocationError = 3, // Memory allocation for mergehex failed. 28 | 29 | /* Command line input errors */ 30 | InvalidArgumentError = 11, // Invalid arguments passed to the application. 31 | InsufficientArgumentsError = 12, // Needed arguments not passed to the application. 32 | IncompatibleArgumentsError = 13, // Incompatible arguments passed to the application. 33 | DuplicatedArgumentsError = 14, // The same argument has been provided twice. 34 | NoOperationError = 15, // The arguments passed do not perform a valid operation. 35 | 36 | /* General errors */ 37 | FileNotFoundError = 51, // Unable to find the given file. 38 | InvalidHexFileError = 52, // File specified does not seem a valid hex file. 39 | NoWritePermissionError = 56, // megehex application has no write permission in the given path. 40 | ConflictError = 60, // There is a conflict in the hex files to merge. 41 | }; 42 | 43 | 44 | 45 | #endif //MERGEHEX_H -------------------------------------------------------------------------------- /tools/mergehex/Linux-i386/mergehex_release_notes.txt: -------------------------------------------------------------------------------- 1 | Release 9.3.1 2 | Changelog 3 | --------------------------------------- 4 | - No changes, updated to synchronize with nRFTools. 5 | 6 | Release 9.2.1 7 | Changelog 8 | --------------------------------------- 9 | - No changes, updated to synchronize with nRFTools. 10 | 11 | Release 9.2.0 12 | Changelog 13 | --------------------------------------- 14 | - No changes, updated to synchronize with nRFTools. 15 | 16 | Release 9.1.0 17 | Changelog 18 | --------------------------------------- 19 | - No changes, updated to synchronize with nRFTools. 20 | 21 | Release 9.0.0 22 | Changelog 23 | --------------------------------------- 24 | - No changes, updated to synchronize with nRFTools. 25 | 26 | Release 8.5.0 27 | Changelog 28 | --------------------------------------- 29 | - No changes, updated to synchronize with nRFTools. 30 | 31 | Release 8.4.0 32 | Changelog 33 | --------------------------------------- 34 | - No changes, updated to synchronize with nRFTools. 35 | 36 | Release 8.3.0 37 | Changelog 38 | --------------------------------------- 39 | - No changes, updated to synchronize with nRFTools. 40 | 41 | Release 8.2.0 42 | Changelog 43 | --------------------------------------- 44 | - OSX support. 45 | 46 | Release 8.1.0 47 | Changelog 48 | --------------------------------------- 49 | - No changes, updated to synchronize with nRFTools. 50 | 51 | Release 8.0.0 52 | Changelog 53 | --------------------------------------- 54 | - Linux support. 55 | 56 | Release 7.6.0 57 | Changelog 58 | --------------------------------------- 59 | - Updated the help. 60 | 61 | Release 7.5.2 62 | Changelog 63 | --------------------------------------- 64 | - No changes, updated to synchronize with nRFTools 65 | 66 | Release 7.5.1 67 | Changelog 68 | --------------------------------------- 69 | - No changes, updated to synchronize with nRFTools 70 | 71 | Release 7.5.0 72 | Changelog 73 | --------------------------------------- 74 | - Added the possibility of a third hex file to merge in the same command. 75 | 76 | Release 7.2.0 77 | Changelog 78 | --------------------------------------- 79 | - Adapted mergehex to nRF52 devices. 80 | - Solved some bugs in parsing of the arguments. 81 | 82 | Release 1.1.4 83 | Changelog 84 | --------------------------------------- 85 | - Modified a library. No change in functionality. 86 | 87 | Release 1.1.3 88 | Changelog 89 | --------------------------------------- 90 | - Modified a library. No change in functionality. 91 | 92 | Release 1.1.2 93 | Changelog 94 | --------------------------------------- 95 | - Modified a library. No change in functionality. 96 | 97 | Release 1.1.1 98 | Changelog 99 | --------------------------------------- 100 | - Corrected a minor typo in the help. 101 | 102 | Release 1.1.0 103 | Changelog 104 | --------------------------------------- 105 | - Cleaned up general structure, and use the facilities existing developed for nrfjprog. 106 | It should now be faster to merge two files. 107 | 108 | Release 1.0.0 109 | Changelog 110 | --------------------------------------- 111 | - First version of Mergehex.exe 112 | 113 | -------------------------------------------------------------------------------- /tools/mergehex/OSX/mergehex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdiary/nrf52832-mdk/c95b00e7dd578424a9cee56a2ac61fc929598ed1/tools/mergehex/OSX/mergehex -------------------------------------------------------------------------------- /tools/mergehex/OSX/mergehex.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | */ 11 | 12 | #ifndef MERGEHEX_H 13 | #define MERGEHEX_H 14 | 15 | //@TODO: Have the build system update this. 16 | #define major_version (9) 17 | #define minor_version (3) 18 | #define micro_version (1) 19 | 20 | enum MergehexErrorCodesType { 21 | 22 | Success = 0, // Requested operation (operations) were successfully completed. 23 | 24 | /* mergehex.exe or PC errors */ 25 | MergehexError = 1, // An error condition that should not occur has happened. 26 | // It is most probably a bug in mergehex.exe. 27 | MemoryAllocationError = 3, // Memory allocation for mergehex failed. 28 | 29 | /* Command line input errors */ 30 | InvalidArgumentError = 11, // Invalid arguments passed to the application. 31 | InsufficientArgumentsError = 12, // Needed arguments not passed to the application. 32 | IncompatibleArgumentsError = 13, // Incompatible arguments passed to the application. 33 | DuplicatedArgumentsError = 14, // The same argument has been provided twice. 34 | NoOperationError = 15, // The arguments passed do not perform a valid operation. 35 | 36 | /* General errors */ 37 | FileNotFoundError = 51, // Unable to find the given file. 38 | InvalidHexFileError = 52, // File specified does not seem a valid hex file. 39 | NoWritePermissionError = 56, // megehex application has no write permission in the given path. 40 | ConflictError = 60, // There is a conflict in the hex files to merge. 41 | }; 42 | 43 | 44 | 45 | #endif //MERGEHEX_H -------------------------------------------------------------------------------- /tools/mergehex/OSX/mergehex_release_notes.txt: -------------------------------------------------------------------------------- 1 | Release 9.3.1 2 | Changelog 3 | --------------------------------------- 4 | - No changes, updated to synchronize with nRFTools. 5 | 6 | Release 9.2.1 7 | Changelog 8 | --------------------------------------- 9 | - No changes, updated to synchronize with nRFTools. 10 | 11 | Release 9.2.0 12 | Changelog 13 | --------------------------------------- 14 | - No changes, updated to synchronize with nRFTools. 15 | 16 | Release 9.1.0 17 | Changelog 18 | --------------------------------------- 19 | - No changes, updated to synchronize with nRFTools. 20 | 21 | Release 9.0.0 22 | Changelog 23 | --------------------------------------- 24 | - No changes, updated to synchronize with nRFTools. 25 | 26 | Release 8.5.0 27 | Changelog 28 | --------------------------------------- 29 | - No changes, updated to synchronize with nRFTools. 30 | 31 | Release 8.4.0 32 | Changelog 33 | --------------------------------------- 34 | - No changes, updated to synchronize with nRFTools. 35 | 36 | Release 8.3.0 37 | Changelog 38 | --------------------------------------- 39 | - No changes, updated to synchronize with nRFTools. 40 | 41 | Release 8.2.0 42 | Changelog 43 | --------------------------------------- 44 | - OSX support. 45 | 46 | Release 8.1.0 47 | Changelog 48 | --------------------------------------- 49 | - No changes, updated to synchronize with nRFTools. 50 | 51 | Release 8.0.0 52 | Changelog 53 | --------------------------------------- 54 | - Linux support. 55 | 56 | Release 7.6.0 57 | Changelog 58 | --------------------------------------- 59 | - Updated the help. 60 | 61 | Release 7.5.2 62 | Changelog 63 | --------------------------------------- 64 | - No changes, updated to synchronize with nRFTools 65 | 66 | Release 7.5.1 67 | Changelog 68 | --------------------------------------- 69 | - No changes, updated to synchronize with nRFTools 70 | 71 | Release 7.5.0 72 | Changelog 73 | --------------------------------------- 74 | - Added the possibility of a third hex file to merge in the same command. 75 | 76 | Release 7.2.0 77 | Changelog 78 | --------------------------------------- 79 | - Adapted mergehex to nRF52 devices. 80 | - Solved some bugs in parsing of the arguments. 81 | 82 | Release 1.1.4 83 | Changelog 84 | --------------------------------------- 85 | - Modified a library. No change in functionality. 86 | 87 | Release 1.1.3 88 | Changelog 89 | --------------------------------------- 90 | - Modified a library. No change in functionality. 91 | 92 | Release 1.1.2 93 | Changelog 94 | --------------------------------------- 95 | - Modified a library. No change in functionality. 96 | 97 | Release 1.1.1 98 | Changelog 99 | --------------------------------------- 100 | - Corrected a minor typo in the help. 101 | 102 | Release 1.1.0 103 | Changelog 104 | --------------------------------------- 105 | - Cleaned up general structure, and use the facilities existing developed for nrfjprog. 106 | It should now be faster to merge two files. 107 | 108 | Release 1.0.0 109 | Changelog 110 | --------------------------------------- 111 | - First version of Mergehex.exe 112 | 113 | --------------------------------------------------------------------------------