├── .gitignore ├── Makefile ├── README.md ├── battery_service ├── battery.c └── battery.h ├── boards ├── BLE400.h ├── WT51822_S4AT.h ├── beacon_big.h ├── beacon_round.h ├── boards.c └── boards.h ├── keys.h ├── main.c ├── nrf51822.ld └── sdk_config.h /.gitignore: -------------------------------------------------------------------------------- 1 | keys* 2 | nrf_51_native.zip 3 | .vscode/ 4 | _build/ 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TARGETS := nrf51822_xxac 2 | OUTPUT_DIRECTORY := _build 3 | 4 | BLE_ROOT := ../../../../.. 5 | 6 | APPLICATION_HEX := $(OUTPUT_DIRECTORY)/$(TARGETS).hex 7 | KEY_FILE := $(BLE_ROOT)/private.pem 8 | PROJECT_ID := $(shell basename `pwd`) 9 | OUT_ZIP = $(PROJECT_ID).zip 10 | SOFTDEVICE_HEX = $(SDK_ROOT)/components/softdevice/s130/hex/s130_nrf51_2.0.1_softdevice.hex 11 | 12 | SHELL := /bin/bash 13 | 14 | SDK_ROOT := $(BLE_ROOT)/nRF5_SDK_12.3.0_d7731ad 15 | PROJ_DIR := . 16 | CUSTOM_INCLUDES_DIR = $(PROJ_DIR) 17 | ADB_TARGET := pixel 18 | ADB_DIRECTORY := /sdcard/dfu 19 | 20 | BOARD := BEACON_SMALL 21 | 22 | BIN_OUTPUT_FOLDER = /home/daniel/Desktop/Development/AirTags/KeyGeneratorWeb/firmware/files/ 23 | BIN_OUTPUT_WITH_CRYSTAL = scaffold_with_crystal.bin 24 | BIN_OUTPUT_WITHOUT_CRYSTAL = scaffold_without_crystal.bin 25 | 26 | $(OUTPUT_DIRECTORY)/$(TARGETS).out: \ 27 | LINKER_SCRIPT := nrf51822.ld 28 | 29 | # Source files common to all targets 30 | SRC_FILES += \ 31 | $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \ 32 | $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \ 33 | $(SDK_ROOT)/components/libraries/button/app_button.c \ 34 | $(SDK_ROOT)/components/libraries/util/app_error.c \ 35 | $(SDK_ROOT)/components/libraries/util/app_error_weak.c \ 36 | $(SDK_ROOT)/components/libraries/scheduler/app_scheduler.c \ 37 | $(SDK_ROOT)/components/libraries/fifo/app_fifo.c \ 38 | $(SDK_ROOT)/components/libraries/timer/app_timer.c \ 39 | $(SDK_ROOT)/components/libraries/timer/app_timer_appsh.c \ 40 | $(SDK_ROOT)/components/libraries/uart/app_uart_fifo.c \ 41 | $(SDK_ROOT)/components/libraries/util/app_util_platform.c \ 42 | $(SDK_ROOT)/components/libraries/fstorage/fstorage.c \ 43 | $(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c \ 44 | $(SDK_ROOT)/components/libraries/util/nrf_assert.c \ 45 | $(SDK_ROOT)/components/libraries/uart/retarget.c \ 46 | $(SDK_ROOT)/components/libraries/util/sdk_errors.c \ 47 | $(SDK_ROOT)/components/drivers_nrf/clock/nrf_drv_clock.c \ 48 | $(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \ 49 | $(SDK_ROOT)/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \ 50 | $(SDK_ROOT)/components/drivers_nrf/uart/nrf_drv_uart.c \ 51 | $(SDK_ROOT)/components/drivers_nrf/spi_master/nrf_drv_spi.c \ 52 | $(SDK_ROOT)/components/libraries/bsp/bsp.c \ 53 | $(SDK_ROOT)/components/libraries/bsp/bsp_btn_ble.c \ 54 | $(SDK_ROOT)/components/libraries/bsp/bsp_nfc.c \ 55 | $(PROJ_DIR)/main.c \ 56 | $(SDK_ROOT)/external/segger_rtt/RTT_Syscalls_GCC.c \ 57 | $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \ 58 | $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \ 59 | $(SDK_ROOT)/components/ble/common/ble_advdata.c \ 60 | $(SDK_ROOT)/components/ble/ble_advertising/ble_advertising.c \ 61 | $(SDK_ROOT)/components/ble/common/ble_conn_params.c \ 62 | $(SDK_ROOT)/components/ble/common/ble_srv_common.c \ 63 | $(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf51.S \ 64 | $(SDK_ROOT)/components/toolchain/system_nrf51.c \ 65 | $(SDK_ROOT)/components/softdevice/common/softdevice_handler/softdevice_handler.c \ 66 | $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_flash.c \ 67 | $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_settings.c \ 68 | $(SDK_ROOT)/components/drivers_nrf/hal/nrf_nvmc.c \ 69 | $(SDK_ROOT)/components/libraries/crc32/crc32.c \ 70 | $(SDK_ROOT)/components/ble/ble_services/ble_dfu/ble_dfu.c \ 71 | $(SDK_ROOT)/components/libraries/fds/fds.c \ 72 | $(CUSTOM_INCLUDES_DIR)/battery_service/battery.c \ 73 | $(CUSTOM_INCLUDES_DIR)/boards/boards.c \ 74 | 75 | # Include folders common to all targets 76 | INC_FOLDERS += \ 77 | $(SDK_ROOT)/components/drivers_nrf/comp \ 78 | $(SDK_ROOT)/components/drivers_nrf/twi_master \ 79 | $(SDK_ROOT)/components/ble/ble_services/ble_ancs_c \ 80 | $(SDK_ROOT)/components/ble/ble_services/ble_ias_c \ 81 | $(SDK_ROOT)/components/softdevice/s130/headers \ 82 | $(SDK_ROOT)/components/libraries/pwm \ 83 | $(SDK_ROOT)/components/libraries/usbd/class/cdc/acm \ 84 | $(SDK_ROOT)/components/libraries/usbd/class/hid/generic \ 85 | $(SDK_ROOT)/components/libraries/usbd/class/msc \ 86 | $(SDK_ROOT)/components/libraries/usbd/class/hid \ 87 | $(SDK_ROOT)/components/libraries/scheduler \ 88 | $(SDK_ROOT)/components/libraries/log \ 89 | $(SDK_ROOT)/components/ble/ble_services/ble_gls \ 90 | $(SDK_ROOT)/components/libraries/fstorage \ 91 | $(SDK_ROOT)/components/drivers_nrf/i2s \ 92 | $(SDK_ROOT)/components/libraries/gpiote \ 93 | $(SDK_ROOT)/components/drivers_nrf/gpiote \ 94 | $(SDK_ROOT)/components/libraries/fifo \ 95 | $(SDK_ROOT)/components/drivers_nrf/common \ 96 | $(SDK_ROOT)/components/ble/ble_advertising \ 97 | $(SDK_ROOT)/components/drivers_nrf/adc \ 98 | $(SDK_ROOT)/components/softdevice/s130/headers/nrf51 \ 99 | $(SDK_ROOT)/components/ble/ble_services/ble_bas_c \ 100 | $(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \ 101 | $(SDK_ROOT)/components/libraries/queue \ 102 | $(SDK_ROOT)/components/ble/ble_dtm \ 103 | $(SDK_ROOT)/components/toolchain/cmsis/include \ 104 | $(SDK_ROOT)/components/ble/ble_services/ble_rscs_c \ 105 | $(SDK_ROOT)/components/drivers_nrf/uart \ 106 | $(SDK_ROOT)/components/ble/common \ 107 | $(SDK_ROOT)/components/ble/ble_services/ble_lls \ 108 | $(SDK_ROOT)/components/drivers_nrf/wdt \ 109 | $(SDK_ROOT)/components/libraries/bsp \ 110 | $(SDK_ROOT)/components/ble/ble_services/ble_bas \ 111 | $(SDK_ROOT)/components/libraries/experimental_section_vars \ 112 | $(SDK_ROOT)/components/ble/ble_services/ble_ans_c \ 113 | $(SDK_ROOT)/components/libraries/slip \ 114 | $(SDK_ROOT)/components/libraries/mem_manager \ 115 | $(SDK_ROOT)/external/segger_rtt \ 116 | $(SDK_ROOT)/components/libraries/csense_drv \ 117 | $(SDK_ROOT)/components/drivers_nrf/hal \ 118 | $(SDK_ROOT)/components/drivers_nrf/rtc \ 119 | $(SDK_ROOT)/components/ble/ble_services/ble_ias \ 120 | $(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \ 121 | $(SDK_ROOT)/components/drivers_nrf/ppi \ 122 | $(SDK_ROOT)/components/drivers_nrf/twis_slave \ 123 | $(SDK_ROOT)/components \ 124 | $(SDK_ROOT)/components/libraries/scheduler \ 125 | $(SDK_ROOT)/components/ble/ble_services/ble_lbs \ 126 | $(SDK_ROOT)/components/ble/ble_services/ble_hts \ 127 | $(SDK_ROOT)/components/drivers_nrf/delay \ 128 | $(SDK_ROOT)/components/drivers_nrf/spi_master \ 129 | $(SDK_ROOT)/components/libraries/crc16 \ 130 | $(SDK_ROOT)/components/drivers_nrf/timer \ 131 | $(SDK_ROOT)/components/libraries/util \ 132 | $(SDK_ROOT)/components/drivers_nrf/pwm \ 133 | $(SDK_ROOT)/components/libraries/usbd/class/cdc \ 134 | $(SDK_ROOT)/components/libraries/csense \ 135 | $(SDK_ROOT)/components/drivers_nrf/rng \ 136 | $(SDK_ROOT)/components/libraries/low_power_pwm \ 137 | $(SDK_ROOT)/components/libraries/hardfault \ 138 | $(SDK_ROOT)/components/ble/ble_services/ble_cscs \ 139 | $(SDK_ROOT)/components/libraries/uart \ 140 | $(SDK_ROOT)/components/libraries/hci \ 141 | $(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \ 142 | $(SDK_ROOT)/components/drivers_nrf/spi_slave \ 143 | $(SDK_ROOT)/components/drivers_nrf/lpcomp \ 144 | $(SDK_ROOT)/components/libraries/timer \ 145 | $(SDK_ROOT)/components/drivers_nrf/power \ 146 | $(SDK_ROOT)/components/libraries/usbd/config \ 147 | $(SDK_ROOT)/components/toolchain \ 148 | $(SDK_ROOT)/components/libraries/led_softblink \ 149 | $(SDK_ROOT)/components/drivers_nrf/qdec \ 150 | $(SDK_ROOT)/components/ble/ble_services/ble_cts_c \ 151 | $(SDK_ROOT)/components/drivers_nrf/spi_master \ 152 | $(SDK_ROOT)/components/ble/ble_services/ble_hids \ 153 | $(SDK_ROOT)/components/drivers_nrf/pdm \ 154 | $(SDK_ROOT)/components/libraries/crc32 \ 155 | $(SDK_ROOT)/components/libraries/usbd/class/audio \ 156 | $(SDK_ROOT)/components/ble/peer_manager \ 157 | $(SDK_ROOT)/components/drivers_nrf/swi \ 158 | $(SDK_ROOT)/components/ble/ble_services/ble_tps \ 159 | $(SDK_ROOT)/components/ble/ble_services/ble_dis \ 160 | $(SDK_ROOT)/components/device \ 161 | $(SDK_ROOT)/components/ble/nrf_ble_qwr \ 162 | $(SDK_ROOT)/components/libraries/button \ 163 | $(SDK_ROOT)/components/libraries/usbd \ 164 | $(SDK_ROOT)/components/drivers_nrf/saadc \ 165 | $(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \ 166 | $(SDK_ROOT)/components/ble/ble_racp \ 167 | $(SDK_ROOT)/components/toolchain/gcc \ 168 | $(SDK_ROOT)/components/libraries/fds \ 169 | $(SDK_ROOT)/components/libraries/twi \ 170 | $(SDK_ROOT)/components/drivers_nrf/clock \ 171 | $(SDK_ROOT)/components/ble/ble_services/ble_rscs \ 172 | $(SDK_ROOT)/components/drivers_nrf/usbd \ 173 | $(SDK_ROOT)/components/softdevice/common/softdevice_handler \ 174 | $(SDK_ROOT)/components/ble/ble_services/ble_hrs \ 175 | $(SDK_ROOT)/components/libraries/log/src \ 176 | $(SDK_ROOT)/components/libraries/bootloader/ble_dfu \ 177 | $(SDK_ROOT)/components/libraries/bootloader/dfu \ 178 | $(SDK_ROOT)/components/libraries/bootloader \ 179 | $(SDK_ROOT)/components/drivers_nrf/hal \ 180 | $(SDK_ROOT)/components/libraries/crc32 \ 181 | $(SDK_ROOT)/components/ble/ble_services/ble_dfu \ 182 | $(PROJ_DIR) \ 183 | $(CUSTOM_INCLUDES_DIR)/battery_service \ 184 | $(CUSTOM_INCLUDES_DIR)/boards \ 185 | 186 | # Libraries common to all targets 187 | LIB_FILES += \ 188 | 189 | # C flags common to all targets 190 | CFLAGS += -DBOARD_$(BOARD) 191 | CFLAGS += -DSOFTDEVICE_PRESENT 192 | CFLAGS += -DNRF51 193 | CFLAGS += -DS130 194 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 195 | CFLAGS += -DSWI_DISABLE0 196 | CFLAGS += -DNRF51822 197 | CFLAGS += -DNRF_SD_BLE_API_VERSION=2 198 | CFLAGS += -mcpu=cortex-m0 199 | CFLAGS += -mthumb -mabi=aapcs 200 | CFLAGS += -Wall -Werror -O3 -g3 201 | CFLAGS += -mfloat-abi=soft 202 | # keep every function in separate section, this allows linker to discard unused ones 203 | CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing 204 | CFLAGS += -fno-builtin --short-enums 205 | CFLAGS += -DNRF_DFU_SETTINGS_VERSION=1 206 | CFLAGS += -DUSE_DFU 207 | CFLAGS += -DUSE_SPI 208 | CFLAGS += -DUSE_UART 209 | CFLAGS += -DDEBUG 210 | CFLAGS += -DBUTTON_PIN=BUTTON_0 211 | 212 | # C++ flags common to all targets 213 | CXXFLAGS += \ 214 | 215 | # Assembler flags common to all targets 216 | ASMFLAGS += -x assembler-with-cpp 217 | ASMFLAGS += -DBOARD_$(BOARD) 218 | ASMFLAGS += -DSOFTDEVICE_PRESENT 219 | ASMFLAGS += -DNRF51 220 | ASMFLAGS += -DS130 221 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 222 | ASMFLAGS += -DSWI_DISABLE0 223 | ASMFLAGS += -DNRF51822 224 | ASMFLAGS += -DNRF_SD_BLE_API_VERSION=2 225 | 226 | # Linker flags 227 | LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT) 228 | LDFLAGS += -mcpu=cortex-m0 229 | # let linker to dump unused sections 230 | LDFLAGS += -Wl,--gc-sections 231 | # use newlib in nano version 232 | LDFLAGS += --specs=nano.specs -lc -lnosys 233 | 234 | 235 | .PHONY: $(TARGETS) default all clean help flash flash_softdevice erase merge_softdevice applicaiton_zip push sign reset 236 | 237 | # Default target - first one defined 238 | default: $(TARGETS) 239 | 240 | # Print all targets that can be built 241 | help: 242 | @echo following targets are available: 243 | @echo $(TARGETS) 244 | 245 | TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc 246 | 247 | include $(TEMPLATE_PATH)/Makefile.common 248 | 249 | $(foreach target, $(TARGETS), $(call define_target, $(target))) 250 | 251 | # Flash the program 252 | flash: $(APPLICATION_HEX) 253 | @echo Flashing: $< 254 | nrfjprog --program $< -f nrf51 --sectorerase 255 | nrfjprog --reset -f nrf51 256 | 257 | # Flash softdevice 258 | flash_softdevice: $(SOFTDEVICE_HEX) 259 | @echo Flashing: s130_nrf51_2.0.1_softdevice.hex 260 | nrfjprog --program $(SOFTDEVICE_HEX) -f nrf51 261 | nrfjprog --reset -f nrf51 262 | 263 | erase: 264 | nrfjprog --eraseall -f nrf51 265 | 266 | merge_softdevice: $(APPLICATION_HEX) $(SOFTDEVICE_HEX) 267 | mergehex -m \ 268 | $(APPLICATION_HEX) \ 269 | $(SOFTDEVICE_HEX) \ 270 | -o application_with_softdevice.hex 271 | 272 | sign: $(APPLICATION_HEX) 273 | rm -f $(OUT_ZIP) 274 | ls -lh $(APPLICATION_HEX) 275 | nrfutil pkg generate --application $(APPLICATION_HEX) --debug-mode $(OUT_ZIP) --key-file $(KEY_FILE) 276 | 277 | $(OUT_ZIP): sign 278 | 279 | push: $(OUT_ZIP) 280 | adb connect $(ADB_TARGET) 281 | adb shell mkdir -p $(ADB_DIRECTORY) 282 | adb push $(OUT_ZIP) $(ADB_DIRECTORY) 283 | 284 | config: sdk_config.h 285 | java -jar ../../CMSIS_Configuration_Wizard.jar sdk_config.h 286 | 287 | reset: 288 | nrfjprog --reset 289 | 290 | bin: 291 | rm -f without_crtystal.bin with_crtystal.bin nrf51822_xxac.bin 292 | make clean default sign BOARD=BOARD_BEACON_BIG 293 | unzip $(PROJECT_ID).zip nrf51822_xxac.bin 294 | mv nrf51822_xxac.bin "$(BIN_OUTPUT_FOLDER)$(BIN_OUTPUT_WITHOUT_CRYSTAL)" 295 | make clean default sign BOARD=BOARD_BEACON_SMALL 296 | unzip $(PROJECT_ID).zip nrf51822_xxac.bin 297 | mv nrf51822_xxac.bin "$(BIN_OUTPUT_FOLDER)$(BIN_OUTPUT_WITH_CRYSTAL)" 298 | rm $(PROJECT_ID).zip 299 | make clean 300 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FakeTag 2 | 3 | ## Disclaimer 4 | This project is not meant to be used by beginners. While it is based on OpenHaystack, it is not compatible with it. 5 | The keys are generated by an undisclosed mechanism, the date is fetched and decoded by a private project. 6 | I am not planning on making this a easy-to-use project. 7 | 8 | ## Summary 9 | firmware for nRF51 chips that is coincidentally compatible with the FindMy (AirTag) ecosystem. 10 | 11 | You can read about this project [here](https://hackaday.com/2022/05/30/check-your-mailbox-using-the-airtag-infrastructure/). 12 | 13 | It sends out advertisement keys defined in [keys.h](keys.h), rotating keys every hour. 14 | 15 | Also, an input pin can be defined. Whenever that input pin is triggered, the status byte increments by one. 16 | The first two bits of the status byte contain battery information, the other six bits contain the counter in my code. 17 | 18 | I use this for my Mailbox-sensor. 19 | There is a vibraion sensor attached to the board, and whener the Mailbox is opened the vibration sensor triggers, which 20 | makes the chip send out a different status byte. 21 | That status byte, traveling through the FindMy network and [OpenHaystack](https://github.com/seemoo-lab/openhaystack), reaches my smarthome and I get a notification. 22 | 23 | ![PXL_20220504_162815409](https://user-images.githubusercontent.com/26143255/167520287-0ad64cf0-5481-4109-9714-0aaf7d0d3763.jpg) 24 | -------------------------------------------------------------------------------- /battery_service/battery.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | 41 | /* Attention! 42 | * To maintain compliance with Nordic Semiconductor ASA�s Bluetooth profile 43 | * qualification listings, this section of source code must not be modified. 44 | */ 45 | #include "battery.h" 46 | 47 | 48 | #define INVALID_BATTERY_LEVEL 255 49 | 50 | 51 | #define BATTERY_VOLTAGE_MIN 1800.0 52 | #define BATTERY_VOLTAGE_MAX 3000.0 53 | 54 | 55 | /**@brief Function for handling the Connect event. 56 | * 57 | * @param[in] p_bas Battery Service structure. 58 | * @param[in] p_ble_evt Event received from the BLE stack. 59 | */ 60 | static void on_connect(ble_bas_t * p_bas, ble_evt_t * p_ble_evt) 61 | { 62 | p_bas->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; 63 | } 64 | 65 | 66 | /**@brief Function for handling the Disconnect event. 67 | * 68 | * @param[in] p_bas Battery Service structure. 69 | * @param[in] p_ble_evt Event received from the BLE stack. 70 | */ 71 | static void on_disconnect(ble_bas_t * p_bas, ble_evt_t * p_ble_evt) 72 | { 73 | UNUSED_PARAMETER(p_ble_evt); 74 | p_bas->conn_handle = BLE_CONN_HANDLE_INVALID; 75 | } 76 | 77 | 78 | 79 | 80 | uint16_t battery_voltage_get (void) 81 | { 82 | // Configure ADC 83 | NRF_ADC->CONFIG = (ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos) | 84 | (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) | 85 | (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos) | 86 | (ADC_CONFIG_PSEL_Disabled << ADC_CONFIG_PSEL_Pos) | 87 | (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos); 88 | NRF_ADC->EVENTS_END = 0; 89 | NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled; 90 | 91 | NRF_ADC->EVENTS_END = 0; // Stop any running conversions. 92 | NRF_ADC->TASKS_START = 1; 93 | 94 | while (!NRF_ADC->EVENTS_END); 95 | 96 | uint16_t vbg_in_mv = 1200; 97 | uint8_t adc_max = 255; 98 | uint16_t vbat_current_in_mv = (NRF_ADC->RESULT * 3 * vbg_in_mv) / adc_max; 99 | 100 | NRF_ADC->EVENTS_END = 0; 101 | NRF_ADC->TASKS_STOP = 1; 102 | 103 | return vbat_current_in_mv; 104 | } 105 | 106 | uint8_t level_get(uint16_t voltage){ 107 | return (uint8_t) ((voltage - 108 | BATTERY_VOLTAGE_MIN) / (BATTERY_VOLTAGE_MAX - 109 | BATTERY_VOLTAGE_MIN) * 100.0); 110 | } 111 | 112 | uint8_t get_current_level(void){ 113 | return level_get(battery_voltage_get()); 114 | } 115 | 116 | void on_authorize(ble_bas_t * p_bas, ble_evt_t * p_ble_evt) { 117 | NRF_LOG_INFO("auth\n"); 118 | uint8_t * data = NULL; 119 | uint8_t len = 0; 120 | uint8_t level; 121 | 122 | ble_gatts_evt_read_t evt = p_ble_evt->evt.gatts_evt.params.authorize_request.request.read; 123 | 124 | uint16_t uuid = evt.uuid.uuid; 125 | 126 | uint16_t voltage = battery_voltage_get(); 127 | 128 | NRF_LOG_INFO("requesting uuid %i\n", uuid); 129 | 130 | if(uuid == 0x2A19){ 131 | len = 1; 132 | level = MIN(100, level_get(voltage)); 133 | data = &level; 134 | }else if(uuid == 0x3A19){ 135 | NRF_LOG_INFO("requesting voltage \n"); 136 | len = 2; 137 | data = (uint8_t*) &voltage; 138 | } 139 | 140 | 141 | ble_gatts_rw_authorize_reply_params_t reply; 142 | 143 | reply.params.read.gatt_status = BLE_GATT_STATUS_SUCCESS; 144 | reply.type = BLE_GATTS_AUTHORIZE_TYPE_READ; 145 | reply.params.read.len = len; 146 | reply.params.read.offset = 0; 147 | reply.params.read.update = 1; 148 | reply.params.read.p_data = data; 149 | 150 | sd_ble_gatts_rw_authorize_reply(p_bas->conn_handle, &reply); 151 | } 152 | 153 | 154 | void ble_bas_on_ble_evt(ble_bas_t * p_bas, ble_evt_t * p_ble_evt) 155 | { 156 | if (p_bas == NULL || p_ble_evt == NULL) 157 | { 158 | return; 159 | } 160 | 161 | switch (p_ble_evt->header.evt_id) 162 | { 163 | case BLE_GAP_EVT_CONNECTED: 164 | on_connect(p_bas, p_ble_evt); 165 | break; 166 | 167 | case BLE_GAP_EVT_DISCONNECTED: 168 | on_disconnect(p_bas, p_ble_evt); 169 | break; 170 | 171 | case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: 172 | on_authorize(p_bas, p_ble_evt); 173 | break; 174 | 175 | default: 176 | // No implementation needed. 177 | break; 178 | } 179 | } 180 | 181 | 182 | /**@brief Function for adding the Battery Level characteristic. 183 | * 184 | * @param[in] p_bas Battery Service structure. 185 | * @param[in] p_bas_init Information needed to initialize the service. 186 | * 187 | * @return NRF_SUCCESS on success, otherwise an error code. 188 | */ 189 | static uint32_t battery_level_char_add(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init) 190 | { 191 | uint32_t err_code; 192 | ble_uuid_t ble_uuid; 193 | 194 | ble_gatts_char_md_t char_md = { 195 | .char_props.read = 1, 196 | .char_props.notify = 0, 197 | .char_props.write = 0 198 | }; 199 | 200 | BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BATTERY_LEVEL_CHAR); 201 | 202 | ble_gatts_attr_md_t attr_md = { 203 | .read_perm = p_bas_init->battery_level_char_attr_md.read_perm, 204 | .write_perm = p_bas_init->battery_level_char_attr_md.write_perm, 205 | .vloc = BLE_GATTS_VLOC_STACK, 206 | .rd_auth = 1, 207 | .wr_auth = 0, 208 | .vlen = 0 209 | }; 210 | 211 | ble_gatts_attr_t attr_char_value = { 212 | .p_uuid = &ble_uuid, 213 | .p_attr_md = &attr_md, 214 | .init_len = sizeof(uint8_t), 215 | .init_offs = 0, 216 | .max_len = sizeof(uint8_t), 217 | }; 218 | 219 | err_code = sd_ble_gatts_characteristic_add(p_bas->service_handle, 220 | &char_md, 221 | &attr_char_value, 222 | &p_bas->battery_level_handles 223 | ); 224 | return err_code; 225 | } 226 | 227 | 228 | /**@brief Function for adding the Battery Level characteristic. 229 | * 230 | * @param[in] p_bas Battery Service structure. 231 | * @param[in] p_bas_init Information needed to initialize the service. 232 | * 233 | * @return NRF_SUCCESS on success, otherwise an error code. 234 | */ 235 | static uint32_t battery_voltage_char_add(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init) 236 | { 237 | uint32_t err_code; 238 | ble_uuid_t ble_uuid; 239 | 240 | ble_gatts_char_md_t char_md = { 241 | .char_props.read = 1, 242 | .char_props.notify = 0, 243 | .char_props.write = 0 244 | }; 245 | 246 | BLE_UUID_BLE_ASSIGN(ble_uuid, 0x3A19); 247 | 248 | ble_gatts_attr_md_t attr_md = { 249 | .read_perm = p_bas_init->battery_level_char_attr_md.read_perm, 250 | .write_perm = p_bas_init->battery_level_char_attr_md.write_perm, 251 | .vloc = BLE_GATTS_VLOC_STACK, 252 | .rd_auth = 1, 253 | .wr_auth = 0, 254 | .vlen = 0 255 | }; 256 | 257 | ble_gatts_attr_t attr_char_value = { 258 | .p_uuid = &ble_uuid, 259 | .p_attr_md = &attr_md, 260 | .init_len = sizeof(uint16_t), 261 | .init_offs = 0, 262 | .max_len = sizeof(uint16_t), 263 | }; 264 | 265 | err_code = sd_ble_gatts_characteristic_add(p_bas->service_handle, 266 | &char_md, 267 | &attr_char_value, 268 | &p_bas->battery_voltage_handles 269 | ); 270 | return err_code; 271 | } 272 | 273 | uint32_t ble_bas_init(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init) 274 | { 275 | if (p_bas == NULL || p_bas_init == NULL) 276 | { 277 | return NRF_ERROR_NULL; 278 | } 279 | 280 | uint32_t err_code; 281 | ble_uuid_t ble_uuid; 282 | 283 | // Initialize service structure 284 | p_bas->evt_handler = p_bas_init->evt_handler; 285 | p_bas->conn_handle = BLE_CONN_HANDLE_INVALID; 286 | p_bas->is_notification_supported = p_bas_init->support_notification; 287 | p_bas->battery_level_last = INVALID_BATTERY_LEVEL; 288 | 289 | // Add service 290 | BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BATTERY_SERVICE); 291 | 292 | err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_bas->service_handle); 293 | if (err_code != NRF_SUCCESS) 294 | { 295 | return err_code; 296 | } 297 | 298 | // Add battery level characteristic 299 | battery_level_char_add(p_bas, p_bas_init); 300 | battery_voltage_char_add(p_bas, p_bas_init); 301 | 302 | return NRF_SUCCESS; 303 | } 304 | -------------------------------------------------------------------------------- /battery_service/battery.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef BLE_BAS_H__ 3 | #define BLE_BAS_H__ 4 | 5 | #include 6 | #include 7 | #include "ble.h" 8 | #include "ble_srv_common.h" 9 | #include "nrf_log.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /**@brief Battery Service event type. */ 16 | typedef enum 17 | { 18 | BLE_BAS_EVT_NOTIFICATION_ENABLED, /**< Battery value notification enabled event. */ 19 | BLE_BAS_EVT_NOTIFICATION_DISABLED /**< Battery value notification disabled event. */ 20 | } ble_bas_evt_type_t; 21 | 22 | /**@brief Battery Service event. */ 23 | typedef struct 24 | { 25 | ble_bas_evt_type_t evt_type; /**< Type of event. */ 26 | } ble_bas_evt_t; 27 | 28 | // Forward declaration of the ble_bas_t type. 29 | typedef struct ble_bas_s ble_bas_t; 30 | 31 | /**@brief Battery Service event handler type. */ 32 | typedef void (*ble_bas_evt_handler_t) (ble_bas_t * p_bas, ble_bas_evt_t * p_evt); 33 | 34 | /**@brief Battery Service init structure. This contains all options and data needed for 35 | * initialization of the service.*/ 36 | typedef struct 37 | { 38 | ble_bas_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Battery Service. */ 39 | bool support_notification; /**< TRUE if notification of Battery Level measurement is supported. */ 40 | ble_srv_report_ref_t * p_report_ref; /**< If not NULL, a Report Reference descriptor with the specified value will be added to the Battery Level characteristic */ 41 | uint8_t initial_batt_level; /**< Initial battery level */ 42 | ble_srv_cccd_security_mode_t battery_level_char_attr_md; /**< Initial security level for battery characteristics attribute */ 43 | ble_gap_conn_sec_mode_t battery_level_report_read_perm; /**< Initial security level for battery report read attribute */ 44 | } ble_bas_init_t; 45 | 46 | /**@brief Battery Service structure. This contains various status information for the service. */ 47 | struct ble_bas_s 48 | { 49 | ble_bas_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Battery Service. */ 50 | uint16_t service_handle; /**< Handle of Battery Service (as provided by the BLE stack). */ 51 | ble_gatts_char_handles_t battery_level_handles; /**< Handles related to the Battery Level characteristic. */ 52 | ble_gatts_char_handles_t battery_voltage_handles; /**< Handles related to the Battery Level characteristic. */ 53 | uint16_t report_ref_handle; /**< Handle of the Report Reference descriptor. */ 54 | uint8_t battery_level_last; /**< Last Battery Level measurement passed to the Battery Service. */ 55 | uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ 56 | bool is_notification_supported; /**< TRUE if notification of Battery Level is supported. */ 57 | }; 58 | 59 | /**@brief Function for initializing the Battery Service. 60 | * 61 | * @param[out] p_bas Battery Service structure. This structure will have to be supplied by 62 | * the application. It will be initialized by this function, and will later 63 | * be used to identify this particular service instance. 64 | * @param[in] p_bas_init Information needed to initialize the service. 65 | * 66 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. 67 | */ 68 | uint32_t ble_bas_init(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init); 69 | 70 | /**@brief Function for handling the Application's BLE Stack events. 71 | * 72 | * @details Handles all events from the BLE stack of interest to the Battery Service. 73 | * 74 | * @note For the requirements in the BAS specification to be fulfilled, 75 | * ble_bas_battery_level_update() must be called upon reconnection if the 76 | * battery level has changed while the service has been disconnected from a bonded 77 | * client. 78 | * 79 | * @param[in] p_bas Battery Service structure. 80 | * @param[in] p_ble_evt Event received from the BLE stack. 81 | */ 82 | void ble_bas_on_ble_evt(ble_bas_t * p_bas, ble_evt_t * p_ble_evt); 83 | 84 | uint8_t get_current_level (void); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif // BLE_BAS_H__ 91 | 92 | /** @} */ 93 | -------------------------------------------------------------------------------- /boards/BLE400.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | #ifndef BLE_400_H 41 | #define BLE_400_H 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #include "nrf_gpio.h" 48 | 49 | // LEDs definitions for PCA10028 50 | #define LEDS_NUMBER 5 51 | 52 | #define LED_START 18 53 | #define LED_0 18 54 | #define LED_1 19 55 | #define LED_2 20 56 | #define LED_3 21 57 | #define LED_4 22 58 | #define LED_STOP 22 59 | 60 | #define LEDS_ACTIVE_STATE 1 61 | 62 | #define LEDS_LIST { LED_0, LED_1, LED_2, LED_3, LED_4 } 63 | 64 | #define LEDS_INV_MASK LEDS_MASK 65 | 66 | #define BUTTONS_NUMBER 2 67 | 68 | #define BUTTON_START 16 69 | #define BUTTON_0 16 70 | #define BUTTON_1 17 71 | #define BUTTON_STOP 17 72 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 73 | 74 | #define BUTTONS_ACTIVE_STATE 0 75 | 76 | #define BUTTONS_LIST { BUTTON_0, BUTTON_1 } 77 | 78 | #define RX_PIN_NUMBER 11 79 | #define TX_PIN_NUMBER 9 80 | #define CTS_PIN_NUMBER 10 81 | #define RTS_PIN_NUMBER 8 82 | #define HWFC true 83 | 84 | #define SPIS_MISO_PIN 28 // SPI MISO signal. 85 | #define SPIS_CSN_PIN 12 // SPI CSN signal. 86 | #define SPIS_MOSI_PIN 25 // SPI MOSI signal. 87 | #define SPIS_SCK_PIN 29 // SPI SCK signal. 88 | 89 | #define SPIM0_SCK_PIN 4 /**< SPI clock GPIO pin number. */ 90 | #define SPIM0_MOSI_PIN 1 /**< SPI Master Out Slave In GPIO pin number. */ 91 | #define SPIM0_MISO_PIN 3 /**< SPI Master In Slave Out GPIO pin number. */ 92 | #define SPIM0_SS_PIN 2 /**< SPI Slave Select GPIO pin number. */ 93 | 94 | #define SPIM1_SCK_PIN 15 /**< SPI clock GPIO pin number. */ 95 | #define SPIM1_MOSI_PIN 12 /**< SPI Master Out Slave In GPIO pin number. */ 96 | #define SPIM1_MISO_PIN 14 /**< SPI Master In Slave Out GPIO pin number. */ 97 | #define SPIM1_SS_PIN 13 /**< SPI Slave Select GPIO pin number. */ 98 | 99 | // serialization APPLICATION board 100 | #define SER_CONN_CHIP_RESET_PIN 12 // Pin used to reset connectivity chip 101 | 102 | #define SER_APP_RX_PIN 25 // UART RX pin number. 103 | #define SER_APP_TX_PIN 28 // UART TX pin number. 104 | #define SER_APP_CTS_PIN 0 // UART Clear To Send pin number. 105 | #define SER_APP_RTS_PIN 29 // UART Request To Send pin number. 106 | 107 | #define SER_APP_SPIM0_SCK_PIN 7 // SPI clock GPIO pin number. 108 | #define SER_APP_SPIM0_MOSI_PIN 0 // SPI Master Out Slave In GPIO pin number 109 | #define SER_APP_SPIM0_MISO_PIN 30 // SPI Master In Slave Out GPIO pin number 110 | #define SER_APP_SPIM0_SS_PIN 25 // SPI Slave Select GPIO pin number 111 | #define SER_APP_SPIM0_RDY_PIN 29 // SPI READY GPIO pin number 112 | #define SER_APP_SPIM0_REQ_PIN 28 // SPI REQUEST GPIO pin number 113 | 114 | // serialization CONNECTIVITY board 115 | #define SER_CON_RX_PIN 28 // UART RX pin number. 116 | #define SER_CON_TX_PIN 25 // UART TX pin number. 117 | #define SER_CON_CTS_PIN 29 // UART Clear To Send pin number. Not used if HWFC is set to false. 118 | #define SER_CON_RTS_PIN 0 // UART Request To Send pin number. Not used if HWFC is set to false. 119 | 120 | 121 | #define SER_CON_SPIS_SCK_PIN 7 // SPI SCK signal. 122 | #define SER_CON_SPIS_MOSI_PIN 0 // SPI MOSI signal. 123 | #define SER_CON_SPIS_MISO_PIN 30 // SPI MISO signal. 124 | #define SER_CON_SPIS_CSN_PIN 25 // SPI CSN signal. 125 | #define SER_CON_SPIS_RDY_PIN 29 // SPI READY GPIO pin number. 126 | #define SER_CON_SPIS_REQ_PIN 28 // SPI REQUEST GPIO pin number. 127 | 128 | // Arduino board mappings 129 | #define ARDUINO_SCL_PIN 7 // SCL signal pin 130 | #define ARDUINO_SDA_PIN 30 // SDA signal pin 131 | #define ARDUINO_AREF_PIN 0 // Aref pin 132 | #define ARDUINO_13_PIN 29 // Digital pin 13 133 | #define ARDUINO_12_PIN 28 // Digital pin 12 134 | #define ARDUINO_11_PIN 25 // Digital pin 11 135 | #define ARDUINO_10_PIN 24 // Digital pin 10 136 | #define ARDUINO_9_PIN 23 // Digital pin 9 137 | #define ARDUINO_8_PIN 20 // Digital pin 8 138 | 139 | #define ARDUINO_7_PIN 19 // Digital pin 7 140 | #define ARDUINO_6_PIN 18 // Digital pin 6 141 | #define ARDUINO_5_PIN 17 // Digital pin 5 142 | #define ARDUINO_4_PIN 16 // Digital pin 4 143 | #define ARDUINO_3_PIN 15 // Digital pin 3 144 | #define ARDUINO_2_PIN 14 // Digital pin 2 145 | #define ARDUINO_1_PIN 13 // Digital pin 1 146 | #define ARDUINO_0_PIN 12 // Digital pin 0 147 | 148 | #define ARDUINO_A0_PIN 1 // Analog channel 0 149 | #define ARDUINO_A1_PIN 2 // Analog channel 1 150 | #define ARDUINO_A2_PIN 3 // Analog channel 2 151 | #define ARDUINO_A3_PIN 4 // Analog channel 3 152 | #define ARDUINO_A4_PIN 5 // Analog channel 4 153 | #define ARDUINO_A5_PIN 6 // Analog channel 5 154 | 155 | // Low frequency clock source to be used by the SoftDevice 156 | 157 | #define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ 158 | .rc_ctiv = 0, \ 159 | .rc_temp_ctiv = 0, \ 160 | .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} 161 | 162 | #ifdef __cplusplus 163 | } 164 | #endif 165 | 166 | #endif // BLE_400_H 167 | -------------------------------------------------------------------------------- /boards/WT51822_S4AT.h: -------------------------------------------------------------------------------- 1 | #ifndef WT51822_S4AT_H 2 | #define WT51822_S4AT_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "nrf_gpio.h" 9 | 10 | // LEDs definitions for WT51822_S4AT 11 | #define LEDS_NUMBER 0 12 | 13 | #define LEDS_ACTIVE_STATE 0 14 | 15 | #define LEDS_LIST {} 16 | 17 | #define LEDS_INV_MASK LEDS_MASK 18 | 19 | #define BUTTONS_NUMBER 0 20 | 21 | #define BUTTONS_ACTIVE_STATE 0 22 | 23 | #define BUTTONS_LIST {} 24 | 25 | #define RX_PIN_NUMBER 1 26 | #define TX_PIN_NUMBER 2 27 | #define CTS_PIN_NUMBER 3 28 | #define RTS_PIN_NUMBER 4 29 | #define HWFC false 30 | 31 | #define SPIS_MISO_PIN 28 // SPI MISO signal. 32 | #define SPIS_CSN_PIN 12 // SPI CSN signal. 33 | #define SPIS_MOSI_PIN 25 // SPI MOSI signal. 34 | #define SPIS_SCK_PIN 29 // SPI SCK signal. 35 | 36 | #define SPIM0_SCK_PIN 3 /**< SPI clock GPIO pin number. */ 37 | #define SPIM0_MOSI_PIN 4 /**< SPI Master Out Slave In GPIO pin number. */ 38 | #define SPIM0_MISO_PIN 5 /**< SPI Master In Slave Out GPIO pin number. */ 39 | #define SPIM0_SS_PIN 6 /**< SPI Slave Select GPIO pin number. */ 40 | 41 | #define SPIM1_SCK_PIN 15 /**< SPI clock GPIO pin number. */ 42 | #define SPIM1_MOSI_PIN 12 /**< SPI Master Out Slave In GPIO pin number. */ 43 | #define SPIM1_MISO_PIN 14 /**< SPI Master In Slave Out GPIO pin number. */ 44 | #define SPIM1_SS_PIN 13 /**< SPI Slave Select GPIO pin number. */ 45 | 46 | // serialization APPLICATION board 47 | #define SER_CONN_CHIP_RESET_PIN 12 // Pin used to reset connectivity chip 48 | 49 | #define SER_APP_RX_PIN 25 // UART RX pin number. 50 | #define SER_APP_TX_PIN 28 // UART TX pin number. 51 | #define SER_APP_CTS_PIN 0 // UART Clear To Send pin number. 52 | #define SER_APP_RTS_PIN 29 // UART Request To Send pin number. 53 | 54 | #define SER_APP_SPIM0_SCK_PIN 7 // SPI clock GPIO pin number. 55 | #define SER_APP_SPIM0_MOSI_PIN 0 // SPI Master Out Slave In GPIO pin number 56 | #define SER_APP_SPIM0_MISO_PIN 30 // SPI Master In Slave Out GPIO pin number 57 | #define SER_APP_SPIM0_SS_PIN 25 // SPI Slave Select GPIO pin number 58 | #define SER_APP_SPIM0_RDY_PIN 29 // SPI READY GPIO pin number 59 | #define SER_APP_SPIM0_REQ_PIN 28 // SPI REQUEST GPIO pin number 60 | 61 | // serialization CONNECTIVITY board 62 | #define SER_CON_RX_PIN 28 // UART RX pin number. 63 | #define SER_CON_TX_PIN 25 // UART TX pin number. 64 | #define SER_CON_CTS_PIN 29 // UART Clear To Send pin number. Not used if HWFC is set to false. 65 | #define SER_CON_RTS_PIN 0 // UART Request To Send pin number. Not used if HWFC is set to false. 66 | 67 | 68 | #define SER_CON_SPIS_SCK_PIN 7 // SPI SCK signal. 69 | #define SER_CON_SPIS_MOSI_PIN 0 // SPI MOSI signal. 70 | #define SER_CON_SPIS_MISO_PIN 30 // SPI MISO signal. 71 | #define SER_CON_SPIS_CSN_PIN 25 // SPI CSN signal. 72 | #define SER_CON_SPIS_RDY_PIN 29 // SPI READY GPIO pin number. 73 | #define SER_CON_SPIS_REQ_PIN 28 // SPI REQUEST GPIO pin number. 74 | // Low frequency clock source to be used by the SoftDevice 75 | 76 | #define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_RC, \ 77 | .rc_ctiv = 16, \ 78 | .rc_temp_ctiv = 2, \ 79 | .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM} 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif // WT51822_S4AT_H 86 | -------------------------------------------------------------------------------- /boards/beacon_big.h: -------------------------------------------------------------------------------- 1 | #ifndef BEACON_BIG_H 2 | #define BEACON_BIG_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "nrf_gpio.h" 9 | 10 | // LEDs definitions for PCA10028 11 | #define LEDS_NUMBER 3 12 | 13 | #define LED_START 12 14 | #define LED_0 12 15 | #define LED_1 15 16 | #define LED_2 16 17 | #define LED_STOP 16 18 | 19 | #define LEDS_ACTIVE_STATE 1 20 | 21 | #define LEDS_LIST { LED_0, LED_1, LED_2 } 22 | 23 | #define LEDS_INV_MASK LEDS_MASK 24 | 25 | #define BUTTONS_NUMBER 2 26 | 27 | #define BUTTON_START 8 28 | #define BUTTON_0 8 29 | #define BUTTON_1 18 30 | #define BUTTON_STOP 18 31 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 32 | 33 | #define BUTTONS_ACTIVE_STATE 0 34 | 35 | #define BUTTONS_LIST { BUTTON_0, BUTTON_1 } 36 | 37 | #define HWFC true 38 | 39 | // Low frequency clock source to be used by the SoftDevice 40 | 41 | #define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_RC, \ 42 | .rc_ctiv = 16, \ 43 | .rc_temp_ctiv = 2, \ 44 | .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM} 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif // BEACON_BIG_H 51 | -------------------------------------------------------------------------------- /boards/beacon_round.h: -------------------------------------------------------------------------------- 1 | #ifndef BEACON_ROUND_H 2 | #define BEACON_ROUND_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "nrf_gpio.h" 9 | 10 | // LEDs definitions for PCA10028 11 | #define LEDS_NUMBER 1 12 | 13 | #define LED_START 29 14 | #define LED_0 29 15 | #define LED_STOP 29 16 | 17 | #define LEDS_ACTIVE_STATE 1 18 | 19 | #define LEDS_LIST { LED_0 } 20 | 21 | #define LEDS_INV_MASK LEDS_MASK 22 | 23 | #define BUTTONS_NUMBER 1 24 | 25 | #define BUTTON_START 28 26 | #define BUTTON_0 28 27 | #define BUTTON_STOP 28 28 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 29 | 30 | #define BUTTONS_ACTIVE_STATE 0 31 | 32 | #define BUTTONS_LIST { BUTTON_0 } 33 | 34 | #define HWFC true 35 | 36 | // Low frequency clock source to be used by the SoftDevice 37 | 38 | #define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ 39 | .rc_ctiv = 0, \ 40 | .rc_temp_ctiv = 0, \ 41 | .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif // BEACON_ROUND_H 48 | -------------------------------------------------------------------------------- /boards/boards.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | #include "boards.h" 41 | #include 42 | #include 43 | 44 | #if LEDS_NUMBER > 0 45 | static const uint8_t m_board_led_list[LEDS_NUMBER] = LEDS_LIST; 46 | #endif 47 | 48 | #if BUTTONS_NUMBER > 0 49 | static const uint8_t m_board_btn_list[BUTTONS_NUMBER] = BUTTONS_LIST; 50 | #endif 51 | 52 | #if LEDS_NUMBER > 0 53 | bool bsp_board_led_state_get(uint32_t led_idx) 54 | { 55 | ASSERT(led_idx < LEDS_NUMBER); 56 | bool pin_set = nrf_gpio_pin_out_read(m_board_led_list[led_idx]) ? true : false; 57 | return (pin_set == (LEDS_ACTIVE_STATE ? true : false)); 58 | } 59 | 60 | void bsp_board_led_on(uint32_t led_idx) 61 | { 62 | ASSERT(led_idx < LEDS_NUMBER); 63 | nrf_gpio_pin_write(m_board_led_list[led_idx], LEDS_ACTIVE_STATE ? 1 : 0); 64 | } 65 | 66 | void bsp_board_led_off(uint32_t led_idx) 67 | { 68 | ASSERT(led_idx < LEDS_NUMBER); 69 | nrf_gpio_pin_write(m_board_led_list[led_idx], LEDS_ACTIVE_STATE ? 0 : 1); 70 | } 71 | 72 | void bsp_board_leds_off(void) 73 | { 74 | uint32_t i; 75 | for(i = 0; i < LEDS_NUMBER; ++i) 76 | { 77 | bsp_board_led_off(i); 78 | } 79 | } 80 | 81 | void bsp_board_leds_on(void) 82 | { 83 | uint32_t i; 84 | for(i = 0; i < LEDS_NUMBER; ++i) 85 | { 86 | bsp_board_led_on(i); 87 | } 88 | } 89 | 90 | void bsp_board_led_invert(uint32_t led_idx) 91 | { 92 | ASSERT(led_idx < LEDS_NUMBER); 93 | nrf_gpio_pin_toggle(m_board_led_list[led_idx]); 94 | } 95 | 96 | void bsp_board_leds_init(void) 97 | { 98 | uint32_t i; 99 | for(i = 0; i < LEDS_NUMBER; ++i) 100 | { 101 | nrf_gpio_cfg_output(m_board_led_list[i]); 102 | } 103 | bsp_board_leds_off(); 104 | } 105 | 106 | uint32_t bsp_board_led_idx_to_pin(uint32_t led_idx) 107 | { 108 | ASSERT(led_idx < LEDS_NUMBER); 109 | return m_board_led_list[led_idx]; 110 | } 111 | 112 | uint32_t bsp_board_pin_to_led_idx(uint32_t pin_number) 113 | { 114 | uint32_t ret = 0xFFFFFFFF; 115 | uint32_t i; 116 | for(i = 0; i < LEDS_NUMBER; ++i) 117 | { 118 | if (m_board_led_list[i] == pin_number) 119 | { 120 | ret = i; 121 | break; 122 | } 123 | } 124 | return ret; 125 | } 126 | #endif //LEDS_NUMBER > 0 127 | 128 | #if BUTTONS_NUMBER > 0 129 | bool bsp_board_button_state_get(uint32_t button_idx) 130 | { 131 | ASSERT(button_idx < BUTTONS_NUMBER); 132 | bool pin_set = nrf_gpio_pin_read(m_board_btn_list[button_idx]) ? true : false; 133 | return (pin_set == (BUTTONS_ACTIVE_STATE ? true : false)); 134 | } 135 | 136 | void bsp_board_buttons_init(void) 137 | { 138 | uint32_t i; 139 | for(i = 0; i < BUTTONS_NUMBER; ++i) 140 | { 141 | nrf_gpio_cfg_input(m_board_btn_list[i], BUTTON_PULL); 142 | } 143 | } 144 | 145 | uint32_t bsp_board_pin_to_button_idx(uint32_t pin_number) 146 | { 147 | uint32_t i; 148 | uint32_t ret = 0xFFFFFFFF; 149 | for(i = 0; i < BUTTONS_NUMBER; ++i) 150 | { 151 | if (m_board_btn_list[i] == pin_number) 152 | { 153 | ret = i; 154 | break; 155 | } 156 | } 157 | return ret; 158 | } 159 | 160 | uint32_t bsp_board_button_idx_to_pin(uint32_t button_idx) 161 | { 162 | ASSERT(button_idx < BUTTONS_NUMBER); 163 | return m_board_btn_list[button_idx]; 164 | } 165 | #endif //BUTTONS_NUMBER > 0 166 | -------------------------------------------------------------------------------- /boards/boards.h: -------------------------------------------------------------------------------- 1 | #ifndef BOARDS_H 2 | #define BOARDS_H 3 | 4 | #include "nrf_gpio.h" 5 | 6 | #if defined(BOARD_NRF6310) 7 | #include "nrf6310.h" 8 | #elif defined(BOARD_PCA10000) 9 | #include "pca10000.h" 10 | #elif defined(BOARD_PCA10001) 11 | #include "pca10001.h" 12 | #elif defined(BOARD_PCA10002) 13 | #include "pca10000.h" 14 | #elif defined(BOARD_PCA10003) 15 | #include "pca10003.h" 16 | #elif defined(BOARD_PCA20006) 17 | #include "pca20006.h" 18 | #elif defined(BOARD_PCA10028) 19 | #include "pca10028.h" 20 | #elif defined(BOARD_PCA10031) 21 | #include "pca10031.h" 22 | #elif defined(BOARD_PCA10036) 23 | #include "pca10036.h" 24 | #elif defined(BOARD_PCA10040) 25 | #include "pca10040.h" 26 | #elif defined(BOARD_PCA10056) 27 | #include "pca10056.h" 28 | #elif defined(BOARD_WT51822) 29 | #include "wt51822.h" 30 | #elif defined(BOARD_N5DK1) 31 | #include "n5_starterkit.h" 32 | #elif defined (BOARD_D52DK1) 33 | #include "d52_starterkit.h" 34 | #elif defined (BOARD_ARDUINO_PRIMO) 35 | #include "arduino_primo.h" 36 | #elif defined(BOARD_CUSTOM) 37 | #include "custom_board.h" 38 | #elif defined(BOARD_WT51822_S4AT) 39 | #include "WT51822_S4AT.h" 40 | #elif defined(BOARD_BLE400) 41 | #include "BLE400.h" 42 | #elif defined(BOARD_BEACON_BIG) 43 | #include "beacon_big.h" 44 | #elif defined(BOARD_BEACON_SMALL) 45 | #include "beacon_round.h" 46 | #else 47 | #error "Board is not defined" 48 | 49 | #endif 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /** 56 | * Function for returning the state of an LED. 57 | * 58 | * @param led_idx LED index (starting from 0), as defined in the board-specific header. 59 | * 60 | * @return True if the LED is turned on. 61 | */ 62 | bool bsp_board_led_state_get(uint32_t led_idx); 63 | 64 | /** 65 | * Function for turning on an LED. 66 | * 67 | * @param led_idx LED index (starting from 0), as defined in the board-specific header. 68 | */ 69 | void bsp_board_led_on(uint32_t led_idx); 70 | 71 | /** 72 | * Function for turning off an LED. 73 | * 74 | * @param led_idx LED index (starting from 0), as defined in the board-specific header. 75 | */ 76 | void bsp_board_led_off(uint32_t led_idx); 77 | 78 | /** 79 | * Function for inverting the state of an LED. 80 | * 81 | * @param led_idx LED index (starting from 0), as defined in the board-specific header. 82 | */ 83 | void bsp_board_led_invert(uint32_t led_idx); 84 | /** 85 | * Function for turning off all LEDs. 86 | */ 87 | void bsp_board_leds_off(void); 88 | 89 | /** 90 | * Function for turning on all LEDs. 91 | */ 92 | void bsp_board_leds_on(void); 93 | 94 | /** 95 | * Function for initializing LEDs. 96 | */ 97 | void bsp_board_leds_init(void); 98 | 99 | /** 100 | * Function for converting pin number to LED index. 101 | * 102 | * @param pin_number Pin number. 103 | * 104 | * @return LED index of the given pin or 0xFFFFFFFF if invalid pin provided. 105 | */ 106 | uint32_t bsp_board_pin_to_led_idx(uint32_t pin_number); 107 | 108 | /** 109 | * Function for converting LED index to pin number. 110 | * 111 | * @param led_idx LED index. 112 | * 113 | * @return Pin number. 114 | */ 115 | uint32_t bsp_board_led_idx_to_pin(uint32_t led_idx); 116 | 117 | /** 118 | * Function for returning the state of a button. 119 | * 120 | * @param button_idx Button index (starting from 0), as defined in the board-specific header. 121 | * 122 | * @return True if the button is pressed. 123 | */ 124 | bool bsp_board_button_state_get(uint32_t button_idx); 125 | 126 | /** 127 | * Function for initializing buttons. 128 | */ 129 | void bsp_board_buttons_init(void); 130 | 131 | /** 132 | * Function for converting pin number to button index. 133 | * 134 | * @param pin_number Pin number. 135 | * 136 | * @return Button index of the given pin or 0xFFFFFFFF if invalid pin provided. 137 | */ 138 | uint32_t bsp_board_pin_to_button_idx(uint32_t pin_number); 139 | 140 | 141 | /** 142 | * Function for converting button index to pin number. 143 | * 144 | * @param button_idx Button index. 145 | * 146 | * @return Pin number. 147 | */ 148 | uint32_t bsp_board_button_idx_to_pin(uint32_t button_idx); 149 | 150 | #define BSP_BOARD_LED_0 0 151 | #define BSP_BOARD_LED_1 1 152 | #define BSP_BOARD_LED_2 2 153 | #define BSP_BOARD_LED_3 3 154 | #define BSP_BOARD_LED_4 4 155 | #define BSP_BOARD_LED_5 5 156 | #define BSP_BOARD_LED_6 6 157 | #define BSP_BOARD_LED_7 7 158 | 159 | #ifdef BSP_LED_0 160 | #define BSP_LED_0_MASK (1<OUTSET = (leds_mask) & (LEDS_MASK & LEDS_INV_MASK); \ 265 | NRF_GPIO->OUTCLR = (leds_mask) & (LEDS_MASK & ~LEDS_INV_MASK); } while (0) 266 | 267 | #define LEDS_ON(leds_mask) do { ASSERT(sizeof(leds_mask) == 4); \ 268 | NRF_GPIO->OUTCLR = (leds_mask) & (LEDS_MASK & LEDS_INV_MASK); \ 269 | NRF_GPIO->OUTSET = (leds_mask) & (LEDS_MASK & ~LEDS_INV_MASK); } while (0) 270 | 271 | #define LED_IS_ON(leds_mask) ((leds_mask) & (NRF_GPIO->OUT ^ LEDS_INV_MASK) ) 272 | 273 | #define LEDS_INVERT(leds_mask) do { uint32_t gpio_state = NRF_GPIO->OUT; \ 274 | ASSERT(sizeof(leds_mask) == 4); \ 275 | NRF_GPIO->OUTSET = ((leds_mask) & ~gpio_state); \ 276 | NRF_GPIO->OUTCLR = ((leds_mask) & gpio_state); } while (0) 277 | 278 | #define LEDS_CONFIGURE(leds_mask) do { uint32_t pin; \ 279 | ASSERT(sizeof(leds_mask) == 4); \ 280 | for (pin = 0; pin < 32; pin++) \ 281 | if ( (leds_mask) & (1 << pin) ) \ 282 | nrf_gpio_cfg_output(pin); } while (0) 283 | 284 | #ifdef __cplusplus 285 | } 286 | #endif 287 | 288 | #endif 289 | -------------------------------------------------------------------------------- /keys.h: -------------------------------------------------------------------------------- 1 | // this file is imcomplete and contains invalid public keys. You'll have to generate it yourself... 2 | 3 | uint8_t advertisement_keys[][28] = { 4 | 5 | { 0x92, 0xb1, 0xe3, 0xf6, 0xdb, 0xd5, 0x98, 0x2f, 0xe7, 0x22, 0x2c, 0xdc, 0x32, 0x63, 0x85, 0x1e, 0xd9, 0x75, 0xcb, 0xc6, 0x39, 0x71, 0x2e, 0x9c, 0xc8, 0xb5, 0xb6, 0x11, }, 6 | 7 | { 0x7f, 0x2a, 0x5, 0x93, 0x68, 0x9a, 0x51, 0xea, 0x48, 0xd, 0x9b, 0x61, 0x17, 0x4f, 0x51, 0x5a, 0xa0, 0x41, 0x9c, 0x1a, 0xef, 0x83, 0xb5, 0xe8, 0xa5, 0x65, 0x10, 0x55, }, 8 | 9 | ... 10 | }; 11 | uint16_t advertisement_key_count = 100; 12 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ble_advdata.h" 4 | #include "nordic_common.h" 5 | #include "softdevice_handler.h" 6 | #include "app_timer.h" 7 | #include "nrf_log.h" 8 | #include "nrf_log_ctrl.h" 9 | #include "bsp.h" 10 | #include "keys.h" 11 | #include "battery.h" 12 | #include "nrf_drv_gpiote.h" 13 | 14 | #define CENTRAL_LINK_COUNT 0 /**< Number of central links used by the application. When changing this number remember to adjust the RAM settings*/ 15 | #define PERIPHERAL_LINK_COUNT 0 /**< Number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/ 16 | 17 | #define IS_SRVC_CHANGED_CHARACT_PRESENT 0 /**< Include or not the service_changed characteristic. if not enabled, the server's database cannot be changed for the lifetime of the device*/ 18 | 19 | #define APP_CFG_NON_CONN_ADV_TIMEOUT 0 /**< Time for which the device must be advertising in non-connectable mode (in seconds). 0 disables timeout. */ 20 | #define NON_CONNECTABLE_ADV_INTERVAL MSEC_TO_UNITS(5000, UNIT_0_625_MS) /**< T 21 | err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);he advertising interval for non-connectable advertisement (100 ms). This value can vary between 100ms to 10.24s). */ 22 | 23 | #define DEAD_BEEF 0xDEADBEEF /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */ 24 | 25 | #define APP_TIMER_PRESCALER 8 /**< Value of the RTC1 PRESCALER register. */ 26 | #define APP_TIMER_OP_QUEUE_SIZE 4 /**< Size of timer operation queues. */ 27 | 28 | #define KEY_CYCLE_PERIOD APP_TIMER_TICKS(3600 * 1000, APP_TIMER_PRESCALER) 29 | #define LED_BLINK_PERIOD APP_TIMER_TICKS(100, APP_TIMER_PRESCALER) 30 | #define LED_BLINK_COUNT 3 31 | #define DEBOUNCE_PERIOD APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER) 32 | 33 | #define STATUS_FLAG_BATTERY_MASK 0b11000000 34 | #define STATUS_FLAG_COUNTER_MASK 0b00111111 35 | #define STATUS_FLAG_MEDIUM_BATTERY 0b01000000 36 | #define STATUS_FLAG_LOW_BATTERY 0b10000000 37 | #define STATUS_FLAG_CRITICALLY_LOW_BATTERY 0b11000000 38 | #define STATUS_FLAG_MAINTAINED 0b00000100 39 | 40 | #define BATTERY_COUNTER_THRESHOLD 10 41 | 42 | static ble_gap_adv_params_t m_adv_params; /**< Parameters to be passed to the stack when starting advertising. */ 43 | 44 | uint8_t status_flag = 0; 45 | uint16_t current_key_index = 0; 46 | uint8_t limit_led_blink = true; 47 | 48 | APP_TIMER_DEF(key_cycle_timer); 49 | APP_TIMER_DEF(led_blink_timer); 50 | #ifdef BUTTON_PIN 51 | APP_TIMER_DEF(debounce_timer); 52 | uint8_t ignore_button = false; 53 | #endif 54 | #ifdef BUTTON_PIN 55 | #endif 56 | 57 | static uint8_t offline_finding_adv_template[] = { 58 | 0x1e, /* Length (30) */ 59 | 0xff, /* Manufacturer Specific Data (type 0xff) */ 60 | 0x4c, 0x00, /* Company ID (Apple) */ 61 | 0x12, 0x19, /* Offline Finding type and length */ 62 | 0x00, /* State */ 63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 65 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 66 | 0x00, /* First two bits */ 67 | 0x00, /* Hint (0x00) */ 68 | }; 69 | 70 | /**@brief Callback function for asserts in the SoftDevice. 71 | * 72 | * @details This function will be called in case of an assert in the SoftDevice. 73 | * 74 | * @warning This handler is an example only and does not fit a final product. You need to analyze 75 | * how your product is supposed to react in case of Assert. 76 | * @warning On assert from the SoftDevice, the system can only recover on reset. 77 | * 78 | * @param[in] line_num Line number of the failing ASSERT call. 79 | * @param[in] file_name File name of the failing ASSERT call. 80 | */ 81 | void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name) 82 | { 83 | app_error_handler(DEAD_BEEF, line_num, p_file_name); 84 | } 85 | 86 | void fill_adv_template_from_key(uint8_t *key) { 87 | /* copy last 22 bytes */ 88 | memcpy(&offline_finding_adv_template[7], &key[6], 22); 89 | /* append two bits of public key */ 90 | offline_finding_adv_template[29] = key[0] >> 6; 91 | } 92 | 93 | void set_addr_from_key(uint8_t *key) { 94 | /* copy first 6 bytes */ 95 | /* BLESSED seems to reorder address bytes, so we copy them in reverse order */ 96 | 97 | ble_gap_addr_t address = { 98 | .addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC 99 | }; 100 | 101 | address.addr[5] = key[0] | 0b11000000; 102 | address.addr[4] = key[1]; 103 | address.addr[3] = key[2]; 104 | address.addr[2] = key[3]; 105 | address.addr[1] = key[4]; 106 | address.addr[0] = key[5]; 107 | 108 | NRF_LOG_DEBUG( 109 | "address is: %X:%X:%X:%X:%X:%X\n", 110 | address.addr[5], 111 | address.addr[4], 112 | address.addr[3], 113 | address.addr[2], 114 | address.addr[1], 115 | address.addr[0] 116 | ); 117 | 118 | ret_code_t ret_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &address); 119 | APP_ERROR_CHECK(ret_code); 120 | } 121 | 122 | /**@brief Function for initializing the Advertising functionality. 123 | * 124 | * @details Encodes the required advertising data and passes it to the stack. 125 | * Also builds a structure to be passed to the stack when starting advertising. 126 | */ 127 | static void advertising_init(void) 128 | { 129 | memset(&m_adv_params, 0, sizeof(m_adv_params)); 130 | 131 | m_adv_params.type = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND; 132 | m_adv_params.p_peer_addr = NULL; // Undirected advertisement. 133 | m_adv_params.fp = BLE_GAP_ADV_FP_ANY; 134 | m_adv_params.interval = NON_CONNECTABLE_ADV_INTERVAL; 135 | m_adv_params.timeout = APP_CFG_NON_CONN_ADV_TIMEOUT; 136 | } 137 | 138 | static void set_key(uint8_t *key){ 139 | set_addr_from_key(key); 140 | fill_adv_template_from_key(key); 141 | offline_finding_adv_template[6] = status_flag; 142 | ret_code_t err_code = sd_ble_gap_adv_data_set( 143 | offline_finding_adv_template, 144 | sizeof(offline_finding_adv_template), 145 | NULL, 146 | 0 147 | ); 148 | APP_ERROR_CHECK(err_code); 149 | } 150 | 151 | 152 | /**@brief Function for starting advertising. 153 | */ 154 | static void advertising_start(void) 155 | { 156 | ret_code_t err_code; 157 | 158 | err_code = sd_ble_gap_adv_start(&m_adv_params); 159 | APP_ERROR_CHECK(err_code); 160 | } 161 | 162 | 163 | /**@brief Function for initializing the BLE stack. 164 | * 165 | * @details Initializes the SoftDevice and the BLE event interrupt. 166 | */ 167 | static void ble_stack_init(void) 168 | { 169 | uint32_t err_code; 170 | 171 | nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC; 172 | 173 | // Initialize the SoftDevice handler module. 174 | SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL); 175 | 176 | ble_enable_params_t ble_enable_params; 177 | err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT, 178 | PERIPHERAL_LINK_COUNT, 179 | &ble_enable_params); 180 | APP_ERROR_CHECK(err_code); 181 | 182 | //Check the ram settings against the used number of links 183 | CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT); 184 | 185 | // Enable BLE stack. 186 | err_code = softdevice_enable(&ble_enable_params); 187 | APP_ERROR_CHECK(err_code); 188 | } 189 | 190 | 191 | /**@brief Function for doing power management. 192 | */ 193 | static void power_manage(void) 194 | { 195 | uint32_t err_code = sd_app_evt_wait(); 196 | APP_ERROR_CHECK(err_code); 197 | } 198 | 199 | void set_key_by_index(uint16_t key_index){ 200 | set_key(advertisement_keys[key_index]); 201 | } 202 | 203 | void update_battery_level(){ 204 | static uint16_t battery_counter = BATTERY_COUNTER_THRESHOLD; 205 | if((++battery_counter) < BATTERY_COUNTER_THRESHOLD){ 206 | return; 207 | } 208 | battery_counter = 0; 209 | uint8_t battery_level = get_current_level(); 210 | NRF_LOG_DEBUG("battery level: %d\n", battery_level); 211 | status_flag &= (~STATUS_FLAG_BATTERY_MASK); 212 | if(battery_level > 80){ 213 | // do nothing 214 | }else if(battery_level > 50){ 215 | status_flag |= STATUS_FLAG_MEDIUM_BATTERY; 216 | }else if(battery_level > 30){ 217 | status_flag |= STATUS_FLAG_LOW_BATTERY; 218 | }else{ 219 | status_flag |= STATUS_FLAG_CRITICALLY_LOW_BATTERY; 220 | } 221 | } 222 | 223 | void key_cycle_timer_handler(void *context){ 224 | update_battery_level(); 225 | 226 | current_key_index++; 227 | current_key_index %= advertisement_key_count; 228 | set_key_by_index(current_key_index); 229 | NRF_LOG_DEBUG("current key index: %d\n", current_key_index); 230 | 231 | } 232 | 233 | void led_timer_handler(void *context){ 234 | uint8_t blink_count = *((uint8_t*) context); 235 | if(blink_count & 1){ 236 | bsp_board_leds_on(); 237 | NRF_LOG_DEBUG("leds on\n"); 238 | }else{ 239 | bsp_board_leds_off(); 240 | NRF_LOG_DEBUG("leds off\n"); 241 | } 242 | (*((uint8_t*) context))--; 243 | if(blink_count <= 0){ 244 | app_timer_stop(led_blink_timer); 245 | } 246 | } 247 | 248 | #ifdef BUTTON_PIN 249 | void debounce_timer_handler(void *context){ 250 | ignore_button = false; 251 | NRF_LOG_DEBUG("debounce timer\n"); 252 | } 253 | #endif 254 | 255 | void timers_init(){ 256 | APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); 257 | 258 | app_timer_create( 259 | &key_cycle_timer, 260 | APP_TIMER_MODE_REPEATED, 261 | key_cycle_timer_handler 262 | ); 263 | app_timer_create( 264 | &led_blink_timer, 265 | APP_TIMER_MODE_REPEATED, 266 | led_timer_handler 267 | ); 268 | 269 | #ifdef BUTTON_PIN 270 | app_timer_create( 271 | &debounce_timer, 272 | APP_TIMER_MODE_SINGLE_SHOT, 273 | debounce_timer_handler 274 | ); 275 | #endif 276 | } 277 | 278 | void blink_leds(uint8_t blink_count){ 279 | static uint8_t blink_count_; 280 | blink_count_ = blink_count * 2; 281 | app_timer_start( 282 | led_blink_timer, 283 | LED_BLINK_PERIOD, 284 | &blink_count_ 285 | ); 286 | } 287 | 288 | void timers_start(){ 289 | app_timer_start( 290 | key_cycle_timer, 291 | KEY_CYCLE_PERIOD, 292 | NULL 293 | ); 294 | blink_leds(4); 295 | } 296 | 297 | void leds_init(){ 298 | bsp_board_leds_init(); 299 | } 300 | 301 | void button_handler(long unsigned int pin, nrf_gpiote_polarity_t polarity){ 302 | if(ignore_button){ 303 | return; 304 | } 305 | ignore_button = true; 306 | ret_code_t err_code; 307 | err_code = app_timer_start( 308 | debounce_timer, 309 | DEBOUNCE_PERIOD, 310 | NULL 311 | ); 312 | APP_ERROR_CHECK(err_code); 313 | 314 | static uint8_t button_counter = 0; 315 | button_counter++; 316 | status_flag &= (~STATUS_FLAG_COUNTER_MASK); 317 | status_flag |= (button_counter & STATUS_FLAG_COUNTER_MASK); 318 | NRF_LOG_DEBUG("setting button counter to %d\n", (button_counter & STATUS_FLAG_COUNTER_MASK)); 319 | set_key_by_index(current_key_index); 320 | blink_leds(25); 321 | } 322 | 323 | void buttons_init(){ 324 | #ifdef BUTTON_PIN 325 | NRF_LOG_DEBUG("enabling button support\n"); 326 | ret_code_t err_code; 327 | err_code = nrf_drv_gpiote_init(); 328 | APP_ERROR_CHECK(err_code); 329 | nrf_drv_gpiote_in_config_t in_config = { 330 | .sense = BUTTON_PULL == NRF_GPIO_PIN_PULLUP ? NRF_GPIOTE_POLARITY_HITOLO : NRF_GPIOTE_POLARITY_LOTOHI, 331 | .pull = BUTTON_PULL, 332 | .hi_accuracy = false, 333 | .is_watcher = false 334 | }; 335 | err_code = nrf_drv_gpiote_in_init(BUTTON_PIN, &in_config, button_handler); 336 | APP_ERROR_CHECK(err_code); 337 | nrf_drv_gpiote_in_event_enable(BUTTON_PIN, true); 338 | #endif 339 | 340 | } 341 | 342 | /** 343 | * @brief Function for application main entry. 344 | */ 345 | int main(void) 346 | { 347 | ret_code_t err_code; 348 | // Initialize. 349 | err_code = NRF_LOG_INIT(NULL); 350 | APP_ERROR_CHECK(err_code); 351 | 352 | NRF_LOG_DEBUG("key count: %d\n", advertisement_key_count); 353 | 354 | leds_init(); 355 | buttons_init(); 356 | 357 | timers_init(); 358 | timers_start(); 359 | 360 | ble_stack_init(); 361 | advertising_init(); 362 | 363 | update_battery_level(); 364 | 365 | set_key_by_index(0); 366 | // Start execution. 367 | NRF_LOG_INFO("BLE Beacon started\r\n"); 368 | advertising_start(); 369 | 370 | // Enter main loop. 371 | for (;; ) 372 | { 373 | if (NRF_LOG_PROCESS() == false) 374 | { 375 | power_manage(); 376 | } 377 | } 378 | } 379 | 380 | 381 | /** 382 | * @} 383 | */ 384 | -------------------------------------------------------------------------------- /nrf51822.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | /* flash length is calculated using the flash origin of the bootloader_secure */ 9 | FLASH (rx) : ORIGIN = 0x0001b000, LENGTH = 0x00035C00 - 0x0001b000 10 | RAM (rwx) : ORIGIN = 0x20001870, LENGTH = 0x2790 11 | } 12 | 13 | SECTIONS 14 | { 15 | .fs_data : 16 | { 17 | PROVIDE(__start_fs_data = .); 18 | KEEP(*(.fs_data)) 19 | PROVIDE(__stop_fs_data = .); 20 | } > RAM 21 | .pwr_mgmt_data : 22 | { 23 | PROVIDE(__start_pwr_mgmt_data = .); 24 | KEEP(*(.pwr_mgmt_data)) 25 | PROVIDE(__stop_pwr_mgmt_data = .); 26 | } > RAM 27 | } INSERT AFTER .data; 28 | 29 | INCLUDE "nrf5x_common.ld" 30 | -------------------------------------------------------------------------------- /sdk_config.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef SDK_CONFIG_H 4 | #define SDK_CONFIG_H 5 | // <<< Use Configuration Wizard in Context Menu >>>\n 6 | #ifdef USE_APP_CONFIG 7 | #include "app_config.h" 8 | #endif 9 | // nRF_BLE 10 | 11 | //========================================================== 12 | // BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module 13 | 14 | 15 | #ifndef BLE_ADVERTISING_ENABLED 16 | #define BLE_ADVERTISING_ENABLED 0 17 | #endif 18 | 19 | // BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands 20 | 21 | 22 | #ifndef BLE_DTM_ENABLED 23 | #define BLE_DTM_ENABLED 0 24 | #endif 25 | 26 | // BLE_RACP_ENABLED - ble_racp - Record Access Control Point library 27 | 28 | 29 | #ifndef BLE_RACP_ENABLED 30 | #define BLE_RACP_ENABLED 0 31 | #endif 32 | 33 | // NRF_BLE_QWR_ENABLED - nrf_ble_qwr - Queued writes support module (prepare/execute write) 34 | 35 | 36 | #ifndef NRF_BLE_QWR_ENABLED 37 | #define NRF_BLE_QWR_ENABLED 0 38 | #endif 39 | 40 | // PEER_MANAGER_ENABLED - peer_manager - Peer Manager 41 | 42 | 43 | #ifndef PEER_MANAGER_ENABLED 44 | #define PEER_MANAGER_ENABLED 0 45 | #endif 46 | 47 | // 48 | //========================================================== 49 | 50 | // nRF_BLE_Services 51 | 52 | //========================================================== 53 | // BLE_ANCS_C_ENABLED - ble_ancs_c - Apple Notification Service Client 54 | 55 | 56 | #ifndef BLE_ANCS_C_ENABLED 57 | #define BLE_ANCS_C_ENABLED 0 58 | #endif 59 | 60 | // BLE_ANS_C_ENABLED - ble_ans_c - Alert Notification Service Client 61 | 62 | 63 | #ifndef BLE_ANS_C_ENABLED 64 | #define BLE_ANS_C_ENABLED 0 65 | #endif 66 | 67 | // BLE_BAS_C_ENABLED - ble_bas_c - Battery Service Client 68 | 69 | 70 | #ifndef BLE_BAS_C_ENABLED 71 | #define BLE_BAS_C_ENABLED 0 72 | #endif 73 | 74 | // BLE_BAS_ENABLED - ble_bas - Battery Service 75 | 76 | 77 | #ifndef BLE_BAS_ENABLED 78 | #define BLE_BAS_ENABLED 0 79 | #endif 80 | 81 | // BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service 82 | 83 | 84 | #ifndef BLE_CSCS_ENABLED 85 | #define BLE_CSCS_ENABLED 0 86 | #endif 87 | 88 | // BLE_CTS_C_ENABLED - ble_cts_c - Current Time Service Client 89 | 90 | 91 | #ifndef BLE_CTS_C_ENABLED 92 | #define BLE_CTS_C_ENABLED 0 93 | #endif 94 | 95 | // BLE_DIS_ENABLED - ble_dis - Device Information Service 96 | 97 | 98 | #ifndef BLE_DIS_ENABLED 99 | #define BLE_DIS_ENABLED 0 100 | #endif 101 | 102 | // BLE_GLS_ENABLED - ble_gls - Glucose Service 103 | 104 | 105 | #ifndef BLE_GLS_ENABLED 106 | #define BLE_GLS_ENABLED 0 107 | #endif 108 | 109 | // BLE_HIDS_ENABLED - ble_hids - Human Interface Device Service 110 | 111 | 112 | #ifndef BLE_HIDS_ENABLED 113 | #define BLE_HIDS_ENABLED 0 114 | #endif 115 | 116 | // BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client 117 | //========================================================== 118 | #ifndef BLE_HRS_C_ENABLED 119 | #define BLE_HRS_C_ENABLED 0 120 | #endif 121 | #if BLE_HRS_C_ENABLED 122 | // BLE_HRS_C_RR_INTERVALS_MAX_CNT - Maximum number of RR_INTERVALS per notification to be decoded 123 | #ifndef BLE_HRS_C_RR_INTERVALS_MAX_CNT 124 | #define BLE_HRS_C_RR_INTERVALS_MAX_CNT 30 125 | #endif 126 | 127 | #endif //BLE_HRS_C_ENABLED 128 | // 129 | 130 | // BLE_HRS_ENABLED - ble_hrs - Heart Rate Service 131 | 132 | 133 | #ifndef BLE_HRS_ENABLED 134 | #define BLE_HRS_ENABLED 0 135 | #endif 136 | 137 | // BLE_HTS_ENABLED - ble_hts - Health Thermometer Service 138 | 139 | 140 | #ifndef BLE_HTS_ENABLED 141 | #define BLE_HTS_ENABLED 0 142 | #endif 143 | 144 | // BLE_IAS_C_ENABLED - ble_ias_c - Immediate Alert Service Client 145 | 146 | 147 | #ifndef BLE_IAS_C_ENABLED 148 | #define BLE_IAS_C_ENABLED 0 149 | #endif 150 | 151 | // BLE_IAS_ENABLED - ble_ias - Immediate Alert Service 152 | 153 | 154 | #ifndef BLE_IAS_ENABLED 155 | #define BLE_IAS_ENABLED 0 156 | #endif 157 | 158 | // BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client 159 | 160 | 161 | #ifndef BLE_LBS_C_ENABLED 162 | #define BLE_LBS_C_ENABLED 0 163 | #endif 164 | 165 | // BLE_LBS_ENABLED - ble_lbs - LED Button Service 166 | 167 | 168 | #ifndef BLE_LBS_ENABLED 169 | #define BLE_LBS_ENABLED 0 170 | #endif 171 | 172 | // BLE_LLS_ENABLED - ble_lls - Link Loss Service 173 | 174 | 175 | #ifndef BLE_LLS_ENABLED 176 | #define BLE_LLS_ENABLED 0 177 | #endif 178 | 179 | // BLE_NUS_C_ENABLED - ble_nus_c - Nordic UART Central Service 180 | 181 | 182 | #ifndef BLE_NUS_C_ENABLED 183 | #define BLE_NUS_C_ENABLED 0 184 | #endif 185 | 186 | // BLE_NUS_ENABLED - ble_nus - Nordic UART Service 187 | 188 | 189 | #ifndef BLE_NUS_ENABLED 190 | #define BLE_NUS_ENABLED 0 191 | #endif 192 | 193 | // BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client 194 | 195 | 196 | #ifndef BLE_RSCS_C_ENABLED 197 | #define BLE_RSCS_C_ENABLED 0 198 | #endif 199 | 200 | // BLE_RSCS_ENABLED - ble_rscs - Running Speed and Cadence Service 201 | 202 | 203 | #ifndef BLE_RSCS_ENABLED 204 | #define BLE_RSCS_ENABLED 0 205 | #endif 206 | 207 | // BLE_TPS_ENABLED - ble_tps - TX Power Service 208 | 209 | 210 | #ifndef BLE_TPS_ENABLED 211 | #define BLE_TPS_ENABLED 0 212 | #endif 213 | 214 | // 215 | //========================================================== 216 | 217 | // nRF_Drivers 218 | 219 | //========================================================== 220 | // ADC_ENABLED - nrf_drv_adc - Driver for ADC peripheral (nRF51) 221 | //========================================================== 222 | #ifndef ADC_ENABLED 223 | #define ADC_ENABLED 0 224 | #endif 225 | #if ADC_ENABLED 226 | // ADC_CONFIG_IRQ_PRIORITY - Interrupt priority 227 | 228 | 229 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 230 | // <0=> 0 (highest) 231 | // <1=> 1 232 | // <2=> 2 233 | // <3=> 3 234 | 235 | #ifndef ADC_CONFIG_IRQ_PRIORITY 236 | #define ADC_CONFIG_IRQ_PRIORITY 3 237 | #endif 238 | 239 | // ADC_CONFIG_LOG_ENABLED - Enables logging in the module. 240 | //========================================================== 241 | #ifndef ADC_CONFIG_LOG_ENABLED 242 | #define ADC_CONFIG_LOG_ENABLED 0 243 | #endif 244 | #if ADC_CONFIG_LOG_ENABLED 245 | // ADC_CONFIG_LOG_LEVEL - Default Severity level 246 | 247 | // <0=> Off 248 | // <1=> Error 249 | // <2=> Warning 250 | // <3=> Info 251 | // <4=> Debug 252 | 253 | #ifndef ADC_CONFIG_LOG_LEVEL 254 | #define ADC_CONFIG_LOG_LEVEL 3 255 | #endif 256 | 257 | // ADC_CONFIG_INFO_COLOR - ANSI escape code prefix. 258 | 259 | // <0=> Default 260 | // <1=> Black 261 | // <2=> Red 262 | // <3=> Green 263 | // <4=> Yellow 264 | // <5=> Blue 265 | // <6=> Magenta 266 | // <7=> Cyan 267 | // <8=> White 268 | 269 | #ifndef ADC_CONFIG_INFO_COLOR 270 | #define ADC_CONFIG_INFO_COLOR 0 271 | #endif 272 | 273 | // ADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 274 | 275 | // <0=> Default 276 | // <1=> Black 277 | // <2=> Red 278 | // <3=> Green 279 | // <4=> Yellow 280 | // <5=> Blue 281 | // <6=> Magenta 282 | // <7=> Cyan 283 | // <8=> White 284 | 285 | #ifndef ADC_CONFIG_DEBUG_COLOR 286 | #define ADC_CONFIG_DEBUG_COLOR 0 287 | #endif 288 | 289 | #endif //ADC_CONFIG_LOG_ENABLED 290 | // 291 | 292 | #endif //ADC_ENABLED 293 | // 294 | 295 | // APP_USBD_ENABLED - app_usbd - USB Device library 296 | //========================================================== 297 | #ifndef APP_USBD_ENABLED 298 | #define APP_USBD_ENABLED 0 299 | #endif 300 | #if APP_USBD_ENABLED 301 | // APP_USBD_VID - Vendor ID <0x0000-0xFFFF> 302 | 303 | 304 | // Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ 305 | 306 | #ifndef APP_USBD_VID 307 | #define APP_USBD_VID 0 308 | #endif 309 | 310 | // APP_USBD_PID - Product ID <0x0000-0xFFFF> 311 | 312 | 313 | // Selected Product ID 314 | 315 | #ifndef APP_USBD_PID 316 | #define APP_USBD_PID 0 317 | #endif 318 | 319 | // APP_USBD_DEVICE_VER_MAJOR - Device version, major part <0-99> 320 | 321 | 322 | // Device version, will be converted automatically to BCD notation. Use just decimal values. 323 | 324 | #ifndef APP_USBD_DEVICE_VER_MAJOR 325 | #define APP_USBD_DEVICE_VER_MAJOR 1 326 | #endif 327 | 328 | // APP_USBD_DEVICE_VER_MINOR - Device version, minor part <0-99> 329 | 330 | 331 | // Device version, will be converted automatically to BCD notation. Use just decimal values. 332 | 333 | #ifndef APP_USBD_DEVICE_VER_MINOR 334 | #define APP_USBD_DEVICE_VER_MINOR 0 335 | #endif 336 | 337 | #endif //APP_USBD_ENABLED 338 | // 339 | 340 | // CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver 341 | //========================================================== 342 | #ifndef CLOCK_ENABLED 343 | #define CLOCK_ENABLED 1 344 | #endif 345 | #if CLOCK_ENABLED 346 | // CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency 347 | 348 | // <0=> Default (64 MHz) 349 | // <255=> Default (16 MHz) 350 | // <0=> 32 MHz 351 | 352 | #ifndef CLOCK_CONFIG_XTAL_FREQ 353 | #define CLOCK_CONFIG_XTAL_FREQ 255 354 | #endif 355 | 356 | // CLOCK_CONFIG_LF_SRC - LF Clock Source 357 | 358 | // <0=> RC 359 | // <1=> XTAL 360 | // <2=> Synth 361 | 362 | #ifndef CLOCK_CONFIG_LF_SRC 363 | #define CLOCK_CONFIG_LF_SRC 1 364 | #endif 365 | 366 | // CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority 367 | 368 | 369 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 370 | // <0=> 0 (highest) 371 | // <1=> 1 372 | // <2=> 2 373 | // <3=> 3 374 | 375 | #ifndef CLOCK_CONFIG_IRQ_PRIORITY 376 | #define CLOCK_CONFIG_IRQ_PRIORITY 3 377 | #endif 378 | 379 | // CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. 380 | //========================================================== 381 | #ifndef CLOCK_CONFIG_LOG_ENABLED 382 | #define CLOCK_CONFIG_LOG_ENABLED 0 383 | #endif 384 | #if CLOCK_CONFIG_LOG_ENABLED 385 | // CLOCK_CONFIG_LOG_LEVEL - Default Severity level 386 | 387 | // <0=> Off 388 | // <1=> Error 389 | // <2=> Warning 390 | // <3=> Info 391 | // <4=> Debug 392 | 393 | #ifndef CLOCK_CONFIG_LOG_LEVEL 394 | #define CLOCK_CONFIG_LOG_LEVEL 3 395 | #endif 396 | 397 | // CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. 398 | 399 | // <0=> Default 400 | // <1=> Black 401 | // <2=> Red 402 | // <3=> Green 403 | // <4=> Yellow 404 | // <5=> Blue 405 | // <6=> Magenta 406 | // <7=> Cyan 407 | // <8=> White 408 | 409 | #ifndef CLOCK_CONFIG_INFO_COLOR 410 | #define CLOCK_CONFIG_INFO_COLOR 0 411 | #endif 412 | 413 | // CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 414 | 415 | // <0=> Default 416 | // <1=> Black 417 | // <2=> Red 418 | // <3=> Green 419 | // <4=> Yellow 420 | // <5=> Blue 421 | // <6=> Magenta 422 | // <7=> Cyan 423 | // <8=> White 424 | 425 | #ifndef CLOCK_CONFIG_DEBUG_COLOR 426 | #define CLOCK_CONFIG_DEBUG_COLOR 0 427 | #endif 428 | 429 | #endif //CLOCK_CONFIG_LOG_ENABLED 430 | // 431 | 432 | #endif //CLOCK_ENABLED 433 | // 434 | 435 | // COMP_ENABLED - nrf_drv_comp - COMP peripheral driver 436 | //========================================================== 437 | #ifndef COMP_ENABLED 438 | #define COMP_ENABLED 0 439 | #endif 440 | #if COMP_ENABLED 441 | // COMP_CONFIG_REF - Reference voltage 442 | 443 | // <0=> Internal 1.2V 444 | // <1=> Internal 1.8V 445 | // <2=> Internal 2.4V 446 | // <4=> VDD 447 | // <7=> ARef 448 | 449 | #ifndef COMP_CONFIG_REF 450 | #define COMP_CONFIG_REF 1 451 | #endif 452 | 453 | // COMP_CONFIG_MAIN_MODE - Main mode 454 | 455 | // <0=> Single ended 456 | // <1=> Differential 457 | 458 | #ifndef COMP_CONFIG_MAIN_MODE 459 | #define COMP_CONFIG_MAIN_MODE 0 460 | #endif 461 | 462 | // COMP_CONFIG_SPEED_MODE - Speed mode 463 | 464 | // <0=> Low power 465 | // <1=> Normal 466 | // <2=> High speed 467 | 468 | #ifndef COMP_CONFIG_SPEED_MODE 469 | #define COMP_CONFIG_SPEED_MODE 2 470 | #endif 471 | 472 | // COMP_CONFIG_HYST - Hystheresis 473 | 474 | // <0=> No 475 | // <1=> 50mV 476 | 477 | #ifndef COMP_CONFIG_HYST 478 | #define COMP_CONFIG_HYST 0 479 | #endif 480 | 481 | // COMP_CONFIG_ISOURCE - Current Source 482 | 483 | // <0=> Off 484 | // <1=> 2.5 uA 485 | // <2=> 5 uA 486 | // <3=> 10 uA 487 | 488 | #ifndef COMP_CONFIG_ISOURCE 489 | #define COMP_CONFIG_ISOURCE 0 490 | #endif 491 | 492 | // COMP_CONFIG_INPUT - Analog input 493 | 494 | // <0=> 0 495 | // <1=> 1 496 | // <2=> 2 497 | // <3=> 3 498 | // <4=> 4 499 | // <5=> 5 500 | // <6=> 6 501 | // <7=> 7 502 | 503 | #ifndef COMP_CONFIG_INPUT 504 | #define COMP_CONFIG_INPUT 0 505 | #endif 506 | 507 | // COMP_CONFIG_IRQ_PRIORITY - Interrupt priority 508 | 509 | 510 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 511 | // <0=> 0 (highest) 512 | // <1=> 1 513 | // <2=> 2 514 | // <3=> 3 515 | 516 | #ifndef COMP_CONFIG_IRQ_PRIORITY 517 | #define COMP_CONFIG_IRQ_PRIORITY 3 518 | #endif 519 | 520 | // COMP_CONFIG_LOG_ENABLED - Enables logging in the module. 521 | //========================================================== 522 | #ifndef COMP_CONFIG_LOG_ENABLED 523 | #define COMP_CONFIG_LOG_ENABLED 0 524 | #endif 525 | #if COMP_CONFIG_LOG_ENABLED 526 | // COMP_CONFIG_LOG_LEVEL - Default Severity level 527 | 528 | // <0=> Off 529 | // <1=> Error 530 | // <2=> Warning 531 | // <3=> Info 532 | // <4=> Debug 533 | 534 | #ifndef COMP_CONFIG_LOG_LEVEL 535 | #define COMP_CONFIG_LOG_LEVEL 3 536 | #endif 537 | 538 | // COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. 539 | 540 | // <0=> Default 541 | // <1=> Black 542 | // <2=> Red 543 | // <3=> Green 544 | // <4=> Yellow 545 | // <5=> Blue 546 | // <6=> Magenta 547 | // <7=> Cyan 548 | // <8=> White 549 | 550 | #ifndef COMP_CONFIG_INFO_COLOR 551 | #define COMP_CONFIG_INFO_COLOR 0 552 | #endif 553 | 554 | // COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 555 | 556 | // <0=> Default 557 | // <1=> Black 558 | // <2=> Red 559 | // <3=> Green 560 | // <4=> Yellow 561 | // <5=> Blue 562 | // <6=> Magenta 563 | // <7=> Cyan 564 | // <8=> White 565 | 566 | #ifndef COMP_CONFIG_DEBUG_COLOR 567 | #define COMP_CONFIG_DEBUG_COLOR 0 568 | #endif 569 | 570 | #endif //COMP_CONFIG_LOG_ENABLED 571 | // 572 | 573 | #endif //COMP_ENABLED 574 | // 575 | 576 | // EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver 577 | //========================================================== 578 | #ifndef EGU_ENABLED 579 | #define EGU_ENABLED 0 580 | #endif 581 | #if EGU_ENABLED 582 | // SWI_CONFIG_LOG_ENABLED - Enables logging in the module. 583 | //========================================================== 584 | #ifndef SWI_CONFIG_LOG_ENABLED 585 | #define SWI_CONFIG_LOG_ENABLED 0 586 | #endif 587 | #if SWI_CONFIG_LOG_ENABLED 588 | // SWI_CONFIG_LOG_LEVEL - Default Severity level 589 | 590 | // <0=> Off 591 | // <1=> Error 592 | // <2=> Warning 593 | // <3=> Info 594 | // <4=> Debug 595 | 596 | #ifndef SWI_CONFIG_LOG_LEVEL 597 | #define SWI_CONFIG_LOG_LEVEL 3 598 | #endif 599 | 600 | // SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. 601 | 602 | // <0=> Default 603 | // <1=> Black 604 | // <2=> Red 605 | // <3=> Green 606 | // <4=> Yellow 607 | // <5=> Blue 608 | // <6=> Magenta 609 | // <7=> Cyan 610 | // <8=> White 611 | 612 | #ifndef SWI_CONFIG_INFO_COLOR 613 | #define SWI_CONFIG_INFO_COLOR 0 614 | #endif 615 | 616 | // SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 617 | 618 | // <0=> Default 619 | // <1=> Black 620 | // <2=> Red 621 | // <3=> Green 622 | // <4=> Yellow 623 | // <5=> Blue 624 | // <6=> Magenta 625 | // <7=> Cyan 626 | // <8=> White 627 | 628 | #ifndef SWI_CONFIG_DEBUG_COLOR 629 | #define SWI_CONFIG_DEBUG_COLOR 0 630 | #endif 631 | 632 | #endif //SWI_CONFIG_LOG_ENABLED 633 | // 634 | 635 | #endif //EGU_ENABLED 636 | // 637 | 638 | // GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver 639 | //========================================================== 640 | #ifndef GPIOTE_ENABLED 641 | #define GPIOTE_ENABLED 1 642 | #endif 643 | #if GPIOTE_ENABLED 644 | // GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins 645 | #ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 646 | #define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4 647 | #endif 648 | 649 | // GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority 650 | 651 | 652 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 653 | // <0=> 0 (highest) 654 | // <1=> 1 655 | // <2=> 2 656 | // <3=> 3 657 | 658 | #ifndef GPIOTE_CONFIG_IRQ_PRIORITY 659 | #define GPIOTE_CONFIG_IRQ_PRIORITY 3 660 | #endif 661 | 662 | // GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. 663 | //========================================================== 664 | #ifndef GPIOTE_CONFIG_LOG_ENABLED 665 | #define GPIOTE_CONFIG_LOG_ENABLED 0 666 | #endif 667 | #if GPIOTE_CONFIG_LOG_ENABLED 668 | // GPIOTE_CONFIG_LOG_LEVEL - Default Severity level 669 | 670 | // <0=> Off 671 | // <1=> Error 672 | // <2=> Warning 673 | // <3=> Info 674 | // <4=> Debug 675 | 676 | #ifndef GPIOTE_CONFIG_LOG_LEVEL 677 | #define GPIOTE_CONFIG_LOG_LEVEL 3 678 | #endif 679 | 680 | // GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. 681 | 682 | // <0=> Default 683 | // <1=> Black 684 | // <2=> Red 685 | // <3=> Green 686 | // <4=> Yellow 687 | // <5=> Blue 688 | // <6=> Magenta 689 | // <7=> Cyan 690 | // <8=> White 691 | 692 | #ifndef GPIOTE_CONFIG_INFO_COLOR 693 | #define GPIOTE_CONFIG_INFO_COLOR 0 694 | #endif 695 | 696 | // GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 697 | 698 | // <0=> Default 699 | // <1=> Black 700 | // <2=> Red 701 | // <3=> Green 702 | // <4=> Yellow 703 | // <5=> Blue 704 | // <6=> Magenta 705 | // <7=> Cyan 706 | // <8=> White 707 | 708 | #ifndef GPIOTE_CONFIG_DEBUG_COLOR 709 | #define GPIOTE_CONFIG_DEBUG_COLOR 0 710 | #endif 711 | 712 | #endif //GPIOTE_CONFIG_LOG_ENABLED 713 | // 714 | 715 | #endif //GPIOTE_ENABLED 716 | // 717 | 718 | // I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver 719 | //========================================================== 720 | #ifndef I2S_ENABLED 721 | #define I2S_ENABLED 0 722 | #endif 723 | #if I2S_ENABLED 724 | // I2S_CONFIG_SCK_PIN - SCK pin <0-31> 725 | 726 | 727 | #ifndef I2S_CONFIG_SCK_PIN 728 | #define I2S_CONFIG_SCK_PIN 31 729 | #endif 730 | 731 | // I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> 732 | 733 | 734 | #ifndef I2S_CONFIG_LRCK_PIN 735 | #define I2S_CONFIG_LRCK_PIN 30 736 | #endif 737 | 738 | // I2S_CONFIG_MCK_PIN - MCK pin 739 | #ifndef I2S_CONFIG_MCK_PIN 740 | #define I2S_CONFIG_MCK_PIN 255 741 | #endif 742 | 743 | // I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> 744 | 745 | 746 | #ifndef I2S_CONFIG_SDOUT_PIN 747 | #define I2S_CONFIG_SDOUT_PIN 29 748 | #endif 749 | 750 | // I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> 751 | 752 | 753 | #ifndef I2S_CONFIG_SDIN_PIN 754 | #define I2S_CONFIG_SDIN_PIN 28 755 | #endif 756 | 757 | // I2S_CONFIG_MASTER - Mode 758 | 759 | // <0=> Master 760 | // <1=> Slave 761 | 762 | #ifndef I2S_CONFIG_MASTER 763 | #define I2S_CONFIG_MASTER 0 764 | #endif 765 | 766 | // I2S_CONFIG_FORMAT - Format 767 | 768 | // <0=> I2S 769 | // <1=> Aligned 770 | 771 | #ifndef I2S_CONFIG_FORMAT 772 | #define I2S_CONFIG_FORMAT 0 773 | #endif 774 | 775 | // I2S_CONFIG_ALIGN - Alignment 776 | 777 | // <0=> Left 778 | // <1=> Right 779 | 780 | #ifndef I2S_CONFIG_ALIGN 781 | #define I2S_CONFIG_ALIGN 0 782 | #endif 783 | 784 | // I2S_CONFIG_SWIDTH - Sample width (bits) 785 | 786 | // <0=> 8 787 | // <1=> 16 788 | // <2=> 24 789 | 790 | #ifndef I2S_CONFIG_SWIDTH 791 | #define I2S_CONFIG_SWIDTH 1 792 | #endif 793 | 794 | // I2S_CONFIG_CHANNELS - Channels 795 | 796 | // <0=> Stereo 797 | // <1=> Left 798 | // <2=> Right 799 | 800 | #ifndef I2S_CONFIG_CHANNELS 801 | #define I2S_CONFIG_CHANNELS 1 802 | #endif 803 | 804 | // I2S_CONFIG_MCK_SETUP - MCK behavior 805 | 806 | // <0=> Disabled 807 | // <2147483648=> 32MHz/2 808 | // <1342177280=> 32MHz/3 809 | // <1073741824=> 32MHz/4 810 | // <805306368=> 32MHz/5 811 | // <671088640=> 32MHz/6 812 | // <536870912=> 32MHz/8 813 | // <402653184=> 32MHz/10 814 | // <369098752=> 32MHz/11 815 | // <285212672=> 32MHz/15 816 | // <268435456=> 32MHz/16 817 | // <201326592=> 32MHz/21 818 | // <184549376=> 32MHz/23 819 | // <142606336=> 32MHz/30 820 | // <138412032=> 32MHz/31 821 | // <134217728=> 32MHz/32 822 | // <100663296=> 32MHz/42 823 | // <68157440=> 32MHz/63 824 | // <34340864=> 32MHz/125 825 | 826 | #ifndef I2S_CONFIG_MCK_SETUP 827 | #define I2S_CONFIG_MCK_SETUP 536870912 828 | #endif 829 | 830 | // I2S_CONFIG_RATIO - MCK/LRCK ratio 831 | 832 | // <0=> 32x 833 | // <1=> 48x 834 | // <2=> 64x 835 | // <3=> 96x 836 | // <4=> 128x 837 | // <5=> 192x 838 | // <6=> 256x 839 | // <7=> 384x 840 | // <8=> 512x 841 | 842 | #ifndef I2S_CONFIG_RATIO 843 | #define I2S_CONFIG_RATIO 2000 844 | #endif 845 | 846 | // I2S_CONFIG_IRQ_PRIORITY - Interrupt priority 847 | 848 | 849 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 850 | // <0=> 0 (highest) 851 | // <1=> 1 852 | // <2=> 2 853 | // <3=> 3 854 | 855 | #ifndef I2S_CONFIG_IRQ_PRIORITY 856 | #define I2S_CONFIG_IRQ_PRIORITY 3 857 | #endif 858 | 859 | // I2S_CONFIG_LOG_ENABLED - Enables logging in the module. 860 | //========================================================== 861 | #ifndef I2S_CONFIG_LOG_ENABLED 862 | #define I2S_CONFIG_LOG_ENABLED 0 863 | #endif 864 | #if I2S_CONFIG_LOG_ENABLED 865 | // I2S_CONFIG_LOG_LEVEL - Default Severity level 866 | 867 | // <0=> Off 868 | // <1=> Error 869 | // <2=> Warning 870 | // <3=> Info 871 | // <4=> Debug 872 | 873 | #ifndef I2S_CONFIG_LOG_LEVEL 874 | #define I2S_CONFIG_LOG_LEVEL 3 875 | #endif 876 | 877 | // I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. 878 | 879 | // <0=> Default 880 | // <1=> Black 881 | // <2=> Red 882 | // <3=> Green 883 | // <4=> Yellow 884 | // <5=> Blue 885 | // <6=> Magenta 886 | // <7=> Cyan 887 | // <8=> White 888 | 889 | #ifndef I2S_CONFIG_INFO_COLOR 890 | #define I2S_CONFIG_INFO_COLOR 0 891 | #endif 892 | 893 | // I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 894 | 895 | // <0=> Default 896 | // <1=> Black 897 | // <2=> Red 898 | // <3=> Green 899 | // <4=> Yellow 900 | // <5=> Blue 901 | // <6=> Magenta 902 | // <7=> Cyan 903 | // <8=> White 904 | 905 | #ifndef I2S_CONFIG_DEBUG_COLOR 906 | #define I2S_CONFIG_DEBUG_COLOR 0 907 | #endif 908 | 909 | #endif //I2S_CONFIG_LOG_ENABLED 910 | // 911 | 912 | #endif //I2S_ENABLED 913 | // 914 | 915 | // LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver 916 | //========================================================== 917 | #ifndef LPCOMP_ENABLED 918 | #define LPCOMP_ENABLED 0 919 | #endif 920 | #if LPCOMP_ENABLED 921 | // LPCOMP_CONFIG_REFERENCE - Reference voltage 922 | 923 | // <0=> Supply 1/8 924 | // <1=> Supply 2/8 925 | // <2=> Supply 3/8 926 | // <3=> Supply 4/8 927 | // <4=> Supply 5/8 928 | // <5=> Supply 6/8 929 | // <6=> Supply 7/8 930 | // <8=> Supply 1/16 (nRF52) 931 | // <9=> Supply 3/16 (nRF52) 932 | // <10=> Supply 5/16 (nRF52) 933 | // <11=> Supply 7/16 (nRF52) 934 | // <12=> Supply 9/16 (nRF52) 935 | // <13=> Supply 11/16 (nRF52) 936 | // <14=> Supply 13/16 (nRF52) 937 | // <15=> Supply 15/16 (nRF52) 938 | // <7=> External Ref 0 939 | // <65543=> External Ref 1 940 | 941 | #ifndef LPCOMP_CONFIG_REFERENCE 942 | #define LPCOMP_CONFIG_REFERENCE 3 943 | #endif 944 | 945 | // LPCOMP_CONFIG_DETECTION - Detection 946 | 947 | // <0=> Crossing 948 | // <1=> Up 949 | // <2=> Down 950 | 951 | #ifndef LPCOMP_CONFIG_DETECTION 952 | #define LPCOMP_CONFIG_DETECTION 2 953 | #endif 954 | 955 | // LPCOMP_CONFIG_INPUT - Analog input 956 | 957 | // <0=> 0 958 | // <1=> 1 959 | // <2=> 2 960 | // <3=> 3 961 | // <4=> 4 962 | // <5=> 5 963 | // <6=> 6 964 | // <7=> 7 965 | 966 | #ifndef LPCOMP_CONFIG_INPUT 967 | #define LPCOMP_CONFIG_INPUT 0 968 | #endif 969 | 970 | // LPCOMP_CONFIG_HYST - Hysteresis 971 | 972 | 973 | #ifndef LPCOMP_CONFIG_HYST 974 | #define LPCOMP_CONFIG_HYST 0 975 | #endif 976 | 977 | // LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority 978 | 979 | 980 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 981 | // <0=> 0 (highest) 982 | // <1=> 1 983 | // <2=> 2 984 | // <3=> 3 985 | 986 | #ifndef LPCOMP_CONFIG_IRQ_PRIORITY 987 | #define LPCOMP_CONFIG_IRQ_PRIORITY 3 988 | #endif 989 | 990 | // LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. 991 | //========================================================== 992 | #ifndef LPCOMP_CONFIG_LOG_ENABLED 993 | #define LPCOMP_CONFIG_LOG_ENABLED 0 994 | #endif 995 | #if LPCOMP_CONFIG_LOG_ENABLED 996 | // LPCOMP_CONFIG_LOG_LEVEL - Default Severity level 997 | 998 | // <0=> Off 999 | // <1=> Error 1000 | // <2=> Warning 1001 | // <3=> Info 1002 | // <4=> Debug 1003 | 1004 | #ifndef LPCOMP_CONFIG_LOG_LEVEL 1005 | #define LPCOMP_CONFIG_LOG_LEVEL 3 1006 | #endif 1007 | 1008 | // LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. 1009 | 1010 | // <0=> Default 1011 | // <1=> Black 1012 | // <2=> Red 1013 | // <3=> Green 1014 | // <4=> Yellow 1015 | // <5=> Blue 1016 | // <6=> Magenta 1017 | // <7=> Cyan 1018 | // <8=> White 1019 | 1020 | #ifndef LPCOMP_CONFIG_INFO_COLOR 1021 | #define LPCOMP_CONFIG_INFO_COLOR 0 1022 | #endif 1023 | 1024 | // LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 1025 | 1026 | // <0=> Default 1027 | // <1=> Black 1028 | // <2=> Red 1029 | // <3=> Green 1030 | // <4=> Yellow 1031 | // <5=> Blue 1032 | // <6=> Magenta 1033 | // <7=> Cyan 1034 | // <8=> White 1035 | 1036 | #ifndef LPCOMP_CONFIG_DEBUG_COLOR 1037 | #define LPCOMP_CONFIG_DEBUG_COLOR 0 1038 | #endif 1039 | 1040 | #endif //LPCOMP_CONFIG_LOG_ENABLED 1041 | // 1042 | 1043 | #endif //LPCOMP_ENABLED 1044 | // 1045 | 1046 | // PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver 1047 | //========================================================== 1048 | #ifndef PDM_ENABLED 1049 | #define PDM_ENABLED 0 1050 | #endif 1051 | #if PDM_ENABLED 1052 | // PDM_CONFIG_MODE - Mode 1053 | 1054 | // <0=> Stereo 1055 | // <1=> Mono 1056 | 1057 | #ifndef PDM_CONFIG_MODE 1058 | #define PDM_CONFIG_MODE 1 1059 | #endif 1060 | 1061 | // PDM_CONFIG_EDGE - Edge 1062 | 1063 | // <0=> Left falling 1064 | // <1=> Left rising 1065 | 1066 | #ifndef PDM_CONFIG_EDGE 1067 | #define PDM_CONFIG_EDGE 0 1068 | #endif 1069 | 1070 | // PDM_CONFIG_CLOCK_FREQ - Clock frequency 1071 | 1072 | // <134217728=> 1000k 1073 | // <138412032=> 1032k (default) 1074 | // <142606336=> 1067k 1075 | 1076 | #ifndef PDM_CONFIG_CLOCK_FREQ 1077 | #define PDM_CONFIG_CLOCK_FREQ 138412032 1078 | #endif 1079 | 1080 | // PDM_CONFIG_IRQ_PRIORITY - Interrupt priority 1081 | 1082 | 1083 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 1084 | // <0=> 0 (highest) 1085 | // <1=> 1 1086 | // <2=> 2 1087 | // <3=> 3 1088 | 1089 | #ifndef PDM_CONFIG_IRQ_PRIORITY 1090 | #define PDM_CONFIG_IRQ_PRIORITY 3 1091 | #endif 1092 | 1093 | // PDM_CONFIG_LOG_ENABLED - Enables logging in the module. 1094 | //========================================================== 1095 | #ifndef PDM_CONFIG_LOG_ENABLED 1096 | #define PDM_CONFIG_LOG_ENABLED 0 1097 | #endif 1098 | #if PDM_CONFIG_LOG_ENABLED 1099 | // PDM_CONFIG_LOG_LEVEL - Default Severity level 1100 | 1101 | // <0=> Off 1102 | // <1=> Error 1103 | // <2=> Warning 1104 | // <3=> Info 1105 | // <4=> Debug 1106 | 1107 | #ifndef PDM_CONFIG_LOG_LEVEL 1108 | #define PDM_CONFIG_LOG_LEVEL 3 1109 | #endif 1110 | 1111 | // PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. 1112 | 1113 | // <0=> Default 1114 | // <1=> Black 1115 | // <2=> Red 1116 | // <3=> Green 1117 | // <4=> Yellow 1118 | // <5=> Blue 1119 | // <6=> Magenta 1120 | // <7=> Cyan 1121 | // <8=> White 1122 | 1123 | #ifndef PDM_CONFIG_INFO_COLOR 1124 | #define PDM_CONFIG_INFO_COLOR 0 1125 | #endif 1126 | 1127 | // PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 1128 | 1129 | // <0=> Default 1130 | // <1=> Black 1131 | // <2=> Red 1132 | // <3=> Green 1133 | // <4=> Yellow 1134 | // <5=> Blue 1135 | // <6=> Magenta 1136 | // <7=> Cyan 1137 | // <8=> White 1138 | 1139 | #ifndef PDM_CONFIG_DEBUG_COLOR 1140 | #define PDM_CONFIG_DEBUG_COLOR 0 1141 | #endif 1142 | 1143 | #endif //PDM_CONFIG_LOG_ENABLED 1144 | // 1145 | 1146 | #endif //PDM_ENABLED 1147 | // 1148 | 1149 | // PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module 1150 | //========================================================== 1151 | #ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED 1152 | #define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 1153 | #endif 1154 | #if PERIPHERAL_RESOURCE_SHARING_ENABLED 1155 | // COMMON_CONFIG_LOG_ENABLED - Enables logging in the module. 1156 | //========================================================== 1157 | #ifndef COMMON_CONFIG_LOG_ENABLED 1158 | #define COMMON_CONFIG_LOG_ENABLED 0 1159 | #endif 1160 | #if COMMON_CONFIG_LOG_ENABLED 1161 | // COMMON_CONFIG_LOG_LEVEL - Default Severity level 1162 | 1163 | // <0=> Off 1164 | // <1=> Error 1165 | // <2=> Warning 1166 | // <3=> Info 1167 | // <4=> Debug 1168 | 1169 | #ifndef COMMON_CONFIG_LOG_LEVEL 1170 | #define COMMON_CONFIG_LOG_LEVEL 3 1171 | #endif 1172 | 1173 | // COMMON_CONFIG_INFO_COLOR - ANSI escape code prefix. 1174 | 1175 | // <0=> Default 1176 | // <1=> Black 1177 | // <2=> Red 1178 | // <3=> Green 1179 | // <4=> Yellow 1180 | // <5=> Blue 1181 | // <6=> Magenta 1182 | // <7=> Cyan 1183 | // <8=> White 1184 | 1185 | #ifndef COMMON_CONFIG_INFO_COLOR 1186 | #define COMMON_CONFIG_INFO_COLOR 0 1187 | #endif 1188 | 1189 | // COMMON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 1190 | 1191 | // <0=> Default 1192 | // <1=> Black 1193 | // <2=> Red 1194 | // <3=> Green 1195 | // <4=> Yellow 1196 | // <5=> Blue 1197 | // <6=> Magenta 1198 | // <7=> Cyan 1199 | // <8=> White 1200 | 1201 | #ifndef COMMON_CONFIG_DEBUG_COLOR 1202 | #define COMMON_CONFIG_DEBUG_COLOR 0 1203 | #endif 1204 | 1205 | #endif //COMMON_CONFIG_LOG_ENABLED 1206 | // 1207 | 1208 | #endif //PERIPHERAL_RESOURCE_SHARING_ENABLED 1209 | // 1210 | 1211 | // POWER_ENABLED - nrf_drv_power - POWER peripheral driver 1212 | //========================================================== 1213 | #ifndef POWER_ENABLED 1214 | #define POWER_ENABLED 0 1215 | #endif 1216 | #if POWER_ENABLED 1217 | // POWER_CONFIG_IRQ_PRIORITY - Interrupt priority 1218 | 1219 | 1220 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 1221 | // <0=> 0 (highest) 1222 | // <1=> 1 1223 | // <2=> 2 1224 | // <3=> 3 1225 | 1226 | #ifndef POWER_CONFIG_IRQ_PRIORITY 1227 | #define POWER_CONFIG_IRQ_PRIORITY 3 1228 | #endif 1229 | 1230 | // POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator 1231 | 1232 | 1233 | // This settings means only that components for DCDC regulator are installed and it can be enabled. 1234 | 1235 | #ifndef POWER_CONFIG_DEFAULT_DCDCEN 1236 | #define POWER_CONFIG_DEFAULT_DCDCEN 0 1237 | #endif 1238 | 1239 | // POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator 1240 | 1241 | 1242 | // This settings means only that components for DCDC regulator are installed and it can be enabled. 1243 | 1244 | #ifndef POWER_CONFIG_DEFAULT_DCDCENHV 1245 | #define POWER_CONFIG_DEFAULT_DCDCENHV 0 1246 | #endif 1247 | 1248 | #endif //POWER_ENABLED 1249 | // 1250 | 1251 | // PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver 1252 | //========================================================== 1253 | #ifndef PPI_ENABLED 1254 | #define PPI_ENABLED 0 1255 | #endif 1256 | #if PPI_ENABLED 1257 | // PPI_CONFIG_LOG_ENABLED - Enables logging in the module. 1258 | //========================================================== 1259 | #ifndef PPI_CONFIG_LOG_ENABLED 1260 | #define PPI_CONFIG_LOG_ENABLED 0 1261 | #endif 1262 | #if PPI_CONFIG_LOG_ENABLED 1263 | // PPI_CONFIG_LOG_LEVEL - Default Severity level 1264 | 1265 | // <0=> Off 1266 | // <1=> Error 1267 | // <2=> Warning 1268 | // <3=> Info 1269 | // <4=> Debug 1270 | 1271 | #ifndef PPI_CONFIG_LOG_LEVEL 1272 | #define PPI_CONFIG_LOG_LEVEL 3 1273 | #endif 1274 | 1275 | // PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. 1276 | 1277 | // <0=> Default 1278 | // <1=> Black 1279 | // <2=> Red 1280 | // <3=> Green 1281 | // <4=> Yellow 1282 | // <5=> Blue 1283 | // <6=> Magenta 1284 | // <7=> Cyan 1285 | // <8=> White 1286 | 1287 | #ifndef PPI_CONFIG_INFO_COLOR 1288 | #define PPI_CONFIG_INFO_COLOR 0 1289 | #endif 1290 | 1291 | // PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 1292 | 1293 | // <0=> Default 1294 | // <1=> Black 1295 | // <2=> Red 1296 | // <3=> Green 1297 | // <4=> Yellow 1298 | // <5=> Blue 1299 | // <6=> Magenta 1300 | // <7=> Cyan 1301 | // <8=> White 1302 | 1303 | #ifndef PPI_CONFIG_DEBUG_COLOR 1304 | #define PPI_CONFIG_DEBUG_COLOR 0 1305 | #endif 1306 | 1307 | #endif //PPI_CONFIG_LOG_ENABLED 1308 | // 1309 | 1310 | #endif //PPI_ENABLED 1311 | // 1312 | 1313 | // PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver 1314 | //========================================================== 1315 | #ifndef PWM_ENABLED 1316 | #define PWM_ENABLED 0 1317 | #endif 1318 | #if PWM_ENABLED 1319 | // PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> 1320 | 1321 | 1322 | #ifndef PWM_DEFAULT_CONFIG_OUT0_PIN 1323 | #define PWM_DEFAULT_CONFIG_OUT0_PIN 31 1324 | #endif 1325 | 1326 | // PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> 1327 | 1328 | 1329 | #ifndef PWM_DEFAULT_CONFIG_OUT1_PIN 1330 | #define PWM_DEFAULT_CONFIG_OUT1_PIN 31 1331 | #endif 1332 | 1333 | // PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> 1334 | 1335 | 1336 | #ifndef PWM_DEFAULT_CONFIG_OUT2_PIN 1337 | #define PWM_DEFAULT_CONFIG_OUT2_PIN 31 1338 | #endif 1339 | 1340 | // PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> 1341 | 1342 | 1343 | #ifndef PWM_DEFAULT_CONFIG_OUT3_PIN 1344 | #define PWM_DEFAULT_CONFIG_OUT3_PIN 31 1345 | #endif 1346 | 1347 | // PWM_DEFAULT_CONFIG_BASE_CLOCK - Base clock 1348 | 1349 | // <0=> 16 MHz 1350 | // <1=> 8 MHz 1351 | // <2=> 4 MHz 1352 | // <3=> 2 MHz 1353 | // <4=> 1 MHz 1354 | // <5=> 500 kHz 1355 | // <6=> 250 kHz 1356 | // <7=> 125 MHz 1357 | 1358 | #ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK 1359 | #define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 1360 | #endif 1361 | 1362 | // PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode 1363 | 1364 | // <0=> Up 1365 | // <1=> Up and Down 1366 | 1367 | #ifndef PWM_DEFAULT_CONFIG_COUNT_MODE 1368 | #define PWM_DEFAULT_CONFIG_COUNT_MODE 0 1369 | #endif 1370 | 1371 | // PWM_DEFAULT_CONFIG_TOP_VALUE - Top value 1372 | #ifndef PWM_DEFAULT_CONFIG_TOP_VALUE 1373 | #define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 1374 | #endif 1375 | 1376 | // PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode 1377 | 1378 | // <0=> Common 1379 | // <1=> Grouped 1380 | // <2=> Individual 1381 | // <3=> Waveform 1382 | 1383 | #ifndef PWM_DEFAULT_CONFIG_LOAD_MODE 1384 | #define PWM_DEFAULT_CONFIG_LOAD_MODE 0 1385 | #endif 1386 | 1387 | // PWM_DEFAULT_CONFIG_STEP_MODE - Step mode 1388 | 1389 | // <0=> Auto 1390 | // <1=> Triggered 1391 | 1392 | #ifndef PWM_DEFAULT_CONFIG_STEP_MODE 1393 | #define PWM_DEFAULT_CONFIG_STEP_MODE 0 1394 | #endif 1395 | 1396 | // PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority 1397 | 1398 | 1399 | // Priorities 0,1,4,5 (nRF52) are reserved for SoftDevice 1400 | // <0=> 0 (highest) 1401 | // <1=> 1 1402 | // <2=> 2 1403 | // <3=> 3 1404 | // <4=> 4 1405 | // <5=> 5 1406 | // <6=> 6 1407 | // <7=> 7 1408 | 1409 | #ifndef PWM_DEFAULT_CONFIG_IRQ_PRIORITY 1410 | #define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 7 1411 | #endif 1412 | 1413 | // PWM0_ENABLED - Enable PWM0 instance 1414 | 1415 | 1416 | #ifndef PWM0_ENABLED 1417 | #define PWM0_ENABLED 0 1418 | #endif 1419 | 1420 | // PWM1_ENABLED - Enable PWM1 instance 1421 | 1422 | 1423 | #ifndef PWM1_ENABLED 1424 | #define PWM1_ENABLED 0 1425 | #endif 1426 | 1427 | // PWM2_ENABLED - Enable PWM2 instance 1428 | 1429 | 1430 | #ifndef PWM2_ENABLED 1431 | #define PWM2_ENABLED 0 1432 | #endif 1433 | 1434 | // PWM_CONFIG_LOG_ENABLED - Enables logging in the module. 1435 | //========================================================== 1436 | #ifndef PWM_CONFIG_LOG_ENABLED 1437 | #define PWM_CONFIG_LOG_ENABLED 0 1438 | #endif 1439 | #if PWM_CONFIG_LOG_ENABLED 1440 | // PWM_CONFIG_LOG_LEVEL - Default Severity level 1441 | 1442 | // <0=> Off 1443 | // <1=> Error 1444 | // <2=> Warning 1445 | // <3=> Info 1446 | // <4=> Debug 1447 | 1448 | #ifndef PWM_CONFIG_LOG_LEVEL 1449 | #define PWM_CONFIG_LOG_LEVEL 3 1450 | #endif 1451 | 1452 | // PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. 1453 | 1454 | // <0=> Default 1455 | // <1=> Black 1456 | // <2=> Red 1457 | // <3=> Green 1458 | // <4=> Yellow 1459 | // <5=> Blue 1460 | // <6=> Magenta 1461 | // <7=> Cyan 1462 | // <8=> White 1463 | 1464 | #ifndef PWM_CONFIG_INFO_COLOR 1465 | #define PWM_CONFIG_INFO_COLOR 0 1466 | #endif 1467 | 1468 | // PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 1469 | 1470 | // <0=> Default 1471 | // <1=> Black 1472 | // <2=> Red 1473 | // <3=> Green 1474 | // <4=> Yellow 1475 | // <5=> Blue 1476 | // <6=> Magenta 1477 | // <7=> Cyan 1478 | // <8=> White 1479 | 1480 | #ifndef PWM_CONFIG_DEBUG_COLOR 1481 | #define PWM_CONFIG_DEBUG_COLOR 0 1482 | #endif 1483 | 1484 | #endif //PWM_CONFIG_LOG_ENABLED 1485 | // 1486 | 1487 | #endif //PWM_ENABLED 1488 | // 1489 | 1490 | // QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver 1491 | //========================================================== 1492 | #ifndef QDEC_ENABLED 1493 | #define QDEC_ENABLED 0 1494 | #endif 1495 | #if QDEC_ENABLED 1496 | // QDEC_CONFIG_REPORTPER - Report period 1497 | 1498 | // <0=> 10 Samples 1499 | // <1=> 40 Samples 1500 | // <2=> 80 Samples 1501 | // <3=> 120 Samples 1502 | // <4=> 160 Samples 1503 | // <5=> 200 Samples 1504 | // <6=> 240 Samples 1505 | // <7=> 280 Samples 1506 | 1507 | #ifndef QDEC_CONFIG_REPORTPER 1508 | #define QDEC_CONFIG_REPORTPER 0 1509 | #endif 1510 | 1511 | // QDEC_CONFIG_SAMPLEPER - Sample period 1512 | 1513 | // <0=> 128 us 1514 | // <1=> 256 us 1515 | // <2=> 512 us 1516 | // <3=> 1024 us 1517 | // <4=> 2048 us 1518 | // <5=> 4096 us 1519 | // <6=> 8192 us 1520 | // <7=> 16384 us 1521 | 1522 | #ifndef QDEC_CONFIG_SAMPLEPER 1523 | #define QDEC_CONFIG_SAMPLEPER 7 1524 | #endif 1525 | 1526 | // QDEC_CONFIG_PIO_A - A pin <0-31> 1527 | 1528 | 1529 | #ifndef QDEC_CONFIG_PIO_A 1530 | #define QDEC_CONFIG_PIO_A 31 1531 | #endif 1532 | 1533 | // QDEC_CONFIG_PIO_B - B pin <0-31> 1534 | 1535 | 1536 | #ifndef QDEC_CONFIG_PIO_B 1537 | #define QDEC_CONFIG_PIO_B 31 1538 | #endif 1539 | 1540 | // QDEC_CONFIG_PIO_LED - LED pin <0-31> 1541 | 1542 | 1543 | #ifndef QDEC_CONFIG_PIO_LED 1544 | #define QDEC_CONFIG_PIO_LED 31 1545 | #endif 1546 | 1547 | // QDEC_CONFIG_LEDPRE - LED pre 1548 | #ifndef QDEC_CONFIG_LEDPRE 1549 | #define QDEC_CONFIG_LEDPRE 511 1550 | #endif 1551 | 1552 | // QDEC_CONFIG_LEDPOL - LED polarity 1553 | 1554 | // <0=> Active low 1555 | // <1=> Active high 1556 | 1557 | #ifndef QDEC_CONFIG_LEDPOL 1558 | #define QDEC_CONFIG_LEDPOL 1 1559 | #endif 1560 | 1561 | // QDEC_CONFIG_DBFEN - Debouncing enable 1562 | 1563 | 1564 | #ifndef QDEC_CONFIG_DBFEN 1565 | #define QDEC_CONFIG_DBFEN 0 1566 | #endif 1567 | 1568 | // QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable 1569 | 1570 | 1571 | #ifndef QDEC_CONFIG_SAMPLE_INTEN 1572 | #define QDEC_CONFIG_SAMPLE_INTEN 0 1573 | #endif 1574 | 1575 | // QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority 1576 | 1577 | 1578 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 1579 | // <0=> 0 (highest) 1580 | // <1=> 1 1581 | // <2=> 2 1582 | // <3=> 3 1583 | 1584 | #ifndef QDEC_CONFIG_IRQ_PRIORITY 1585 | #define QDEC_CONFIG_IRQ_PRIORITY 3 1586 | #endif 1587 | 1588 | // QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. 1589 | //========================================================== 1590 | #ifndef QDEC_CONFIG_LOG_ENABLED 1591 | #define QDEC_CONFIG_LOG_ENABLED 0 1592 | #endif 1593 | #if QDEC_CONFIG_LOG_ENABLED 1594 | // QDEC_CONFIG_LOG_LEVEL - Default Severity level 1595 | 1596 | // <0=> Off 1597 | // <1=> Error 1598 | // <2=> Warning 1599 | // <3=> Info 1600 | // <4=> Debug 1601 | 1602 | #ifndef QDEC_CONFIG_LOG_LEVEL 1603 | #define QDEC_CONFIG_LOG_LEVEL 3 1604 | #endif 1605 | 1606 | // QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. 1607 | 1608 | // <0=> Default 1609 | // <1=> Black 1610 | // <2=> Red 1611 | // <3=> Green 1612 | // <4=> Yellow 1613 | // <5=> Blue 1614 | // <6=> Magenta 1615 | // <7=> Cyan 1616 | // <8=> White 1617 | 1618 | #ifndef QDEC_CONFIG_INFO_COLOR 1619 | #define QDEC_CONFIG_INFO_COLOR 0 1620 | #endif 1621 | 1622 | // QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 1623 | 1624 | // <0=> Default 1625 | // <1=> Black 1626 | // <2=> Red 1627 | // <3=> Green 1628 | // <4=> Yellow 1629 | // <5=> Blue 1630 | // <6=> Magenta 1631 | // <7=> Cyan 1632 | // <8=> White 1633 | 1634 | #ifndef QDEC_CONFIG_DEBUG_COLOR 1635 | #define QDEC_CONFIG_DEBUG_COLOR 0 1636 | #endif 1637 | 1638 | #endif //QDEC_CONFIG_LOG_ENABLED 1639 | // 1640 | 1641 | #endif //QDEC_ENABLED 1642 | // 1643 | 1644 | // RNG_ENABLED - nrf_drv_rng - RNG peripheral driver 1645 | //========================================================== 1646 | #ifndef RNG_ENABLED 1647 | #define RNG_ENABLED 0 1648 | #endif 1649 | #if RNG_ENABLED 1650 | // RNG_CONFIG_ERROR_CORRECTION - Error correction 1651 | 1652 | 1653 | #ifndef RNG_CONFIG_ERROR_CORRECTION 1654 | #define RNG_CONFIG_ERROR_CORRECTION 0 1655 | #endif 1656 | 1657 | // RNG_CONFIG_POOL_SIZE - Pool size 1658 | #ifndef RNG_CONFIG_POOL_SIZE 1659 | #define RNG_CONFIG_POOL_SIZE 32 1660 | #endif 1661 | 1662 | // RNG_CONFIG_IRQ_PRIORITY - Interrupt priority 1663 | 1664 | 1665 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 1666 | // <0=> 0 (highest) 1667 | // <1=> 1 1668 | // <2=> 2 1669 | // <3=> 3 1670 | 1671 | #ifndef RNG_CONFIG_IRQ_PRIORITY 1672 | #define RNG_CONFIG_IRQ_PRIORITY 3 1673 | #endif 1674 | 1675 | // RNG_CONFIG_LOG_ENABLED - Enables logging in the module. 1676 | //========================================================== 1677 | #ifndef RNG_CONFIG_LOG_ENABLED 1678 | #define RNG_CONFIG_LOG_ENABLED 0 1679 | #endif 1680 | #if RNG_CONFIG_LOG_ENABLED 1681 | // RNG_CONFIG_LOG_LEVEL - Default Severity level 1682 | 1683 | // <0=> Off 1684 | // <1=> Error 1685 | // <2=> Warning 1686 | // <3=> Info 1687 | // <4=> Debug 1688 | 1689 | #ifndef RNG_CONFIG_LOG_LEVEL 1690 | #define RNG_CONFIG_LOG_LEVEL 3 1691 | #endif 1692 | 1693 | // RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. 1694 | 1695 | // <0=> Default 1696 | // <1=> Black 1697 | // <2=> Red 1698 | // <3=> Green 1699 | // <4=> Yellow 1700 | // <5=> Blue 1701 | // <6=> Magenta 1702 | // <7=> Cyan 1703 | // <8=> White 1704 | 1705 | #ifndef RNG_CONFIG_INFO_COLOR 1706 | #define RNG_CONFIG_INFO_COLOR 0 1707 | #endif 1708 | 1709 | // RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 1710 | 1711 | // <0=> Default 1712 | // <1=> Black 1713 | // <2=> Red 1714 | // <3=> Green 1715 | // <4=> Yellow 1716 | // <5=> Blue 1717 | // <6=> Magenta 1718 | // <7=> Cyan 1719 | // <8=> White 1720 | 1721 | #ifndef RNG_CONFIG_DEBUG_COLOR 1722 | #define RNG_CONFIG_DEBUG_COLOR 0 1723 | #endif 1724 | 1725 | #endif //RNG_CONFIG_LOG_ENABLED 1726 | // 1727 | 1728 | #endif //RNG_ENABLED 1729 | // 1730 | 1731 | // RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver 1732 | //========================================================== 1733 | #ifndef RTC_ENABLED 1734 | #define RTC_ENABLED 0 1735 | #endif 1736 | #if RTC_ENABLED 1737 | // RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> 1738 | 1739 | 1740 | #ifndef RTC_DEFAULT_CONFIG_FREQUENCY 1741 | #define RTC_DEFAULT_CONFIG_FREQUENCY 32768 1742 | #endif 1743 | 1744 | // RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering 1745 | 1746 | 1747 | #ifndef RTC_DEFAULT_CONFIG_RELIABLE 1748 | #define RTC_DEFAULT_CONFIG_RELIABLE 0 1749 | #endif 1750 | 1751 | // RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority 1752 | 1753 | 1754 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 1755 | // <0=> 0 (highest) 1756 | // <1=> 1 1757 | // <2=> 2 1758 | // <3=> 3 1759 | 1760 | #ifndef RTC_DEFAULT_CONFIG_IRQ_PRIORITY 1761 | #define RTC_DEFAULT_CONFIG_IRQ_PRIORITY 3 1762 | #endif 1763 | 1764 | // RTC0_ENABLED - Enable RTC0 instance 1765 | 1766 | 1767 | #ifndef RTC0_ENABLED 1768 | #define RTC0_ENABLED 0 1769 | #endif 1770 | 1771 | // RTC1_ENABLED - Enable RTC1 instance 1772 | 1773 | 1774 | #ifndef RTC1_ENABLED 1775 | #define RTC1_ENABLED 0 1776 | #endif 1777 | 1778 | // RTC2_ENABLED - Enable RTC2 instance 1779 | 1780 | 1781 | #ifndef RTC2_ENABLED 1782 | #define RTC2_ENABLED 0 1783 | #endif 1784 | 1785 | // NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt 1786 | #ifndef NRF_MAXIMUM_LATENCY_US 1787 | #define NRF_MAXIMUM_LATENCY_US 2000 1788 | #endif 1789 | 1790 | // RTC_CONFIG_LOG_ENABLED - Enables logging in the module. 1791 | //========================================================== 1792 | #ifndef RTC_CONFIG_LOG_ENABLED 1793 | #define RTC_CONFIG_LOG_ENABLED 0 1794 | #endif 1795 | #if RTC_CONFIG_LOG_ENABLED 1796 | // RTC_CONFIG_LOG_LEVEL - Default Severity level 1797 | 1798 | // <0=> Off 1799 | // <1=> Error 1800 | // <2=> Warning 1801 | // <3=> Info 1802 | // <4=> Debug 1803 | 1804 | #ifndef RTC_CONFIG_LOG_LEVEL 1805 | #define RTC_CONFIG_LOG_LEVEL 3 1806 | #endif 1807 | 1808 | // RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. 1809 | 1810 | // <0=> Default 1811 | // <1=> Black 1812 | // <2=> Red 1813 | // <3=> Green 1814 | // <4=> Yellow 1815 | // <5=> Blue 1816 | // <6=> Magenta 1817 | // <7=> Cyan 1818 | // <8=> White 1819 | 1820 | #ifndef RTC_CONFIG_INFO_COLOR 1821 | #define RTC_CONFIG_INFO_COLOR 0 1822 | #endif 1823 | 1824 | // RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 1825 | 1826 | // <0=> Default 1827 | // <1=> Black 1828 | // <2=> Red 1829 | // <3=> Green 1830 | // <4=> Yellow 1831 | // <5=> Blue 1832 | // <6=> Magenta 1833 | // <7=> Cyan 1834 | // <8=> White 1835 | 1836 | #ifndef RTC_CONFIG_DEBUG_COLOR 1837 | #define RTC_CONFIG_DEBUG_COLOR 0 1838 | #endif 1839 | 1840 | #endif //RTC_CONFIG_LOG_ENABLED 1841 | // 1842 | 1843 | #endif //RTC_ENABLED 1844 | // 1845 | 1846 | // SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver 1847 | //========================================================== 1848 | #ifndef SAADC_ENABLED 1849 | #define SAADC_ENABLED 0 1850 | #endif 1851 | #if SAADC_ENABLED 1852 | // SAADC_CONFIG_RESOLUTION - Resolution 1853 | 1854 | // <0=> 8 bit 1855 | // <1=> 10 bit 1856 | // <2=> 12 bit 1857 | // <3=> 14 bit 1858 | 1859 | #ifndef SAADC_CONFIG_RESOLUTION 1860 | #define SAADC_CONFIG_RESOLUTION 1 1861 | #endif 1862 | 1863 | // SAADC_CONFIG_OVERSAMPLE - Sample period 1864 | 1865 | // <0=> Disabled 1866 | // <1=> 2x 1867 | // <2=> 4x 1868 | // <3=> 8x 1869 | // <4=> 16x 1870 | // <5=> 32x 1871 | // <6=> 64x 1872 | // <7=> 128x 1873 | // <8=> 256x 1874 | 1875 | #ifndef SAADC_CONFIG_OVERSAMPLE 1876 | #define SAADC_CONFIG_OVERSAMPLE 0 1877 | #endif 1878 | 1879 | // SAADC_CONFIG_LP_MODE - Enabling low power mode 1880 | 1881 | 1882 | #ifndef SAADC_CONFIG_LP_MODE 1883 | #define SAADC_CONFIG_LP_MODE 0 1884 | #endif 1885 | 1886 | // SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority 1887 | 1888 | 1889 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 1890 | // <0=> 0 (highest) 1891 | // <1=> 1 1892 | // <2=> 2 1893 | // <3=> 3 1894 | 1895 | #ifndef SAADC_CONFIG_IRQ_PRIORITY 1896 | #define SAADC_CONFIG_IRQ_PRIORITY 3 1897 | #endif 1898 | 1899 | // SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. 1900 | //========================================================== 1901 | #ifndef SAADC_CONFIG_LOG_ENABLED 1902 | #define SAADC_CONFIG_LOG_ENABLED 0 1903 | #endif 1904 | #if SAADC_CONFIG_LOG_ENABLED 1905 | // SAADC_CONFIG_LOG_LEVEL - Default Severity level 1906 | 1907 | // <0=> Off 1908 | // <1=> Error 1909 | // <2=> Warning 1910 | // <3=> Info 1911 | // <4=> Debug 1912 | 1913 | #ifndef SAADC_CONFIG_LOG_LEVEL 1914 | #define SAADC_CONFIG_LOG_LEVEL 3 1915 | #endif 1916 | 1917 | // SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. 1918 | 1919 | // <0=> Default 1920 | // <1=> Black 1921 | // <2=> Red 1922 | // <3=> Green 1923 | // <4=> Yellow 1924 | // <5=> Blue 1925 | // <6=> Magenta 1926 | // <7=> Cyan 1927 | // <8=> White 1928 | 1929 | #ifndef SAADC_CONFIG_INFO_COLOR 1930 | #define SAADC_CONFIG_INFO_COLOR 0 1931 | #endif 1932 | 1933 | // SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 1934 | 1935 | // <0=> Default 1936 | // <1=> Black 1937 | // <2=> Red 1938 | // <3=> Green 1939 | // <4=> Yellow 1940 | // <5=> Blue 1941 | // <6=> Magenta 1942 | // <7=> Cyan 1943 | // <8=> White 1944 | 1945 | #ifndef SAADC_CONFIG_DEBUG_COLOR 1946 | #define SAADC_CONFIG_DEBUG_COLOR 0 1947 | #endif 1948 | 1949 | #endif //SAADC_CONFIG_LOG_ENABLED 1950 | // 1951 | 1952 | #endif //SAADC_ENABLED 1953 | // 1954 | 1955 | // SPIS_ENABLED - nrf_drv_spis - SPI Slave driver 1956 | //========================================================== 1957 | #ifndef SPIS_ENABLED 1958 | #define SPIS_ENABLED 0 1959 | #endif 1960 | #if SPIS_ENABLED 1961 | // SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority 1962 | 1963 | 1964 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 1965 | // <0=> 0 (highest) 1966 | // <1=> 1 1967 | // <2=> 2 1968 | // <3=> 3 1969 | 1970 | #ifndef SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 1971 | #define SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 3 1972 | #endif 1973 | 1974 | // SPIS_DEFAULT_MODE - Mode 1975 | 1976 | // <0=> MODE_0 1977 | // <1=> MODE_1 1978 | // <2=> MODE_2 1979 | // <3=> MODE_3 1980 | 1981 | #ifndef SPIS_DEFAULT_MODE 1982 | #define SPIS_DEFAULT_MODE 0 1983 | #endif 1984 | 1985 | // SPIS_DEFAULT_BIT_ORDER - SPIS default bit order 1986 | 1987 | // <0=> MSB first 1988 | // <1=> LSB first 1989 | 1990 | #ifndef SPIS_DEFAULT_BIT_ORDER 1991 | #define SPIS_DEFAULT_BIT_ORDER 0 1992 | #endif 1993 | 1994 | // SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> 1995 | 1996 | 1997 | #ifndef SPIS_DEFAULT_DEF 1998 | #define SPIS_DEFAULT_DEF 255 1999 | #endif 2000 | 2001 | // SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> 2002 | 2003 | 2004 | #ifndef SPIS_DEFAULT_ORC 2005 | #define SPIS_DEFAULT_ORC 255 2006 | #endif 2007 | 2008 | // SPIS0_ENABLED - Enable SPIS0 instance 2009 | 2010 | 2011 | #ifndef SPIS0_ENABLED 2012 | #define SPIS0_ENABLED 0 2013 | #endif 2014 | 2015 | // SPIS1_ENABLED - Enable SPIS1 instance 2016 | 2017 | 2018 | #ifndef SPIS1_ENABLED 2019 | #define SPIS1_ENABLED 0 2020 | #endif 2021 | 2022 | // SPIS2_ENABLED - Enable SPIS2 instance 2023 | 2024 | 2025 | #ifndef SPIS2_ENABLED 2026 | #define SPIS2_ENABLED 0 2027 | #endif 2028 | 2029 | // SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. 2030 | //========================================================== 2031 | #ifndef SPIS_CONFIG_LOG_ENABLED 2032 | #define SPIS_CONFIG_LOG_ENABLED 0 2033 | #endif 2034 | #if SPIS_CONFIG_LOG_ENABLED 2035 | // SPIS_CONFIG_LOG_LEVEL - Default Severity level 2036 | 2037 | // <0=> Off 2038 | // <1=> Error 2039 | // <2=> Warning 2040 | // <3=> Info 2041 | // <4=> Debug 2042 | 2043 | #ifndef SPIS_CONFIG_LOG_LEVEL 2044 | #define SPIS_CONFIG_LOG_LEVEL 3 2045 | #endif 2046 | 2047 | // SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. 2048 | 2049 | // <0=> Default 2050 | // <1=> Black 2051 | // <2=> Red 2052 | // <3=> Green 2053 | // <4=> Yellow 2054 | // <5=> Blue 2055 | // <6=> Magenta 2056 | // <7=> Cyan 2057 | // <8=> White 2058 | 2059 | #ifndef SPIS_CONFIG_INFO_COLOR 2060 | #define SPIS_CONFIG_INFO_COLOR 0 2061 | #endif 2062 | 2063 | // SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 2064 | 2065 | // <0=> Default 2066 | // <1=> Black 2067 | // <2=> Red 2068 | // <3=> Green 2069 | // <4=> Yellow 2070 | // <5=> Blue 2071 | // <6=> Magenta 2072 | // <7=> Cyan 2073 | // <8=> White 2074 | 2075 | #ifndef SPIS_CONFIG_DEBUG_COLOR 2076 | #define SPIS_CONFIG_DEBUG_COLOR 0 2077 | #endif 2078 | 2079 | #endif //SPIS_CONFIG_LOG_ENABLED 2080 | // 2081 | 2082 | #endif //SPIS_ENABLED 2083 | // 2084 | 2085 | // SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver 2086 | //========================================================== 2087 | #ifndef SPI_ENABLED 2088 | #define SPI_ENABLED 0 2089 | #endif 2090 | #if SPI_ENABLED 2091 | // SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority 2092 | 2093 | 2094 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 2095 | // <0=> 0 (highest) 2096 | // <1=> 1 2097 | // <2=> 2 2098 | // <3=> 3 2099 | 2100 | #ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY 2101 | #define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 3 2102 | #endif 2103 | 2104 | // SPI0_ENABLED - Enable SPI0 instance 2105 | //========================================================== 2106 | #ifndef SPI0_ENABLED 2107 | #define SPI0_ENABLED 0 2108 | #endif 2109 | #if SPI0_ENABLED 2110 | // SPI0_USE_EASY_DMA - Use EasyDMA 2111 | 2112 | 2113 | #ifndef SPI0_USE_EASY_DMA 2114 | #define SPI0_USE_EASY_DMA 0 2115 | #endif 2116 | 2117 | // SPI0_DEFAULT_FREQUENCY - SPI frequency 2118 | 2119 | // <33554432=> 125 kHz 2120 | // <67108864=> 250 kHz 2121 | // <134217728=> 500 kHz 2122 | // <268435456=> 1 MHz 2123 | // <536870912=> 2 MHz 2124 | // <1073741824=> 4 MHz 2125 | // <2147483648=> 8 MHz 2126 | 2127 | #ifndef SPI0_DEFAULT_FREQUENCY 2128 | #define SPI0_DEFAULT_FREQUENCY 1073741824 2129 | #endif 2130 | 2131 | #endif //SPI0_ENABLED 2132 | // 2133 | 2134 | // SPI1_ENABLED - Enable SPI1 instance 2135 | //========================================================== 2136 | #ifndef SPI1_ENABLED 2137 | #define SPI1_ENABLED 0 2138 | #endif 2139 | #if SPI1_ENABLED 2140 | // SPI1_USE_EASY_DMA - Use EasyDMA 2141 | 2142 | 2143 | #ifndef SPI1_USE_EASY_DMA 2144 | #define SPI1_USE_EASY_DMA 0 2145 | #endif 2146 | 2147 | // SPI1_DEFAULT_FREQUENCY - SPI frequency 2148 | 2149 | // <33554432=> 125 kHz 2150 | // <67108864=> 250 kHz 2151 | // <134217728=> 500 kHz 2152 | // <268435456=> 1 MHz 2153 | // <536870912=> 2 MHz 2154 | // <1073741824=> 4 MHz 2155 | // <2147483648=> 8 MHz 2156 | 2157 | #ifndef SPI1_DEFAULT_FREQUENCY 2158 | #define SPI1_DEFAULT_FREQUENCY 1073741824 2159 | #endif 2160 | 2161 | #endif //SPI1_ENABLED 2162 | // 2163 | 2164 | // SPI2_ENABLED - Enable SPI2 instance 2165 | //========================================================== 2166 | #ifndef SPI2_ENABLED 2167 | #define SPI2_ENABLED 0 2168 | #endif 2169 | #if SPI2_ENABLED 2170 | // SPI2_USE_EASY_DMA - Use EasyDMA 2171 | 2172 | 2173 | #ifndef SPI2_USE_EASY_DMA 2174 | #define SPI2_USE_EASY_DMA 0 2175 | #endif 2176 | 2177 | // SPI2_DEFAULT_FREQUENCY - Use EasyDMA 2178 | 2179 | 2180 | #ifndef SPI2_DEFAULT_FREQUENCY 2181 | #define SPI2_DEFAULT_FREQUENCY 0 2182 | #endif 2183 | 2184 | #endif //SPI2_ENABLED 2185 | // 2186 | 2187 | // SPI_CONFIG_LOG_ENABLED - Enables logging in the module. 2188 | //========================================================== 2189 | #ifndef SPI_CONFIG_LOG_ENABLED 2190 | #define SPI_CONFIG_LOG_ENABLED 0 2191 | #endif 2192 | #if SPI_CONFIG_LOG_ENABLED 2193 | // SPI_CONFIG_LOG_LEVEL - Default Severity level 2194 | 2195 | // <0=> Off 2196 | // <1=> Error 2197 | // <2=> Warning 2198 | // <3=> Info 2199 | // <4=> Debug 2200 | 2201 | #ifndef SPI_CONFIG_LOG_LEVEL 2202 | #define SPI_CONFIG_LOG_LEVEL 3 2203 | #endif 2204 | 2205 | // SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. 2206 | 2207 | // <0=> Default 2208 | // <1=> Black 2209 | // <2=> Red 2210 | // <3=> Green 2211 | // <4=> Yellow 2212 | // <5=> Blue 2213 | // <6=> Magenta 2214 | // <7=> Cyan 2215 | // <8=> White 2216 | 2217 | #ifndef SPI_CONFIG_INFO_COLOR 2218 | #define SPI_CONFIG_INFO_COLOR 0 2219 | #endif 2220 | 2221 | // SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 2222 | 2223 | // <0=> Default 2224 | // <1=> Black 2225 | // <2=> Red 2226 | // <3=> Green 2227 | // <4=> Yellow 2228 | // <5=> Blue 2229 | // <6=> Magenta 2230 | // <7=> Cyan 2231 | // <8=> White 2232 | 2233 | #ifndef SPI_CONFIG_DEBUG_COLOR 2234 | #define SPI_CONFIG_DEBUG_COLOR 0 2235 | #endif 2236 | 2237 | #endif //SPI_CONFIG_LOG_ENABLED 2238 | // 2239 | 2240 | #endif //SPI_ENABLED 2241 | // 2242 | 2243 | // TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver 2244 | //========================================================== 2245 | #ifndef TIMER_ENABLED 2246 | #define TIMER_ENABLED 0 2247 | #endif 2248 | #if TIMER_ENABLED 2249 | // TIMER_DEFAULT_CONFIG_FREQUENCY - Timer frequency if in Timer mode 2250 | 2251 | // <0=> 16 MHz 2252 | // <1=> 8 MHz 2253 | // <2=> 4 MHz 2254 | // <3=> 2 MHz 2255 | // <4=> 1 MHz 2256 | // <5=> 500 kHz 2257 | // <6=> 250 kHz 2258 | // <7=> 125 kHz 2259 | // <8=> 62.5 kHz 2260 | // <9=> 31.25 kHz 2261 | 2262 | #ifndef TIMER_DEFAULT_CONFIG_FREQUENCY 2263 | #define TIMER_DEFAULT_CONFIG_FREQUENCY 0 2264 | #endif 2265 | 2266 | // TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation 2267 | 2268 | // <0=> Timer 2269 | // <1=> Counter 2270 | 2271 | #ifndef TIMER_DEFAULT_CONFIG_MODE 2272 | #define TIMER_DEFAULT_CONFIG_MODE 0 2273 | #endif 2274 | 2275 | // TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width 2276 | 2277 | // <0=> 16 bit 2278 | // <1=> 8 bit 2279 | // <2=> 24 bit 2280 | // <3=> 32 bit 2281 | 2282 | #ifndef TIMER_DEFAULT_CONFIG_BIT_WIDTH 2283 | #define TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 2284 | #endif 2285 | 2286 | // TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority 2287 | 2288 | 2289 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 2290 | // <0=> 0 (highest) 2291 | // <1=> 1 2292 | // <2=> 2 2293 | // <3=> 3 2294 | 2295 | #ifndef TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 2296 | #define TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 3 2297 | #endif 2298 | 2299 | // TIMER0_ENABLED - Enable TIMER0 instance 2300 | 2301 | 2302 | #ifndef TIMER0_ENABLED 2303 | #define TIMER0_ENABLED 0 2304 | #endif 2305 | 2306 | // TIMER1_ENABLED - Enable TIMER1 instance 2307 | 2308 | 2309 | #ifndef TIMER1_ENABLED 2310 | #define TIMER1_ENABLED 0 2311 | #endif 2312 | 2313 | // TIMER2_ENABLED - Enable TIMER2 instance 2314 | 2315 | 2316 | #ifndef TIMER2_ENABLED 2317 | #define TIMER2_ENABLED 0 2318 | #endif 2319 | 2320 | // TIMER3_ENABLED - Enable TIMER3 instance 2321 | 2322 | 2323 | #ifndef TIMER3_ENABLED 2324 | #define TIMER3_ENABLED 0 2325 | #endif 2326 | 2327 | // TIMER4_ENABLED - Enable TIMER4 instance 2328 | 2329 | 2330 | #ifndef TIMER4_ENABLED 2331 | #define TIMER4_ENABLED 0 2332 | #endif 2333 | 2334 | // TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. 2335 | //========================================================== 2336 | #ifndef TIMER_CONFIG_LOG_ENABLED 2337 | #define TIMER_CONFIG_LOG_ENABLED 0 2338 | #endif 2339 | #if TIMER_CONFIG_LOG_ENABLED 2340 | // TIMER_CONFIG_LOG_LEVEL - Default Severity level 2341 | 2342 | // <0=> Off 2343 | // <1=> Error 2344 | // <2=> Warning 2345 | // <3=> Info 2346 | // <4=> Debug 2347 | 2348 | #ifndef TIMER_CONFIG_LOG_LEVEL 2349 | #define TIMER_CONFIG_LOG_LEVEL 3 2350 | #endif 2351 | 2352 | // TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. 2353 | 2354 | // <0=> Default 2355 | // <1=> Black 2356 | // <2=> Red 2357 | // <3=> Green 2358 | // <4=> Yellow 2359 | // <5=> Blue 2360 | // <6=> Magenta 2361 | // <7=> Cyan 2362 | // <8=> White 2363 | 2364 | #ifndef TIMER_CONFIG_INFO_COLOR 2365 | #define TIMER_CONFIG_INFO_COLOR 0 2366 | #endif 2367 | 2368 | // TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 2369 | 2370 | // <0=> Default 2371 | // <1=> Black 2372 | // <2=> Red 2373 | // <3=> Green 2374 | // <4=> Yellow 2375 | // <5=> Blue 2376 | // <6=> Magenta 2377 | // <7=> Cyan 2378 | // <8=> White 2379 | 2380 | #ifndef TIMER_CONFIG_DEBUG_COLOR 2381 | #define TIMER_CONFIG_DEBUG_COLOR 0 2382 | #endif 2383 | 2384 | #endif //TIMER_CONFIG_LOG_ENABLED 2385 | // 2386 | 2387 | #endif //TIMER_ENABLED 2388 | // 2389 | 2390 | // TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver 2391 | //========================================================== 2392 | #ifndef TWIS_ENABLED 2393 | #define TWIS_ENABLED 0 2394 | #endif 2395 | #if TWIS_ENABLED 2396 | // TWIS_DEFAULT_CONFIG_ADDR0 - Address0 2397 | #ifndef TWIS_DEFAULT_CONFIG_ADDR0 2398 | #define TWIS_DEFAULT_CONFIG_ADDR0 0 2399 | #endif 2400 | 2401 | // TWIS_DEFAULT_CONFIG_ADDR1 - Address1 2402 | #ifndef TWIS_DEFAULT_CONFIG_ADDR1 2403 | #define TWIS_DEFAULT_CONFIG_ADDR1 0 2404 | #endif 2405 | 2406 | // TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration 2407 | 2408 | // <0=> Disabled 2409 | // <1=> Pull down 2410 | // <3=> Pull up 2411 | 2412 | #ifndef TWIS_DEFAULT_CONFIG_SCL_PULL 2413 | #define TWIS_DEFAULT_CONFIG_SCL_PULL 0 2414 | #endif 2415 | 2416 | // TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration 2417 | 2418 | // <0=> Disabled 2419 | // <1=> Pull down 2420 | // <3=> Pull up 2421 | 2422 | #ifndef TWIS_DEFAULT_CONFIG_SDA_PULL 2423 | #define TWIS_DEFAULT_CONFIG_SDA_PULL 0 2424 | #endif 2425 | 2426 | // TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority 2427 | 2428 | 2429 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 2430 | // <0=> 0 (highest) 2431 | // <1=> 1 2432 | // <2=> 2 2433 | // <3=> 3 2434 | 2435 | #ifndef TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 2436 | #define TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 3 2437 | #endif 2438 | 2439 | // TWIS0_ENABLED - Enable TWIS0 instance 2440 | 2441 | 2442 | #ifndef TWIS0_ENABLED 2443 | #define TWIS0_ENABLED 0 2444 | #endif 2445 | 2446 | // TWIS1_ENABLED - Enable TWIS1 instance 2447 | 2448 | 2449 | #ifndef TWIS1_ENABLED 2450 | #define TWIS1_ENABLED 0 2451 | #endif 2452 | 2453 | // TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once 2454 | 2455 | 2456 | // Optimization flag. Registers used by TWIS are shared by other peripherals. Normally, during initialization driver tries to clear all registers to known state before doing the initialization itself. This gives initialization safe procedure, no matter when it would be called. If you activate TWIS only once and do never uninitialize it - set this flag to 1 what gives more optimal code. 2457 | 2458 | #ifndef TWIS_ASSUME_INIT_AFTER_RESET_ONLY 2459 | #define TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 2460 | #endif 2461 | 2462 | // TWIS_NO_SYNC_MODE - Remove support for synchronous mode 2463 | 2464 | 2465 | // Synchronous mode would be used in specific situations. And it uses some additional code and data memory to safely process state machine by polling it in status functions. If this functionality is not required it may be disabled to free some resources. 2466 | 2467 | #ifndef TWIS_NO_SYNC_MODE 2468 | #define TWIS_NO_SYNC_MODE 0 2469 | #endif 2470 | 2471 | // TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. 2472 | //========================================================== 2473 | #ifndef TWIS_CONFIG_LOG_ENABLED 2474 | #define TWIS_CONFIG_LOG_ENABLED 0 2475 | #endif 2476 | #if TWIS_CONFIG_LOG_ENABLED 2477 | // TWIS_CONFIG_LOG_LEVEL - Default Severity level 2478 | 2479 | // <0=> Off 2480 | // <1=> Error 2481 | // <2=> Warning 2482 | // <3=> Info 2483 | // <4=> Debug 2484 | 2485 | #ifndef TWIS_CONFIG_LOG_LEVEL 2486 | #define TWIS_CONFIG_LOG_LEVEL 3 2487 | #endif 2488 | 2489 | // TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. 2490 | 2491 | // <0=> Default 2492 | // <1=> Black 2493 | // <2=> Red 2494 | // <3=> Green 2495 | // <4=> Yellow 2496 | // <5=> Blue 2497 | // <6=> Magenta 2498 | // <7=> Cyan 2499 | // <8=> White 2500 | 2501 | #ifndef TWIS_CONFIG_INFO_COLOR 2502 | #define TWIS_CONFIG_INFO_COLOR 0 2503 | #endif 2504 | 2505 | // TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 2506 | 2507 | // <0=> Default 2508 | // <1=> Black 2509 | // <2=> Red 2510 | // <3=> Green 2511 | // <4=> Yellow 2512 | // <5=> Blue 2513 | // <6=> Magenta 2514 | // <7=> Cyan 2515 | // <8=> White 2516 | 2517 | #ifndef TWIS_CONFIG_DEBUG_COLOR 2518 | #define TWIS_CONFIG_DEBUG_COLOR 0 2519 | #endif 2520 | 2521 | #endif //TWIS_CONFIG_LOG_ENABLED 2522 | // 2523 | 2524 | #endif //TWIS_ENABLED 2525 | // 2526 | 2527 | // TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver 2528 | //========================================================== 2529 | #ifndef TWI_ENABLED 2530 | #define TWI_ENABLED 0 2531 | #endif 2532 | #if TWI_ENABLED 2533 | // TWI_DEFAULT_CONFIG_FREQUENCY - Frequency 2534 | 2535 | // <26738688=> 100k 2536 | // <67108864=> 250k 2537 | // <104857600=> 400k 2538 | 2539 | #ifndef TWI_DEFAULT_CONFIG_FREQUENCY 2540 | #define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 2541 | #endif 2542 | 2543 | // TWI_DEFAULT_CONFIG_CLR_BUS_INIT - Enables bus clearing procedure during init 2544 | 2545 | 2546 | #ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT 2547 | #define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 0 2548 | #endif 2549 | 2550 | // TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit 2551 | 2552 | 2553 | #ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 2554 | #define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 2555 | #endif 2556 | 2557 | // TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority 2558 | 2559 | 2560 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 2561 | // <0=> 0 (highest) 2562 | // <1=> 1 2563 | // <2=> 2 2564 | // <3=> 3 2565 | 2566 | #ifndef TWI_DEFAULT_CONFIG_IRQ_PRIORITY 2567 | #define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 3 2568 | #endif 2569 | 2570 | // TWI0_ENABLED - Enable TWI0 instance 2571 | //========================================================== 2572 | #ifndef TWI0_ENABLED 2573 | #define TWI0_ENABLED 0 2574 | #endif 2575 | #if TWI0_ENABLED 2576 | // TWI0_USE_EASY_DMA - Use EasyDMA (if present) 2577 | 2578 | 2579 | #ifndef TWI0_USE_EASY_DMA 2580 | #define TWI0_USE_EASY_DMA 0 2581 | #endif 2582 | 2583 | #endif //TWI0_ENABLED 2584 | // 2585 | 2586 | // TWI1_ENABLED - Enable TWI1 instance 2587 | //========================================================== 2588 | #ifndef TWI1_ENABLED 2589 | #define TWI1_ENABLED 0 2590 | #endif 2591 | #if TWI1_ENABLED 2592 | // TWI1_USE_EASY_DMA - Use EasyDMA (if present) 2593 | 2594 | 2595 | #ifndef TWI1_USE_EASY_DMA 2596 | #define TWI1_USE_EASY_DMA 0 2597 | #endif 2598 | 2599 | #endif //TWI1_ENABLED 2600 | // 2601 | 2602 | // TWI_CONFIG_LOG_ENABLED - Enables logging in the module. 2603 | //========================================================== 2604 | #ifndef TWI_CONFIG_LOG_ENABLED 2605 | #define TWI_CONFIG_LOG_ENABLED 0 2606 | #endif 2607 | #if TWI_CONFIG_LOG_ENABLED 2608 | // TWI_CONFIG_LOG_LEVEL - Default Severity level 2609 | 2610 | // <0=> Off 2611 | // <1=> Error 2612 | // <2=> Warning 2613 | // <3=> Info 2614 | // <4=> Debug 2615 | 2616 | #ifndef TWI_CONFIG_LOG_LEVEL 2617 | #define TWI_CONFIG_LOG_LEVEL 3 2618 | #endif 2619 | 2620 | // TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. 2621 | 2622 | // <0=> Default 2623 | // <1=> Black 2624 | // <2=> Red 2625 | // <3=> Green 2626 | // <4=> Yellow 2627 | // <5=> Blue 2628 | // <6=> Magenta 2629 | // <7=> Cyan 2630 | // <8=> White 2631 | 2632 | #ifndef TWI_CONFIG_INFO_COLOR 2633 | #define TWI_CONFIG_INFO_COLOR 0 2634 | #endif 2635 | 2636 | // TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 2637 | 2638 | // <0=> Default 2639 | // <1=> Black 2640 | // <2=> Red 2641 | // <3=> Green 2642 | // <4=> Yellow 2643 | // <5=> Blue 2644 | // <6=> Magenta 2645 | // <7=> Cyan 2646 | // <8=> White 2647 | 2648 | #ifndef TWI_CONFIG_DEBUG_COLOR 2649 | #define TWI_CONFIG_DEBUG_COLOR 0 2650 | #endif 2651 | 2652 | #endif //TWI_CONFIG_LOG_ENABLED 2653 | // 2654 | 2655 | #endif //TWI_ENABLED 2656 | // 2657 | 2658 | // UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver 2659 | //========================================================== 2660 | #ifndef UART_ENABLED 2661 | #define UART_ENABLED 1 2662 | #endif 2663 | #if UART_ENABLED 2664 | // UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control 2665 | 2666 | // <0=> Disabled 2667 | // <1=> Enabled 2668 | 2669 | #ifndef UART_DEFAULT_CONFIG_HWFC 2670 | #define UART_DEFAULT_CONFIG_HWFC 0 2671 | #endif 2672 | 2673 | // UART_DEFAULT_CONFIG_PARITY - Parity 2674 | 2675 | // <0=> Excluded 2676 | // <14=> Included 2677 | 2678 | #ifndef UART_DEFAULT_CONFIG_PARITY 2679 | #define UART_DEFAULT_CONFIG_PARITY 0 2680 | #endif 2681 | 2682 | // UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate 2683 | 2684 | // <323584=> 1200 baud 2685 | // <643072=> 2400 baud 2686 | // <1290240=> 4800 baud 2687 | // <2576384=> 9600 baud 2688 | // <3862528=> 14400 baud 2689 | // <5152768=> 19200 baud 2690 | // <7716864=> 28800 baud 2691 | // <10289152=> 38400 baud 2692 | // <15400960=> 57600 baud 2693 | // <20615168=> 76800 baud 2694 | // <30924800=> 115200 baud 2695 | // <61865984=> 230400 baud 2696 | // <67108864=> 250000 baud 2697 | // <121634816=> 460800 baud 2698 | // <251658240=> 921600 baud 2699 | // <268435456=> 57600 baud 2700 | 2701 | #ifndef UART_DEFAULT_CONFIG_BAUDRATE 2702 | #define UART_DEFAULT_CONFIG_BAUDRATE 30924800 2703 | #endif 2704 | 2705 | // UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority 2706 | 2707 | 2708 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 2709 | // <0=> 0 (highest) 2710 | // <1=> 1 2711 | // <2=> 2 2712 | // <3=> 3 2713 | 2714 | #ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY 2715 | #define UART_DEFAULT_CONFIG_IRQ_PRIORITY 3 2716 | #endif 2717 | 2718 | // UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA 2719 | 2720 | 2721 | #ifndef UART_EASY_DMA_SUPPORT 2722 | #define UART_EASY_DMA_SUPPORT 1 2723 | #endif 2724 | 2725 | // UART_LEGACY_SUPPORT - Driver supporting Legacy mode 2726 | 2727 | 2728 | #ifndef UART_LEGACY_SUPPORT 2729 | #define UART_LEGACY_SUPPORT 1 2730 | #endif 2731 | 2732 | // UART0_ENABLED - Enable UART0 instance 2733 | //========================================================== 2734 | #ifndef UART0_ENABLED 2735 | #define UART0_ENABLED 1 2736 | #endif 2737 | #if UART0_ENABLED 2738 | // UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA 2739 | 2740 | 2741 | #ifndef UART0_CONFIG_USE_EASY_DMA 2742 | #define UART0_CONFIG_USE_EASY_DMA 1 2743 | #endif 2744 | 2745 | #endif //UART0_ENABLED 2746 | // 2747 | 2748 | // UART_CONFIG_LOG_ENABLED - Enables logging in the module. 2749 | //========================================================== 2750 | #ifndef UART_CONFIG_LOG_ENABLED 2751 | #define UART_CONFIG_LOG_ENABLED 0 2752 | #endif 2753 | #if UART_CONFIG_LOG_ENABLED 2754 | // UART_CONFIG_LOG_LEVEL - Default Severity level 2755 | 2756 | // <0=> Off 2757 | // <1=> Error 2758 | // <2=> Warning 2759 | // <3=> Info 2760 | // <4=> Debug 2761 | 2762 | #ifndef UART_CONFIG_LOG_LEVEL 2763 | #define UART_CONFIG_LOG_LEVEL 3 2764 | #endif 2765 | 2766 | // UART_CONFIG_INFO_COLOR - ANSI escape code prefix. 2767 | 2768 | // <0=> Default 2769 | // <1=> Black 2770 | // <2=> Red 2771 | // <3=> Green 2772 | // <4=> Yellow 2773 | // <5=> Blue 2774 | // <6=> Magenta 2775 | // <7=> Cyan 2776 | // <8=> White 2777 | 2778 | #ifndef UART_CONFIG_INFO_COLOR 2779 | #define UART_CONFIG_INFO_COLOR 0 2780 | #endif 2781 | 2782 | // UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 2783 | 2784 | // <0=> Default 2785 | // <1=> Black 2786 | // <2=> Red 2787 | // <3=> Green 2788 | // <4=> Yellow 2789 | // <5=> Blue 2790 | // <6=> Magenta 2791 | // <7=> Cyan 2792 | // <8=> White 2793 | 2794 | #ifndef UART_CONFIG_DEBUG_COLOR 2795 | #define UART_CONFIG_DEBUG_COLOR 0 2796 | #endif 2797 | 2798 | #endif //UART_CONFIG_LOG_ENABLED 2799 | // 2800 | 2801 | #endif //UART_ENABLED 2802 | // 2803 | 2804 | // USBD_ENABLED - nrf_drv_usbd - USB driver 2805 | //========================================================== 2806 | #ifndef USBD_ENABLED 2807 | #define USBD_ENABLED 0 2808 | #endif 2809 | #if USBD_ENABLED 2810 | // NRF_DRV_USBD_DMASCHEDULER_MODE - USBD SMA scheduler working scheme 2811 | 2812 | // <0=> Prioritized access 2813 | // <1=> Round Robin 2814 | 2815 | #ifndef NRF_DRV_USBD_DMASCHEDULER_MODE 2816 | #define NRF_DRV_USBD_DMASCHEDULER_MODE 0 2817 | #endif 2818 | 2819 | // NRF_USBD_DRV_LOG_ENABLED - Enable logging. 2820 | 2821 | 2822 | #ifndef NRF_USBD_DRV_LOG_ENABLED 2823 | #define NRF_USBD_DRV_LOG_ENABLED 0 2824 | #endif 2825 | 2826 | #endif //USBD_ENABLED 2827 | // 2828 | 2829 | // WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver 2830 | //========================================================== 2831 | #ifndef WDT_ENABLED 2832 | #define WDT_ENABLED 0 2833 | #endif 2834 | #if WDT_ENABLED 2835 | // WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode 2836 | 2837 | // <1=> Run in SLEEP, Pause in HALT 2838 | // <8=> Pause in SLEEP, Run in HALT 2839 | // <9=> Run in SLEEP and HALT 2840 | // <0=> Pause in SLEEP and HALT 2841 | 2842 | #ifndef WDT_CONFIG_BEHAVIOUR 2843 | #define WDT_CONFIG_BEHAVIOUR 1 2844 | #endif 2845 | 2846 | // WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> 2847 | 2848 | 2849 | #ifndef WDT_CONFIG_RELOAD_VALUE 2850 | #define WDT_CONFIG_RELOAD_VALUE 2000 2851 | #endif 2852 | 2853 | // WDT_CONFIG_IRQ_PRIORITY - Interrupt priority 2854 | 2855 | 2856 | // Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice 2857 | // <0=> 0 (highest) 2858 | // <1=> 1 2859 | // <2=> 2 2860 | // <3=> 3 2861 | 2862 | #ifndef WDT_CONFIG_IRQ_PRIORITY 2863 | #define WDT_CONFIG_IRQ_PRIORITY 3 2864 | #endif 2865 | 2866 | // WDT_CONFIG_LOG_ENABLED - Enables logging in the module. 2867 | //========================================================== 2868 | #ifndef WDT_CONFIG_LOG_ENABLED 2869 | #define WDT_CONFIG_LOG_ENABLED 0 2870 | #endif 2871 | #if WDT_CONFIG_LOG_ENABLED 2872 | // WDT_CONFIG_LOG_LEVEL - Default Severity level 2873 | 2874 | // <0=> Off 2875 | // <1=> Error 2876 | // <2=> Warning 2877 | // <3=> Info 2878 | // <4=> Debug 2879 | 2880 | #ifndef WDT_CONFIG_LOG_LEVEL 2881 | #define WDT_CONFIG_LOG_LEVEL 3 2882 | #endif 2883 | 2884 | // WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. 2885 | 2886 | // <0=> Default 2887 | // <1=> Black 2888 | // <2=> Red 2889 | // <3=> Green 2890 | // <4=> Yellow 2891 | // <5=> Blue 2892 | // <6=> Magenta 2893 | // <7=> Cyan 2894 | // <8=> White 2895 | 2896 | #ifndef WDT_CONFIG_INFO_COLOR 2897 | #define WDT_CONFIG_INFO_COLOR 0 2898 | #endif 2899 | 2900 | // WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. 2901 | 2902 | // <0=> Default 2903 | // <1=> Black 2904 | // <2=> Red 2905 | // <3=> Green 2906 | // <4=> Yellow 2907 | // <5=> Blue 2908 | // <6=> Magenta 2909 | // <7=> Cyan 2910 | // <8=> White 2911 | 2912 | #ifndef WDT_CONFIG_DEBUG_COLOR 2913 | #define WDT_CONFIG_DEBUG_COLOR 0 2914 | #endif 2915 | 2916 | #endif //WDT_CONFIG_LOG_ENABLED 2917 | // 2918 | 2919 | #endif //WDT_ENABLED 2920 | // 2921 | 2922 | // 2923 | //========================================================== 2924 | 2925 | // nRF_Libraries 2926 | 2927 | //========================================================== 2928 | // APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher 2929 | 2930 | 2931 | #ifndef APP_GPIOTE_ENABLED 2932 | #define APP_GPIOTE_ENABLED 0 2933 | #endif 2934 | 2935 | // APP_PWM_ENABLED - app_pwm - PWM functionality 2936 | 2937 | 2938 | #ifndef APP_PWM_ENABLED 2939 | #define APP_PWM_ENABLED 0 2940 | #endif 2941 | 2942 | // APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler 2943 | //========================================================== 2944 | #ifndef APP_SCHEDULER_ENABLED 2945 | #define APP_SCHEDULER_ENABLED 0 2946 | #endif 2947 | #if APP_SCHEDULER_ENABLED 2948 | // APP_SCHEDULER_WITH_PAUSE - Enabling pause feature 2949 | 2950 | 2951 | #ifndef APP_SCHEDULER_WITH_PAUSE 2952 | #define APP_SCHEDULER_WITH_PAUSE 0 2953 | #endif 2954 | 2955 | // APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling 2956 | 2957 | 2958 | #ifndef APP_SCHEDULER_WITH_PROFILER 2959 | #define APP_SCHEDULER_WITH_PROFILER 0 2960 | #endif 2961 | 2962 | #endif //APP_SCHEDULER_ENABLED 2963 | // 2964 | 2965 | // APP_TIMER_ENABLED - app_timer - Application timer functionality 2966 | //========================================================== 2967 | #ifndef APP_TIMER_ENABLED 2968 | #define APP_TIMER_ENABLED 1 2969 | #endif 2970 | #if APP_TIMER_ENABLED 2971 | // APP_TIMER_WITH_PROFILER - Enable app_timer profiling 2972 | 2973 | 2974 | #ifndef APP_TIMER_WITH_PROFILER 2975 | #define APP_TIMER_WITH_PROFILER 0 2976 | #endif 2977 | 2978 | // APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on 2979 | 2980 | 2981 | // If option is enabled RTC is kept running even if there is no active timers. 2982 | // This option can be used when app_timer is used for timestamping. 2983 | 2984 | #ifndef APP_TIMER_KEEPS_RTC_ACTIVE 2985 | #define APP_TIMER_KEEPS_RTC_ACTIVE 0 2986 | #endif 2987 | 2988 | #endif //APP_TIMER_ENABLED 2989 | // 2990 | 2991 | // APP_TWI_ENABLED - app_twi - TWI transaction manager 2992 | 2993 | 2994 | #ifndef APP_TWI_ENABLED 2995 | #define APP_TWI_ENABLED 0 2996 | #endif 2997 | 2998 | // APP_UART_ENABLED - app_uart - UART driver 2999 | //========================================================== 3000 | #ifndef APP_UART_ENABLED 3001 | #define APP_UART_ENABLED 0 3002 | #endif 3003 | #if APP_UART_ENABLED 3004 | // APP_UART_DRIVER_INSTANCE - UART instance used 3005 | 3006 | // <0=> 0 3007 | 3008 | #ifndef APP_UART_DRIVER_INSTANCE 3009 | #define APP_UART_DRIVER_INSTANCE 0 3010 | #endif 3011 | 3012 | #endif //APP_UART_ENABLED 3013 | // 3014 | 3015 | // APP_USBD_CLASS_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class 3016 | 3017 | 3018 | #ifndef APP_USBD_CLASS_AUDIO_ENABLED 3019 | #define APP_USBD_CLASS_AUDIO_ENABLED 0 3020 | #endif 3021 | 3022 | // APP_USBD_CLASS_HID_ENABLED - app_usbd_hid - USB HID class 3023 | 3024 | 3025 | #ifndef APP_USBD_CLASS_HID_ENABLED 3026 | #define APP_USBD_CLASS_HID_ENABLED 0 3027 | #endif 3028 | 3029 | // APP_USBD_HID_GENERIC_ENABLED - app_usbd_hid_generic - USB HID generic 3030 | 3031 | 3032 | #ifndef APP_USBD_HID_GENERIC_ENABLED 3033 | #define APP_USBD_HID_GENERIC_ENABLED 0 3034 | #endif 3035 | 3036 | // APP_USBD_HID_KBD_ENABLED - app_usbd_hid_kbd - USB HID keyboard 3037 | 3038 | 3039 | #ifndef APP_USBD_HID_KBD_ENABLED 3040 | #define APP_USBD_HID_KBD_ENABLED 0 3041 | #endif 3042 | 3043 | // APP_USBD_HID_MOUSE_ENABLED - app_usbd_hid_mouse - USB HID mouse 3044 | 3045 | 3046 | #ifndef APP_USBD_HID_MOUSE_ENABLED 3047 | #define APP_USBD_HID_MOUSE_ENABLED 0 3048 | #endif 3049 | 3050 | // BUTTON_ENABLED - app_button - buttons handling module 3051 | 3052 | 3053 | #ifndef BUTTON_ENABLED 3054 | #define BUTTON_ENABLED 1 3055 | #endif 3056 | 3057 | // CRC16_ENABLED - crc16 - CRC16 calculation routines 3058 | 3059 | 3060 | #ifndef CRC16_ENABLED 3061 | #define CRC16_ENABLED 0 3062 | #endif 3063 | 3064 | // CRC32_ENABLED - crc32 - CRC32 calculation routines 3065 | 3066 | 3067 | #ifndef CRC32_ENABLED 3068 | #define CRC32_ENABLED 0 3069 | #endif 3070 | 3071 | // ECC_ENABLED - ecc - Elliptic Curve Cryptography Library 3072 | 3073 | 3074 | #ifndef ECC_ENABLED 3075 | #define ECC_ENABLED 0 3076 | #endif 3077 | 3078 | // FDS_ENABLED - fds - Flash data storage module 3079 | //========================================================== 3080 | #ifndef FDS_ENABLED 3081 | #define FDS_ENABLED 0 3082 | #endif 3083 | #if FDS_ENABLED 3084 | // FDS_OP_QUEUE_SIZE - Size of the internal queue. 3085 | #ifndef FDS_OP_QUEUE_SIZE 3086 | #define FDS_OP_QUEUE_SIZE 4 3087 | #endif 3088 | 3089 | // FDS_CHUNK_QUEUE_SIZE - Determines how many @ref fds_record_chunk_t structures can be buffered at any time. 3090 | #ifndef FDS_CHUNK_QUEUE_SIZE 3091 | #define FDS_CHUNK_QUEUE_SIZE 8 3092 | #endif 3093 | 3094 | // FDS_MAX_USERS - Maximum number of callbacks that can be registered. 3095 | #ifndef FDS_MAX_USERS 3096 | #define FDS_MAX_USERS 8 3097 | #endif 3098 | 3099 | // FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. 3100 | // One of the virtual pages is reserved by the system for garbage collection. 3101 | // Therefore, the minimum is two virtual pages: one page to store data and 3102 | // one page to be used by the system for garbage collection. The total amount 3103 | // of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES 3104 | // @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. 3105 | 3106 | #ifndef FDS_VIRTUAL_PAGES 3107 | #define FDS_VIRTUAL_PAGES 3 3108 | #endif 3109 | 3110 | // FDS_VIRTUAL_PAGE_SIZE - The size of a virtual page of flash memory, expressed in number of 4-byte words. 3111 | 3112 | 3113 | // By default, a virtual page is the same size as a physical page. 3114 | // The size of a virtual page must be a multiple of the size of a physical page. 3115 | // <256=> 256 3116 | // <512=> 512 3117 | // <1024=> 1024 3118 | 3119 | #ifndef FDS_VIRTUAL_PAGE_SIZE 3120 | #define FDS_VIRTUAL_PAGE_SIZE 256 3121 | #endif 3122 | 3123 | #endif //FDS_ENABLED 3124 | // 3125 | 3126 | // FSTORAGE_ENABLED - fstorage - Flash storage module 3127 | //========================================================== 3128 | #ifndef FSTORAGE_ENABLED 3129 | #define FSTORAGE_ENABLED 0 3130 | #endif 3131 | #if FSTORAGE_ENABLED 3132 | // FS_QUEUE_SIZE - Configures the size of the internal queue. 3133 | // Increase this if there are many users, or if it is likely that many 3134 | // operation will be queued at once without waiting for the previous operations 3135 | // to complete. In general, increase the queue size if you frequently receive 3136 | // @ref FS_ERR_QUEUE_FULL errors when calling @ref fs_store or @ref fs_erase. 3137 | 3138 | #ifndef FS_QUEUE_SIZE 3139 | #define FS_QUEUE_SIZE 4 3140 | #endif 3141 | 3142 | // FS_OP_MAX_RETRIES - Number attempts to execute an operation if the SoftDevice fails. 3143 | // Increase this value if events return the @ref FS_ERR_OPERATION_TIMEOUT 3144 | // error often. The SoftDevice may fail to schedule flash access due to high BLE activity. 3145 | 3146 | #ifndef FS_OP_MAX_RETRIES 3147 | #define FS_OP_MAX_RETRIES 3 3148 | #endif 3149 | 3150 | // FS_MAX_WRITE_SIZE_WORDS - Maximum number of words to be written to flash in a single operation. 3151 | // Tweaking this value can increase the chances of the SoftDevice being 3152 | // able to fit flash operations in between radio activity. This value is bound by the 3153 | // maximum number of words which the SoftDevice can write to flash in a single call to 3154 | // @ref sd_flash_write, which is 256 words for nRF51 ICs and 1024 words for nRF52 ICs. 3155 | 3156 | #ifndef FS_MAX_WRITE_SIZE_WORDS 3157 | #define FS_MAX_WRITE_SIZE_WORDS 256 3158 | #endif 3159 | 3160 | #endif //FSTORAGE_ENABLED 3161 | // 3162 | 3163 | // HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release 3164 | 3165 | 3166 | #ifndef HARDFAULT_HANDLER_ENABLED 3167 | #define HARDFAULT_HANDLER_ENABLED 0 3168 | #endif 3169 | 3170 | // HCI_MEM_POOL_ENABLED - hci_mem_pool - memory pool implementation used by HCI 3171 | //========================================================== 3172 | #ifndef HCI_MEM_POOL_ENABLED 3173 | #define HCI_MEM_POOL_ENABLED 0 3174 | #endif 3175 | #if HCI_MEM_POOL_ENABLED 3176 | // HCI_TX_BUF_SIZE - TX buffer size in bytes. 3177 | #ifndef HCI_TX_BUF_SIZE 3178 | #define HCI_TX_BUF_SIZE 600 3179 | #endif 3180 | 3181 | // HCI_RX_BUF_SIZE - RX buffer size in bytes. 3182 | #ifndef HCI_RX_BUF_SIZE 3183 | #define HCI_RX_BUF_SIZE 600 3184 | #endif 3185 | 3186 | // HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. 3187 | #ifndef HCI_RX_BUF_QUEUE_SIZE 3188 | #define HCI_RX_BUF_QUEUE_SIZE 4 3189 | #endif 3190 | 3191 | #endif //HCI_MEM_POOL_ENABLED 3192 | // 3193 | 3194 | // HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI 3195 | //========================================================== 3196 | #ifndef HCI_SLIP_ENABLED 3197 | #define HCI_SLIP_ENABLED 0 3198 | #endif 3199 | #if HCI_SLIP_ENABLED 3200 | // HCI_UART_BAUDRATE - Default Baudrate 3201 | 3202 | // <323584=> 1200 baud 3203 | // <643072=> 2400 baud 3204 | // <1290240=> 4800 baud 3205 | // <2576384=> 9600 baud 3206 | // <3862528=> 14400 baud 3207 | // <5152768=> 19200 baud 3208 | // <7716864=> 28800 baud 3209 | // <10289152=> 38400 baud 3210 | // <15400960=> 57600 baud 3211 | // <20615168=> 76800 baud 3212 | // <30924800=> 115200 baud 3213 | // <61865984=> 230400 baud 3214 | // <67108864=> 250000 baud 3215 | // <121634816=> 460800 baud 3216 | // <251658240=> 921600 baud 3217 | // <268435456=> 57600 baud 3218 | 3219 | #ifndef HCI_UART_BAUDRATE 3220 | #define HCI_UART_BAUDRATE 30924800 3221 | #endif 3222 | 3223 | // HCI_UART_FLOW_CONTROL - Hardware Flow Control 3224 | 3225 | // <0=> Disabled 3226 | // <1=> Enabled 3227 | 3228 | #ifndef HCI_UART_FLOW_CONTROL 3229 | #define HCI_UART_FLOW_CONTROL 0 3230 | #endif 3231 | 3232 | // HCI_UART_RX_PIN - UART RX pin 3233 | #ifndef HCI_UART_RX_PIN 3234 | #define HCI_UART_RX_PIN 11 3235 | #endif 3236 | 3237 | // HCI_UART_TX_PIN - UART TX pin 3238 | #ifndef HCI_UART_TX_PIN 3239 | #define HCI_UART_TX_PIN 9 3240 | #endif 3241 | 3242 | // HCI_UART_RTS_PIN - UART RTS pin 3243 | #ifndef HCI_UART_RTS_PIN 3244 | #define HCI_UART_RTS_PIN 8 3245 | #endif 3246 | 3247 | // HCI_UART_CTS_PIN - UART CTS pin 3248 | #ifndef HCI_UART_CTS_PIN 3249 | #define HCI_UART_CTS_PIN 10 3250 | #endif 3251 | 3252 | #endif //HCI_SLIP_ENABLED 3253 | // 3254 | 3255 | // HCI_TRANSPORT_ENABLED - hci_transport - HCI transport 3256 | //========================================================== 3257 | #ifndef HCI_TRANSPORT_ENABLED 3258 | #define HCI_TRANSPORT_ENABLED 0 3259 | #endif 3260 | #if HCI_TRANSPORT_ENABLED 3261 | // HCI_MAX_PACKET_SIZE_IN_BITS - Maximum size of a single application packet in bits. 3262 | #ifndef HCI_MAX_PACKET_SIZE_IN_BITS 3263 | #define HCI_MAX_PACKET_SIZE_IN_BITS 8000 3264 | #endif 3265 | 3266 | #endif //HCI_TRANSPORT_ENABLED 3267 | // 3268 | 3269 | // LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module 3270 | 3271 | 3272 | #ifndef LED_SOFTBLINK_ENABLED 3273 | #define LED_SOFTBLINK_ENABLED 0 3274 | #endif 3275 | 3276 | // LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module 3277 | 3278 | 3279 | #ifndef LOW_POWER_PWM_ENABLED 3280 | #define LOW_POWER_PWM_ENABLED 0 3281 | #endif 3282 | 3283 | // MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator 3284 | //========================================================== 3285 | #ifndef MEM_MANAGER_ENABLED 3286 | #define MEM_MANAGER_ENABLED 0 3287 | #endif 3288 | #if MEM_MANAGER_ENABLED 3289 | // MEMORY_MANAGER_SMALL_BLOCK_COUNT - Size of each memory blocks identified as 'small' block. <0-255> 3290 | 3291 | 3292 | #ifndef MEMORY_MANAGER_SMALL_BLOCK_COUNT 3293 | #define MEMORY_MANAGER_SMALL_BLOCK_COUNT 1 3294 | #endif 3295 | 3296 | // MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. 3297 | // Size of each memory blocks identified as 'small' block. Memory block are recommended to be word-sized. 3298 | 3299 | #ifndef MEMORY_MANAGER_SMALL_BLOCK_SIZE 3300 | #define MEMORY_MANAGER_SMALL_BLOCK_SIZE 32 3301 | #endif 3302 | 3303 | // MEMORY_MANAGER_MEDIUM_BLOCK_COUNT - Size of each memory blocks identified as 'medium' block. <0-255> 3304 | 3305 | 3306 | #ifndef MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 3307 | #define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 0 3308 | #endif 3309 | 3310 | // MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. 3311 | // Size of each memory blocks identified as 'medium' block. Memory block are recommended to be word-sized. 3312 | 3313 | #ifndef MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 3314 | #define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 256 3315 | #endif 3316 | 3317 | // MEMORY_MANAGER_LARGE_BLOCK_COUNT - Size of each memory blocks identified as 'large' block. <0-255> 3318 | 3319 | 3320 | #ifndef MEMORY_MANAGER_LARGE_BLOCK_COUNT 3321 | #define MEMORY_MANAGER_LARGE_BLOCK_COUNT 0 3322 | #endif 3323 | 3324 | // MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. 3325 | // Size of each memory blocks identified as 'large' block. Memory block are recommended to be word-sized. 3326 | 3327 | #ifndef MEMORY_MANAGER_LARGE_BLOCK_SIZE 3328 | #define MEMORY_MANAGER_LARGE_BLOCK_SIZE 256 3329 | #endif 3330 | 3331 | // MEM_MANAGER_ENABLE_LOGS - Enable debug trace in the module. 3332 | 3333 | 3334 | #ifndef MEM_MANAGER_ENABLE_LOGS 3335 | #define MEM_MANAGER_ENABLE_LOGS 0 3336 | #endif 3337 | 3338 | // MEM_MANAGER_DISABLE_API_PARAM_CHECK - Disable API parameter checks in the module. 3339 | 3340 | 3341 | #ifndef MEM_MANAGER_DISABLE_API_PARAM_CHECK 3342 | #define MEM_MANAGER_DISABLE_API_PARAM_CHECK 0 3343 | #endif 3344 | 3345 | #endif //MEM_MANAGER_ENABLED 3346 | // 3347 | 3348 | // NRF_CSENSE_ENABLED - nrf_csense - nrf_csense module 3349 | //========================================================== 3350 | #ifndef NRF_CSENSE_ENABLED 3351 | #define NRF_CSENSE_ENABLED 0 3352 | #endif 3353 | #if NRF_CSENSE_ENABLED 3354 | // NRF_CSENSE_PAD_HYSTERESIS - Minimal value of change to decide that pad was touched. 3355 | #ifndef NRF_CSENSE_PAD_HYSTERESIS 3356 | #define NRF_CSENSE_PAD_HYSTERESIS 15 3357 | #endif 3358 | 3359 | // NRF_CSENSE_PAD_DEVIATION - Minimal value measured on pad to take its value while calculating step. 3360 | #ifndef NRF_CSENSE_PAD_DEVIATION 3361 | #define NRF_CSENSE_PAD_DEVIATION 70 3362 | #endif 3363 | 3364 | // NRF_CSENSE_MIN_PAD_VALUE - Minimum normalized value on pad to take its value into account. 3365 | #ifndef NRF_CSENSE_MIN_PAD_VALUE 3366 | #define NRF_CSENSE_MIN_PAD_VALUE 20 3367 | #endif 3368 | 3369 | // NRF_CSENSE_MAX_PADS_NUMBER - Maximum number of pads used for one instance. 3370 | #ifndef NRF_CSENSE_MAX_PADS_NUMBER 3371 | #define NRF_CSENSE_MAX_PADS_NUMBER 20 3372 | #endif 3373 | 3374 | // NRF_CSENSE_MAX_VALUE - Maximum normalized value got from measurement. 3375 | #ifndef NRF_CSENSE_MAX_VALUE 3376 | #define NRF_CSENSE_MAX_VALUE 1000 3377 | #endif 3378 | 3379 | // NRF_CSENSE_OUTPUT_PIN - Output pin used by lower module. 3380 | // This is only used when running on NRF51. 3381 | 3382 | #ifndef NRF_CSENSE_OUTPUT_PIN 3383 | #define NRF_CSENSE_OUTPUT_PIN 30 3384 | #endif 3385 | 3386 | #endif //NRF_CSENSE_ENABLED 3387 | // 3388 | 3389 | // NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor module 3390 | //========================================================== 3391 | #ifndef NRF_DRV_CSENSE_ENABLED 3392 | #define NRF_DRV_CSENSE_ENABLED 0 3393 | #endif 3394 | #if NRF_DRV_CSENSE_ENABLED 3395 | // TIMER0_FOR_CSENSE - First TIMER instance used by the driver (except nRF51) 3396 | #ifndef TIMER0_FOR_CSENSE 3397 | #define TIMER0_FOR_CSENSE 1 3398 | #endif 3399 | 3400 | // TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (except nRF51) 3401 | #ifndef TIMER1_FOR_CSENSE 3402 | #define TIMER1_FOR_CSENSE 2 3403 | #endif 3404 | 3405 | // MEASUREMENT_PERIOD - Single measurement period. 3406 | // Time of single measurement can be calculated as T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). I_SOURCE, VUP and VDOWN are values used to initialize COMP and C is capacitance of used pad. 3407 | 3408 | #ifndef MEASUREMENT_PERIOD 3409 | #define MEASUREMENT_PERIOD 20 3410 | #endif 3411 | 3412 | #endif //NRF_DRV_CSENSE_ENABLED 3413 | // 3414 | 3415 | // NRF_QUEUE_ENABLED - nrf_queue - Queue module 3416 | 3417 | 3418 | #ifndef NRF_QUEUE_ENABLED 3419 | #define NRF_QUEUE_ENABLED 0 3420 | #endif 3421 | 3422 | // SLIP_ENABLED - slip - SLIP encoding decoding 3423 | 3424 | 3425 | #ifndef SLIP_ENABLED 3426 | #define SLIP_ENABLED 0 3427 | #endif 3428 | 3429 | // app_usbd_cdc_acm - USB CDC ACM class 3430 | 3431 | //========================================================== 3432 | // APP_USBD_CLASS_CDC_ACM_ENABLED - Enabling USBD CDC ACM Class library 3433 | 3434 | 3435 | #ifndef APP_USBD_CLASS_CDC_ACM_ENABLED 3436 | #define APP_USBD_CLASS_CDC_ACM_ENABLED 0 3437 | #endif 3438 | 3439 | // APP_USBD_CDC_ACM_LOG_ENABLED - Enables logging in the module. 3440 | 3441 | 3442 | #ifndef APP_USBD_CDC_ACM_LOG_ENABLED 3443 | #define APP_USBD_CDC_ACM_LOG_ENABLED 0 3444 | #endif 3445 | 3446 | // 3447 | //========================================================== 3448 | 3449 | // app_usbd_msc - USB MSC class 3450 | 3451 | //========================================================== 3452 | // APP_USBD_CLASS_MSC_ENABLED - Enabling USBD MSC Class library 3453 | 3454 | 3455 | #ifndef APP_USBD_CLASS_MSC_ENABLED 3456 | #define APP_USBD_CLASS_MSC_ENABLED 0 3457 | #endif 3458 | 3459 | // APP_USBD_MSC_CLASS_LOG_ENABLED - Enables logging in the module. 3460 | 3461 | 3462 | #ifndef APP_USBD_MSC_CLASS_LOG_ENABLED 3463 | #define APP_USBD_MSC_CLASS_LOG_ENABLED 0 3464 | #endif 3465 | 3466 | // 3467 | //========================================================== 3468 | 3469 | // 3470 | //========================================================== 3471 | 3472 | // nRF_Log 3473 | 3474 | //========================================================== 3475 | // NRF_LOG_ENABLED - nrf_log - Logging 3476 | //========================================================== 3477 | #ifndef NRF_LOG_ENABLED 3478 | #define NRF_LOG_ENABLED 1 3479 | #endif 3480 | #if NRF_LOG_ENABLED 3481 | // NRF_LOG_USES_COLORS - If enabled then ANSI escape code for colors is prefixed to every string 3482 | //========================================================== 3483 | #ifndef NRF_LOG_USES_COLORS 3484 | #define NRF_LOG_USES_COLORS 0 3485 | #endif 3486 | #if NRF_LOG_USES_COLORS 3487 | // NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. 3488 | 3489 | // <0=> Default 3490 | // <1=> Black 3491 | // <2=> Red 3492 | // <3=> Green 3493 | // <4=> Yellow 3494 | // <5=> Blue 3495 | // <6=> Magenta 3496 | // <7=> Cyan 3497 | // <8=> White 3498 | 3499 | #ifndef NRF_LOG_COLOR_DEFAULT 3500 | #define NRF_LOG_COLOR_DEFAULT 0 3501 | #endif 3502 | 3503 | // NRF_LOG_ERROR_COLOR - ANSI escape code prefix. 3504 | 3505 | // <0=> Default 3506 | // <1=> Black 3507 | // <2=> Red 3508 | // <3=> Green 3509 | // <4=> Yellow 3510 | // <5=> Blue 3511 | // <6=> Magenta 3512 | // <7=> Cyan 3513 | // <8=> White 3514 | 3515 | #ifndef NRF_LOG_ERROR_COLOR 3516 | #define NRF_LOG_ERROR_COLOR 0 3517 | #endif 3518 | 3519 | // NRF_LOG_WARNING_COLOR - ANSI escape code prefix. 3520 | 3521 | // <0=> Default 3522 | // <1=> Black 3523 | // <2=> Red 3524 | // <3=> Green 3525 | // <4=> Yellow 3526 | // <5=> Blue 3527 | // <6=> Magenta 3528 | // <7=> Cyan 3529 | // <8=> White 3530 | 3531 | #ifndef NRF_LOG_WARNING_COLOR 3532 | #define NRF_LOG_WARNING_COLOR 0 3533 | #endif 3534 | 3535 | #endif //NRF_LOG_USES_COLORS 3536 | // 3537 | 3538 | // NRF_LOG_DEFAULT_LEVEL - Default Severity level 3539 | 3540 | // <0=> Off 3541 | // <1=> Error 3542 | // <2=> Warning 3543 | // <3=> Info 3544 | // <4=> Debug 3545 | 3546 | #ifndef NRF_LOG_DEFAULT_LEVEL 3547 | #define NRF_LOG_DEFAULT_LEVEL 4 3548 | #endif 3549 | 3550 | // NRF_LOG_DEFERRED - Enable deffered logger. 3551 | 3552 | // Log data is buffered and can be processed in idle. 3553 | //========================================================== 3554 | #ifndef NRF_LOG_DEFERRED 3555 | #define NRF_LOG_DEFERRED 0 3556 | #endif 3557 | #if NRF_LOG_DEFERRED 3558 | // NRF_LOG_DEFERRED_BUFSIZE - Size of the buffer for logs in words. 3559 | // Must be power of 2 3560 | 3561 | #ifndef NRF_LOG_DEFERRED_BUFSIZE 3562 | #define NRF_LOG_DEFERRED_BUFSIZE 256 3563 | #endif 3564 | 3565 | #endif //NRF_LOG_DEFERRED 3566 | // 3567 | 3568 | // NRF_LOG_USES_TIMESTAMP - Enable timestamping 3569 | 3570 | 3571 | // Function for getting the timestamp is provided by the user 3572 | 3573 | #ifndef NRF_LOG_USES_TIMESTAMP 3574 | #define NRF_LOG_USES_TIMESTAMP 0 3575 | #endif 3576 | 3577 | #endif //NRF_LOG_ENABLED 3578 | // 3579 | 3580 | // nrf_log_backend - Logging sink 3581 | 3582 | //========================================================== 3583 | // NRF_LOG_BACKEND_MAX_STRING_LENGTH - Buffer for storing single output string 3584 | // Logger backend RAM usage is determined by this value. 3585 | 3586 | #ifndef NRF_LOG_BACKEND_MAX_STRING_LENGTH 3587 | #define NRF_LOG_BACKEND_MAX_STRING_LENGTH 256 3588 | #endif 3589 | 3590 | // NRF_LOG_TIMESTAMP_DIGITS - Number of digits for timestamp 3591 | // If higher resolution timestamp source is used it might be needed to increase that 3592 | 3593 | #ifndef NRF_LOG_TIMESTAMP_DIGITS 3594 | #define NRF_LOG_TIMESTAMP_DIGITS 8 3595 | #endif 3596 | 3597 | // NRF_LOG_BACKEND_SERIAL_USES_UART - If enabled data is printed over UART 3598 | //========================================================== 3599 | #ifndef NRF_LOG_BACKEND_SERIAL_USES_UART 3600 | #define NRF_LOG_BACKEND_SERIAL_USES_UART 0 3601 | #endif 3602 | #if NRF_LOG_BACKEND_SERIAL_USES_UART 3603 | // NRF_LOG_BACKEND_SERIAL_UART_BAUDRATE - Default Baudrate 3604 | 3605 | // <323584=> 1200 baud 3606 | // <643072=> 2400 baud 3607 | // <1290240=> 4800 baud 3608 | // <2576384=> 9600 baud 3609 | // <3862528=> 14400 baud 3610 | // <5152768=> 19200 baud 3611 | // <7716864=> 28800 baud 3612 | // <10289152=> 38400 baud 3613 | // <15400960=> 57600 baud 3614 | // <20615168=> 76800 baud 3615 | // <30924800=> 115200 baud 3616 | // <61865984=> 230400 baud 3617 | // <67108864=> 250000 baud 3618 | // <121634816=> 460800 baud 3619 | // <251658240=> 921600 baud 3620 | // <268435456=> 57600 baud 3621 | 3622 | #ifndef NRF_LOG_BACKEND_SERIAL_UART_BAUDRATE 3623 | #define NRF_LOG_BACKEND_SERIAL_UART_BAUDRATE 30924800 3624 | #endif 3625 | 3626 | // NRF_LOG_BACKEND_SERIAL_UART_TX_PIN - UART TX pin 3627 | #ifndef NRF_LOG_BACKEND_SERIAL_UART_TX_PIN 3628 | #define NRF_LOG_BACKEND_SERIAL_UART_TX_PIN 9 3629 | #endif 3630 | 3631 | // NRF_LOG_BACKEND_SERIAL_UART_RX_PIN - UART RX pin 3632 | #ifndef NRF_LOG_BACKEND_SERIAL_UART_RX_PIN 3633 | #define NRF_LOG_BACKEND_SERIAL_UART_RX_PIN 11 3634 | #endif 3635 | 3636 | // NRF_LOG_BACKEND_SERIAL_UART_RTS_PIN - UART RTS pin 3637 | #ifndef NRF_LOG_BACKEND_SERIAL_UART_RTS_PIN 3638 | #define NRF_LOG_BACKEND_SERIAL_UART_RTS_PIN 8 3639 | #endif 3640 | 3641 | // NRF_LOG_BACKEND_SERIAL_UART_CTS_PIN - UART CTS pin 3642 | #ifndef NRF_LOG_BACKEND_SERIAL_UART_CTS_PIN 3643 | #define NRF_LOG_BACKEND_SERIAL_UART_CTS_PIN 10 3644 | #endif 3645 | 3646 | // NRF_LOG_BACKEND_SERIAL_UART_FLOW_CONTROL - Hardware Flow Control 3647 | 3648 | // <0=> Disabled 3649 | // <1=> Enabled 3650 | 3651 | #ifndef NRF_LOG_BACKEND_SERIAL_UART_FLOW_CONTROL 3652 | #define NRF_LOG_BACKEND_SERIAL_UART_FLOW_CONTROL 0 3653 | #endif 3654 | 3655 | // NRF_LOG_BACKEND_UART_INSTANCE - UART instance used 3656 | 3657 | // <0=> 0 3658 | 3659 | #ifndef NRF_LOG_BACKEND_UART_INSTANCE 3660 | #define NRF_LOG_BACKEND_UART_INSTANCE 0 3661 | #endif 3662 | 3663 | #endif //NRF_LOG_BACKEND_SERIAL_USES_UART 3664 | // 3665 | 3666 | // NRF_LOG_BACKEND_SERIAL_USES_RTT - If enabled data is printed using RTT 3667 | //========================================================== 3668 | #ifndef NRF_LOG_BACKEND_SERIAL_USES_RTT 3669 | #define NRF_LOG_BACKEND_SERIAL_USES_RTT 1 3670 | #endif 3671 | #if NRF_LOG_BACKEND_SERIAL_USES_RTT 3672 | // NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE - RTT output buffer size. 3673 | // Should be equal or bigger than \ref NRF_LOG_BACKEND_MAX_STRING_LENGTH. 3674 | // This value is used in Segger RTT configuration to set the buffer size 3675 | // if it is bigger than default RTT buffer size. 3676 | 3677 | #ifndef NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE 3678 | #define NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE 512 3679 | #endif 3680 | 3681 | #endif //NRF_LOG_BACKEND_SERIAL_USES_RTT 3682 | // 3683 | 3684 | // 3685 | //========================================================== 3686 | 3687 | // 3688 | //========================================================== 3689 | 3690 | // nRF_Segger_RTT 3691 | 3692 | //========================================================== 3693 | // segger_rtt - SEGGER RTT 3694 | 3695 | //========================================================== 3696 | // SEGGER_RTT_CONFIG_BUFFER_SIZE_UP - Size of upstream buffer. 3697 | #ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 3698 | #define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 64 3699 | #endif 3700 | 3701 | // SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer. 3702 | #ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 3703 | #define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2 3704 | #endif 3705 | 3706 | // SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer. 3707 | #ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 3708 | #define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16 3709 | #endif 3710 | 3711 | // SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer. 3712 | #ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 3713 | #define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2 3714 | #endif 3715 | 3716 | // 3717 | //========================================================== 3718 | 3719 | // 3720 | //========================================================== 3721 | 3722 | // <<< end of configuration section >>> 3723 | #endif //SDK_CONFIG_H 3724 | 3725 | --------------------------------------------------------------------------------