├── .gitignore ├── LICENSE ├── README.md ├── bin ├── S132 │ └── S132_201.bin └── feather52832 │ ├── 0.5.0 │ ├── dual │ │ ├── feather52_bootloader_v050_s132_v201_dual.hex │ │ └── feather52_bootloader_v050_s132_v201_dual.zip │ └── single │ │ ├── feather52_bootloader_v050_s132_v201_single.hex │ │ └── feather52_bootloader_v050_s132_v201_single.zip │ ├── 5.1.0 │ ├── dual │ │ ├── feather52_bootloader_5.1.0_s132_dual.bin │ │ ├── feather52_bootloader_5.1.0_s132_dual.hex │ │ └── feather52_bootloader_5.1.0_s132_dual.zip │ └── single │ │ ├── feather52_bootloader_5.1.0_s132_single.bin │ │ ├── feather52_bootloader_5.1.0_s132_single.hex │ │ └── feather52_bootloader_5.1.0_s132_single.zip │ └── 6.0.0 │ ├── feather52832_bootloader_6.0.0_s132.bin │ ├── feather52832_bootloader_6.0.0_s132.hex │ └── feather52832_bootloader_6.0.0_s132.zip ├── layout ├── Feather52 S132 v2.x.x Dual Layout.jpg ├── Feather52 S132 v5.x.x Dual Layout.jpg └── Feather52 S132 v5.x.x Single Layout.jpg ├── lib ├── sdk11 │ ├── components │ │ ├── ble │ │ │ ├── ble_services │ │ │ │ ├── ble_dfu │ │ │ │ │ ├── ble_dfu.c │ │ │ │ │ └── ble_dfu.h │ │ │ │ └── ble_dis │ │ │ │ │ ├── ble_dis.c │ │ │ │ │ └── ble_dis.h │ │ │ └── common │ │ │ │ ├── ble_srv_common.c │ │ │ │ └── ble_srv_common.h │ │ ├── device │ │ │ ├── compiler_abstraction.h │ │ │ ├── nrf.h │ │ │ ├── nrf51_to_nrf52.h │ │ │ ├── nrf52.h │ │ │ ├── nrf52_bitfields.h │ │ │ └── nrf52_name_change.h │ │ ├── drivers_nrf │ │ │ ├── common │ │ │ │ ├── nrf_drv_common.c │ │ │ │ └── nrf_drv_common.h │ │ │ ├── config │ │ │ │ ├── nrf_drv_config.h │ │ │ │ └── nrf_drv_config_validation.h │ │ │ ├── delay │ │ │ │ ├── nrf_delay.c │ │ │ │ └── nrf_delay.h │ │ │ ├── hal │ │ │ │ ├── nrf_adc.c │ │ │ │ ├── nrf_adc.h │ │ │ │ ├── nrf_clock.h │ │ │ │ ├── nrf_comp.h │ │ │ │ ├── nrf_ecb.c │ │ │ │ ├── nrf_ecb.h │ │ │ │ ├── nrf_egu.h │ │ │ │ ├── nrf_gpio.h │ │ │ │ ├── nrf_gpiote.h │ │ │ │ ├── nrf_i2s.h │ │ │ │ ├── nrf_lpcomp.h │ │ │ │ ├── nrf_nvmc.c │ │ │ │ ├── nrf_nvmc.h │ │ │ │ ├── nrf_pdm.h │ │ │ │ ├── nrf_ppi.h │ │ │ │ ├── nrf_pwm.h │ │ │ │ ├── nrf_qdec.h │ │ │ │ ├── nrf_rng.h │ │ │ │ ├── nrf_rtc.h │ │ │ │ ├── nrf_saadc.c │ │ │ │ ├── nrf_saadc.h │ │ │ │ ├── nrf_spi.h │ │ │ │ ├── nrf_spim.h │ │ │ │ ├── nrf_spis.h │ │ │ │ ├── nrf_temp.h │ │ │ │ ├── nrf_timer.h │ │ │ │ ├── nrf_twi.h │ │ │ │ ├── nrf_twim.h │ │ │ │ ├── nrf_twis.h │ │ │ │ ├── nrf_uart.h │ │ │ │ ├── nrf_uarte.h │ │ │ │ └── nrf_wdt.h │ │ │ ├── pstorage │ │ │ │ ├── pstorage.h │ │ │ │ └── pstorage_raw.c │ │ │ └── uart │ │ │ │ ├── nrf_drv_uart.c │ │ │ │ └── nrf_drv_uart.h │ │ ├── libraries │ │ │ ├── bootloader_dfu │ │ │ │ ├── ble_transport │ │ │ │ │ └── hci_mem_pool_internal.h │ │ │ │ ├── bootloader.c │ │ │ │ ├── bootloader.h │ │ │ │ ├── bootloader_settings.c │ │ │ │ ├── bootloader_settings.h │ │ │ │ ├── bootloader_types.h │ │ │ │ ├── bootloader_util.c │ │ │ │ ├── bootloader_util.h │ │ │ │ ├── dfu.h │ │ │ │ ├── dfu_bank_internal.h │ │ │ │ ├── dfu_ble_svc.h │ │ │ │ ├── dfu_ble_svc_internal.h │ │ │ │ ├── dfu_dual_bank.c │ │ │ │ ├── dfu_init.h │ │ │ │ ├── dfu_init_template.c │ │ │ │ ├── dfu_single_bank.c │ │ │ │ ├── dfu_transport.h │ │ │ │ ├── dfu_transport_ble.c │ │ │ │ ├── dfu_transport_serial.c │ │ │ │ ├── dfu_types.h │ │ │ │ └── hci_transport │ │ │ │ │ ├── hci_mem_pool_internal.h │ │ │ │ │ └── hci_transport_config.h │ │ │ ├── crc16 │ │ │ │ ├── crc16.c │ │ │ │ └── crc16.h │ │ │ ├── fifo │ │ │ │ ├── app_fifo.c │ │ │ │ └── app_fifo.h │ │ │ ├── hci │ │ │ │ ├── hci_mem_pool.c │ │ │ │ ├── hci_mem_pool.h │ │ │ │ ├── hci_slip.c │ │ │ │ ├── hci_slip.h │ │ │ │ ├── hci_transport.c │ │ │ │ └── hci_transport.h │ │ │ ├── scheduler │ │ │ │ ├── app_scheduler.c │ │ │ │ └── app_scheduler.h │ │ │ ├── slip │ │ │ │ ├── slip.c │ │ │ │ └── slip.h │ │ │ ├── timer │ │ │ │ ├── app_timer.c │ │ │ │ ├── app_timer.h │ │ │ │ ├── app_timer_appsh.c │ │ │ │ └── app_timer_appsh.h │ │ │ ├── uart │ │ │ │ ├── app_uart.c │ │ │ │ └── app_uart.h │ │ │ └── util │ │ │ │ ├── app_error.c │ │ │ │ ├── app_error.h │ │ │ │ ├── app_error_weak.h │ │ │ │ ├── app_util.h │ │ │ │ ├── app_util_bds.h │ │ │ │ ├── app_util_platform.c │ │ │ │ ├── app_util_platform.h │ │ │ │ ├── common.h │ │ │ │ ├── nordic_common.h │ │ │ │ ├── nrf_assert.c │ │ │ │ ├── nrf_assert.h │ │ │ │ ├── nrf_log.h │ │ │ │ ├── sdk_common.h │ │ │ │ ├── sdk_errors.h │ │ │ │ ├── sdk_macros.h │ │ │ │ ├── sdk_os.h │ │ │ │ └── sdk_resources.h │ │ └── toolchain │ │ │ ├── cmsis │ │ │ └── include │ │ │ │ ├── arm_common_tables.h │ │ │ │ ├── arm_const_structs.h │ │ │ │ ├── arm_math.h │ │ │ │ ├── cmsis_armcc.h │ │ │ │ ├── cmsis_armcc_V6.h │ │ │ │ ├── cmsis_gcc.h │ │ │ │ ├── core_cm0.h │ │ │ │ ├── core_cm0plus.h │ │ │ │ ├── core_cm3.h │ │ │ │ ├── core_cm4.h │ │ │ │ ├── core_cm7.h │ │ │ │ ├── core_cmFunc.h │ │ │ │ ├── core_cmInstr.h │ │ │ │ └── core_cmSimd.h │ │ │ ├── gcc │ │ │ ├── gcc_startup_nrf52.S │ │ │ ├── nrf52_common.ld │ │ │ ├── nrf52_xxaa.ld │ │ │ └── nrf5x_common.ld │ │ │ ├── system_nrf52.c │ │ │ └── system_nrf52.h │ └── documentation │ │ ├── license.txt │ │ └── release_notes.txt └── softdevice │ └── s132 │ ├── 2.0.1 │ ├── headers │ │ ├── ble.h │ │ ├── ble_err.h │ │ ├── ble_gap.h │ │ ├── ble_gatt.h │ │ ├── ble_gattc.h │ │ ├── ble_gatts.h │ │ ├── ble_hci.h │ │ ├── ble_l2cap.h │ │ ├── ble_ranges.h │ │ ├── ble_types.h │ │ ├── nrf52 │ │ │ └── nrf_mbr.h │ │ ├── nrf_error.h │ │ ├── nrf_error_sdm.h │ │ ├── nrf_error_soc.h │ │ ├── nrf_nvic.h │ │ ├── nrf_sd_def.h │ │ ├── nrf_sdm.h │ │ ├── nrf_soc.h │ │ └── nrf_svc.h │ └── hex │ │ └── s132_nrf52_2.0.1_softdevice.hex │ ├── 5.1.0 │ ├── headers │ │ ├── ble.h │ │ ├── ble_err.h │ │ ├── ble_gap.h │ │ ├── ble_gatt.h │ │ ├── ble_gattc.h │ │ ├── ble_gatts.h │ │ ├── ble_hci.h │ │ ├── ble_l2cap.h │ │ ├── ble_ranges.h │ │ ├── ble_types.h │ │ ├── nrf52 │ │ │ └── nrf_mbr.h │ │ ├── nrf_error.h │ │ ├── nrf_error_sdm.h │ │ ├── nrf_error_soc.h │ │ ├── nrf_nvic.h │ │ ├── nrf_sdm.h │ │ ├── nrf_soc.h │ │ └── nrf_svc.h │ └── hex │ │ ├── s132_nrf52_5.1.0_license-agreement.txt │ │ └── s132_nrf52_5.1.0_softdevice.hex │ └── 6.0.0 │ ├── headers │ ├── ble.h │ ├── ble_err.h │ ├── ble_gap.h │ ├── ble_gatt.h │ ├── ble_gattc.h │ ├── ble_gatts.h │ ├── ble_hci.h │ ├── ble_l2cap.h │ ├── ble_ranges.h │ ├── ble_types.h │ ├── nrf52 │ │ └── nrf_mbr.h │ ├── nrf_error.h │ ├── nrf_error_sdm.h │ ├── nrf_error_soc.h │ ├── nrf_nvic.h │ ├── nrf_sdm.h │ ├── nrf_soc.h │ └── nrf_svc.h │ └── hex │ └── s132_nrf52_6.0.0_softdevice.hex └── src ├── Makefile ├── boards.h ├── bootloader_s132.ld ├── dfu_ble_svc.c ├── feather52.h ├── license.txt ├── main.c ├── metro52.h ├── nrf52_common.ld ├── nrf_drv_config.h ├── pstorage_platform.h ├── sdk_config.h └── segger ├── SEGGER_RTT.c ├── SEGGER_RTT.h ├── SEGGER_RTT_Conf.h ├── SEGGER_RTT_SES.c ├── flash_placement.xml ├── nRF52832_xxAA_MemoryMap.xml ├── nRF_Target.js ├── nrf52832_bootloader.emProject ├── nrf52_Registers.xml ├── ses_nRF_Startup.s ├── ses_nrf52_Vectors.s └── thumb_crt0.s /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.la 14 | *.lo 15 | 16 | # Shared objects (inc. Windows DLLs) 17 | *.dll 18 | *.so 19 | *.so.* 20 | *.dylib 21 | 22 | # Executables 23 | *.exe 24 | *.out 25 | *.app 26 | *.i*86 27 | *.x86_64 28 | 29 | # Debug files 30 | *.dSYM/ 31 | *.su 32 | *_build/ 33 | 34 | src/segger/Output 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Adafruit Industries 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **IMPORTATNT: Development is moved to new repo https://github.com/adafruit/Adafruit_nRF52_Bootloader, this repo is obsolete and for reference only** 2 | 3 | # Adafruit nRF52832 Arduino Bootloader 4 | 5 | This repository contains the bootloader for Adafruit nRF52832 boards (512KB flash, 64KB SRAM). 6 | 7 | It is based on nRF52 SDK 11.0.0 using the classic serial and OTA update options, and adds the following additional features: 8 | 9 | - Reset into serial boot mode: When the bootloader powers up, it starts in serial bootloader mode for about 1.5s waiting to see if any serial update requests come in. If this delay times out without a valid serial request, it then passes execution to the user binary. 10 | - Adds a special bootloader blinky pattern on the status LED 11 | - Checks the factory reset pin status at startup and clears the device if the pin is GND'ed 12 | - Adds a Device Information Service (DIS) in bootloader mode with Adafruit Industries as the manufacturer, plus some meta data like the SoftDevice family and version so that we can distinguish nRF51 from nRF52 in the Bluefruit LE Connect apps. DIS will report the versions in the following format: `S132 2.0.1, 0.5.0` (SoftDevice Family and Version, Bootloader Version) 13 | 14 | Note: The bootloader .hex file gets merged with the SoftDevice .hex file since they are dependent on each other due to the OTA DFU support, and to avoid having to flash multiple binaries or any version conflicts between the two. 15 | 16 | ## Files 17 | 18 | - `feather52_bootloader_v050_s132_v201.hex` - Intel hex file containing the Bluefruit nRF52 Feather bootloader ans S132 (v2.0.1) SD, for use when flashing with Adalink or a JLink 19 | - `metro52_bootloader_v050_s132_v201.hex` - Intel hex file containing the Metro nRF52 bootloader ans S132 (v2.0.1) SD, for use when flashing with Adalink or a JLink 20 | 21 | > `.zip` files are used for OTA updates and are provided for testing purposes, but shouldn't be made available to customers since OTA bootloader and SD updates are a high risk operation. 22 | -------------------------------------------------------------------------------- /bin/S132/S132_201.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/bin/S132/S132_201.bin -------------------------------------------------------------------------------- /bin/feather52832/0.5.0/dual/feather52_bootloader_v050_s132_v201_dual.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/bin/feather52832/0.5.0/dual/feather52_bootloader_v050_s132_v201_dual.zip -------------------------------------------------------------------------------- /bin/feather52832/0.5.0/single/feather52_bootloader_v050_s132_v201_single.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/bin/feather52832/0.5.0/single/feather52_bootloader_v050_s132_v201_single.zip -------------------------------------------------------------------------------- /bin/feather52832/5.1.0/dual/feather52_bootloader_5.1.0_s132_dual.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/bin/feather52832/5.1.0/dual/feather52_bootloader_5.1.0_s132_dual.bin -------------------------------------------------------------------------------- /bin/feather52832/5.1.0/dual/feather52_bootloader_5.1.0_s132_dual.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/bin/feather52832/5.1.0/dual/feather52_bootloader_5.1.0_s132_dual.zip -------------------------------------------------------------------------------- /bin/feather52832/5.1.0/single/feather52_bootloader_5.1.0_s132_single.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/bin/feather52832/5.1.0/single/feather52_bootloader_5.1.0_s132_single.bin -------------------------------------------------------------------------------- /bin/feather52832/5.1.0/single/feather52_bootloader_5.1.0_s132_single.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/bin/feather52832/5.1.0/single/feather52_bootloader_5.1.0_s132_single.zip -------------------------------------------------------------------------------- /bin/feather52832/6.0.0/feather52832_bootloader_6.0.0_s132.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/bin/feather52832/6.0.0/feather52832_bootloader_6.0.0_s132.bin -------------------------------------------------------------------------------- /bin/feather52832/6.0.0/feather52832_bootloader_6.0.0_s132.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/bin/feather52832/6.0.0/feather52832_bootloader_6.0.0_s132.zip -------------------------------------------------------------------------------- /layout/Feather52 S132 v2.x.x Dual Layout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/layout/Feather52 S132 v2.x.x Dual Layout.jpg -------------------------------------------------------------------------------- /layout/Feather52 S132 v5.x.x Dual Layout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/layout/Feather52 S132 v5.x.x Dual Layout.jpg -------------------------------------------------------------------------------- /layout/Feather52 S132 v5.x.x Single Layout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/layout/Feather52 S132 v5.x.x Single Layout.jpg -------------------------------------------------------------------------------- /lib/sdk11/components/ble/ble_services/ble_dis/ble_dis.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 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 | 13 | /** @file 14 | * 15 | * @defgroup ble_sdk_srv_dis Device Information Service 16 | * @{ 17 | * @ingroup ble_sdk_srv 18 | * @brief Device Information Service module. 19 | * 20 | * @details This module implements the Device Information Service. 21 | * During initialization it adds the Device Information Service to the BLE stack database. 22 | * It then encodes the supplied information, and adds the curresponding characteristics. 23 | * 24 | * @note Attention! 25 | * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 26 | * qualification listings, this section of source code must not be modified. 27 | */ 28 | 29 | #ifndef BLE_DIS_H__ 30 | #define BLE_DIS_H__ 31 | 32 | #include 33 | #include "ble_srv_common.h" 34 | 35 | /** @defgroup DIS_VENDOR_ID_SRC_VALUES Vendor ID Source values 36 | * @{ 37 | */ 38 | #define BLE_DIS_VENDOR_ID_SRC_BLUETOOTH_SIG 1 /**< Vendor ID assigned by Bluetooth SIG. */ 39 | #define BLE_DIS_VENDOR_ID_SRC_USB_IMPL_FORUM 2 /**< Vendor ID assigned by USB Implementer's Forum. */ 40 | /** @} */ 41 | 42 | /**@brief System ID parameters */ 43 | typedef struct 44 | { 45 | uint64_t manufacturer_id; /**< Manufacturer ID. Only 5 LSOs shall be used. */ 46 | uint32_t organizationally_unique_id; /**< Organizationally unique ID. Only 3 LSOs shall be used. */ 47 | } ble_dis_sys_id_t; 48 | 49 | /**@brief IEEE 11073-20601 Regulatory Certification Data List Structure */ 50 | typedef struct 51 | { 52 | uint8_t * p_list; /**< Pointer the byte array containing the encoded opaque structure based on IEEE 11073-20601 specification. */ 53 | uint8_t list_len; /**< Length of the byte array. */ 54 | } ble_dis_reg_cert_data_list_t; 55 | 56 | /**@brief PnP ID parameters */ 57 | typedef struct 58 | { 59 | uint8_t vendor_id_source; /**< Vendor ID Source. see @ref DIS_VENDOR_ID_SRC_VALUES. */ 60 | uint16_t vendor_id; /**< Vendor ID. */ 61 | uint16_t product_id; /**< Product ID. */ 62 | uint16_t product_version; /**< Product Version. */ 63 | } ble_dis_pnp_id_t; 64 | 65 | /**@brief Device Information Service init structure. This contains all possible characteristics 66 | * needed for initialization of the service. 67 | */ 68 | typedef struct 69 | { 70 | ble_srv_utf8_str_t manufact_name_str; /**< Manufacturer Name String. */ 71 | ble_srv_utf8_str_t model_num_str; /**< Model Number String. */ 72 | ble_srv_utf8_str_t serial_num_str; /**< Serial Number String. */ 73 | ble_srv_utf8_str_t hw_rev_str; /**< Hardware Revision String. */ 74 | ble_srv_utf8_str_t fw_rev_str; /**< Firmware Revision String. */ 75 | ble_srv_utf8_str_t sw_rev_str; /**< Software Revision String. */ 76 | ble_dis_sys_id_t * p_sys_id; /**< System ID. */ 77 | ble_dis_reg_cert_data_list_t * p_reg_cert_data_list; /**< IEEE 11073-20601 Regulatory Certification Data List. */ 78 | ble_dis_pnp_id_t * p_pnp_id; /**< PnP ID. */ 79 | ble_srv_security_mode_t dis_attr_md; /**< Initial Security Setting for Device Information Characteristics. */ 80 | } ble_dis_init_t; 81 | 82 | /**@brief Function for initializing the Device Information Service. 83 | * 84 | * @details This call allows the application to initialize the device information service. 85 | * It adds the DIS service and DIS characteristics to the database, using the initial 86 | * values supplied through the p_dis_init parameter. Characteristics which are not to be 87 | * added, shall be set to NULL in p_dis_init. 88 | * 89 | * @param[in] p_dis_init The structure containing the values of characteristics needed by the 90 | * service. 91 | * 92 | * @return NRF_SUCCESS on successful initialization of service. 93 | */ 94 | uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init); 95 | 96 | #endif // BLE_DIS_H__ 97 | 98 | /** @} */ 99 | -------------------------------------------------------------------------------- /lib/sdk11/components/ble/common/ble_srv_common.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/lib/sdk11/components/ble/common/ble_srv_common.c -------------------------------------------------------------------------------- /lib/sdk11/components/device/nrf.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2010 - 2017, Nordic Semiconductor ASA 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form, except as embedded into a Nordic 14 | Semiconductor ASA integrated circuit in a product or a software update for 15 | such product, must reproduce the above copyright notice, this list of 16 | conditions and the following disclaimer in the documentation and/or other 17 | materials provided with the distribution. 18 | 19 | 3. Neither the name of Nordic Semiconductor ASA nor the names of its 20 | contributors may be used to endorse or promote products derived from this 21 | software without specific prior written permission. 22 | 23 | 4. This software, with or without modification, must only be used with a 24 | Nordic Semiconductor ASA integrated circuit. 25 | 26 | 5. Any software provided in binary form under this license must not be reverse 27 | engineered, decompiled, modified and/or disassembled. 28 | 29 | THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 30 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 31 | OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 32 | DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 33 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 34 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 35 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 38 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | */ 41 | 42 | #ifndef NRF_H 43 | #define NRF_H 44 | 45 | /* MDK version */ 46 | #define MDK_MAJOR_VERSION 8 47 | #define MDK_MINOR_VERSION 15 48 | #define MDK_MICRO_VERSION 0 49 | 50 | /* Redefine "old" too-generic name NRF52 to NRF52832_XXAA to keep backwards compatibility. */ 51 | #if defined (NRF52) 52 | #ifndef NRF52832_XXAA 53 | #define NRF52832_XXAA 54 | #endif 55 | #endif 56 | 57 | /* Define NRF52_SERIES for common use in nRF52 series devices. Only if not previously defined. */ 58 | #if defined (NRF52810_XXAA) || defined (NRF52832_XXAA) || defined (NRF52832_XXAB) || defined (NRF52840_XXAA) 59 | #ifndef NRF52_SERIES 60 | #define NRF52_SERIES 61 | #endif 62 | #endif 63 | 64 | 65 | #if defined(_WIN32) 66 | /* Do not include nrf specific files when building for PC host */ 67 | #elif defined(__unix) 68 | /* Do not include nrf specific files when building for PC host */ 69 | #elif defined(__APPLE__) 70 | /* Do not include nrf specific files when building for PC host */ 71 | #else 72 | 73 | /* Device selection for device includes. */ 74 | #if defined (NRF51) 75 | #include "nrf51.h" 76 | #include "nrf51_bitfields.h" 77 | #include "nrf51_deprecated.h" 78 | #elif defined (NRF52840_XXAA) 79 | #include "nrf52840.h" 80 | #include "nrf52840_bitfields.h" 81 | #include "nrf51_to_nrf52840.h" 82 | #include "nrf52_to_nrf52840.h" 83 | #elif defined (NRF52832_XXAA) || defined (NRF52832_XXAB) 84 | #include "nrf52.h" 85 | #include "nrf52_bitfields.h" 86 | #include "nrf51_to_nrf52.h" 87 | #include "nrf52_name_change.h" 88 | #elif defined (NRF52810_XXAA) 89 | #include "nrf52810.h" 90 | #include "nrf52810_bitfields.h" 91 | #include "nrf51_to_nrf52810.h" 92 | #include "nrf52_to_nrf52810.h" 93 | #else 94 | #error "Device must be defined. See nrf.h." 95 | #endif /* NRF51, NRF52832_XXAA, NRF52832_XXAB, NRF52810_XXAA, NRF52840_XXAA */ 96 | 97 | #include "compiler_abstraction.h" 98 | 99 | #endif /* _WIN32 || __unix || __APPLE__ */ 100 | 101 | #endif /* NRF_H */ 102 | 103 | -------------------------------------------------------------------------------- /lib/sdk11/components/device/nrf52_name_change.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2010 - 2017, Nordic Semiconductor ASA 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form, except as embedded into a Nordic 14 | Semiconductor ASA integrated circuit in a product or a software update for 15 | such product, must reproduce the above copyright notice, this list of 16 | conditions and the following disclaimer in the documentation and/or other 17 | materials provided with the distribution. 18 | 19 | 3. Neither the name of Nordic Semiconductor ASA nor the names of its 20 | contributors may be used to endorse or promote products derived from this 21 | software without specific prior written permission. 22 | 23 | 4. This software, with or without modification, must only be used with a 24 | Nordic Semiconductor ASA integrated circuit. 25 | 26 | 5. Any software provided in binary form under this license must not be reverse 27 | engineered, decompiled, modified and/or disassembled. 28 | 29 | THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 30 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 31 | OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 32 | DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 33 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 34 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 35 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 38 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | */ 41 | 42 | #ifndef NRF52_NAME_CHANGE_H 43 | #define NRF52_NAME_CHANGE_H 44 | 45 | /*lint ++flb "Enter library region */ 46 | 47 | /* This file is given to prevent your SW from not compiling with the updates made to nrf52.h and 48 | * nrf52_bitfields.h. The macros defined in this file were available previously. Do not use these 49 | * macros on purpose. Use the ones defined in nrf52.h and nrf52_bitfields.h instead. 50 | */ 51 | 52 | /* I2S */ 53 | /* Several enumerations changed case. Adding old macros to keep compilation compatibility. */ 54 | #define I2S_ENABLE_ENABLE_DISABLE I2S_ENABLE_ENABLE_Disabled 55 | #define I2S_ENABLE_ENABLE_ENABLE I2S_ENABLE_ENABLE_Enabled 56 | #define I2S_CONFIG_MODE_MODE_MASTER I2S_CONFIG_MODE_MODE_Master 57 | #define I2S_CONFIG_MODE_MODE_SLAVE I2S_CONFIG_MODE_MODE_Slave 58 | #define I2S_CONFIG_RXEN_RXEN_DISABLE I2S_CONFIG_RXEN_RXEN_Disabled 59 | #define I2S_CONFIG_RXEN_RXEN_ENABLE I2S_CONFIG_RXEN_RXEN_Enabled 60 | #define I2S_CONFIG_TXEN_TXEN_DISABLE I2S_CONFIG_TXEN_TXEN_Disabled 61 | #define I2S_CONFIG_TXEN_TXEN_ENABLE I2S_CONFIG_TXEN_TXEN_Enabled 62 | #define I2S_CONFIG_MCKEN_MCKEN_DISABLE I2S_CONFIG_MCKEN_MCKEN_Disabled 63 | #define I2S_CONFIG_MCKEN_MCKEN_ENABLE I2S_CONFIG_MCKEN_MCKEN_Enabled 64 | #define I2S_CONFIG_SWIDTH_SWIDTH_8BIT I2S_CONFIG_SWIDTH_SWIDTH_8Bit 65 | #define I2S_CONFIG_SWIDTH_SWIDTH_16BIT I2S_CONFIG_SWIDTH_SWIDTH_16Bit 66 | #define I2S_CONFIG_SWIDTH_SWIDTH_24BIT I2S_CONFIG_SWIDTH_SWIDTH_24Bit 67 | #define I2S_CONFIG_ALIGN_ALIGN_LEFT I2S_CONFIG_ALIGN_ALIGN_Left 68 | #define I2S_CONFIG_ALIGN_ALIGN_RIGHT I2S_CONFIG_ALIGN_ALIGN_Right 69 | #define I2S_CONFIG_FORMAT_FORMAT_ALIGNED I2S_CONFIG_FORMAT_FORMAT_Aligned 70 | #define I2S_CONFIG_CHANNELS_CHANNELS_STEREO I2S_CONFIG_CHANNELS_CHANNELS_Stereo 71 | #define I2S_CONFIG_CHANNELS_CHANNELS_LEFT I2S_CONFIG_CHANNELS_CHANNELS_Left 72 | #define I2S_CONFIG_CHANNELS_CHANNELS_RIGHT I2S_CONFIG_CHANNELS_CHANNELS_Right 73 | 74 | /* LPCOMP */ 75 | /* Corrected typo in RESULT register. */ 76 | #define LPCOMP_RESULT_RESULT_Bellow LPCOMP_RESULT_RESULT_Below 77 | 78 | /*lint --flb "Leave library region" */ 79 | 80 | #endif /* NRF52_NAME_CHANGE_H */ 81 | 82 | -------------------------------------------------------------------------------- /lib/sdk11/components/drivers_nrf/config/nrf_drv_config_validation.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 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 | 13 | #ifndef NRF_DRV_CONFIG_VALIDATION_H 14 | #define NRF_DRV_CONFIG_VALIDATION_H 15 | 16 | #ifdef NRF52 17 | 18 | #if (!PERIPHERAL_RESOURCE_SHARING_ENABLED) && \ 19 | ((SPI0_ENABLED + SPIS0_ENABLED + TWI0_ENABLED + TWIS0_ENABLED) > 1) 20 | #error "Peripherals overlap. SPI0, SPIS0, TWI0, TWIS0 - only one of these can be enabled." 21 | #endif 22 | 23 | #if (!PERIPHERAL_RESOURCE_SHARING_ENABLED) && \ 24 | ((SPI1_ENABLED + SPIS1_ENABLED + TWI1_ENABLED + TWIS1_ENABLED) > 1) 25 | #error "Peripherals overlap. SPI1, SPIS1, TWI1, TWIS1 - only one of these can be enabled." 26 | #endif 27 | 28 | #if (!PERIPHERAL_RESOURCE_SHARING_ENABLED) && \ 29 | ((SPI2_ENABLED + SPIS2_ENABLED) > 1) 30 | #error "Peripherals overlap. SPI2, SPIS2 - only one of these can be enabled." 31 | #endif 32 | 33 | #if (!PERIPHERAL_RESOURCE_SHARING_ENABLED) && \ 34 | ((COMP_ENABLED + LPCOMP_ENABLED) > 1) 35 | #error "COMP and LPCOMP cannot be enabled together. Peripherals overlap." 36 | #endif 37 | 38 | #else //NRF51 39 | 40 | #if (TWIS0_ENABLED + TWIS1_ENABLED) > 0 41 | #error "TWIS not present in nRF51." 42 | #endif 43 | 44 | #if SPIS0_ENABLED > 0 45 | #error "SPIS0 instance not present in nRF51." 46 | #endif 47 | 48 | #if (SPI2_ENABLED + SPIS2_ENABLED) > 0 49 | #error "SPI2/SPIS2 instance not present in nRF51." 50 | #endif 51 | 52 | #if RTC2_ENABLED 53 | #error "RTC2 not present in NRF51." 54 | #endif 55 | 56 | #if (TIMER3_ENABLED + TIMER4_ENABLED) > 0 57 | #error "TIMER3 and TIMER4 not present in nRF51." 58 | #endif 59 | 60 | #if (!PERIPHERAL_RESOURCE_SHARING_ENABLED) && \ 61 | ((SPI0_ENABLED + TWI0_ENABLED) > 1) 62 | #error "Peripherals overlap. SPI0, TWI0 - only one of these can be enabled." 63 | #endif 64 | 65 | #if (!PERIPHERAL_RESOURCE_SHARING_ENABLED) && \ 66 | ((SPI1_ENABLED + SPIS1_ENABLED + TWI1_ENABLED) > 1) 67 | #error "Peripherals overlap. SPI1, SPIS1, TWI1 - only one of these can be enabled." 68 | #endif 69 | 70 | #if SAADC_ENABLED > 0 71 | #error "SAADC not present in nRF51." 72 | #endif 73 | 74 | #if I2S_ENABLED > 0 75 | #error "I2S not present in nRF51." 76 | #endif 77 | #if COMP_ENABLED > 0 78 | #error "COMP not present in nRF51." 79 | #endif 80 | 81 | #endif //NRF51 82 | 83 | #endif // NRF_DRV_CONFIG_VALIDATION_H 84 | -------------------------------------------------------------------------------- /lib/sdk11/components/drivers_nrf/delay/nrf_delay.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 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 | 13 | #include 14 | #include "compiler_abstraction.h" 15 | #include "nrf.h" 16 | #include "nrf_delay.h" 17 | 18 | /*lint --e{438} "Variable not used" */ 19 | void nrf_delay_ms(uint32_t volatile number_of_ms) 20 | { 21 | while(number_of_ms != 0) 22 | { 23 | number_of_ms--; 24 | nrf_delay_us(999); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/sdk11/components/drivers_nrf/hal/nrf_adc.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 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 | 13 | /** 14 | * @file 15 | * @brief ADC HAL implementation 16 | */ 17 | 18 | #include "nrf_adc.h" 19 | 20 | #ifndef NRF52 21 | 22 | /** 23 | * @brief Function for configuring ADC. 24 | * 25 | * This function powers on ADC and configures it. ADC is in DISABLE state after configuration, 26 | * so it should be enabled before using it. 27 | * 28 | * @param[in] config Requested configuration. 29 | */ 30 | void nrf_adc_configure(nrf_adc_config_t * config) 31 | { 32 | uint32_t config_reg = 0; 33 | 34 | config_reg |= ((uint32_t)config->resolution << ADC_CONFIG_RES_Pos) & ADC_CONFIG_RES_Msk; 35 | config_reg |= ((uint32_t)config->scaling << ADC_CONFIG_INPSEL_Pos) & ADC_CONFIG_INPSEL_Msk; 36 | config_reg |= ((uint32_t)config->reference << ADC_CONFIG_REFSEL_Pos) & ADC_CONFIG_REFSEL_Msk; 37 | 38 | if (config->reference & ADC_CONFIG_EXTREFSEL_Msk) 39 | { 40 | config_reg |= config->reference & ADC_CONFIG_EXTREFSEL_Msk; 41 | } 42 | 43 | /* select input */ 44 | nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_DISABLED); 45 | 46 | /* set new configuration keeping selected input */ 47 | NRF_ADC->CONFIG = config_reg | (NRF_ADC->CONFIG & ADC_CONFIG_PSEL_Msk); 48 | } 49 | 50 | 51 | /** 52 | * @brief Blocking function for executing single ADC conversion. 53 | * 54 | * This function selects the desired input, starts a single conversion, 55 | * waits for it to finish, and returns the result. 56 | * ADC is left in STOP state, the given input is selected. 57 | * This function does not check if ADC is initialized and powered. 58 | * 59 | * @param[in] input Requested input to be selected. 60 | * 61 | * @return Conversion result 62 | */ 63 | int32_t nrf_adc_convert_single(nrf_adc_config_input_t input) 64 | { 65 | int32_t val; 66 | 67 | nrf_adc_input_select(input); 68 | nrf_adc_start(); 69 | 70 | while (!nrf_adc_conversion_finished()) 71 | { 72 | } 73 | nrf_adc_conversion_event_clean(); 74 | val = nrf_adc_result_get(); 75 | nrf_adc_stop(); 76 | return val; 77 | } 78 | #endif 79 | -------------------------------------------------------------------------------- /lib/sdk11/components/drivers_nrf/hal/nrf_ecb.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 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 | * $LastChangedRevision: 25419 $ 12 | */ 13 | 14 | /** 15 | * @file 16 | * @brief Implementation of AES ECB driver 17 | */ 18 | 19 | 20 | //lint -e438 21 | 22 | #include 23 | #include 24 | #include 25 | #include "nrf.h" 26 | #include "nrf_ecb.h" 27 | 28 | static uint8_t ecb_data[48]; ///< ECB data structure for RNG peripheral to access. 29 | static uint8_t* ecb_key; ///< Key: Starts at ecb_data 30 | static uint8_t* ecb_cleartext; ///< Cleartext: Starts at ecb_data + 16 bytes. 31 | static uint8_t* ecb_ciphertext; ///< Ciphertext: Starts at ecb_data + 32 bytes. 32 | 33 | bool nrf_ecb_init(void) 34 | { 35 | ecb_key = ecb_data; 36 | ecb_cleartext = ecb_data + 16; 37 | ecb_ciphertext = ecb_data + 32; 38 | 39 | NRF_ECB->ECBDATAPTR = (uint32_t)ecb_data; 40 | return true; 41 | } 42 | 43 | 44 | bool nrf_ecb_crypt(uint8_t * dest_buf, const uint8_t * src_buf) 45 | { 46 | uint32_t counter = 0x1000000; 47 | if(src_buf != ecb_cleartext) 48 | { 49 | memcpy(ecb_cleartext,src_buf,16); 50 | } 51 | NRF_ECB->EVENTS_ENDECB = 0; 52 | NRF_ECB->TASKS_STARTECB = 1; 53 | while(NRF_ECB->EVENTS_ENDECB == 0) 54 | { 55 | counter--; 56 | if(counter == 0) 57 | { 58 | return false; 59 | } 60 | } 61 | NRF_ECB->EVENTS_ENDECB = 0; 62 | if(dest_buf != ecb_ciphertext) 63 | { 64 | memcpy(dest_buf,ecb_ciphertext,16); 65 | } 66 | return true; 67 | } 68 | 69 | void nrf_ecb_set_key(const uint8_t * key) 70 | { 71 | memcpy(ecb_key,key,16); 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /lib/sdk11/components/drivers_nrf/hal/nrf_ecb.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is confidential property of Nordic 4 | * Semiconductor ASA.Terms and conditions of usage are described in detail 5 | * in NORDIC 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 | * $LastChangedRevision: 13999 $ 12 | */ 13 | 14 | /** 15 | * @file 16 | * @brief ECB driver API. 17 | */ 18 | 19 | #ifndef NRF_ECB_H__ 20 | #define NRF_ECB_H__ 21 | 22 | /** 23 | * @defgroup nrf_ecb AES ECB encryption 24 | * @{ 25 | * @ingroup nrf_drivers 26 | * @brief Driver for the AES Electronic Code Book (ECB) peripheral. 27 | * 28 | * To encrypt and decrypt data, the peripheral must first be powered on 29 | * using @ref nrf_ecb_init. Next, the key must be set using @ref nrf_ecb_set_key. 30 | */ 31 | 32 | #include 33 | 34 | /** 35 | * @brief Function for initializing and powering on the ECB peripheral. 36 | * 37 | * This function allocates memory for the ECBDATAPTR. 38 | * @retval true If initialization was successful. 39 | * @retval false If powering on failed. 40 | */ 41 | bool nrf_ecb_init(void); 42 | 43 | /** 44 | * @brief Function for encrypting and decrypting 16-byte data using current key. 45 | * 46 | * This function avoids unnecessary copying of data if the parameters point to the 47 | * correct locations in the ECB data structure. 48 | * 49 | * @param dst Result of encryption/decryption. 16 bytes will be written. 50 | * @param src Source with 16-byte data to be encrypted/decrypted. 51 | * 52 | * @retval true If the encryption operation completed. 53 | * @retval false If the encryption operation did not complete. 54 | */ 55 | bool nrf_ecb_crypt(uint8_t * dst, const uint8_t * src); 56 | 57 | /** 58 | * @brief Function for setting the key to be used for encryption and decryption. 59 | * 60 | * @param key Pointer to the key. 16 bytes will be read. 61 | */ 62 | void nrf_ecb_set_key(const uint8_t * key); 63 | 64 | #endif // NRF_ECB_H__ 65 | 66 | /** @} */ 67 | -------------------------------------------------------------------------------- /lib/sdk11/components/drivers_nrf/hal/nrf_nvmc.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 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 | * $LastChangedRevision: 17685 $ 12 | */ 13 | 14 | /** 15 | *@file 16 | *@brief NMVC driver implementation 17 | */ 18 | 19 | #include 20 | #include "nrf.h" 21 | #include "nrf_nvmc.h" 22 | 23 | 24 | void nrf_nvmc_page_erase(uint32_t address) 25 | { 26 | // Enable erase. 27 | NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een; 28 | while (NRF_NVMC->READY == NVMC_READY_READY_Busy) 29 | { 30 | } 31 | 32 | // Erase the page 33 | NRF_NVMC->ERASEPAGE = address; 34 | while (NRF_NVMC->READY == NVMC_READY_READY_Busy) 35 | { 36 | } 37 | 38 | NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren; 39 | while (NRF_NVMC->READY == NVMC_READY_READY_Busy) 40 | { 41 | } 42 | } 43 | 44 | 45 | void nrf_nvmc_write_byte(uint32_t address, uint8_t value) 46 | { 47 | uint32_t byte_shift = address & (uint32_t)0x03; 48 | uint32_t address32 = address & ~byte_shift; // Address to the word this byte is in. 49 | uint32_t value32 = (*(uint32_t*)address32 & ~((uint32_t)0xFF << (byte_shift << (uint32_t)3))); 50 | value32 = value32 + ((uint32_t)value << (byte_shift << 3)); 51 | 52 | // Enable write. 53 | NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos); 54 | while (NRF_NVMC->READY == NVMC_READY_READY_Busy) 55 | { 56 | } 57 | 58 | *(uint32_t*)address32 = value32; 59 | while(NRF_NVMC->READY == NVMC_READY_READY_Busy) 60 | { 61 | } 62 | 63 | NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos); 64 | { 65 | } 66 | } 67 | 68 | void nrf_nvmc_write_word(uint32_t address, uint32_t value) 69 | { 70 | // Enable write. 71 | NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen; 72 | while (NRF_NVMC->READY == NVMC_READY_READY_Busy){ 73 | } 74 | 75 | *(uint32_t*)address = value; 76 | while (NRF_NVMC->READY == NVMC_READY_READY_Busy){ 77 | } 78 | 79 | NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren; 80 | while (NRF_NVMC->READY == NVMC_READY_READY_Busy) 81 | { 82 | } 83 | } 84 | 85 | void nrf_nvmc_write_bytes(uint32_t address, const uint8_t * src, uint32_t num_bytes) 86 | { 87 | uint32_t i; 88 | for(i=0;iCONFIG = NVMC_CONFIG_WEN_Wen; 100 | while (NRF_NVMC->READY == NVMC_READY_READY_Busy) 101 | { 102 | } 103 | 104 | for(i=0;iREADY == NVMC_READY_READY_Busy) 108 | { 109 | } 110 | } 111 | 112 | NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren; 113 | while (NRF_NVMC->READY == NVMC_READY_READY_Busy) 114 | { 115 | } 116 | } 117 | 118 | -------------------------------------------------------------------------------- /lib/sdk11/components/drivers_nrf/hal/nrf_nvmc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is confidential property of Nordic 4 | * Semiconductor ASA.Terms and conditions of usage are described in detail 5 | * in NORDIC 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 | * $LastChangedRevision: 17685 $ 12 | */ 13 | 14 | /** 15 | * @file 16 | * @brief NMVC driver API. 17 | */ 18 | 19 | #ifndef NRF_NVMC_H__ 20 | #define NRF_NVMC_H__ 21 | 22 | #include 23 | 24 | 25 | /** 26 | * @defgroup nrf_nvmc Non-volatile memory controller 27 | * @{ 28 | * @ingroup nrf_drivers 29 | * @brief Driver for the NVMC peripheral. 30 | * 31 | * This driver allows writing to the non-volatile memory (NVM) regions 32 | * of the chip. In order to write to NVM the controller must be powered 33 | * on and the relevant page must be erased. 34 | * 35 | */ 36 | 37 | 38 | /** 39 | * @brief Erase a page in flash. This is required before writing to any 40 | * address in the page. 41 | * 42 | * @param address Start address of the page. 43 | */ 44 | void nrf_nvmc_page_erase(uint32_t address); 45 | 46 | 47 | /** 48 | * @brief Write a single byte to flash. 49 | * 50 | * The function reads the word containing the byte, and then 51 | * rewrites the entire word. 52 | * 53 | * @param address Address to write to. 54 | * @param value Value to write. 55 | */ 56 | void nrf_nvmc_write_byte(uint32_t address , uint8_t value); 57 | 58 | 59 | /** 60 | * @brief Write a 32-bit word to flash. 61 | * @param address Address to write to. 62 | * @param value Value to write. 63 | */ 64 | void nrf_nvmc_write_word(uint32_t address, uint32_t value); 65 | 66 | 67 | /** 68 | * @brief Write consecutive bytes to flash. 69 | * 70 | * @param address Address to write to. 71 | * @param src Pointer to data to copy from. 72 | * @param num_bytes Number of bytes in src to write. 73 | */ 74 | void nrf_nvmc_write_bytes(uint32_t address, const uint8_t * src, uint32_t num_bytes); 75 | 76 | 77 | /** 78 | * @brief Write consecutive words to flash. 79 | * 80 | * @param address Address to write to. 81 | * @param src Pointer to data to copy from. 82 | * @param num_words Number of bytes in src to write. 83 | */ 84 | void nrf_nvmc_write_words(uint32_t address, const uint32_t * src, uint32_t num_words); 85 | 86 | 87 | #endif // NRF_NVMC_H__ 88 | /** @} */ 89 | 90 | 91 | -------------------------------------------------------------------------------- /lib/sdk11/components/drivers_nrf/hal/nrf_saadc.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 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 | 13 | /** 14 | * @file 15 | * @brief SAADC HAL implementation 16 | */ 17 | 18 | #include "nrf_saadc.h" 19 | 20 | void nrf_saadc_channel_init(uint8_t channel, nrf_saadc_channel_config_t const * const config) 21 | { 22 | NRF_SAADC->CH[channel].CONFIG = 23 | ((config->resistor_p << SAADC_CH_CONFIG_RESP_Pos) & SAADC_CH_CONFIG_RESP_Msk) 24 | | ((config->resistor_n << SAADC_CH_CONFIG_RESN_Pos) & SAADC_CH_CONFIG_RESN_Msk) 25 | | ((config->gain << SAADC_CH_CONFIG_GAIN_Pos) & SAADC_CH_CONFIG_GAIN_Msk) 26 | | ((config->reference << SAADC_CH_CONFIG_REFSEL_Pos) & SAADC_CH_CONFIG_REFSEL_Msk) 27 | | ((config->acq_time << SAADC_CH_CONFIG_TACQ_Pos) & SAADC_CH_CONFIG_TACQ_Msk) 28 | | ((config->mode << SAADC_CH_CONFIG_MODE_Pos) & SAADC_CH_CONFIG_MODE_Msk); 29 | nrf_saadc_channel_input_set(channel, config->pin_p, config->pin_n); 30 | return; 31 | } 32 | -------------------------------------------------------------------------------- /lib/sdk11/components/drivers_nrf/hal/nrf_temp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 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 | 13 | #ifndef NRF_TEMP_H__ 14 | #define NRF_TEMP_H__ 15 | 16 | #include "nrf.h" 17 | 18 | /** 19 | * @defgroup nrf_temperature TEMP (temperature) abstraction 20 | * @{ 21 | * @ingroup nrf_drivers temperature_example 22 | * @brief Temperature module init and read functions. 23 | * 24 | */ 25 | 26 | /**@cond NO_DOXYGEN */ 27 | #define MASK_SIGN (0x00000200UL) 28 | #define MASK_SIGN_EXTENSION (0xFFFFFC00UL) 29 | 30 | /** 31 | * @brief Function for preparing the temp module for temperature measurement. 32 | * 33 | * This function initializes the TEMP module and writes to the hidden configuration register. 34 | */ 35 | static __INLINE void nrf_temp_init(void) 36 | { 37 | /**@note Workaround for PAN_028 rev2.0A anomaly 31 - TEMP: Temperature offset value has to be manually loaded to the TEMP module */ 38 | *(uint32_t *) 0x4000C504 = 0; 39 | } 40 | 41 | /** 42 | * @brief Function for reading temperature measurement. 43 | * 44 | * The function reads the 10 bit 2's complement value and transforms it to a 32 bit 2's complement value. 45 | */ 46 | static __INLINE int32_t nrf_temp_read(void) 47 | { 48 | /**@note Workaround for PAN_028 rev2.0A anomaly 28 - TEMP: Negative measured values are not represented correctly */ 49 | return ((NRF_TEMP->TEMP & MASK_SIGN) != 0) ? (NRF_TEMP->TEMP | MASK_SIGN_EXTENSION) : (NRF_TEMP->TEMP); 50 | } 51 | /**@endcond */ 52 | 53 | /** @} */ 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/ble_transport/hci_mem_pool_internal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /** @file 14 | * 15 | * @defgroup memory_pool_internal Memory Pool Internal 16 | * @{ 17 | * @ingroup memory_pool 18 | * 19 | * @brief Memory pool internal definitions 20 | */ 21 | 22 | #ifndef MEM_POOL_INTERNAL_H__ 23 | #define MEM_POOL_INTERNAL_H__ 24 | 25 | #define TX_BUF_SIZE 4u /**< TX buffer size in bytes. */ 26 | #define RX_BUF_SIZE 32u /**< RX buffer size in bytes. */ 27 | 28 | #define RX_BUF_QUEUE_SIZE 8u /**< RX buffer element size. */ 29 | 30 | #endif // MEM_POOL_INTERNAL_H__ 31 | 32 | /** @} */ 33 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/bootloader.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader Bootloader API. 16 | * @{ 17 | * 18 | * @brief Bootloader module interface. 19 | */ 20 | 21 | #ifndef BOOTLOADER_H__ 22 | #define BOOTLOADER_H__ 23 | 24 | #include 25 | #include 26 | #include "bootloader_types.h" 27 | #include 28 | 29 | /**@brief Function for initializing the Bootloader. 30 | * 31 | * @retval NRF_SUCCESS If bootloader was succesfully initialized. 32 | */ 33 | uint32_t bootloader_init(void); 34 | 35 | /**@brief Function for validating application region in flash. 36 | * 37 | * @param[in] app_addr Address to the region in flash where the application is stored. 38 | * 39 | * @retval true If Application region is valid. 40 | * @retval false If Application region is not valid. 41 | */ 42 | bool bootloader_app_is_valid(uint32_t app_addr); 43 | 44 | /**@brief Function for starting the Device Firmware Update. 45 | * 46 | * @retval NRF_SUCCESS If new application image was successfully transferred. 47 | */ 48 | uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms); 49 | 50 | /**@brief Function for exiting bootloader and booting into application. 51 | * 52 | * @details This function will disable SoftDevice and all interrupts before jumping to application. 53 | * The SoftDevice vector table base for interrupt forwarding will be set the application 54 | * address. 55 | * 56 | * @param[in] app_addr Address to the region where the application is stored. 57 | */ 58 | void bootloader_app_start(uint32_t app_addr); 59 | 60 | /**@brief Function for retrieving the bootloader settings. 61 | * 62 | * @param[out] p_settings A copy of the current bootloader settings is returned in the structure 63 | * provided. 64 | */ 65 | void bootloader_settings_get(bootloader_settings_t * const p_settings); 66 | 67 | /**@brief Function for processing DFU status update. 68 | * 69 | * @param[in] update_status DFU update status. 70 | */ 71 | void bootloader_dfu_update_process(dfu_update_status_t update_status); 72 | 73 | /**@brief Function getting state of SoftDevice update in progress. 74 | * After a successfull SoftDevice transfer the system restarts in orderto disable SoftDevice 75 | * and complete the update. 76 | * 77 | * @retval true A SoftDevice update is in progress. This indicates that second stage 78 | * of a SoftDevice update procedure can be initiated. 79 | * @retval false No SoftDevice update is in progress. 80 | */ 81 | bool bootloader_dfu_sd_in_progress(void); 82 | 83 | /**@brief Function for continuing the Device Firmware Update of a SoftDevice. 84 | * 85 | * @retval NRF_SUCCESS If the final stage of SoftDevice update was successful. 86 | */ 87 | uint32_t bootloader_dfu_sd_update_continue(void); 88 | 89 | /**@brief Function for finalizing the Device Firmware Update of a SoftDevice. 90 | * 91 | * @retval NRF_SUCCESS If the final stage of SoftDevice update was successful. 92 | */ 93 | uint32_t bootloader_dfu_sd_update_finalize(void); 94 | 95 | #endif // BOOTLOADER_H__ 96 | 97 | /**@} */ 98 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 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 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader_settings Bootloader settings API. 16 | * @{ 17 | * 18 | * @brief Bootloader settings module interface. 19 | */ 20 | 21 | #ifndef BOOTLOADER_SETTINGS_H__ 22 | #define BOOTLOADER_SETTINGS_H__ 23 | 24 | #include 25 | #include "bootloader_types.h" 26 | 27 | /**@brief Function for getting the bootloader settings. 28 | * 29 | * @param[out] pp_bootloader_settings Bootloader settings. 30 | */ 31 | void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings); 32 | 33 | #endif // BOOTLOADER_SETTINGS_H__ 34 | 35 | /**@} */ 36 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/bootloader_types.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader_types Types and definitions. 16 | * @{ 17 | * 18 | * @ingroup nrf_bootloader 19 | * 20 | * @brief Bootloader module type and definitions. 21 | */ 22 | 23 | #ifndef BOOTLOADER_TYPES_H__ 24 | #define BOOTLOADER_TYPES_H__ 25 | 26 | #include 27 | 28 | #define BOOTLOADER_DFU_START 0xB1 29 | 30 | #define BOOTLOADER_SVC_APP_DATA_PTR_GET 0x02 31 | 32 | /**@brief DFU Bank state code, which indicates wether the bank contains: A valid image, invalid image, or an erased flash. 33 | */ 34 | typedef enum 35 | { 36 | BANK_VALID_APP = 0x01, 37 | BANK_VALID_SD = 0xA5, 38 | BANK_VALID_BOOT = 0xAA, 39 | BANK_ERASED = 0xFE, 40 | BANK_INVALID_APP = 0xFF, 41 | } bootloader_bank_code_t; 42 | 43 | /**@brief Structure holding bootloader settings for application and bank data. 44 | */ 45 | typedef struct 46 | { 47 | bootloader_bank_code_t bank_0; /**< Variable to store if bank 0 contains a valid application. */ 48 | uint16_t bank_0_crc; /**< If bank is valid, this field will contain a valid CRC of the total image. */ 49 | bootloader_bank_code_t bank_1; /**< Variable to store if bank 1 has been erased/prepared for new image. Bank 1 is only used in Banked Update scenario. */ 50 | uint32_t bank_0_size; /**< Size of active image in bank0 if present, otherwise 0. */ 51 | uint32_t sd_image_size; /**< Size of SoftDevice image in bank0 if bank_0 code is BANK_VALID_SD. */ 52 | uint32_t bl_image_size; /**< Size of Bootloader image in bank0 if bank_0 code is BANK_VALID_SD. */ 53 | uint32_t app_image_size; /**< Size of Application image in bank0 if bank_0 code is BANK_VALID_SD. */ 54 | uint32_t sd_image_start; /**< Location in flash where SoftDevice image is stored for SoftDevice update. */ 55 | } bootloader_settings_t; 56 | 57 | #endif // BOOTLOADER_TYPES_H__ 58 | 59 | /**@} */ 60 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/bootloader_util.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader_util Bootloader util API. 16 | * @{ 17 | * 18 | * @brief Bootloader util module interface. 19 | */ 20 | 21 | #ifndef BOOTLOADER_UTIL_H__ 22 | #define BOOTLOADER_UTIL_H__ 23 | 24 | #include 25 | #include "bootloader_types.h" 26 | 27 | /**@brief Function for starting the application (or bootloader) at the provided address. 28 | * 29 | * @param[in] start_addr Start address. 30 | * 31 | * @note This function will never retrun. Instead it will reset into the application of the 32 | * provided address. 33 | */ 34 | void bootloader_util_app_start(uint32_t start_addr); 35 | 36 | #endif // BOOTLOADER_UTIL_H__ 37 | 38 | /**@} */ 39 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/dfu_bank_internal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 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 | 13 | /**@file 14 | * 15 | * @defgroup dfu_bank_internal Device Firmware Update internal header for bank handling in DFU. 16 | * @{ 17 | * 18 | * @brief Device Firmware Update Bank handling module interface. 19 | * 20 | * @details This header is intended for shared definition and functions between single and dual bank 21 | * implementations used for DFU support. It is not supposed to be used for external access 22 | * to the DFU module. 23 | * 24 | */ 25 | #ifndef DFU_BANK_INTERNAL_H__ 26 | #define DFU_BANK_INTERNAL_H__ 27 | 28 | #include 29 | 30 | /**@brief States of the DFU state machine. */ 31 | typedef enum 32 | { 33 | DFU_STATE_INIT_ERROR, /**< State for: dfu_init(...) error. */ 34 | DFU_STATE_IDLE, /**< State for: idle. */ 35 | DFU_STATE_PREPARING, /**< State for: preparing, indicates that the flash is being erased and no data packets can be processed. */ 36 | DFU_STATE_RDY, /**< State for: ready. */ 37 | DFU_STATE_RX_INIT_PKT, /**< State for: receiving initialization packet. */ 38 | DFU_STATE_RX_DATA_PKT, /**< State for: receiving data packet. */ 39 | DFU_STATE_VALIDATE, /**< State for: validate. */ 40 | DFU_STATE_WAIT_4_ACTIVATE /**< State for: waiting for dfu_image_activate(). */ 41 | } dfu_state_t; 42 | 43 | #define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */ 44 | #define DFU_TIMEOUT_INTERVAL APP_TIMER_TICKS(300000, APP_TIMER_PRESCALER) /**< DFU timeout interval in units of timer ticks. */ 45 | 46 | #define IS_UPDATING_SD(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_SD) /**< Macro for determining if a SoftDevice update is ongoing. */ 47 | #define IS_UPDATING_BL(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_BL) /**< Macro for determining if a Bootloader update is ongoing. */ 48 | #define IS_UPDATING_APP(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_APP) /**< Macro for determining if a Application update is ongoing. */ 49 | #define IMAGE_WRITE_IN_PROGRESS() (m_data_received > 0) /**< Macro for determining if an image write is in progress. */ 50 | #define IS_WORD_SIZED(SIZE) ((SIZE & (sizeof(uint32_t) - 1)) == 0) /**< Macro for checking that the provided is word sized. */ 51 | 52 | /**@cond NO_DOXYGEN */ 53 | static uint32_t m_data_received; /**< Amount of received data. */ 54 | /**@endcond */ 55 | 56 | /**@brief Type definition of function used for preparing of the bank before receiving of a 57 | * software image. 58 | * 59 | * @param[in] image_size Size of software image being received. 60 | */ 61 | typedef void (*dfu_bank_prepare_t)(uint32_t image_size); 62 | 63 | /**@brief Type definition of function used for handling clear complete of the bank before 64 | * receiving of a software image. 65 | */ 66 | typedef void (*dfu_bank_cleared_t)(void); 67 | 68 | /**@brief Type definition of function used for activating of the software image received. 69 | * 70 | * @return NRF_SUCCESS If the image has been successfully activated any other NRF_ERROR code in 71 | * case of a failure. 72 | */ 73 | typedef uint32_t (*dfu_bank_activate_t)(void); 74 | 75 | /**@brief Structure for holding of function pointers for needed prepare and activate procedure for 76 | * the requested update procedure. 77 | */ 78 | typedef struct 79 | { 80 | dfu_bank_prepare_t prepare; /**< Function pointer to the prepare function called on start of update procedure. */ 81 | dfu_bank_cleared_t cleared; /**< Function pointer to the cleared function called after prepare function completes. */ 82 | dfu_bank_activate_t activate; /**< Function pointer to the activate function called on finalizing the update procedure. */ 83 | } dfu_bank_func_t; 84 | 85 | #endif // DFU_BANK_INTERNAL_H__ 86 | 87 | /** @} */ 88 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/dfu_ble_svc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 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 | 13 | /** @file 14 | * 15 | * @defgroup nrf_dfu_ble_svc DFU BLE SVC 16 | * @{ 17 | * 18 | * @brief DFU BLE SVC in bootloader. The DFU BLE SuperVisor Calls allow an application to execute 19 | * functions in the installed bootloader. 20 | * 21 | * @details This module implements handling of SuperVisor Calls in the bootloader. 22 | * SuperVisor Calls allow for an application to execute calls into the bootloader. 23 | * Currently, it is possible to exchange bonding information (like keys) from the 24 | * application to a bootloader supporting DFU OTA using BLE, so the update process can be 25 | * done through an already existing bond. 26 | * 27 | * @note The application must make sure that all SuperVisor Calls (SVC) are forwarded to the 28 | * bootloader to ensure correct behavior. Forwarding of SVCs to the bootloader is 29 | * done using the SoftDevice SVC @ref sd_softdevice_vector_table_base_set with the value 30 | * present in @c NRF_UICR->NRFFW[0]. 31 | */ 32 | 33 | #ifndef DFU_BLE_SVC_H__ 34 | #define DFU_BLE_SVC_H__ 35 | 36 | #include "nrf_svc.h" 37 | #include 38 | #include "ble_gap.h" 39 | #include "nrf.h" 40 | #include "nrf_soc.h" 41 | #include "nrf_error_sdm.h" 42 | 43 | #define BOOTLOADER_SVC_BASE 0x0 /**< The number of the lowest SVC number reserved for the bootloader. */ 44 | #define SYSTEM_SERVICE_ATT_SIZE 8 /**< Size of the system service attribute length including CRC-16 at the end. */ 45 | 46 | /**@brief The SVC numbers used by the SVC functions in the SoC library. */ 47 | enum BOOTLOADER_SVCS 48 | { 49 | DFU_BLE_SVC_PEER_DATA_SET = BOOTLOADER_SVC_BASE, /**< SVC number for the setting of peer data call. */ 50 | BOOTLOADER_SVC_LAST 51 | }; 52 | 53 | /**@brief DFU Peer data structure. 54 | * 55 | * @details This structure contains peer data needed for connection to a bonded device during DFU. 56 | * The peer data must be provided by the application to the bootloader during buttonless 57 | * update. See @ref dfu_ble_svc_peer_data_set. It contains bond information about the 58 | * desired DFU peer. 59 | */ 60 | typedef struct 61 | { 62 | ble_gap_addr_t addr; /**< BLE GAP address of the device that initiated the DFU process. */ 63 | ble_gap_irk_t irk; /**< IRK of the device that initiated the DFU process if this device uses Private Resolvable Addresses. */ 64 | ble_gap_enc_key_t enc_key; /**< Encryption key structure containing encrypted diversifier and LTK for re-establishing the bond. */ 65 | uint8_t sys_serv_attr[SYSTEM_SERVICE_ATT_SIZE]; /**< System service attributes for restoring of Service Changed Indication setting in DFU mode. */ 66 | } dfu_ble_peer_data_t; 67 | 68 | /**@brief SVC Function for setting peer data containing address, IRK, and LTK to establish bonded 69 | * connection in DFU mode. 70 | * 71 | * @param[in] p_peer_data Pointer to the peer data containing keys for the connection. 72 | * 73 | * @retval NRF_ERROR_NULL If a NULL pointer was provided as argument. 74 | * @retval NRF_SUCCESS If the function completed successfully. 75 | */ 76 | SVCALL(DFU_BLE_SVC_PEER_DATA_SET, uint32_t, dfu_ble_svc_peer_data_set(dfu_ble_peer_data_t * p_peer_data)); 77 | 78 | #endif // DFU_BLE_SVC_H__ 79 | 80 | /** @} */ 81 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/dfu_ble_svc_internal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 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 | 13 | /** @file 14 | * 15 | * @defgroup nrf_dfu_ble_svc_internal DFU BLE SVC internal 16 | * @{ 17 | * 18 | * @brief DFU BLE SVC internal functions in bootloader. The DFU BLE SuperVisor Calls allow an 19 | * application to execute functions in the installed bootloader. This interface provides 20 | * internal Bootloader DFU functions for retrieving data exchanged through SuperVisor Calls. 21 | * 22 | */ 23 | 24 | #ifndef DFU_BLE_SVC_INTERNAL_H__ 25 | #define DFU_BLE_SVC_INTERNAL_H__ 26 | 27 | #include 28 | #include "dfu_ble_svc.h" 29 | #include "ble_gap.h" 30 | 31 | /**@brief Internal bootloader/DFU function for retrieving peer data provided from application. 32 | * 33 | * @param[out] p_peer_data Peer data set by application to be used for DFU connection. 34 | * 35 | * @retval NRF_SUCCESS If peer data is valid and can be used for connection. 36 | * @retval NRF_ERROR_NULL If p_peer_data is a NULL pointer. 37 | * @retval NRF_ERROR_INVALID_DATA If peer data is not available or invalid. 38 | */ 39 | uint32_t dfu_ble_peer_data_get(dfu_ble_peer_data_t * p_peer_data); 40 | 41 | #endif // DFU_BLE_SVC_INTERNAL_H__ 42 | 43 | /** @} */ 44 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/dfu_transport.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /**@file 14 | * 15 | * @defgroup nrf_dfu_transport DFU transport API. 16 | * @{ 17 | * 18 | * @brief DFU transport module interface. 19 | */ 20 | 21 | #ifndef DFU_TRANSPORT_H__ 22 | #define DFU_TRANSPORT_H__ 23 | 24 | #include 25 | 26 | /**@brief Function for starting the update of Device Firmware. 27 | * 28 | * @retval NRF_SUCCESS Operation success. 29 | */ 30 | uint32_t dfu_transport_serial_update_start(void); 31 | 32 | /**@brief Function for closing the transport layer. 33 | * 34 | * @retval NRF_SUCCESS Operation success. 35 | */ 36 | uint32_t dfu_transport_serial_close(void); 37 | 38 | 39 | uint32_t dfu_transport_ble_update_start(void); 40 | uint32_t dfu_transport_ble_close(); 41 | 42 | #endif // DFU_TRANSPORT_H__ 43 | 44 | /**@} */ 45 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/hci_transport/hci_mem_pool_internal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /** @file 14 | * 15 | * @defgroup memory_pool_internal Memory Pool Internal 16 | * @{ 17 | * @ingroup memory_pool 18 | * 19 | * @brief Memory pool internal definitions 20 | */ 21 | 22 | #ifndef MEM_POOL_INTERNAL_H__ 23 | #define MEM_POOL_INTERNAL_H__ 24 | 25 | #define TX_BUF_SIZE 32u /**< TX buffer size in bytes. */ 26 | #define RX_BUF_SIZE 600u /**< RX buffer size in bytes. */ 27 | 28 | #define RX_BUF_QUEUE_SIZE 2u /**< RX buffer element size. */ 29 | 30 | #endif // MEM_POOL_INTERNAL_H__ 31 | 32 | /** @} */ 33 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/bootloader_dfu/hci_transport/hci_transport_config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /**@file 14 | * 15 | * @defgroup ble_sdk_bootloader_hci_congfig HCI Transport Layer Configuration 16 | * @{ 17 | * @ingroup dfu_bootloader_api 18 | * @brief Definition of HCI Transport Layer configurable parameters 19 | */ 20 | 21 | #ifndef HCI_TRANSPORT_CONFIG_H__ 22 | #define HCI_TRANSPORT_CONFIG_H__ 23 | 24 | #include "boards.h" /**< Default include for boards.h which means that default pin numbers will be used for RX, TX, CTS, and RTS on the UART. Other pin number can be used if desired. */ 25 | 26 | /** This section covers configurable parameters for the HCI Transport SLIP layer. */ 27 | #define HCI_SLIP_UART_RX_PIN_NUMBER RX_PIN_NUMBER /**< Defines the UART RX pin number. The default pin for the board is chosen, but can be overwritten. */ 28 | 29 | #define HCI_SLIP_UART_TX_PIN_NUMBER TX_PIN_NUMBER /**< Defines the UART TX pin number. The default pin for the board is chosen, but can be overwritten. */ 30 | 31 | #define HCI_SLIP_UART_RTS_PIN_NUMBER RTS_PIN_NUMBER /**< Defines the UART RTS pin number. The default pin for the board is chosen, but can be overwritten. */ 32 | 33 | #define HCI_SLIP_UART_CTS_PIN_NUMBER CTS_PIN_NUMBER /**< Defines the UART CTS pin number. The default pin for the board is chosen, but can be overwritten. */ 34 | 35 | #define HCI_SLIP_UART_MODE APP_UART_FLOW_CONTROL_DISABLED /**< Defines the UART mode to be used. Use UART Low Power with Flow Control - Valid values are defined in \ref app_uart_flow_control_t. For further information on the UART Low Power mode, please refer to: \ref app_uart . */ 36 | 37 | #define HCI_SLIP_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200 // UART_BAUDRATE_BAUDRATE_Baud38400 /**< Defines the UART Baud rate. Default is 38400 baud. */ 38 | 39 | /** This section covers configurable parameters for the HCI Transport layer that are used for calculating correct value for the retransmission timer timeout. */ 40 | #define MAX_PACKET_SIZE_IN_BITS 8000u /**< Maximum size of a single application packet in bits. */ 41 | #define USED_BAUD_RATE 115200u /**< The used uart baudrate. */ 42 | 43 | #endif // HCI_TRANSPORT_CONFIG_H__ 44 | 45 | /** @} */ 46 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/crc16/crc16.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | #include "crc16.h" 14 | 15 | #include 16 | 17 | uint16_t crc16_compute(uint8_t const * p_data, uint32_t size, uint16_t const * p_crc) 18 | { 19 | uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc; 20 | 21 | for (uint32_t i = 0; i < size; i++) 22 | { 23 | crc = (uint8_t)(crc >> 8) | (crc << 8); 24 | crc ^= p_data[i]; 25 | crc ^= (uint8_t)(crc & 0xFF) >> 4; 26 | crc ^= (crc << 8) << 4; 27 | crc ^= ((crc & 0xFF) << 4) << 1; 28 | } 29 | 30 | return crc; 31 | } 32 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/crc16/crc16.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /** @file 14 | * 15 | * @defgroup crc_compute CRC compute 16 | * @{ 17 | * @ingroup hci_transport 18 | * 19 | * @brief This module implements CRC-16-CCITT (polynomial 0x1021) with 0xFFFF initial value. 20 | * The data can be passed in multiple blocks. 21 | */ 22 | 23 | #ifndef CRC16_H__ 24 | #define CRC16_H__ 25 | 26 | #include 27 | 28 | /**@brief Function for calculating CRC-16 in blocks. 29 | * 30 | * Feed each consecutive data block into this function, along with the current value of p_crc as 31 | * returned by the previous call of this function. The first call of this function should pass NULL 32 | * as the initial value of the crc in p_crc. 33 | * 34 | * @param[in] p_data The input data block for computation. 35 | * @param[in] size The size of the input data block in bytes. 36 | * @param[in] p_crc The previous calculated CRC-16 value or NULL if first call. 37 | * 38 | * @return The updated CRC-16 value, based on the input supplied. 39 | */ 40 | uint16_t crc16_compute(uint8_t const * p_data, uint32_t size, uint16_t const * p_crc); 41 | 42 | #endif // CRC16_H__ 43 | 44 | /** @} */ 45 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/slip/slip.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 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 | 13 | #include "slip.h" 14 | #include "nrf_error.h" 15 | 16 | #define SLIP_END 0300 /* indicates end of packet */ 17 | #define SLIP_ESC 0333 /* indicates byte stuffing */ 18 | #define SLIP_ESC_END 0334 /* ESC ESC_END means END data byte */ 19 | #define SLIP_ESC_ESC 0335 /* ESC ESC_ESC means ESC data byte */ 20 | 21 | 22 | uint32_t slip_encode(uint8_t * p_output, uint8_t * p_input, uint32_t input_length, uint32_t output_buffer_length) 23 | { 24 | uint32_t input_index; 25 | uint32_t output_index; 26 | 27 | for (input_index = 0, output_index = 0; input_index < input_length && output_index < output_buffer_length; input_index++) 28 | { 29 | switch (p_input[input_index]) 30 | { 31 | case SLIP_END: 32 | p_output[output_index++] = SLIP_END; 33 | p_output[output_index++] = SLIP_ESC_END; 34 | break; 35 | 36 | case SLIP_ESC: 37 | p_output[output_index++] = SLIP_ESC; 38 | p_output[output_index++] = SLIP_ESC_ESC; 39 | break; 40 | 41 | default: 42 | p_output[output_index++] = p_input[input_index]; 43 | } 44 | } 45 | p_output[output_index++] = (uint8_t)SLIP_END; 46 | p_output[output_index++] = (uint8_t)SLIP_END; // clarify that the packet has ended. 47 | 48 | return output_index; 49 | } 50 | 51 | 52 | uint32_t slip_decoding_add_char(uint8_t c, buffer_t * p_buf, slip_state_t * current_state) 53 | { 54 | switch (*current_state) 55 | { 56 | case SLIP_DECODING: 57 | if (c == SLIP_END) 58 | { 59 | *current_state = SLIP_END_RECEIVED; 60 | } 61 | else if (c == SLIP_ESC) 62 | { 63 | *current_state = SLIP_END_RECEIVED; 64 | } 65 | else 66 | { 67 | p_buf->p_buffer[p_buf->current_index++] = c; 68 | p_buf->current_length++; 69 | } 70 | break; 71 | 72 | case SLIP_ESC_RECEIVED: 73 | if (c == SLIP_ESC_ESC) 74 | { 75 | p_buf->p_buffer[p_buf->current_index++] = SLIP_ESC; 76 | p_buf->current_length++; 77 | *current_state = SLIP_DECODING; 78 | } 79 | else 80 | { 81 | // violation of protocol 82 | *current_state = SLIP_CLEARING_INVALID_PACKET; 83 | return NRF_ERROR_INVALID_DATA; 84 | } 85 | break; 86 | 87 | case SLIP_END_RECEIVED: 88 | if (c == SLIP_ESC_END) 89 | { 90 | p_buf->p_buffer[p_buf->current_index++] = SLIP_END; 91 | p_buf->current_length++; 92 | *current_state = SLIP_DECODING; 93 | } 94 | else 95 | { 96 | // packet is finished 97 | *current_state = SLIP_DECODING; 98 | return NRF_SUCCESS; 99 | } 100 | break; 101 | 102 | case SLIP_CLEARING_INVALID_PACKET: 103 | if (c == SLIP_END) 104 | { 105 | *current_state = SLIP_DECODING; 106 | p_buf->current_index = 0; 107 | p_buf->current_length = 0; 108 | } 109 | break; 110 | } 111 | return NRF_ERROR_BUSY; 112 | } 113 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/slip/slip.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 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 | 13 | #ifndef SLIP_H__ 14 | #define SLIP_H__ 15 | 16 | #include 17 | #include "app_fifo.h" 18 | 19 | /** @file 20 | * 21 | * @defgroup slip SLIP encoding decoding 22 | * @{ 23 | * @ingroup app_common 24 | * 25 | * @brief This module encodes and decodes slip packages (RFC1055). 26 | * 27 | * @details The standard is described in https://tools.ietf.org/html/rfc1055 28 | */ 29 | 30 | typedef enum { 31 | SLIP_DECODING, 32 | SLIP_END_RECEIVED, 33 | SLIP_ESC_RECEIVED, 34 | SLIP_CLEARING_INVALID_PACKET, 35 | } slip_state_t; 36 | 37 | typedef struct { 38 | uint8_t * p_buffer; 39 | uint32_t current_index; 40 | uint32_t current_length; 41 | uint32_t len; 42 | } buffer_t; 43 | 44 | /**@brief Encodes a slip packet. 45 | * 46 | * @details Note that the encoded output data will be longer than the input data. 47 | * 48 | * @retval The length of the encoded packet. If it is smaller than the input length, an error has occurred. 49 | */ 50 | uint32_t slip_encode(uint8_t * p_output, uint8_t * p_input, uint32_t input_length, uint32_t output_buffer_length); 51 | 52 | /**@brief Decodes a slip packet. 53 | * 54 | * @details When decoding a slip packet, a state must be preserved. Initial state must be set to SLIP_DECODING. 55 | * 56 | * @retval NRF_SUCCESS when a packet is parsed. The length of the packet can be read out from p_buf->current_index 57 | * @retval NRF_ERROR_BUSY when packet is not finished parsing 58 | * @retval NRF_ERROR_INVALID_DATA when packet is encoded wrong. 59 | This moves the decoding to SLIP_CLEARING_INVALID_PACKET, and will stay in this state until SLIP_END is encountered. 60 | */ 61 | uint32_t slip_decoding_add_char(uint8_t c, buffer_t * p_buf, slip_state_t * current_state); 62 | 63 | 64 | #endif // SLIP_H__ 65 | 66 | /** @} */ 67 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/timer/app_timer_appsh.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 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 | 13 | #include "app_timer_appsh.h" 14 | #include "app_scheduler.h" 15 | 16 | static void app_timer_evt_get(void * p_event_data, uint16_t event_size) 17 | { 18 | app_timer_event_t * p_timer_event = (app_timer_event_t *)p_event_data; 19 | 20 | APP_ERROR_CHECK_BOOL(event_size == sizeof(app_timer_event_t)); 21 | p_timer_event->timeout_handler(p_timer_event->p_context); 22 | } 23 | 24 | uint32_t app_timer_evt_schedule(app_timer_timeout_handler_t timeout_handler, 25 | void * p_context) 26 | { 27 | app_timer_event_t timer_event; 28 | 29 | timer_event.timeout_handler = timeout_handler; 30 | timer_event.p_context = p_context; 31 | 32 | return app_sched_event_put(&timer_event, sizeof(timer_event), app_timer_evt_get); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/timer/app_timer_appsh.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 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 | 13 | #ifndef APP_TIMER_APPSH_H 14 | #define APP_TIMER_APPSH_H 15 | 16 | #include "app_timer.h" 17 | 18 | #define APP_TIMER_SCHED_EVT_SIZE sizeof(app_timer_event_t) /**< Size of button events being passed through the scheduler (is to be used for computing the maximum size of scheduler events). */ 19 | 20 | /**@brief Macro for initializing the application timer module to use with app_scheduler. 21 | * 22 | * @param[in] PRESCALER Value of the RTC1 PRESCALER register. This will decide the 23 | * timer tick rate. Set to 0 for no prescaling. 24 | * @param[in] OP_QUEUES_SIZE Size of queues holding timer operations that are pending execution. 25 | * @param[in] USE_SCHEDULER TRUE if the application is using the app_scheduler, 26 | * FALSE otherwise. 27 | * 28 | * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it 29 | * several times as long as it is from the same location, e.g. to do a reinitialization). 30 | */ 31 | #define APP_TIMER_APPSH_INIT(PRESCALER, OP_QUEUES_SIZE, USE_SCHEDULER) \ 32 | APP_TIMER_INIT(PRESCALER, OP_QUEUES_SIZE, \ 33 | (USE_SCHEDULER) ? app_timer_evt_schedule : NULL) 34 | 35 | typedef struct 36 | { 37 | app_timer_timeout_handler_t timeout_handler; 38 | void * p_context; 39 | } app_timer_event_t; 40 | 41 | uint32_t app_timer_evt_schedule(app_timer_timeout_handler_t timeout_handler, 42 | void * p_context); 43 | #endif // APP_TIMER_APPSH_H 44 | 45 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/uart/app_uart.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 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 | 13 | #include "app_uart.h" 14 | #include "nrf_drv_uart.h" 15 | #include "nrf_assert.h" 16 | #include "sdk_common.h" 17 | 18 | static uint8_t tx_buffer[1]; 19 | static uint8_t rx_buffer[1]; 20 | static volatile bool rx_done; 21 | static app_uart_event_handler_t m_event_handler; /**< Event handler function. */ 22 | 23 | void uart_event_handler(nrf_drv_uart_event_t * p_event, void* p_context) 24 | { 25 | if (p_event->type == NRF_DRV_UART_EVT_RX_DONE) 26 | { 27 | app_uart_evt_t app_uart_event; 28 | app_uart_event.evt_type = APP_UART_DATA; 29 | app_uart_event.data.value = p_event->data.rxtx.p_data[0]; 30 | (void)nrf_drv_uart_rx(rx_buffer,1); 31 | rx_done = true; 32 | m_event_handler(&app_uart_event); 33 | } 34 | else if (p_event->type == NRF_DRV_UART_EVT_ERROR) 35 | { 36 | app_uart_evt_t app_uart_event; 37 | app_uart_event.evt_type = APP_UART_COMMUNICATION_ERROR; 38 | app_uart_event.data.error_communication = p_event->data.error.error_mask; 39 | (void)nrf_drv_uart_rx(rx_buffer,1); 40 | m_event_handler(&app_uart_event); 41 | } 42 | else if (p_event->type == NRF_DRV_UART_EVT_TX_DONE) 43 | { 44 | // Last byte from FIFO transmitted, notify the application. 45 | // Notify that new data is available if this was first byte put in the buffer. 46 | app_uart_evt_t app_uart_event; 47 | app_uart_event.evt_type = APP_UART_TX_EMPTY; 48 | m_event_handler(&app_uart_event); 49 | } 50 | } 51 | 52 | uint32_t app_uart_init(const app_uart_comm_params_t * p_comm_params, 53 | app_uart_buffers_t * p_buffers, 54 | app_uart_event_handler_t event_handler, 55 | app_irq_priority_t irq_priority) 56 | { 57 | nrf_drv_uart_config_t config = NRF_DRV_UART_DEFAULT_CONFIG; 58 | config.baudrate = (nrf_uart_baudrate_t)p_comm_params->baud_rate; 59 | config.hwfc = (p_comm_params->flow_control == APP_UART_FLOW_CONTROL_DISABLED) ? 60 | NRF_UART_HWFC_DISABLED : NRF_UART_HWFC_ENABLED; 61 | config.interrupt_priority = irq_priority; 62 | config.parity = p_comm_params->use_parity ? NRF_UART_PARITY_INCLUDED : NRF_UART_PARITY_EXCLUDED; 63 | config.pselcts = p_comm_params->cts_pin_no; 64 | config.pselrts = p_comm_params->rts_pin_no; 65 | config.pselrxd = p_comm_params->rx_pin_no; 66 | config.pseltxd = p_comm_params->tx_pin_no; 67 | 68 | m_event_handler = event_handler; 69 | 70 | rx_done = false; 71 | 72 | if (p_comm_params->flow_control == APP_UART_FLOW_CONTROL_LOW_POWER) 73 | { 74 | return NRF_ERROR_NOT_SUPPORTED; 75 | } 76 | 77 | uint32_t err_code = nrf_drv_uart_init(&config, uart_event_handler); 78 | VERIFY_SUCCESS(err_code); 79 | 80 | #ifdef NRF52 81 | if (!config.use_easy_dma) 82 | #endif 83 | { 84 | nrf_drv_uart_rx_enable(); 85 | } 86 | return nrf_drv_uart_rx(rx_buffer,1); 87 | } 88 | 89 | 90 | uint32_t app_uart_get(uint8_t * p_byte) 91 | { 92 | ASSERT(p_byte); 93 | uint32_t err_code = NRF_SUCCESS; 94 | if (rx_done) 95 | { 96 | *p_byte = rx_buffer[0]; 97 | } 98 | else 99 | { 100 | err_code = NRF_ERROR_NOT_FOUND; 101 | } 102 | return err_code; 103 | } 104 | 105 | uint32_t app_uart_put(uint8_t byte) 106 | { 107 | tx_buffer[0] = byte; 108 | ret_code_t ret = nrf_drv_uart_tx(tx_buffer,1); 109 | if (NRF_ERROR_BUSY == ret) 110 | { 111 | return NRF_ERROR_NO_MEM; 112 | } 113 | else if (ret != NRF_SUCCESS) 114 | { 115 | return NRF_ERROR_INTERNAL; 116 | } 117 | else 118 | { 119 | return NRF_SUCCESS; 120 | } 121 | } 122 | 123 | uint32_t app_uart_flush(void) 124 | { 125 | return NRF_SUCCESS; 126 | } 127 | 128 | uint32_t app_uart_close(void) 129 | { 130 | nrf_drv_uart_uninit(); 131 | return NRF_SUCCESS; 132 | } 133 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/util/app_error.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 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 | 13 | /** @file 14 | * 15 | * @defgroup app_error Common application error handler 16 | * @{ 17 | * @ingroup app_common 18 | * 19 | * @brief Common application error handler. 20 | */ 21 | 22 | #include "nrf.h" 23 | #include 24 | #include "app_error.h" 25 | #include "nordic_common.h" 26 | #include "sdk_errors.h" 27 | #include "nrf_log.h" 28 | 29 | #ifdef DEBUG 30 | //#include "bsp.h" 31 | #endif 32 | 33 | 34 | 35 | /**@brief Function for error handling, which is called when an error has occurred. 36 | * 37 | * @warning This handler is an example only and does not fit a final product. You need to analyze 38 | * how your product is supposed to react in case of error. 39 | * 40 | * @param[in] error_code Error code supplied to the handler. 41 | * @param[in] line_num Line number where the handler is called. 42 | * @param[in] p_file_name Pointer to the file name. 43 | */ 44 | 45 | /*lint -save -e14 */ 46 | void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) 47 | { 48 | error_info_t error_info = 49 | { 50 | .line_num = line_num, 51 | .p_file_name = p_file_name, 52 | .err_code = error_code, 53 | }; 54 | app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info)); 55 | 56 | UNUSED_VARIABLE(error_info); 57 | } 58 | 59 | /*lint -save -e14 */ 60 | void app_error_handler_bare(ret_code_t error_code) 61 | { 62 | error_info_t error_info = 63 | { 64 | .line_num = 0, 65 | .p_file_name = NULL, 66 | .err_code = error_code, 67 | }; 68 | app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info)); 69 | 70 | UNUSED_VARIABLE(error_info); 71 | } 72 | 73 | 74 | void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info) 75 | { 76 | /* static error variables - in order to prevent removal by optimizers */ 77 | static volatile struct 78 | { 79 | uint32_t fault_id; 80 | uint32_t pc; 81 | uint32_t error_info; 82 | assert_info_t * p_assert_info; 83 | error_info_t * p_error_info; 84 | ret_code_t err_code; 85 | uint32_t line_num; 86 | const uint8_t * p_file_name; 87 | } m_error_data = {0}; 88 | 89 | // The following variable helps Keil keep the call stack visible, in addition, it can be set to 90 | // 0 in the debugger to continue executing code after the error check. 91 | volatile bool loop = true; 92 | UNUSED_VARIABLE(loop); 93 | 94 | m_error_data.fault_id = id; 95 | m_error_data.pc = pc; 96 | m_error_data.error_info = info; 97 | 98 | switch (id) 99 | { 100 | case NRF_FAULT_ID_SDK_ASSERT: 101 | m_error_data.p_assert_info = (assert_info_t *)info; 102 | m_error_data.line_num = m_error_data.p_assert_info->line_num; 103 | m_error_data.p_file_name = m_error_data.p_assert_info->p_file_name; 104 | break; 105 | 106 | case NRF_FAULT_ID_SDK_ERROR: 107 | m_error_data.p_error_info = (error_info_t *)info; 108 | m_error_data.err_code = m_error_data.p_error_info->err_code; 109 | m_error_data.line_num = m_error_data.p_error_info->line_num; 110 | m_error_data.p_file_name = m_error_data.p_error_info->p_file_name; 111 | break; 112 | } 113 | 114 | UNUSED_VARIABLE(m_error_data); 115 | 116 | // If printing is disrupted, remove the irq calls, or set the loop variable to 0 in the debugger. 117 | __disable_irq(); 118 | 119 | while(loop); 120 | 121 | __enable_irq(); 122 | } 123 | 124 | /*lint -restore */ 125 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/util/app_error_weak.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 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 | 13 | #ifndef APP_ERROR_WEAK_H__ 14 | #define APP_ERROR_WEAK_H__ 15 | 16 | /** @file 17 | * 18 | * @defgroup app_error Common application error handler 19 | * @{ 20 | * @ingroup app_common 21 | * 22 | * @brief Common application error handler. 23 | */ 24 | 25 | /**@brief Callback function for asserts in the SoftDevice. 26 | * 27 | * @details A pointer to this function will be passed to the SoftDevice. This function will be 28 | * called by the SoftDevice if certain unrecoverable errors occur within the 29 | * application or SoftDevice. 30 | * 31 | * See @ref nrf_fault_handler_t for more details. 32 | * 33 | * @param[in] id Fault identifier. See @ref NRF_FAULT_IDS. 34 | * @param[in] pc The program counter of the instruction that triggered the fault, or 0 if 35 | * unavailable. 36 | * @param[in] info Optional additional information regarding the fault. Refer to each fault 37 | * identifier for details. 38 | * 39 | * @remarks Function is implemented as weak so that it can be overwritten by custom application 40 | * error handler when needed. 41 | */ 42 | #ifdef __CC_ARM 43 | void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info); 44 | #else 45 | __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info); 46 | #endif 47 | 48 | 49 | /** @} */ 50 | 51 | #endif // APP_ERROR_WEAK_H__ 52 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/util/app_util_platform.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 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 | 13 | #include "app_util_platform.h" 14 | 15 | static uint32_t m_in_critical_region = 0; 16 | 17 | void app_util_disable_irq(void) 18 | { 19 | __disable_irq(); 20 | m_in_critical_region++; 21 | } 22 | 23 | void app_util_enable_irq(void) 24 | { 25 | m_in_critical_region--; 26 | if (m_in_critical_region == 0) 27 | { 28 | __enable_irq(); 29 | } 30 | } 31 | 32 | void app_util_critical_region_enter(uint8_t *p_nested) 33 | { 34 | #ifdef NRF52 35 | ASSERT(APP_LEVEL_PRIVILEGED == privilege_level_get()) 36 | #endif 37 | 38 | #if defined(SOFTDEVICE_PRESENT) 39 | /* return value can be safely ignored */ 40 | (void) sd_nvic_critical_region_enter(p_nested); 41 | #else 42 | app_util_disable_irq(); 43 | #endif 44 | } 45 | 46 | void app_util_critical_region_exit(uint8_t nested) 47 | { 48 | #ifdef NRF52 49 | ASSERT(APP_LEVEL_PRIVILEGED == privilege_level_get()) 50 | #endif 51 | 52 | #if defined(SOFTDEVICE_PRESENT) 53 | /* return value can be safely ignored */ 54 | (void) sd_nvic_critical_region_exit(nested); 55 | #else 56 | app_util_enable_irq(); 57 | #endif 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/util/common.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 | 13 | #ifndef COMMON_H 14 | #define COMMON_H 15 | 16 | /*lint ++flb "Enter library region" */ 17 | 18 | #include 19 | #include 20 | 21 | /* @file 22 | * @brief Common header file for generic macros and definitions 23 | * 24 | */ 25 | 26 | /* 27 | * GPIO glue macros, this can be used to define a pin number in source/header file and use that macro for pin 28 | * configuration using this expansion. 29 | * example: 30 | * #define RESET_PIN 8 31 | * NRF_GPIO->PINCNF(RESET_PIN) = XXX ; // Expanded NRF_GPIO->PIN_CNF[8] = XXX 32 | */ 33 | #define PINX_GLUE(x, y, z) x##y##_##z /*!< first level glue for pin macros */ 34 | #define PINCNF(p) PINX_GLUE(PIN,p,CNF) /*!< gpio configure pin number 'p' */ 35 | #define PINOUT(p) PINX_GLUE(PIN,p,OUT) /*!< gpio out pin number 'p' */ 36 | 37 | /*lint --flb "Leave library region" */ 38 | #endif 39 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/util/nordic_common.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 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 | /** @file 13 | * @brief Common defines and macros for firmware developed by Nordic Semiconductor. 14 | */ 15 | 16 | #ifndef NORDIC_COMMON_H__ 17 | #define NORDIC_COMMON_H__ 18 | 19 | /** The upper 8 bits of a 32 bit value */ 20 | //lint -emacro(572,MSB) // Suppress warning 572 "Excessive shift value" 21 | #define MSB_32(a) (((a) & 0xFF000000) >> 24) 22 | /** The lower 8 bits (of a 32 bit value) */ 23 | #define LSB_32(a) ((a) & 0x000000FF) 24 | 25 | /** The upper 8 bits of a 16 bit value */ 26 | //lint -emacro(572,MSB_16) // Suppress warning 572 "Excessive shift value" 27 | #define MSB_16(a) (((a) & 0xFF00) >> 8) 28 | /** The lower 8 bits (of a 16 bit value) */ 29 | #define LSB_16(a) ((a) & 0x00FF) 30 | 31 | /** Leaves the minimum of the two 32-bit arguments */ 32 | /*lint -emacro(506, MIN) */ /* Suppress "Constant value Boolean */ 33 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) 34 | /** Leaves the maximum of the two 32-bit arguments */ 35 | /*lint -emacro(506, MAX) */ /* Suppress "Constant value Boolean */ 36 | #define MAX(a, b) ((a) < (b) ? (b) : (a)) 37 | 38 | /** Concatenates two parameters. Useful as a second level of indirection, 39 | * when a parameter can be macro itself. */ 40 | #define CONCAT_2(p1, p2) p1##p2 41 | /** Concatenates three parameters. Useful as a second level of indirection, 42 | * when a parameter can be macro itself. */ 43 | #define CONCAT_3(p1, p2, p3) p1##p2##p3 44 | 45 | /**@brief Set a bit in the uint32 word. 46 | * 47 | * @param[in] W Word whose bit is being set. 48 | * @param[in] B Bit number in the word to be set. 49 | */ 50 | #define SET_BIT(W,B) ((W) |= (uint32_t)(1U << (B))) 51 | 52 | 53 | /**@brief Clears a bit in the uint32 word. 54 | * 55 | * @param[in] W Word whose bit is to be cleared. 56 | * @param[in] B Bit number in the word to be cleared. 57 | */ 58 | #define CLR_BIT(W, B) ((W) &= (~((uint32_t)1 << (B)))) 59 | 60 | 61 | /**@brief Checks if a bit is set. 62 | * 63 | * @param[in] W Word whose bit is to be checked. 64 | * @param[in] B Bit number in the word to be checked. 65 | * 66 | * @retval 1 if bit is set. 67 | * @retval 0 if bit is not set. 68 | */ 69 | #define IS_SET(W,B) (((W) >> (B)) & 1) 70 | 71 | #define BIT_0 0x01 /**< The value of bit 0 */ 72 | #define BIT_1 0x02 /**< The value of bit 1 */ 73 | #define BIT_2 0x04 /**< The value of bit 2 */ 74 | #define BIT_3 0x08 /**< The value of bit 3 */ 75 | #define BIT_4 0x10 /**< The value of bit 4 */ 76 | #define BIT_5 0x20 /**< The value of bit 5 */ 77 | #define BIT_6 0x40 /**< The value of bit 6 */ 78 | #define BIT_7 0x80 /**< The value of bit 7 */ 79 | #define BIT_8 0x0100 /**< The value of bit 8 */ 80 | #define BIT_9 0x0200 /**< The value of bit 9 */ 81 | #define BIT_10 0x0400 /**< The value of bit 10 */ 82 | #define BIT_11 0x0800 /**< The value of bit 11 */ 83 | #define BIT_12 0x1000 /**< The value of bit 12 */ 84 | #define BIT_13 0x2000 /**< The value of bit 13 */ 85 | #define BIT_14 0x4000 /**< The value of bit 14 */ 86 | #define BIT_15 0x8000 /**< The value of bit 15 */ 87 | #define BIT_16 0x00010000 /**< The value of bit 16 */ 88 | #define BIT_17 0x00020000 /**< The value of bit 17 */ 89 | #define BIT_18 0x00040000 /**< The value of bit 18 */ 90 | #define BIT_19 0x00080000 /**< The value of bit 19 */ 91 | #define BIT_20 0x00100000 /**< The value of bit 20 */ 92 | #define BIT_21 0x00200000 /**< The value of bit 21 */ 93 | #define BIT_22 0x00400000 /**< The value of bit 22 */ 94 | #define BIT_23 0x00800000 /**< The value of bit 23 */ 95 | #define BIT_24 0x01000000 /**< The value of bit 24 */ 96 | #define BIT_25 0x02000000 /**< The value of bit 25 */ 97 | #define BIT_26 0x04000000 /**< The value of bit 26 */ 98 | #define BIT_27 0x08000000 /**< The value of bit 27 */ 99 | #define BIT_28 0x10000000 /**< The value of bit 28 */ 100 | #define BIT_29 0x20000000 /**< The value of bit 29 */ 101 | #define BIT_30 0x40000000 /**< The value of bit 30 */ 102 | #define BIT_31 0x80000000 /**< The value of bit 31 */ 103 | 104 | #define UNUSED_VARIABLE(X) ((void)(X)) 105 | #define UNUSED_PARAMETER(X) UNUSED_VARIABLE(X) 106 | #define UNUSED_RETURN_VALUE(X) UNUSED_VARIABLE(X) 107 | 108 | #endif // NORDIC_COMMON_H__ 109 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/util/nrf_assert.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2006 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 | #include "nrf_assert.h" 13 | #include "app_error.h" 14 | #include "nordic_common.h" 15 | 16 | #if defined(DEBUG_NRF) 17 | void assert_nrf_callback(uint16_t line_num, const uint8_t * file_name) 18 | { 19 | assert_info_t assert_info = 20 | { 21 | .line_num = line_num, 22 | .p_file_name = file_name, 23 | }; 24 | app_error_fault_handler(NRF_FAULT_ID_SDK_ASSERT, 0, (uint32_t)(&assert_info)); 25 | 26 | UNUSED_VARIABLE(assert_info); 27 | } 28 | #endif /* DEBUG_NRF */ 29 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/util/nrf_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | 10 | /** @file 11 | * @brief Utilities for verifying program logic 12 | */ 13 | 14 | #ifndef NRF_ASSERT_H_ 15 | #define NRF_ASSERT_H_ 16 | 17 | #include 18 | #include "nrf.h" 19 | #include "app_error.h" 20 | 21 | #if defined(DEBUG_NRF) || defined(DEBUG_NRF_USER) 22 | 23 | /** @brief Function for handling assertions. 24 | * 25 | * 26 | * @note 27 | * This function is called when an assertion has triggered. 28 | * 29 | * 30 | * @post 31 | * All hardware is put into an idle non-emitting state (in particular the radio is highly 32 | * important to switch off since the radio might be in a state that makes it send 33 | * packets continiously while a typical final infinit ASSERT loop is executing). 34 | * 35 | * 36 | * @param line_num The line number where the assertion is called 37 | * @param file_name Pointer to the file name 38 | */ 39 | void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name); 40 | 41 | /*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */ 42 | /*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \ 43 | 44 | /** @brief Function for checking intended for production code. 45 | * 46 | * Check passes if "expr" evaluates to true. */ 47 | #define ASSERT(expr) \ 48 | if (expr) \ 49 | { \ 50 | } \ 51 | else \ 52 | { \ 53 | assert_nrf_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \ 54 | } 55 | #else 56 | #define ASSERT(expr) //!< Assert empty when disabled 57 | __WEAK void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name); 58 | #endif /* defined(DEBUG_NRF) || defined(DEBUG_NRF_USER) */ 59 | 60 | #endif /* NRF_ASSERT_H_ */ 61 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/util/sdk_macros.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /** @cond */ 14 | /**@file 15 | * 16 | * @ingroup sdk_util 17 | * @defgroup sdk_common_macros SDK Common Header 18 | * @breif Macros for parameter checking and similar tasks 19 | * @{ 20 | */ 21 | 22 | #ifndef SDK_MACROS_H__ 23 | #define SDK_MACROS_H__ 24 | 25 | /**@brief Macro for verifying that the module is initialized. It will cause the function to return 26 | * @ref NRF_ERROR_INVALID_STATE if not. 27 | */ 28 | #ifdef DISABLE_PARAM_CHECK 29 | #define VERIFY_MODULE_INITIALIZED() 30 | #else 31 | #ifdef MODULE_INITIALIZED 32 | #define VERIFY_MODULE_INITIALIZED() \ 33 | do \ 34 | { \ 35 | if (!MODULE_INITIALIZED) \ 36 | { \ 37 | return NRF_ERROR_INVALID_STATE; \ 38 | } \ 39 | } while(0) 40 | #else 41 | #define VERIFY_MODULE_INITIALIZED() 42 | #endif /* MODULE_INITIALIZED */ 43 | #endif /* DISABLE_PARAM_CHECK */ 44 | 45 | 46 | /**@brief Macro for verifying that the module is initialized. It will cause the function to return 47 | * if not. 48 | */ 49 | #ifdef DISABLE_PARAM_CHECK 50 | #define VERIFY_MODULE_INITIALIZED_VOID() 51 | #else 52 | #ifdef MODULE_INITIALIZED 53 | #define VERIFY_MODULE_INITIALIZED_VOID() \ 54 | do \ 55 | { \ 56 | if (!MODULE_INITIALIZED) \ 57 | { \ 58 | return; \ 59 | } \ 60 | } while(0) 61 | #else 62 | #define VERIFY_MODULE_INITIALIZED_VOID() 63 | #endif /* MODULE_INITIALIZED */ 64 | #endif /* DISABLE_PARAM_CHECK */ 65 | 66 | 67 | 68 | 69 | /** @} */ 70 | /** @endcond */ 71 | #endif // SDK_MACROS_H__ 72 | 73 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/util/sdk_os.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /** @cond */ 14 | /**@file 15 | * 16 | * @defgroup sdk_os SDK OS Abstraction 17 | * @ingroup experimental_api 18 | * @details In order to made SDK modules independent of use of an embedded OS, and permit 19 | * application with varied task architecture, SDK abstracts the OS specific 20 | * elements here in order to make all other modules agnostic to the OS or task 21 | * architecture. 22 | * @{ 23 | */ 24 | 25 | #ifndef SDK_OS_H__ 26 | #define SDK_OS_H__ 27 | 28 | #define SDK_MUTEX_DEFINE(X) 29 | #define SDK_MUTEX_INIT(X) 30 | #define SDK_MUTEX_LOCK(X) 31 | #define SDK_MUTEX_UNLOCK(X) 32 | 33 | /** 34 | * @defgroup os_data_type Data types. 35 | */ 36 | 37 | /** @} */ 38 | /** @endcond */ 39 | #endif // SDK_OS_H__ 40 | 41 | -------------------------------------------------------------------------------- /lib/sdk11/components/libraries/util/sdk_resources.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 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 | /** @file 13 | * @brief Definition file for resource usage by SoftDevice, ESB and Gazell. 14 | */ 15 | 16 | #ifndef APP_RESOURCES_H__ 17 | #define APP_RESOURCES_H__ 18 | 19 | #ifdef SOFTDEVICE_PRESENT 20 | #include "nrf_sd_def.h" 21 | #else 22 | #define SD_PPI_RESTRICTED 0uL /**< 1 if PPI peripheral is restricted, 0 otherwise. */ 23 | #define SD_PPI_CHANNELS_USED 0uL /**< PPI channels utilized by SotfDevice (not available to th spplication). */ 24 | #define SD_PPI_GROUPS_USED 0uL /**< PPI groups utilized by SotfDevice (not available to th spplication). */ 25 | #define SD_TIMERS_USED 0uL /**< Timers used by SoftDevice. */ 26 | #define SD_SWI_USED 0uL /**< Software interrupts used by SoftDevice. */ 27 | #endif 28 | 29 | #ifdef GAZELL_PRESENT 30 | #include "nrf_gzll_resources.h" 31 | #else 32 | #define GZLL_PPI_CHANNELS_USED 0uL /**< PPI channels utilized by Gazell (not available to th spplication). */ 33 | #define GZLL_TIMERS_USED 0uL /**< Timers used by Gazell. */ 34 | #define GZLL_SWI_USED 0uL /**< Software interrupts used by Gazell */ 35 | #endif 36 | 37 | #ifdef ESB_PRESENT 38 | #include "nrf_esb_resources.h" 39 | #else 40 | #define ESB_PPI_CHANNELS_USED 0uL /**< PPI channels utilized by ESB (not available to th spplication). */ 41 | #define ESB_TIMERS_USED 0uL /**< Timers used by ESB. */ 42 | #define ESB_SWI_USED 0uL /**< Software interrupts used by ESB */ 43 | #endif 44 | 45 | #define NRF_PPI_CHANNELS_USED (SD_PPI_CHANNELS_USED | GZLL_PPI_CHANNELS_USED | ESB_PPI_CHANNELS_USED) 46 | #define NRF_PPI_GROUPS_USED (SD_PPI_GROUPS_USED) 47 | #define NRF_SWI_USED (SD_SWI_USED | GZLL_SWI_USED | ESB_SWI_USED) 48 | #define NRF_TIMERS_USED (SD_TIMERS_USED | GZLL_TIMERS_USED | ESB_TIMERS_USED) 49 | 50 | #endif // APP_RESOURCES_H__ 51 | -------------------------------------------------------------------------------- /lib/sdk11/components/toolchain/cmsis/include/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /lib/sdk11/components/toolchain/cmsis/include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /lib/sdk11/components/toolchain/cmsis/include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /lib/sdk11/components/toolchain/cmsis/include/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /lib/sdk11/components/toolchain/gcc/nrf52_common.ld: -------------------------------------------------------------------------------- 1 | /* Linker script for Nordic Semiconductor nRF52 devices 2 | * 3 | * Version: Sourcery G++ 4.5-1 4 | * Support: https://support.codesourcery.com/GNUToolchain/ 5 | * 6 | * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc. 7 | * 8 | * The authors hereby grant permission to use, copy, modify, distribute, 9 | * and license this software and its documentation for any purpose, provided 10 | * that existing copyright notices are retained in all copies and that this 11 | * notice is included verbatim in any distributions. No written agreement, 12 | * license, or royalty fee is required for any of the authorized uses. 13 | * Modifications to this software may be copyrighted by their authors 14 | * and need not follow the licensing terms described here, provided that 15 | * the new terms are clearly indicated on the first page of each file where 16 | * they apply. 17 | */ 18 | OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") 19 | 20 | /* Linker script to place sections and symbol values. Should be used together 21 | * with other linker script that defines memory regions FLASH and RAM. 22 | * It references following symbols, which must be defined in code: 23 | * Reset_Handler : Entry of reset handler 24 | * 25 | * It defines following symbols, which code can use without definition: 26 | * __exidx_start 27 | * __exidx_end 28 | * __etext 29 | * __data_start__ 30 | * __preinit_array_start 31 | * __preinit_array_end 32 | * __init_array_start 33 | * __init_array_end 34 | * __fini_array_start 35 | * __fini_array_end 36 | * __data_end__ 37 | * __bss_start__ 38 | * __bss_end__ 39 | * __end__ 40 | * end 41 | * __HeapLimit 42 | * __StackLimit 43 | * __StackTop 44 | * __stack 45 | */ 46 | ENTRY(Reset_Handler) 47 | 48 | SECTIONS 49 | { 50 | .text : 51 | { 52 | KEEP(*(.isr_vector)) 53 | *(.text*) 54 | 55 | KEEP(*(.init)) 56 | KEEP(*(.fini)) 57 | 58 | /* .ctors */ 59 | *crtbegin.o(.ctors) 60 | *crtbegin?.o(.ctors) 61 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) 62 | *(SORT(.ctors.*)) 63 | *(.ctors) 64 | 65 | /* .dtors */ 66 | *crtbegin.o(.dtors) 67 | *crtbegin?.o(.dtors) 68 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) 69 | *(SORT(.dtors.*)) 70 | *(.dtors) 71 | 72 | *(.rodata*) 73 | 74 | KEEP(*(.eh_frame*)) 75 | } > FLASH 76 | 77 | .ARM.extab : 78 | { 79 | *(.ARM.extab* .gnu.linkonce.armextab.*) 80 | } > FLASH 81 | 82 | __exidx_start = .; 83 | .ARM.exidx : 84 | { 85 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 86 | } > FLASH 87 | __exidx_end = .; 88 | 89 | __etext = .; 90 | 91 | .data : AT (__etext) 92 | { 93 | __data_start__ = .; 94 | *(vtable) 95 | *(.data*) 96 | 97 | . = ALIGN(4); 98 | /* preinit data */ 99 | PROVIDE_HIDDEN (__preinit_array_start = .); 100 | KEEP(*(.preinit_array)) 101 | PROVIDE_HIDDEN (__preinit_array_end = .); 102 | 103 | . = ALIGN(4); 104 | /* init data */ 105 | PROVIDE_HIDDEN (__init_array_start = .); 106 | KEEP(*(SORT(.init_array.*))) 107 | KEEP(*(.init_array)) 108 | PROVIDE_HIDDEN (__init_array_end = .); 109 | 110 | 111 | . = ALIGN(4); 112 | /* finit data */ 113 | PROVIDE_HIDDEN (__fini_array_start = .); 114 | KEEP(*(SORT(.fini_array.*))) 115 | KEEP(*(.fini_array)) 116 | PROVIDE_HIDDEN (__fini_array_end = .); 117 | 118 | KEEP(*(.jcr*)) 119 | . = ALIGN(4); 120 | /* All data end */ 121 | __data_end__ = .; 122 | 123 | } > RAM 124 | 125 | .bss : 126 | { 127 | . = ALIGN(4); 128 | __bss_start__ = .; 129 | *(.bss*) 130 | *(COMMON) 131 | . = ALIGN(4); 132 | __bss_end__ = .; 133 | } > RAM 134 | 135 | .heap (COPY): 136 | { 137 | __end__ = .; 138 | PROVIDE(end = .); 139 | *(.heap*) 140 | __HeapLimit = .; 141 | } > RAM 142 | 143 | /* .stack_dummy section doesn't contains any symbols. It is only 144 | * used for linker to calculate size of stack sections, and assign 145 | * values to stack symbols later */ 146 | .stack_dummy (COPY): 147 | { 148 | *(.stack*) 149 | } > RAM 150 | 151 | /* Set stack top to end of RAM, and stack limit move down by 152 | * size of stack_dummy section */ 153 | __StackTop = ORIGIN(RAM) + LENGTH(RAM); 154 | __StackLimit = __StackTop - SIZEOF(.stack_dummy); 155 | PROVIDE(__stack = __StackTop); 156 | 157 | /* Check if data + heap + stack exceeds RAM limit */ 158 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") 159 | } 160 | 161 | -------------------------------------------------------------------------------- /lib/sdk11/components/toolchain/gcc/nrf52_xxaa.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 = 0x00000000, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 10 | } 11 | 12 | 13 | INCLUDE "nrf52_common.ld" 14 | -------------------------------------------------------------------------------- /lib/sdk11/components/toolchain/gcc/nrf5x_common.ld: -------------------------------------------------------------------------------- 1 | /* Linker script for Nordic Semiconductor nRF51 devices 2 | * 3 | * Version: Sourcery G++ 4.5-1 4 | * Support: https://support.codesourcery.com/GNUToolchain/ 5 | * 6 | * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc. 7 | * 8 | * The authors hereby grant permission to use, copy, modify, distribute, 9 | * and license this software and its documentation for any purpose, provided 10 | * that existing copyright notices are retained in all copies and that this 11 | * notice is included verbatim in any distributions. No written agreement, 12 | * license, or royalty fee is required for any of the authorized uses. 13 | * Modifications to this software may be copyrighted by their authors 14 | * and need not follow the licensing terms described here, provided that 15 | * the new terms are clearly indicated on the first page of each file where 16 | * they apply. 17 | */ 18 | OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") 19 | 20 | /* Linker script to place sections and symbol values. Should be used together 21 | * with other linker script that defines memory regions FLASH and RAM. 22 | * It references following symbols, which must be defined in code: 23 | * Reset_Handler : Entry of reset handler 24 | * 25 | * It defines following symbols, which code can use without definition: 26 | * __exidx_start 27 | * __exidx_end 28 | * __etext 29 | * __data_start__ 30 | * __preinit_array_start 31 | * __preinit_array_end 32 | * __init_array_start 33 | * __init_array_end 34 | * __fini_array_start 35 | * __fini_array_end 36 | * __data_end__ 37 | * __bss_start__ 38 | * __bss_end__ 39 | * __end__ 40 | * end 41 | * __HeapLimit 42 | * __StackLimit 43 | * __StackTop 44 | * __stack 45 | */ 46 | ENTRY(Reset_Handler) 47 | 48 | SECTIONS 49 | { 50 | .text : 51 | { 52 | KEEP(*(.isr_vector)) 53 | *(.text*) 54 | 55 | KEEP(*(.init)) 56 | KEEP(*(.fini)) 57 | 58 | /* .ctors */ 59 | *crtbegin.o(.ctors) 60 | *crtbegin?.o(.ctors) 61 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) 62 | *(SORT(.ctors.*)) 63 | *(.ctors) 64 | 65 | /* .dtors */ 66 | *crtbegin.o(.dtors) 67 | *crtbegin?.o(.dtors) 68 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) 69 | *(SORT(.dtors.*)) 70 | *(.dtors) 71 | 72 | *(.rodata*) 73 | 74 | KEEP(*(.eh_frame*)) 75 | } > FLASH 76 | 77 | .ARM.extab : 78 | { 79 | *(.ARM.extab* .gnu.linkonce.armextab.*) 80 | } > FLASH 81 | 82 | __exidx_start = .; 83 | .ARM.exidx : 84 | { 85 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 86 | } > FLASH 87 | __exidx_end = .; 88 | 89 | __etext = .; 90 | 91 | .data : AT (__etext) 92 | { 93 | __data_start__ = .; 94 | *(vtable) 95 | *(.data*) 96 | 97 | . = ALIGN(4); 98 | /* preinit data */ 99 | PROVIDE_HIDDEN (__preinit_array_start = .); 100 | KEEP(*(.preinit_array)) 101 | PROVIDE_HIDDEN (__preinit_array_end = .); 102 | 103 | . = ALIGN(4); 104 | /* init data */ 105 | PROVIDE_HIDDEN (__init_array_start = .); 106 | KEEP(*(SORT(.init_array.*))) 107 | KEEP(*(.init_array)) 108 | PROVIDE_HIDDEN (__init_array_end = .); 109 | 110 | 111 | . = ALIGN(4); 112 | /* finit data */ 113 | PROVIDE_HIDDEN (__fini_array_start = .); 114 | KEEP(*(SORT(.fini_array.*))) 115 | KEEP(*(.fini_array)) 116 | PROVIDE_HIDDEN (__fini_array_end = .); 117 | 118 | KEEP(*(.jcr*)) 119 | . = ALIGN(4); 120 | /* All data end */ 121 | __data_end__ = .; 122 | 123 | } > RAM 124 | 125 | .bss : 126 | { 127 | . = ALIGN(4); 128 | __bss_start__ = .; 129 | *(.bss*) 130 | *(COMMON) 131 | . = ALIGN(4); 132 | __bss_end__ = .; 133 | } > RAM 134 | 135 | .heap (COPY): 136 | { 137 | __end__ = .; 138 | PROVIDE(end = .); 139 | *(.heap*) 140 | __HeapLimit = .; 141 | } > RAM 142 | 143 | /* .stack_dummy section doesn't contains any symbols. It is only 144 | * used for linker to calculate size of stack sections, and assign 145 | * values to stack symbols later */ 146 | .stack_dummy (COPY): 147 | { 148 | *(.stack*) 149 | } > RAM 150 | 151 | /* Set stack top to end of RAM, and stack limit move down by 152 | * size of stack_dummy section */ 153 | __StackTop = ORIGIN(RAM) + LENGTH(RAM); 154 | __StackLimit = __StackTop - SIZEOF(.stack_dummy); 155 | PROVIDE(__stack = __StackTop); 156 | 157 | /* Check if data + heap + stack exceeds RAM limit */ 158 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") 159 | } 160 | 161 | -------------------------------------------------------------------------------- /lib/sdk11/components/toolchain/system_nrf52.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Nordic Semiconductor ASA 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 14 | * * Neither the name of Nordic Semiconductor ASA nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (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 | 31 | #ifndef SYSTEM_NRF52_H 32 | #define SYSTEM_NRF52_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include 39 | 40 | 41 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 42 | 43 | /** 44 | * Initialize the system 45 | * 46 | * @param none 47 | * @return none 48 | * 49 | * @brief Setup the microcontroller system. 50 | * Initialize the System and update the SystemCoreClock variable. 51 | */ 52 | extern void SystemInit (void); 53 | 54 | /** 55 | * Update SystemCoreClock variable 56 | * 57 | * @param none 58 | * @return none 59 | * 60 | * @brief Updates the SystemCoreClock with current core Clock 61 | * retrieved from cpu registers. 62 | */ 63 | extern void SystemCoreClockUpdate (void); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* SYSTEM_NRF52_H */ 70 | -------------------------------------------------------------------------------- /lib/softdevice/s132/2.0.1/headers/ble_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of other 16 | * contributors to this software may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * 4. This software must only be used in a processor manufactured by Nordic 20 | * Semiconductor ASA, or in a processor manufactured by a third party that 21 | * is used in combination with a processor manufactured by Nordic Semiconductor. 22 | * 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | /** 38 | @addtogroup BLE_COMMON 39 | @{ 40 | @addtogroup nrf_error 41 | @{ 42 | @ingroup BLE_COMMON 43 | @} 44 | 45 | @defgroup ble_err General error codes 46 | @{ 47 | 48 | @brief General error code definitions for the BLE API. 49 | 50 | @ingroup BLE_COMMON 51 | */ 52 | #ifndef NRF_BLE_ERR_H__ 53 | #define NRF_BLE_ERR_H__ 54 | 55 | #include "nrf_error.h" 56 | 57 | #ifdef __cplusplus 58 | extern "C" { 59 | #endif 60 | 61 | /* @defgroup BLE_ERRORS Error Codes 62 | * @{ */ 63 | #define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */ 64 | #define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */ 65 | #define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */ 66 | #define BLE_ERROR_NO_TX_PACKETS (NRF_ERROR_STK_BASE_NUM+0x004) /**< Not enough application packets available on this connection. */ 67 | #define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x005) /**< Invalid role. */ 68 | /** @} */ 69 | 70 | 71 | /** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges 72 | * @brief Assignment of subranges for module specific error codes. 73 | * @note For specific error codes, see ble_.h or ble_error_.h. 74 | * @{ */ 75 | #define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */ 76 | #define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */ 77 | #define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */ 78 | #define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */ 79 | /** @} */ 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | #endif 85 | 86 | 87 | /** 88 | @} 89 | @} 90 | */ 91 | -------------------------------------------------------------------------------- /lib/softdevice/s132/2.0.1/headers/nrf_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of other 16 | * contributors to this software may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * 4. This software must only be used in a processor manufactured by Nordic 20 | * Semiconductor ASA, or in a processor manufactured by a third party that 21 | * is used in combination with a processor manufactured by Nordic Semiconductor. 22 | * 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | /** 37 | @defgroup nrf_error SoftDevice Global Error Codes 38 | @{ 39 | 40 | @brief Global Error definitions 41 | */ 42 | 43 | /* Header guard */ 44 | #ifndef NRF_ERROR_H__ 45 | #define NRF_ERROR_H__ 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions 52 | * @{ */ 53 | #define NRF_ERROR_BASE_NUM (0x0) ///< Global error base 54 | #define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base 55 | #define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base 56 | #define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base 57 | /** @} */ 58 | 59 | #define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command 60 | #define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing 61 | #define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled 62 | #define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error 63 | #define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation 64 | #define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found 65 | #define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported 66 | #define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter 67 | #define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state 68 | #define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length 69 | #define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags 70 | #define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data 71 | #define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Invalid Data size 72 | #define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out 73 | #define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer 74 | #define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation 75 | #define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address 76 | #define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy 77 | #define NRF_ERROR_CONN_COUNT (NRF_ERROR_BASE_NUM + 18) ///< Maximum connection count exceeded. 78 | #define NRF_ERROR_RESOURCES (NRF_ERROR_BASE_NUM + 19) ///< Not enough resources for operation 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #endif // NRF_ERROR_H__ 84 | 85 | /** 86 | @} 87 | */ 88 | -------------------------------------------------------------------------------- /lib/softdevice/s132/2.0.1/headers/nrf_error_sdm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of other 16 | * contributors to this software may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * 4. This software must only be used in a processor manufactured by Nordic 20 | * Semiconductor ASA, or in a processor manufactured by a third party that 21 | * is used in combination with a processor manufactured by Nordic Semiconductor. 22 | * 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | /** 37 | @addtogroup nrf_sdm_api 38 | @{ 39 | @defgroup nrf_sdm_error SoftDevice Manager Error Codes 40 | @{ 41 | 42 | @brief Error definitions for the SDM API 43 | */ 44 | 45 | /* Header guard */ 46 | #ifndef NRF_ERROR_SDM_H__ 47 | #define NRF_ERROR_SDM_H__ 48 | 49 | #include "nrf_error.h" 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | #define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown lfclk source. 56 | #define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts). 57 | #define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing). 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | #endif // NRF_ERROR_SDM_H__ 63 | 64 | /** 65 | @} 66 | @} 67 | */ 68 | -------------------------------------------------------------------------------- /lib/softdevice/s132/2.0.1/headers/nrf_error_soc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of other 16 | * contributors to this software may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * 4. This software must only be used in a processor manufactured by Nordic 20 | * Semiconductor ASA, or in a processor manufactured by a third party that 21 | * is used in combination with a processor manufactured by Nordic Semiconductor. 22 | * 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | /** 37 | @addtogroup nrf_soc_api 38 | @{ 39 | @defgroup nrf_soc_error SoC Library Error Codes 40 | @{ 41 | 42 | @brief Error definitions for the SoC library 43 | 44 | */ 45 | 46 | /* Header guard */ 47 | #ifndef NRF_ERROR_SOC_H__ 48 | #define NRF_ERROR_SOC_H__ 49 | 50 | #include "nrf_error.h" 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /* Mutex Errors */ 56 | #define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken 57 | 58 | /* NVIC errors */ 59 | #define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available 60 | #define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed 61 | #define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return 62 | 63 | /* Power errors */ 64 | #define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown 65 | #define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown 66 | #define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return 67 | 68 | /* Rand errors */ 69 | #define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values 70 | 71 | /* PPI errors */ 72 | #define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel 73 | #define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | #endif // NRF_ERROR_SOC_H__ 79 | /** 80 | @} 81 | @} 82 | */ 83 | -------------------------------------------------------------------------------- /lib/softdevice/s132/2.0.1/headers/nrf_sd_def.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 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 | 13 | #ifndef NRF_SD_DEF_H__ 14 | #define NRF_SD_DEF_H__ 15 | 16 | #include 17 | 18 | #define SD_PPI_CHANNELS_USED 0xFFF0C000uL /**< PPI channels utilized by SotfDevice (not available to the application). */ 19 | #define SD_PPI_GROUPS_USED 0x0000000CuL /**< PPI groups utilized by SoftDevice (not available to the application). */ 20 | #define SD_TIMERS_USED 0x00000001uL /**< Timers used by SoftDevice. */ 21 | #define SD_SWI_USED 0x0000003CuL /**< Software interrupts used by SoftDevice */ 22 | 23 | #endif /* NRF_SD_DEF_H__ */ 24 | -------------------------------------------------------------------------------- /lib/softdevice/s132/2.0.1/headers/nrf_svc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of other 16 | * contributors to this software may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * 4. This software must only be used in a processor manufactured by Nordic 20 | * Semiconductor ASA, or in a processor manufactured by a third party that 21 | * is used in combination with a processor manufactured by Nordic Semiconductor. 22 | * 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | */ 36 | 37 | #ifndef NRF_SVC__ 38 | #define NRF_SVC__ 39 | 40 | #include "stdint.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #ifdef SVCALL_AS_NORMAL_FUNCTION 47 | #define SVCALL(number, return_type, signature) return_type signature 48 | #else 49 | 50 | #ifndef SVCALL 51 | #if defined (__CC_ARM) 52 | #define SVCALL(number, return_type, signature) return_type __svc(number) signature 53 | #elif defined (__GNUC__) 54 | #ifdef __cplusplus 55 | #define GCC_CAST_CPP (uint8_t) 56 | #else 57 | #define GCC_CAST_CPP 58 | #endif 59 | #define SVCALL(number, return_type, signature) \ 60 | _Pragma("GCC diagnostic push") \ 61 | _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ 62 | __attribute__((naked)) \ 63 | __attribute__((unused)) \ 64 | static return_type signature \ 65 | { \ 66 | __asm( \ 67 | "svc %0\n" \ 68 | "bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \ 69 | ); \ 70 | } \ 71 | _Pragma("GCC diagnostic pop") 72 | 73 | #elif defined (__ICCARM__) 74 | #define PRAGMA(x) _Pragma(#x) 75 | #define SVCALL(number, return_type, signature) \ 76 | PRAGMA(swi_number = (number)) \ 77 | __swi return_type signature; 78 | #else 79 | #define SVCALL(number, return_type, signature) return_type signature 80 | #endif 81 | #endif // SVCALL 82 | 83 | #endif // SVCALL_AS_NORMAL_FUNCTION 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | #endif // NRF_SVC__ 89 | -------------------------------------------------------------------------------- /lib/softdevice/s132/5.1.0/headers/ble_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | /** 40 | @addtogroup BLE_COMMON 41 | @{ 42 | @addtogroup nrf_error 43 | @{ 44 | @ingroup BLE_COMMON 45 | @} 46 | 47 | @defgroup ble_err General error codes 48 | @{ 49 | 50 | @brief General error code definitions for the BLE API. 51 | 52 | @ingroup BLE_COMMON 53 | */ 54 | #ifndef NRF_BLE_ERR_H__ 55 | #define NRF_BLE_ERR_H__ 56 | 57 | #include "nrf_error.h" 58 | 59 | #ifdef __cplusplus 60 | extern "C" { 61 | #endif 62 | 63 | /* @defgroup BLE_ERRORS Error Codes 64 | * @{ */ 65 | #define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */ 66 | #define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */ 67 | #define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */ 68 | #define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x004) /**< Invalid role. */ 69 | /** @} */ 70 | 71 | 72 | /** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges 73 | * @brief Assignment of subranges for module specific error codes. 74 | * @note For specific error codes, see ble_.h or ble_error_.h. 75 | * @{ */ 76 | #define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */ 77 | #define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */ 78 | #define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */ 79 | #define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */ 80 | /** @} */ 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | #endif 86 | 87 | 88 | /** 89 | @} 90 | @} 91 | */ 92 | -------------------------------------------------------------------------------- /lib/softdevice/s132/5.1.0/headers/nrf_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | /** 40 | @defgroup nrf_error SoftDevice Global Error Codes 41 | @{ 42 | 43 | @brief Global Error definitions 44 | */ 45 | 46 | /* Header guard */ 47 | #ifndef NRF_ERROR_H__ 48 | #define NRF_ERROR_H__ 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | /** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions 55 | * @{ */ 56 | #define NRF_ERROR_BASE_NUM (0x0) ///< Global error base 57 | #define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base 58 | #define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base 59 | #define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base 60 | /** @} */ 61 | 62 | #define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command 63 | #define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing 64 | #define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled 65 | #define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error 66 | #define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation 67 | #define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found 68 | #define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported 69 | #define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter 70 | #define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state 71 | #define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length 72 | #define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags 73 | #define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data 74 | #define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Invalid Data size 75 | #define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out 76 | #define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer 77 | #define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation 78 | #define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address 79 | #define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy 80 | #define NRF_ERROR_CONN_COUNT (NRF_ERROR_BASE_NUM + 18) ///< Maximum connection count exceeded. 81 | #define NRF_ERROR_RESOURCES (NRF_ERROR_BASE_NUM + 19) ///< Not enough resources for operation 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | #endif // NRF_ERROR_H__ 87 | 88 | /** 89 | @} 90 | */ 91 | -------------------------------------------------------------------------------- /lib/softdevice/s132/5.1.0/headers/nrf_error_sdm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | /** 40 | @addtogroup nrf_sdm_api 41 | @{ 42 | @defgroup nrf_sdm_error SoftDevice Manager Error Codes 43 | @{ 44 | 45 | @brief Error definitions for the SDM API 46 | */ 47 | 48 | /* Header guard */ 49 | #ifndef NRF_ERROR_SDM_H__ 50 | #define NRF_ERROR_SDM_H__ 51 | 52 | #include "nrf_error.h" 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | #define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown LFCLK source. 59 | #define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts). 60 | #define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erroneous SoftDevice flashing). 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #endif // NRF_ERROR_SDM_H__ 66 | 67 | /** 68 | @} 69 | @} 70 | */ 71 | -------------------------------------------------------------------------------- /lib/softdevice/s132/5.1.0/headers/nrf_error_soc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | /** 40 | @addtogroup nrf_soc_api 41 | @{ 42 | @defgroup nrf_soc_error SoC Library Error Codes 43 | @{ 44 | 45 | @brief Error definitions for the SoC library 46 | 47 | */ 48 | 49 | /* Header guard */ 50 | #ifndef NRF_ERROR_SOC_H__ 51 | #define NRF_ERROR_SOC_H__ 52 | 53 | #include "nrf_error.h" 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /* Mutex Errors */ 59 | #define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken 60 | 61 | /* NVIC errors */ 62 | #define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available 63 | #define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed 64 | #define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return 65 | 66 | /* Power errors */ 67 | #define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown 68 | #define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown 69 | #define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return 70 | 71 | /* Rand errors */ 72 | #define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values 73 | 74 | /* PPI errors */ 75 | #define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel 76 | #define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | #endif // NRF_ERROR_SOC_H__ 82 | /** 83 | @} 84 | @} 85 | */ 86 | -------------------------------------------------------------------------------- /lib/softdevice/s132/5.1.0/headers/nrf_svc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | #ifndef NRF_SVC__ 40 | #define NRF_SVC__ 41 | 42 | #include "stdint.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | #ifdef SVCALL_AS_NORMAL_FUNCTION 49 | #define SVCALL(number, return_type, signature) return_type signature 50 | #else 51 | 52 | #ifndef SVCALL 53 | #if defined (__CC_ARM) 54 | #define SVCALL(number, return_type, signature) return_type __svc(number) signature 55 | #elif defined (__GNUC__) 56 | #ifdef __cplusplus 57 | #define GCC_CAST_CPP (uint16_t) 58 | #else 59 | #define GCC_CAST_CPP 60 | #endif 61 | #define SVCALL(number, return_type, signature) \ 62 | _Pragma("GCC diagnostic push") \ 63 | _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ 64 | __attribute__((naked)) \ 65 | __attribute__((unused)) \ 66 | static return_type signature \ 67 | { \ 68 | __asm( \ 69 | "svc %0\n" \ 70 | "bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \ 71 | ); \ 72 | } \ 73 | _Pragma("GCC diagnostic pop") 74 | 75 | #elif defined (__ICCARM__) 76 | #define PRAGMA(x) _Pragma(#x) 77 | #define SVCALL(number, return_type, signature) \ 78 | PRAGMA(swi_number = (number)) \ 79 | __swi return_type signature; 80 | #else 81 | #define SVCALL(number, return_type, signature) return_type signature 82 | #endif 83 | #endif // SVCALL 84 | 85 | #endif // SVCALL_AS_NORMAL_FUNCTION 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | #endif // NRF_SVC__ 91 | -------------------------------------------------------------------------------- /lib/softdevice/s132/5.1.0/hex/s132_nrf52_5.1.0_license-agreement.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 - 2017, Nordic Semiconductor ASA 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form, except as embedded into a Nordic 11 | Semiconductor ASA integrated circuit in a product or a software update for 12 | such product, must reproduce the above copyright notice, this list of 13 | conditions and the following disclaimer in the documentation and/or other 14 | materials provided with the distribution. 15 | 16 | 3. Neither the name of Nordic Semiconductor ASA nor the names of its 17 | contributors may be used to endorse or promote products derived from this 18 | software without specific prior written permission. 19 | 20 | 4. This software, with or without modification, must only be used with a 21 | Nordic Semiconductor ASA integrated circuit. 22 | 23 | 5. Any software provided in binary form under this license must not be reverse 24 | engineered, decompiled, modified and/or disassembled. 25 | 26 | THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 27 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28 | OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 30 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 35 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /lib/softdevice/s132/6.0.0/headers/ble_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2018, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | /** 40 | @addtogroup BLE_COMMON 41 | @{ 42 | @addtogroup nrf_error 43 | @{ 44 | @ingroup BLE_COMMON 45 | @} 46 | 47 | @defgroup ble_err General error codes 48 | @{ 49 | 50 | @brief General error code definitions for the BLE API. 51 | 52 | @ingroup BLE_COMMON 53 | */ 54 | #ifndef NRF_BLE_ERR_H__ 55 | #define NRF_BLE_ERR_H__ 56 | 57 | #include "nrf_error.h" 58 | 59 | #ifdef __cplusplus 60 | extern "C" { 61 | #endif 62 | 63 | /* @defgroup BLE_ERRORS Error Codes 64 | * @{ */ 65 | #define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */ 66 | #define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */ 67 | #define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */ 68 | #define BLE_ERROR_INVALID_ADV_HANDLE (NRF_ERROR_STK_BASE_NUM+0x004) /**< Invalid advertising handle. */ 69 | #define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x005) /**< Invalid role. */ 70 | #define BLE_ERROR_BLOCKED_BY_OTHER_LINKS (NRF_ERROR_STK_BASE_NUM+0x006) /**< The attempt to change link settings failed due to the scheduling of other links. */ 71 | /** @} */ 72 | 73 | 74 | /** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges 75 | * @brief Assignment of subranges for module specific error codes. 76 | * @note For specific error codes, see ble_.h or ble_error_.h. 77 | * @{ */ 78 | #define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */ 79 | #define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */ 80 | #define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */ 81 | #define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */ 82 | /** @} */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | #endif 88 | 89 | 90 | /** 91 | @} 92 | @} 93 | */ 94 | -------------------------------------------------------------------------------- /lib/softdevice/s132/6.0.0/headers/nrf_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | /** 40 | @defgroup nrf_error SoftDevice Global Error Codes 41 | @{ 42 | 43 | @brief Global Error definitions 44 | */ 45 | 46 | /* Header guard */ 47 | #ifndef NRF_ERROR_H__ 48 | #define NRF_ERROR_H__ 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | /** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions 55 | * @{ */ 56 | #define NRF_ERROR_BASE_NUM (0x0) ///< Global error base 57 | #define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base 58 | #define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base 59 | #define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base 60 | /** @} */ 61 | 62 | #define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command 63 | #define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing 64 | #define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled 65 | #define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error 66 | #define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation 67 | #define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found 68 | #define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported 69 | #define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter 70 | #define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state 71 | #define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length 72 | #define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags 73 | #define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data 74 | #define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Invalid Data size 75 | #define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out 76 | #define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer 77 | #define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation 78 | #define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address 79 | #define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy 80 | #define NRF_ERROR_CONN_COUNT (NRF_ERROR_BASE_NUM + 18) ///< Maximum connection count exceeded. 81 | #define NRF_ERROR_RESOURCES (NRF_ERROR_BASE_NUM + 19) ///< Not enough resources for operation 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | #endif // NRF_ERROR_H__ 87 | 88 | /** 89 | @} 90 | */ 91 | -------------------------------------------------------------------------------- /lib/softdevice/s132/6.0.0/headers/nrf_error_sdm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | /** 40 | @addtogroup nrf_sdm_api 41 | @{ 42 | @defgroup nrf_sdm_error SoftDevice Manager Error Codes 43 | @{ 44 | 45 | @brief Error definitions for the SDM API 46 | */ 47 | 48 | /* Header guard */ 49 | #ifndef NRF_ERROR_SDM_H__ 50 | #define NRF_ERROR_SDM_H__ 51 | 52 | #include "nrf_error.h" 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | #define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown LFCLK source. 59 | #define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts). 60 | #define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erroneous SoftDevice flashing). 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #endif // NRF_ERROR_SDM_H__ 66 | 67 | /** 68 | @} 69 | @} 70 | */ 71 | -------------------------------------------------------------------------------- /lib/softdevice/s132/6.0.0/headers/nrf_error_soc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | /** 40 | @addtogroup nrf_soc_api 41 | @{ 42 | @defgroup nrf_soc_error SoC Library Error Codes 43 | @{ 44 | 45 | @brief Error definitions for the SoC library 46 | 47 | */ 48 | 49 | /* Header guard */ 50 | #ifndef NRF_ERROR_SOC_H__ 51 | #define NRF_ERROR_SOC_H__ 52 | 53 | #include "nrf_error.h" 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /* Mutex Errors */ 59 | #define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken 60 | 61 | /* NVIC errors */ 62 | #define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available 63 | #define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed 64 | #define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return 65 | 66 | /* Power errors */ 67 | #define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown 68 | #define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown 69 | #define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return 70 | 71 | /* Rand errors */ 72 | #define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values 73 | 74 | /* PPI errors */ 75 | #define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel 76 | #define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | #endif // NRF_ERROR_SOC_H__ 82 | /** 83 | @} 84 | @} 85 | */ 86 | -------------------------------------------------------------------------------- /lib/softdevice/s132/6.0.0/headers/nrf_svc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | #ifndef NRF_SVC__ 40 | #define NRF_SVC__ 41 | 42 | #include "stdint.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | #ifdef SVCALL_AS_NORMAL_FUNCTION 49 | #define SVCALL(number, return_type, signature) return_type signature 50 | #else 51 | 52 | #ifndef SVCALL 53 | #if defined (__CC_ARM) 54 | #define SVCALL(number, return_type, signature) return_type __svc(number) signature 55 | #elif defined (__GNUC__) 56 | #ifdef __cplusplus 57 | #define GCC_CAST_CPP (uint16_t) 58 | #else 59 | #define GCC_CAST_CPP 60 | #endif 61 | #define SVCALL(number, return_type, signature) \ 62 | _Pragma("GCC diagnostic push") \ 63 | _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ 64 | __attribute__((naked)) \ 65 | __attribute__((unused)) \ 66 | static return_type signature \ 67 | { \ 68 | __asm( \ 69 | "svc %0\n" \ 70 | "bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \ 71 | ); \ 72 | } \ 73 | _Pragma("GCC diagnostic pop") 74 | 75 | #elif defined (__ICCARM__) 76 | #define PRAGMA(x) _Pragma(#x) 77 | #define SVCALL(number, return_type, signature) \ 78 | PRAGMA(swi_number = (number)) \ 79 | __swi return_type signature; 80 | #else 81 | #define SVCALL(number, return_type, signature) return_type signature 82 | #endif 83 | #endif // SVCALL 84 | 85 | #endif // SVCALL_AS_NORMAL_FUNCTION 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | #endif // NRF_SVC__ 91 | -------------------------------------------------------------------------------- /src/boards.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 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 BOARDS_H 13 | #define BOARDS_H 14 | 15 | #include 16 | #include 17 | #include "nrf_gpio.h" 18 | 19 | #if defined BOARD_FEATHER52 20 | #include "feather52.h" 21 | #elif defined BOARD_METRO52 22 | #include "metro52.h" 23 | #else 24 | #error No boards defined 25 | #endif 26 | 27 | // Make sure we have at least two buttons (DFU + FRESET since DFU+FRST=OTA) 28 | #if BUTTONS_NUMBER < 2 29 | #error "At least two buttons required in the BSP (see 'BUTTONS_NUMBER')" 30 | #endif 31 | 32 | #define LED_RED LED_1 33 | #define LED_BLUE LED_2 34 | 35 | #define bit(b) (1UL << (b)) 36 | 37 | static inline uint32_t bit_set(uint32_t value, uint8_t n) 38 | { 39 | return value | bit(n); 40 | } 41 | 42 | static inline uint32_t bit_clear(uint32_t value, uint8_t n) 43 | { 44 | return value & (~bit(n)); 45 | } 46 | 47 | static inline bool bit_test(uint32_t value, uint8_t n) 48 | { 49 | return (value & bit(n)) ? true : false; 50 | } 51 | 52 | 53 | void led_control(uint32_t pin, bool state); 54 | 55 | static inline void led_on(uint32_t pin) 56 | { 57 | led_control(pin, true); 58 | } 59 | 60 | static inline void led_off(uint32_t pin) 61 | { 62 | led_control(pin, false); 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/bootloader_s132.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | /** Flash start address for the bootloader. This setting will also be stored in UICR to allow the 9 | * MBR to init the bootloader when starting the system. This value must correspond to 10 | * BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if 11 | * those values do not match. The check is performed in main.c, see 12 | * APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START); 13 | */ 14 | FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0xA000 /* 40 KB */ 15 | 16 | /** RAM Region for bootloader. */ 17 | RAM (rwx) : ORIGIN = 0x20003000, LENGTH = 0x20007F80-0x20003000 18 | 19 | /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information 20 | * from application to bootloader when using buttonluss DFU OTA. 21 | */ 22 | NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80 23 | 24 | /** Location of bootloader setting in flash. */ 25 | BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000 26 | 27 | /** Location in UICR where bootloader start address is stored. */ 28 | UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04 29 | 30 | /** Location of mbr params page in flash. */ 31 | MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000 32 | 33 | /** Location in UICR where mbr params page address is stored. */ 34 | UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 35 | } 36 | 37 | SECTIONS 38 | { 39 | .fs_data_out ALIGN(4): 40 | { 41 | PROVIDE( __start_fs_data = .); 42 | KEEP(*(fs_data)) 43 | PROVIDE( __stop_fs_data = .); 44 | } = 0 45 | 46 | /* Place the bootloader settings page in flash. */ 47 | .bootloaderSettings(NOLOAD) : 48 | { 49 | 50 | } > BOOTLOADER_SETTINGS 51 | 52 | /* Write the bootloader address in UICR. */ 53 | .uicrBootStartAddress : 54 | { 55 | KEEP(*(.uicrBootStartAddress)) 56 | } > UICR_BOOTLOADER 57 | 58 | /* Place the mbr params page in flash. */ 59 | .mbrParamsPage(NOLOAD) : 60 | { 61 | 62 | } > MBR_PARAMS_PAGE 63 | 64 | /* Write the bootloader address in UICR. */ 65 | .uicrMbrParamsPageAddress : 66 | { 67 | KEEP(*(.uicrMbrParamsPageAddress)) 68 | } > UICR_MBR_PARAM_PAGE 69 | 70 | /* No init RAM section in bootloader. Used for bond information exchange. */ 71 | .noinit(NOLOAD) : 72 | { 73 | 74 | } > NOINIT 75 | /* other placements follow here... */ 76 | } 77 | 78 | INCLUDE "nrf52_common.ld" 79 | -------------------------------------------------------------------------------- /src/feather52.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /*! 3 | @file feather52.h 4 | @author hathach 5 | 6 | @section LICENSE 7 | 8 | Software License Agreement (BSD License) 9 | 10 | Copyright (c) ${year}, Adafruit Industries (adafruit.com) 11 | All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions are met: 15 | 1. Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | 2. Redistributions in binary form must reproduce the above copyright 18 | notice, this list of conditions and the following disclaimer in the 19 | documentation and/or other materials provided with the distribution. 20 | 3. Neither the name of the copyright holders nor the 21 | names of its contributors may be used to endorse or promote products 22 | derived from this software without specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | /**************************************************************************/ 36 | 37 | #ifndef FEATHER52_H 38 | #define FEATHER52_H 39 | 40 | /*------------------------------------------------------------------*/ 41 | /* LED 42 | *------------------------------------------------------------------*/ 43 | #define LEDS_NUMBER 2 44 | #define LED_1 17 45 | #define LED_2 19 46 | #define LED_STATE_ON 1 47 | 48 | /*------------------------------------------------------------------*/ 49 | /* BUTTON 50 | *------------------------------------------------------------------*/ 51 | #define BUTTONS_NUMBER 2 52 | #define BUTTON_1 20 53 | #define BUTTON_2 22 54 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 55 | 56 | /*------------------------------------------------------------------*/ 57 | /* UART 58 | *------------------------------------------------------------------*/ 59 | #define RX_PIN_NUMBER 8 60 | #define TX_PIN_NUMBER 6 61 | #define CTS_PIN_NUMBER 7 62 | #define RTS_PIN_NUMBER 5 63 | #define HWFC false 64 | 65 | // Used as model string in OTA mode 66 | #define DIS_MODEL "Bluefruit Feather 52" 67 | 68 | #endif // FEATHER52_H 69 | -------------------------------------------------------------------------------- /src/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino_Bootloader/e37c04aa06858f47ce76994b51417fbcd02e4756/src/license.txt -------------------------------------------------------------------------------- /src/metro52.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /*! 3 | @file metro52.h 4 | @author hathach 5 | 6 | @section LICENSE 7 | 8 | Software License Agreement (BSD License) 9 | 10 | Copyright (c) 2017, Adafruit Industries (adafruit.com) 11 | All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions are met: 15 | 1. Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | 2. Redistributions in binary form must reproduce the above copyright 18 | notice, this list of conditions and the following disclaimer in the 19 | documentation and/or other materials provided with the distribution. 20 | 3. Neither the name of the copyright holders nor the 21 | names of its contributors may be used to endorse or promote products 22 | derived from this software without specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | /**************************************************************************/ 36 | 37 | #ifndef METRO52_H 38 | #define METRO52_H 39 | 40 | // Note: FRST and LED2 are on the same pin, so can't be used together 41 | // LED2 will be disabled since it is less critical 42 | 43 | /*------------------------------------------------------------------*/ 44 | /* LED 45 | *------------------------------------------------------------------*/ 46 | #define LEDS_NUMBER 2 47 | #define LED_1 29 48 | #define LED_2 22 49 | #define LED_STATE_ON 1 50 | 51 | /*------------------------------------------------------------------*/ 52 | /* BUTTON 53 | *------------------------------------------------------------------*/ 54 | #define BUTTONS_NUMBER 2 55 | #define BUTTON_1 18 56 | #define BUTTON_2 22 57 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 58 | 59 | /*------------------------------------------------------------------*/ 60 | /* UART 61 | *------------------------------------------------------------------*/ 62 | #define RX_PIN_NUMBER 23 63 | #define TX_PIN_NUMBER 8 64 | #define CTS_PIN_NUMBER 0 65 | #define RTS_PIN_NUMBER 0 66 | #define HWFC false 67 | 68 | // Used as model string in OTA mode 69 | #define DIS_MODEL "Bluefruit Metro 52" 70 | 71 | #endif // METRO52_H 72 | -------------------------------------------------------------------------------- /src/pstorage_platform.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 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 | 13 | /** @cond To make doxygen skip this file */ 14 | 15 | /** @file 16 | * This header contains defines with respect persistent storage that are specific to 17 | * persistent storage implementation and application use case. 18 | */ 19 | #ifndef PSTORAGE_PL_H__ 20 | #define PSTORAGE_PL_H__ 21 | 22 | #include 23 | #include "nrf.h" 24 | 25 | static __INLINE uint16_t pstorage_flash_page_size() 26 | { 27 | return (uint16_t)NRF_FICR->CODEPAGESIZE; 28 | } 29 | 30 | #define PSTORAGE_FLASH_PAGE_SIZE pstorage_flash_page_size() /**< Size of one flash page. */ 31 | #define PSTORAGE_FLASH_EMPTY_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */ 32 | 33 | static __INLINE uint32_t pstorage_flash_page_end() 34 | { 35 | uint32_t bootloader_addr = NRF_UICR->NRFFW[0]; 36 | 37 | return ((bootloader_addr != PSTORAGE_FLASH_EMPTY_MASK) ? 38 | (bootloader_addr/ PSTORAGE_FLASH_PAGE_SIZE) : NRF_FICR->CODESIZE); 39 | } 40 | 41 | #define PSTORAGE_FLASH_PAGE_END pstorage_flash_page_end() 42 | 43 | #define PSTORAGE_NUM_OF_PAGES 4 //3 /**< Number of flash pages allocated for the pstorage module excluding the swap page, configurable based on system requirements. */ 44 | #define PSTORAGE_MIN_BLOCK_SIZE 0x0010 /**< Minimum size of block that can be registered with the module. Should be configured based on system requirements, recommendation is not have this value to be at least size of word. */ 45 | 46 | #define PSTORAGE_DATA_START_ADDR ((PSTORAGE_FLASH_PAGE_END - PSTORAGE_NUM_OF_PAGES) \ 47 | * PSTORAGE_FLASH_PAGE_SIZE) /**< Start address for persistent data, configurable according to system requirements. */ 48 | #define PSTORAGE_DATA_END_ADDR (PSTORAGE_FLASH_PAGE_END * PSTORAGE_FLASH_PAGE_SIZE) /**< End address for persistent data, configurable according to system requirements. */ 49 | #define PSTORAGE_SWAP_ADDR PSTORAGE_DATA_END_ADDR 50 | 51 | #define PSTORAGE_MAX_BLOCK_SIZE PSTORAGE_FLASH_PAGE_SIZE /**< Maximum size of block that can be registered with the module. Should be configured based on system requirements. And should be greater than or equal to the minimum size. */ 52 | #define PSTORAGE_CMD_QUEUE_SIZE 10 /**< Maximum number of flash access commands that can be maintained by the module for all applications. Configurable. */ 53 | 54 | /**@breif Define this flag in case Raw access to persistent memory is to be enabled. Raw mode 55 | * unlike the data mode is for uses other than storing data from various mode. This mode is 56 | * employed when unpdating firmware or similar uses. Therefore, this mode shall be enabled 57 | * only for these special usecases and typically disabled. 58 | */ 59 | #define PSTORAGE_RAW_MODE_ENABLE 60 | 61 | /** Abstracts persistently memory block identifier. */ 62 | typedef uint32_t pstorage_block_t; 63 | 64 | typedef struct 65 | { 66 | uint32_t module_id; /**< Module ID.*/ 67 | pstorage_block_t block_id; /**< Block ID.*/ 68 | } pstorage_handle_t; 69 | 70 | typedef uint32_t pstorage_size_t; /** Size of length and offset fields. */ 71 | 72 | /**@brief Handles Flash Access Result Events. To be called in the system event dispatcher of the application. */ 73 | void pstorage_sys_event_handler (uint32_t sys_evt); 74 | 75 | #endif // PSTORAGE_PL_H__ 76 | 77 | /** @} */ 78 | /** @endcond */ 79 | -------------------------------------------------------------------------------- /src/segger/SEGGER_RTT_SES.c: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * SEGGER MICROCONTROLLER GmbH & Co. KG * 3 | * Solutions for real time microcontroller applications * 4 | ********************************************************************** 5 | * * 6 | * (c) 2014 - 2015 SEGGER Microcontroller GmbH & Co. KG * 7 | * * 8 | * www.segger.com Support: support@segger.com * 9 | * * 10 | ********************************************************************** 11 | * * 12 | * All rights reserved. * 13 | * * 14 | * * This software may in its unmodified form be freely redistributed * 15 | * in source form. * 16 | * * The source code may be modified, provided the source code * 17 | * retains the above copyright notice, this list of conditions and * 18 | * the following disclaimer. * 19 | * * Modified versions of this software in source or linkable form * 20 | * may not be distributed without prior consent of SEGGER. * 21 | * * This software may only be used for communication with SEGGER * 22 | * J-Link debug probes. * 23 | * * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 25 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * 26 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * 27 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * 28 | * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * 29 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * 31 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * 32 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * 35 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 36 | * DAMAGE. * 37 | * * 38 | ********************************************************************** 39 | -------- END-OF-HEADER --------------------------------------------- 40 | File : SEGGER_RTT_Syscalls_SES.c 41 | Purpose : Reimplementation of printf, puts and 42 | implementation of __putchar and __getchar using RTT in SES. 43 | To use RTT for printf output, include this file in your 44 | application. 45 | ---------------------------------------------------------------------- 46 | */ 47 | #include "SEGGER_RTT.h" 48 | #include "__libc.h" 49 | #include 50 | #include 51 | 52 | int printf(const char *fmt,...) { 53 | char buffer[128]; 54 | va_list args; 55 | va_start (args, fmt); 56 | int n = vsnprintf(buffer, sizeof(buffer), fmt, args); 57 | SEGGER_RTT_Write(0, buffer, n); 58 | va_end(args); 59 | return n; 60 | } 61 | 62 | int puts(const char *s) { 63 | return SEGGER_RTT_WriteString(0, s); 64 | } 65 | 66 | int __putchar(int x, __printf_tag_ptr ctx) { 67 | (void)ctx; 68 | SEGGER_RTT_Write(0, (char *)&x, 1); 69 | return x; 70 | } 71 | 72 | int __getchar() { 73 | return SEGGER_RTT_WaitKey(); 74 | } 75 | 76 | /****** End Of File *************************************************/ 77 | -------------------------------------------------------------------------------- /src/segger/flash_placement.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/segger/nRF52832_xxAA_MemoryMap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/segger/nRF_Target.js: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * SEGGER Microcontroller GmbH & Co. KG * 3 | * Solutions for real time microcontroller applications * 4 | ***************************************************************************** 5 | * * 6 | * (c) 2017 SEGGER Microcontroller GmbH & Co. KG * 7 | * * 8 | * Internet: www.segger.com Support: support@segger.com * 9 | * * 10 | *****************************************************************************/ 11 | 12 | function Reset() { 13 | TargetInterface.resetAndStop(); 14 | } 15 | 16 | function EnableTrace(traceInterfaceType) { 17 | // TODO: Enable trace 18 | } 19 | 20 | --------------------------------------------------------------------------------