├── .gitignore ├── include ├── user_app.h ├── ble_handlers.h ├── user_custs_config.h └── user_custs1_def.h ├── components ├── debug │ ├── inc │ │ └── debug.h │ └── src │ │ └── debug.c └── config │ └── inc │ ├── user_periph_setup.h │ ├── user_modules_config.h │ ├── user_profiles_config.h │ ├── da1458x_config_basic.h │ ├── user_callback_config.h │ ├── user_config.h │ └── da1458x_config_advanced.h ├── src ├── printf_gcc.c ├── user_app.c ├── user_periph_setup.c ├── interrupts.c ├── user_custs_config.c ├── ble_handlers.c └── user_custs1_def.c ├── Libraries └── RTT │ ├── SEGGER_types.h │ ├── License.txt │ ├── SEGGER_SYSVIEW_Conf.h │ ├── SEGGER_SYSVIEW_Int.h │ ├── SEGGER_SYSVIEW_Config_CM0.c │ ├── SEGGER.h │ ├── SEGGER_RTT_ASM_ARMv7M.S │ ├── SEGGER_RTT_printf.c │ └── SEGGER_SYSVIEW.h ├── gcc ├── arm-none-eabi.cmake ├── mem_DA14531.lds ├── ldscript_DA14531.lds.S └── dialog-sdk.cmake ├── LICENSE ├── DA14531-debug.jdebug ├── README.md └── CMakeLists.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # VSCode 2 | .vscode/ 3 | 4 | # Build directory 5 | build/ 6 | 7 | # JLink files 8 | JLinkLog.txt 9 | 10 | # Ozone files 11 | *.jdebug.user 12 | -------------------------------------------------------------------------------- /include/user_app.h: -------------------------------------------------------------------------------- 1 | #ifndef USER_APP_H_ 2 | #define USER_APP_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | void app_on_init(void); 11 | void app_resume_from_sleep(void); 12 | arch_main_loop_callback_ret_t app_on_system_powered(void); 13 | sleep_mode_t app_validate_sleep(sleep_mode_t sleep_mode); 14 | void app_going_to_sleep(sleep_mode_t sleep_mode); 15 | 16 | #endif // USER_APP_H_ 17 | -------------------------------------------------------------------------------- /components/debug/inc/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef DEBUG_H_ 2 | #define DEBUG_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifdef DEBUG_SEGGER 9 | #include 10 | 11 | #define DEBUG_PRINT_STRING(str) SEGGER_RTT_WriteString(0, (str)); 12 | #define DEBUG_PRINTF(...) SEGGER_RTT_printf(0, __VA_ARGS__); 13 | #else 14 | #define DEBUG_PRINT_STRING(str) 15 | #define DEBUG_PRINTF(...) 16 | #endif 17 | 18 | void Debug_CrashHandler(void); 19 | void Debug_PrintMemoryUsage(void); 20 | void Debug_Breakpoint(void); 21 | 22 | #endif // DEBUG_H_ 23 | -------------------------------------------------------------------------------- /include/ble_handlers.h: -------------------------------------------------------------------------------- 1 | #ifndef BLE_HANDLERS_H_ 2 | #define BLE_HANDLERS_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | void user_catch_rest_hndl(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id); 17 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param); 18 | void user_on_disconnect(struct gapc_disconnect_ind const *param); 19 | 20 | #endif // BLE_HANDLERS_H_ 21 | -------------------------------------------------------------------------------- /src/printf_gcc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int _write(int fd, const void *buf, size_t count) 5 | { 6 | const char* bufChar = buf; 7 | int ret = 0; 8 | 9 | while (count--) 10 | { 11 | if (SEGGER_RTT_PutChar(0, *bufChar++)) 12 | { 13 | ret++; 14 | } 15 | else 16 | { 17 | ret = -1; 18 | break; 19 | } 20 | } 21 | 22 | return ret; 23 | } 24 | 25 | int _read(int fd, const void *buf, size_t count) 26 | { 27 | char* bufChar = (char*)buf; 28 | int ret = 0; 29 | 30 | while (count--) 31 | { 32 | *bufChar = SEGGER_RTT_GetKey(); 33 | bufChar++; 34 | } 35 | 36 | return ret; 37 | } 38 | -------------------------------------------------------------------------------- /Libraries/RTT/SEGGER_types.h: -------------------------------------------------------------------------------- 1 | #ifndef SEGGER_TYPES_H 2 | #define SEGGER_TYPES_H 3 | 4 | #include 5 | 6 | #define U8 uint8_t 7 | #define I8 int8_t 8 | #define U16 uint16_t 9 | #define I16 int16_t 10 | #define U32 uint32_t 11 | #define I32 int32_t 12 | 13 | // 14 | // CC_NO_LONG_SUPPORT can be defined to compile test 15 | // without long support for compilers that do not 16 | // support C99 and its long type. 17 | // 18 | #ifdef CC_NO_LONG_SUPPORT 19 | #define PTR_ADDR U32 20 | #else // Supports long type. 21 | // 22 | // C99 compliant compiler 23 | // 24 | #define U64 unsigned long long 25 | #define I64 signed long long 26 | #define U64_C(x) x##ULL 27 | 28 | #define PTR_ADDR U32 29 | #endif // Supports long type. 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /gcc/arm-none-eabi.cmake: -------------------------------------------------------------------------------- 1 | if("${GCC_TOOLCHAIN_PATH}" STREQUAL "") 2 | message(FATAL_ERROR "GCC_TOOLCHAIN_PATH not set") 3 | endif() 4 | 5 | set(CMAKE_SYSTEM_NAME "Cortex-M0plus") 6 | set(CMAKE_SYSTEM_PROCESSOR arm) 7 | set(CMAKE_C_COMPILER_FORCED TRUE) 8 | set(CMAKE_CXX_COMPILER_FORCED TRUE) 9 | 10 | find_program(CMAKE_C_COMPILER NAMES arm-none-eabi-gcc PATHS ${GCC_TOOLCHAIN_PATH}/bin/) 11 | find_program(CMAKE_CXX_COMPILER NAMES arm-none-eabi-g++ PATHS ${GCC_TOOLCHAIN_PATH}/bin/) 12 | find_program(CMAKE_ASM_COMPILER NAMES arm-none-eabi-gcc PATHS ${GCC_TOOLCHAIN_PATH}/bin/) 13 | find_program(CMAKE_OBJCOPY NAMES arm-none-eabi-objcopy PATHS ${GCC_TOOLCHAIN_PATH}/bin/) 14 | find_program(CMAKE_SIZE NAMES arm-none-eabi-size PATHS ${GCC_TOOLCHAIN_PATH}/bin/) 15 | find_program(CMAKE_AR NAMES arm-none-eabi-ar PATHS ${GCC_TOOLCHAIN_PATH}/bin/) 16 | 17 | set(CMAKE_C_COMPILER_ID GNU) 18 | set(CMAKE_CXX_COMPILER_ID GNU) 19 | 20 | set(CMAKE_EXECUTABLE_SUFFIX_C .elf) 21 | set(CMAKE_EXECUTABLE_SUFFIX_CXX .elf) 22 | set(CMAKE_EXECUTABLE_SUFFIX_ASM .elf) 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright 2021 Mikolaj Stawiski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /components/debug/src/debug.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | void Debug_CrashHandler(void) 10 | { 11 | Debug_PrintMemoryUsage(); 12 | __BKPT(0); 13 | } 14 | 15 | static void printMemory(const char* name, uint8_t type, uint16_t size) 16 | { 17 | uint16_t usage = ke_get_mem_usage(type); 18 | DEBUG_PRINTF("%s = %d / %d (%.1f%%)\r\n", name, usage, size, ((float)usage*100.0f)/(float)size); 19 | } 20 | 21 | void Debug_PrintMemoryUsage(void) 22 | { 23 | DEBUG_PRINTF("Mem usage:\r\n"); 24 | printMemory("ENV", KE_MEM_ENV, __SCT_HEAP_ENV_SIZE); 25 | printMemory("ATT_DB", KE_MEM_ATT_DB, __SCT_HEAP_DB_SIZE); 26 | printMemory("KE_MSG", KE_MEM_KE_MSG, __SCT_HEAP_MSG_SIZE); 27 | printMemory("NON_RET", KE_MEM_NON_RETENTION, __SCT_HEAP_NON_RET_SIZE); 28 | DEBUG_PRINTF("MAX = %lu\r\n", (uint32_t)ke_get_max_mem_usage()); 29 | } 30 | 31 | void Debug_Breakpoint(void) 32 | { 33 | __BKPT(0); 34 | } 35 | -------------------------------------------------------------------------------- /Libraries/RTT/License.txt: -------------------------------------------------------------------------------- 1 | Important - Read carefully: 2 | 3 | SEGGER RTT - Real Time Transfer for embedded targets 4 | 5 | All rights reserved. 6 | 7 | SEGGER strongly recommends to not make any changes 8 | to or modify the source code of this software in order to stay 9 | compatible with the RTT protocol and J-Link. 10 | 11 | Redistribution and use in source and binary forms, with or 12 | without modification, are permitted provided that the following 13 | condition is met: 14 | 15 | o Redistributions of source code must retain the above copyright 16 | notice, this condition and the following disclaimer. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 25 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 29 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 30 | DAMAGE. 31 | 32 | 33 | (c) 2014 - 2016 SEGGER Microcontroller GmbH 34 | www.segger.com 35 | -------------------------------------------------------------------------------- /src/user_app.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include // SW configuration 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | /* 16 | This function is called as a callback by system arch, after peripheral init, and app init, but before giving away to the kernel and main loop 17 | */ 18 | void app_on_init(void) 19 | { 20 | // To keep compatibility call default handler 21 | default_app_on_init(); 22 | 23 | extern uint32_t __StackTop; 24 | extern uint32_t __HeapBase; 25 | extern uint32_t __HeapLimit; 26 | 27 | uint32_t initial_sp = (uint32_t)&__StackTop; 28 | uint32_t heap_base = (uint32_t)&__HeapBase; 29 | uint32_t heap_limit = (uint32_t)&__HeapLimit; 30 | 31 | printf("app_on_init()\r\n"); 32 | printf("Compiled: %s %s\r\n", __DATE__, __TIME__); 33 | printf("stack: 0x%08lX\r\n", initial_sp); 34 | printf("heap: 0x%08lX (0x%04X)\r\n", heap_base, (uint16_t)heap_limit); 35 | } 36 | 37 | void app_resume_from_sleep(void) 38 | { 39 | } 40 | 41 | arch_main_loop_callback_ret_t app_on_system_powered(void) 42 | { 43 | wdg_reload(1); 44 | return KEEP_POWERED; 45 | } 46 | 47 | sleep_mode_t app_validate_sleep(sleep_mode_t sleep_mode) 48 | { 49 | /* Block sleep. */ 50 | return mode_active; 51 | } 52 | 53 | void app_going_to_sleep(sleep_mode_t sleep_mode) 54 | { 55 | } 56 | -------------------------------------------------------------------------------- /DA14531-debug.jdebug: -------------------------------------------------------------------------------- 1 | __constant U32 SYS_CTRL_REG = 0x50000012; 2 | __constant U32 SYS_RAM1 = 0x07FC0000; 3 | __constant U32 SYS_RAM2 = 0x07FC4000; 4 | __constant U32 SYS_RAM3 = 0x07FC7000; 5 | 6 | void OnProjectLoad() 7 | { 8 | // Disable RTT to be able to use SystemView simultaneously 9 | Project.SetRTT(0); 10 | // Set the target MCU 11 | Project.SetDevice("Cortex-M0+"); 12 | Project.SetHostIF("USB", ""); 13 | Project.SetTargetIF("SWD"); 14 | Project.SetTIFSpeed("1 MHz"); 15 | Project.AddSvdFile("Cortex-M0.svd"); 16 | Project.SetPeripheralFile("$(ProjectDir)/DA14531.svd"); 17 | Project.AddSearchPath("."); 18 | // elf-like project file 19 | File.Open("$(ProjectDir)/build/DA14531_App.elf"); 20 | } 21 | 22 | void TargetDownload(void) { 23 | U16 sysCtrl; 24 | 25 | // Read 26 | sysCtrl = Target.ReadU16(SYS_CTRL_REG); 27 | Util.LogHex("SYS_CTRL_REG = ", sysCtrl); 28 | // Add bits that remap to SysRAM1 29 | sysCtrl = (sysCtrl & 0xFFFC) | 0x2; 30 | Util.Log("Remapping to SysRAM1."); 31 | 32 | // Write to SYS_CTRL_REG 33 | Target.WriteU16(SYS_CTRL_REG, sysCtrl); 34 | sysCtrl = Target.ReadU16(SYS_CTRL_REG); 35 | Util.LogHex("SYS_CTRL_REG = ", sysCtrl); 36 | Exec.Reset(); 37 | 38 | // Download RAM 39 | Util.Log("Downloading program into RAM."); 40 | Target.LoadMemory("$(ProjectDir)/build/DA14531_App.elf", SYS_RAM1); 41 | 42 | // Set up for execution 43 | Util.Log("Setting up SP and PC."); 44 | Target.SetReg("SP", Target.ReadU32(SYS_RAM1)); 45 | Target.SetReg("PC", Target.ReadU32(SYS_RAM1 + 4)); 46 | Util.Log("Done."); 47 | } 48 | -------------------------------------------------------------------------------- /components/config/inc/user_periph_setup.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.h 5 | * 6 | * @brief Peripherals setup header file. 7 | * 8 | * Copyright (c) 2015-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | #ifndef _USER_PERIPH_SETUP_H_ 34 | #define _USER_PERIPH_SETUP_H_ 35 | 36 | /* 37 | * INCLUDE FILES 38 | **************************************************************************************** 39 | */ 40 | 41 | #include "rwip_config.h" 42 | #include "da1458x_periph_setup.h" 43 | #include "uart.h" 44 | #include "gpio.h" 45 | 46 | void periph_init(void); 47 | void GPIO_reservations(void); 48 | 49 | #endif // _USER_PERIPH_SETUP_H_ 50 | -------------------------------------------------------------------------------- /include/user_custs_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.h 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 7 | * 8 | * Copyright (c) 2016-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | #ifndef _USER_CUSTS_CONFIG_H_ 34 | #define _USER_CUSTS_CONFIG_H_ 35 | 36 | /** 37 | **************************************************************************************** 38 | * @defgroup USER_CONFIG 39 | * @ingroup USER 40 | * @brief Custom1/2 Server (CUSTS1/2) profile database initialization. 41 | * 42 | * @{ 43 | **************************************************************************************** 44 | */ 45 | 46 | /* 47 | * INCLUDE FILES 48 | **************************************************************************************** 49 | */ 50 | 51 | #include "app_prf_types.h" 52 | 53 | /* 54 | * GLOBAL VARIABLE DECLARATIONS 55 | **************************************************************************************** 56 | */ 57 | 58 | extern const struct cust_prf_func_callbacks cust_prf_funcs[]; 59 | 60 | /// @} USER_CONFIG 61 | 62 | #endif // _USER_CUSTS_CONFIG_H_ 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The purpose of this repository is to provide a template to build firmware for DA14531 (Dialog's BLE microcontroller) under CMake with GCC for no code limits. This template integrates SEGGER RTT library for debug `printf`s through SWD using JLink debug probe (no need for hardware serial). 4 | 5 | Author: Mikolaj Stawiski 6 | 7 | # Requirements 8 | 9 | To build the template you'll need: 10 | - CMake >= 3.16 (download from https://cmake.org/download/) 11 | - GCC for ARM (download from ARM's website https://developer.arm.com/). Recommended `gcc-arm-none-eabi-10-2020-q4-major`. 12 | - Dialog SDK v.6.0.14.1114 (download from Dialog's website https://www.dialog-semiconductor.com/) 13 | - make 14 | 15 | Additionally if you want to run the firmware on the target you'll need: 16 | - JLink debug probe 17 | - JLink RTT Viewer (for displaying and logging `printf`s from the target) 18 | - JLink Ozone debugger >= V3.22a 19 | - Hardware based on DA14531 chip with SWD (e.g. DA14531 Basic USB kit) 20 | 21 | Having installed CMake, and downloaded and unzipped GCC for ARM and required Dialog SDK, run `build-linux.sh` (Ubuntu/WSL/MacOS) or `build-windows.bat` (Windows) and supply it with paths to GCC and the SDK. 22 | 23 | --- 24 | **NOTE for Windows** 25 | 26 | You'll need `make` to compile the code, for which you might have to install MSYS. 27 | 28 | --- 29 | 30 | # Running on target 31 | 32 | Upon successful setup and build you'll get firmware files under `./build` directory. The firmware will come in few handy formats: binary, hex and elf. 33 | 34 | If you want to debug the firmware using Ozone debugger, open `DA14531-debug.jdebug` with Ozone. The script will load the firmware into target's RAM and name your target's registers for nice debugging experience. 35 | 36 | # Integration to VSCode 37 | 38 | Below is an example of `tasks.json` for VSCode assuming you're on Linux, installed CMake, downloaded and unzipped GCC for ARM to `~/gcc-arm-none-eabi-10-2020-q4-major/`, and downloaded and unzipped Dialog SDK v.6.0.14.1114 to `~/dialog-sdk/`: 39 | ``` 40 | { 41 | "version": "2.0.0", 42 | "tasks": [ 43 | { 44 | "label": "Build", 45 | "type": "shell", 46 | "command": "${workspaceFolder}/build-linux.sh", 47 | "args": [ 48 | "~/gcc-arm-none-eabi-10-2020-q4-major/", 49 | "~/dialog-sdk" 50 | ], 51 | "problemMatcher": [ 52 | "$gcc" 53 | ], 54 | "group": { 55 | "kind": "build", 56 | "isDefault": true 57 | } 58 | } 59 | ] 60 | } 61 | ``` 62 | -------------------------------------------------------------------------------- /src/user_periph_setup.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_periph_setup.c 5 | * 6 | * @brief Peripherals setup and initialization. 7 | * 8 | * Copyright (c) 2015-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | #if DEVELOPMENT_DEBUG 42 | void GPIO_reservations(void) 43 | { 44 | } 45 | #endif 46 | 47 | static void set_pad_functions(void) 48 | { 49 | } 50 | 51 | void periph_init(void) 52 | { 53 | // Disable HW RST on P0_0 54 | GPIO_Disable_HW_Reset(); 55 | 56 | // Enable DC/DC buck mode 57 | if (syscntl_dcdc_turn_on_in_buck(SYSCNTL_DCDC_LEVEL_1V1) != 0) 58 | { 59 | __BKPT(0); 60 | } 61 | 62 | // ROM patch 63 | patch_func(); 64 | 65 | // Set pad functionality 66 | set_pad_functions(); 67 | 68 | // Enable the pads 69 | GPIO_set_pad_latch_en(true); 70 | 71 | #ifdef DEBUG_SEGGER 72 | static bool isSeggerInitialized = false; 73 | if (!isSeggerInitialized) 74 | { 75 | // Set up JLink RTT 76 | SEGGER_RTT_Init(); 77 | DEBUG_PRINT_STRING("periph_init()\r\n"); 78 | 79 | isSeggerInitialized = true; 80 | } 81 | #endif 82 | } 83 | -------------------------------------------------------------------------------- /src/interrupts.c: -------------------------------------------------------------------------------- 1 | #include // Dialog SDK 2 | 3 | extern void BLE_WAKEUP_LP_Handler(void); 4 | extern void rwble_isr(void); 5 | 6 | void IRQ_BLE_WAKEUP_LP_Handler(void) 7 | { 8 | BLE_WAKEUP_LP_Handler(); 9 | } 10 | 11 | void IRQ_rwble_isr(void) 12 | { 13 | rwble_isr(); 14 | } 15 | 16 | void IRQ_UART_Handler(void) 17 | { 18 | __BKPT(0); 19 | while (1) 20 | { 21 | __NOP(); 22 | } 23 | } 24 | 25 | void IRQ_UART2_Handler(void) 26 | { 27 | __BKPT(0); 28 | while (1) 29 | { 30 | __NOP(); 31 | } 32 | } 33 | 34 | void IRQ_I2C_Handler(void) 35 | { 36 | __BKPT(0); 37 | while (1) 38 | { 39 | __NOP(); 40 | } 41 | } 42 | 43 | void IRQ_SPI_Handler(void) 44 | { 45 | __BKPT(0); 46 | while (1) 47 | { 48 | __NOP(); 49 | } 50 | } 51 | 52 | void IRQ_ADC_Handler(void) 53 | { 54 | __BKPT(0); 55 | while (1) 56 | { 57 | __NOP(); 58 | } 59 | } 60 | 61 | void IRQ_KEYBRD_Handler(void) 62 | { 63 | __BKPT(0); 64 | while (1) 65 | { 66 | __NOP(); 67 | } 68 | } 69 | 70 | void IRQ_BLE_RF_DIAG_Handler(void) 71 | { 72 | __BKPT(0); 73 | while (1) 74 | { 75 | __NOP(); 76 | } 77 | } 78 | 79 | void IRQ_RFCAL_Handler(void) 80 | { 81 | __BKPT(0); 82 | while (1) 83 | { 84 | __NOP(); 85 | } 86 | } 87 | 88 | void IRQ_GPIO0_Handler(void) 89 | { 90 | __BKPT(0); 91 | while (1) 92 | { 93 | __NOP(); 94 | } 95 | } 96 | 97 | void IRQ_GPIO1_Handler(void) 98 | { 99 | __BKPT(0); 100 | while (1) 101 | { 102 | __NOP(); 103 | } 104 | } 105 | 106 | void IRQ_GPIO2_Handler(void) 107 | { 108 | __BKPT(0); 109 | while (1) 110 | { 111 | __NOP(); 112 | } 113 | } 114 | 115 | void IRQ_GPIO3_Handler(void) 116 | { 117 | __BKPT(0); 118 | while (1) 119 | { 120 | __NOP(); 121 | } 122 | } 123 | 124 | void IRQ_GPIO4_Handler(void) 125 | { 126 | __BKPT(0); 127 | while (1) 128 | { 129 | __NOP(); 130 | } 131 | } 132 | 133 | void IRQ_SWTIM_Handler(void) 134 | { 135 | __BKPT(0); 136 | while (1) 137 | { 138 | __NOP(); 139 | } 140 | } 141 | 142 | void IRQ_WKUP_QUADEC_Handler(void) 143 | { 144 | __BKPT(0); 145 | while (1) 146 | { 147 | __NOP(); 148 | } 149 | } 150 | 151 | void IRQ_SWTIM1_Handler(void) 152 | { 153 | __BKPT(0); 154 | while (1) 155 | { 156 | __NOP(); 157 | } 158 | } 159 | 160 | void IRQ_RTC_Handler(void) 161 | { 162 | __BKPT(0); 163 | while (1) 164 | { 165 | __NOP(); 166 | } 167 | } 168 | 169 | void IRQ_DMA_Handler(void) 170 | { 171 | __BKPT(0); 172 | while (1) 173 | { 174 | __NOP(); 175 | } 176 | } 177 | 178 | void IRQ_XTAL32M_RDY_Handler(void) 179 | { 180 | __BKPT(0); 181 | while (1) 182 | { 183 | __NOP(); 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /include/user_custs1_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs1_def.h 5 | * 6 | * @brief Custom Server 1 (CUSTS1) profile database definitions. 7 | * 8 | * Copyright (c) 2016-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | #ifndef _USER_CUSTS1_DEF_H_ 34 | #define _USER_CUSTS1_DEF_H_ 35 | 36 | /** 37 | **************************************************************************************** 38 | * @defgroup USER_CONFIG 39 | * @ingroup USER 40 | * @brief Custom Server 1 (CUSTS1) profile database definitions. 41 | * 42 | * @{ 43 | **************************************************************************************** 44 | */ 45 | 46 | /* 47 | * INCLUDE FILES 48 | **************************************************************************************** 49 | */ 50 | 51 | #include "attm_db_128.h" 52 | 53 | /* 54 | * DEFINES 55 | **************************************************************************************** 56 | */ 57 | 58 | // Service 1 of the custom server 1 59 | #define DEF_SVC1_UUID_128 {0x59, 0x5a, 0x08, 0xe4, 0x86, 0x2a, 0x9e, 0x8f, 0xe9, 0x11, 0xbc, 0x7c, 0x98, 0x43, 0x42, 0x18} 60 | 61 | #define DEF_SVC1_CTRL_POINT_UUID_128 {0x20, 0xEE, 0x8D, 0x0C, 0xE1, 0xF0, 0x4A, 0x0C, 0xB3, 0x25, 0xDC, 0x53, 0x6A, 0x68, 0x86, 0x2D} 62 | #define DEF_SVC1_CTRL_POINT_CHAR_LEN 32 63 | #define DEF_SVC1_CONTROL_POINT_USER_DESC "Control Point" 64 | 65 | /// Custom1 Service Data Base Characteristic enum 66 | enum 67 | { 68 | // Custom Service 1 69 | SVC1_IDX_SVC = 0, 70 | 71 | SVC1_IDX_CONTROL_POINT_CHAR, 72 | SVC1_IDX_CONTROL_POINT_VAL, 73 | SVC1_IDX_CONTROL_POINT_NTF_CFG, 74 | SVC1_IDX_CONTROL_POINT_USER_DESC, 75 | 76 | CUSTS1_IDX_NB 77 | }; 78 | 79 | /// @} USER_CONFIG 80 | 81 | #endif // _USER_CUSTS1_DEF_H_ 82 | -------------------------------------------------------------------------------- /src/user_custs_config.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs_config.c 5 | * 6 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 7 | * 8 | * Copyright (c) 2016-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | /** 34 | **************************************************************************************** 35 | * @defgroup USER_CONFIG 36 | * @ingroup USER 37 | * @brief Custom1/2 Server (CUSTS1/2) profile database structure and initialization. 38 | * 39 | * @{ 40 | **************************************************************************************** 41 | */ 42 | 43 | /* 44 | * INCLUDE FILES 45 | **************************************************************************************** 46 | */ 47 | 48 | #include "app_prf_types.h" 49 | #include "app_customs.h" 50 | #include "user_custs1_def.h" 51 | 52 | /* 53 | * GLOBAL VARIABLE DEFINITIONS 54 | **************************************************************************************** 55 | */ 56 | 57 | #if (BLE_CUSTOM1_SERVER) 58 | extern const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB]; 59 | #endif 60 | 61 | /// Custom1/2 server function callback table 62 | const struct cust_prf_func_callbacks cust_prf_funcs[] = 63 | { 64 | #if (BLE_CUSTOM1_SERVER) 65 | { TASK_ID_CUSTS1, 66 | custs1_att_db, 67 | CUSTS1_IDX_NB, 68 | #if (BLE_APP_PRESENT) 69 | app_custs1_create_db, NULL, 70 | #else 71 | NULL, NULL, 72 | #endif 73 | NULL, NULL, 74 | }, 75 | #endif 76 | #if (BLE_CUSTOM2_SERVER) 77 | { TASK_ID_CUSTS2, 78 | NULL, 79 | 0, 80 | #if (BLE_APP_PRESENT) 81 | app_custs2_create_db, NULL, 82 | #else 83 | NULL, NULL, 84 | #endif 85 | NULL, NULL, 86 | }, 87 | #endif 88 | {TASK_ID_INVALID, NULL, 0, NULL, NULL, NULL, NULL}, // DO NOT MOVE. Must always be last 89 | }; 90 | 91 | /// @} USER_CONFIG 92 | -------------------------------------------------------------------------------- /src/ble_handlers.c: -------------------------------------------------------------------------------- 1 | #include "ble_handlers.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | static const char* msgidToString(ke_msg_id_t msgid) 17 | { 18 | const char* result = "undefined"; 19 | switch (msgid) 20 | { 21 | case CUSTS1_CREATE_DB_REQ: 22 | { 23 | result = "CUSTS1_CREATE_DB_REQ"; 24 | break; 25 | } 26 | case CUSTS1_CREATE_DB_CFM: 27 | { 28 | result = "CUSTS1_CREATE_DB_CFM"; 29 | break; 30 | } 31 | case CUSTS1_ENABLE_REQ: 32 | { 33 | result = "CUSTS1_ENABLE_REQ"; 34 | break; 35 | } 36 | case CUSTS1_VAL_SET_REQ: 37 | { 38 | result = "CUSTS1_VAL_SET_REQ"; 39 | break; 40 | } 41 | case CUSTS1_VALUE_REQ_IND: 42 | { 43 | result = "CUSTS1_VALUE_REQ_IND"; 44 | break; 45 | } 46 | case CUSTS1_VALUE_REQ_RSP: 47 | { 48 | result = "CUSTS1_VALUE_REQ_RSP"; 49 | break; 50 | } 51 | case CUSTS1_VAL_NTF_REQ: 52 | { 53 | result = "CUSTS1_VAL_NTF_REQ"; 54 | break; 55 | } 56 | case CUSTS1_VAL_NTF_CFM: 57 | { 58 | result = "CUSTS1_VAL_NTF_CFM"; 59 | break; 60 | } 61 | case CUSTS1_VAL_IND_REQ: 62 | { 63 | result = "CUSTS1_VAL_IND_REQ"; 64 | break; 65 | } 66 | case CUSTS1_VAL_IND_CFM: 67 | { 68 | result = "CUSTS1_VAL_IND_CFM"; 69 | break; 70 | } 71 | case CUSTS1_VAL_WRITE_IND: 72 | { 73 | result = "CUSTS1_VAL_WRITE_IND"; 74 | break; 75 | } 76 | case CUSTS1_DISABLE_IND: 77 | { 78 | result = "CUSTS1_DISABLE_IND"; 79 | break; 80 | } 81 | case CUSTS1_ERROR_IND: 82 | { 83 | result = "CUSTS1_ERROR_IND"; 84 | break; 85 | } 86 | case CUSTS1_ATT_INFO_REQ: 87 | { 88 | result = "CUSTS1_ATT_INFO_REQ"; 89 | break; 90 | } 91 | case CUSTS1_ATT_INFO_RSP: 92 | { 93 | result = "CUSTS1_ATT_INFO_RSP"; 94 | break; 95 | } 96 | default: 97 | { 98 | break; 99 | } 100 | } 101 | return result; 102 | } 103 | 104 | void user_catch_rest_hndl(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) 105 | { 106 | switch(msgid) 107 | { 108 | default: 109 | { 110 | printf("handler: %s\r\n", msgidToString(msgid)); 111 | break; 112 | } 113 | } 114 | } 115 | 116 | void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) 117 | { 118 | printf("user_on_connection()\r\n"); 119 | default_app_on_connection(connection_idx, param); 120 | } 121 | 122 | void user_on_disconnect( struct gapc_disconnect_ind const *param ) 123 | { 124 | printf("user_on_disconnect()\r\n"); 125 | default_app_on_disconnect(param); 126 | } 127 | -------------------------------------------------------------------------------- /components/config/inc/user_modules_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_modules_config.h 5 | * 6 | * @brief User modules configuration file. 7 | * 8 | * Copyright (c) 2015-2019 Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | #ifndef _USER_MODULES_CONFIG_H_ 34 | #define _USER_MODULES_CONFIG_H_ 35 | 36 | /** 37 | **************************************************************************************** 38 | * @addtogroup APP 39 | * @ingroup RICOW 40 | * 41 | * @brief User modules configuration. 42 | * 43 | * @{ 44 | **************************************************************************************** 45 | */ 46 | 47 | /* 48 | * DEFINES 49 | **************************************************************************************** 50 | */ 51 | 52 | /***************************************************************************************/ 53 | /* Exclude or not a module in user's application code. */ 54 | /* */ 55 | /* (0) - The module is included. The module's messages are handled by the SDK. */ 56 | /* */ 57 | /* (1) - The module is excluded. The user must handle the module's messages. */ 58 | /* */ 59 | /* Note: */ 60 | /* This setting has no effect if the respective module is a BLE Profile */ 61 | /* that is not used included in the user's application. */ 62 | /***************************************************************************************/ 63 | #define EXCLUDE_DLG_GAP (0) 64 | #define EXCLUDE_DLG_TIMER (1) 65 | #define EXCLUDE_DLG_MSG (0) 66 | #define EXCLUDE_DLG_SEC (1) 67 | #define EXCLUDE_DLG_DISS (1) 68 | #define EXCLUDE_DLG_PROXR (1) 69 | #define EXCLUDE_DLG_BASS (1) 70 | #define EXCLUDE_DLG_FINDL (1) 71 | #define EXCLUDE_DLG_FINDT (1) 72 | #define EXCLUDE_DLG_SUOTAR (1) 73 | #define EXCLUDE_DLG_CUSTS1 (0) 74 | #define EXCLUDE_DLG_CUSTS2 (1) 75 | 76 | /// @} APP 77 | 78 | #endif // _USER_MODULES_CONFIG_H_ 79 | -------------------------------------------------------------------------------- /Libraries/RTT/SEGGER_SYSVIEW_Conf.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * SEGGER Microcontroller GmbH * 3 | * The Embedded Experts * 4 | ********************************************************************** 5 | * * 6 | * (c) 1995 - 2019 SEGGER Microcontroller GmbH * 7 | * * 8 | * www.segger.com Support: support@segger.com * 9 | * * 10 | ********************************************************************** 11 | * * 12 | * SEGGER SystemView * Real-time application analysis * 13 | * * 14 | ********************************************************************** 15 | * * 16 | * All rights reserved. * 17 | * * 18 | * SEGGER strongly recommends to not make any changes * 19 | * to or modify the source code of this software in order to stay * 20 | * compatible with the SystemView and RTT protocol, and J-Link. * 21 | * * 22 | * Redistribution and use in source and binary forms, with or * 23 | * without modification, are permitted provided that the following * 24 | * condition is met: * 25 | * * 26 | * o Redistributions of source code must retain the above copyright * 27 | * notice, this condition and the following disclaimer. * 28 | * * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 30 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * 31 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * 32 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * 33 | * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * 34 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * 36 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * 37 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 38 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * 40 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 41 | * DAMAGE. * 42 | * * 43 | ********************************************************************** 44 | * * 45 | * SystemView version: 3.20 * 46 | * * 47 | ********************************************************************** 48 | -------------------------- END-OF-HEADER ----------------------------- 49 | 50 | File : SEGGER_SYSVIEW_Conf.h 51 | Purpose : SEGGER SystemView configuration file. 52 | Set defines which deviate from the defaults (see SEGGER_SYSVIEW_ConfDefaults.h) here. 53 | Revision: $Rev: 21292 $ 54 | 55 | Additional information: 56 | Required defines which must be set are: 57 | SEGGER_SYSVIEW_GET_TIMESTAMP 58 | SEGGER_SYSVIEW_GET_INTERRUPT_ID 59 | For known compilers and cores, these might be set to good defaults 60 | in SEGGER_SYSVIEW_ConfDefaults.h. 61 | 62 | SystemView needs a (nestable) locking mechanism. 63 | If not defined, the RTT locking mechanism is used, 64 | which then needs to be properly configured. 65 | */ 66 | 67 | #ifndef SEGGER_SYSVIEW_CONF_H 68 | #define SEGGER_SYSVIEW_CONF_H 69 | 70 | #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM0 71 | #define SEGGER_SYSVIEW_GET_INTERRUPT_ID SEGGER_SYSVIEW_X_GetInterruptId 72 | 73 | #define SEGGER_SYSVIEW_APP_NAME "DA14531_App" 74 | #define SEGGER_SYSVIEW_DEVICE_NAME "DA14531" 75 | 76 | #endif // SEGGER_SYSVIEW_CONF_H 77 | 78 | /*************************** End of file ****************************/ 79 | -------------------------------------------------------------------------------- /src/user_custs1_def.c: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_custs1_def.c 5 | * 6 | * @brief Custom Server 1 (CUSTS1) profile database definitions. 7 | * 8 | * Copyright (c) 2016-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | /** 34 | **************************************************************************************** 35 | * @defgroup USER_CONFIG 36 | * @ingroup USER 37 | * @brief Custom server 1 (CUSTS1) profile database definitions. 38 | * 39 | * @{ 40 | **************************************************************************************** 41 | */ 42 | 43 | /* 44 | * INCLUDE FILES 45 | **************************************************************************************** 46 | */ 47 | 48 | #include 49 | #include "co_utils.h" 50 | #include "prf_types.h" 51 | #include "attm_db_128.h" 52 | #include "user_custs1_def.h" 53 | 54 | /* 55 | * LOCAL VARIABLE DEFINITIONS 56 | **************************************************************************************** 57 | */ 58 | 59 | // Service 1 of the custom server 1 60 | static const att_svc_desc128_t custs1_svc1 = DEF_SVC1_UUID_128; 61 | 62 | static const uint8_t SVC1_CTRL_POINT_UUID_128[ATT_UUID_128_LEN] = DEF_SVC1_CTRL_POINT_UUID_128; 63 | 64 | // Attribute specifications 65 | static const uint16_t att_decl_svc = ATT_DECL_PRIMARY_SERVICE; 66 | static const uint16_t att_decl_char = ATT_DECL_CHARACTERISTIC; 67 | static const uint16_t att_desc_cfg = ATT_DESC_CLIENT_CHAR_CFG; 68 | static const uint16_t att_desc_user_desc = ATT_DESC_CHAR_USER_DESCRIPTION; 69 | 70 | /* 71 | * GLOBAL VARIABLE DEFINITIONS 72 | **************************************************************************************** 73 | */ 74 | 75 | const uint8_t custs1_services[] = {SVC1_IDX_SVC, CUSTS1_IDX_NB}; 76 | const uint8_t custs1_services_size = ARRAY_LEN(custs1_services) - 1; 77 | const uint16_t custs1_att_max_nb = CUSTS1_IDX_NB; 78 | 79 | /// Full CUSTS1 Database Description - Used to add attributes into the database 80 | const struct attm_desc_128 custs1_att_db[CUSTS1_IDX_NB] = 81 | { 82 | /************************* 83 | * Service 1 configuration 84 | ************************* 85 | */ 86 | 87 | // Service 1 Declaration 88 | [SVC1_IDX_SVC] = {(uint8_t*)&att_decl_svc, ATT_UUID_128_LEN, PERM(WR, ENABLE), sizeof(custs1_svc1), sizeof(custs1_svc1), (uint8_t*)&custs1_svc1}, 89 | 90 | // Control Point Characteristic Declaration 91 | [SVC1_IDX_CONTROL_POINT_CHAR] = {(uint8_t*)&att_decl_char, ATT_UUID_16_LEN, PERM(RD, ENABLE), 0, 0, NULL}, 92 | // Control Point Characteristic Value 93 | [SVC1_IDX_CONTROL_POINT_VAL] = {SVC1_CTRL_POINT_UUID_128, ATT_UUID_128_LEN, PERM(WR, ENABLE) | PERM(WRITE_REQ, ENABLE) | PERM(WRITE_COMMAND, ENABLE) | PERM(NTF, ENABLE), DEF_SVC1_CTRL_POINT_CHAR_LEN, 0, NULL}, 94 | // Control Point Client Characteristic Configuration Descriptor 95 | [SVC1_IDX_CONTROL_POINT_NTF_CFG] = {(uint8_t*)&att_desc_cfg, ATT_UUID_16_LEN, PERM(RD, ENABLE) | PERM(WR, ENABLE) | PERM(WRITE_REQ, ENABLE) | PERM(WRITE_COMMAND, ENABLE), sizeof(uint16_t), 0, NULL}, 96 | // Control Point Characteristic User Description 97 | [SVC1_IDX_CONTROL_POINT_USER_DESC] = {(uint8_t*)&att_desc_user_desc, ATT_UUID_16_LEN, PERM(RD, ENABLE), sizeof(DEF_SVC1_CONTROL_POINT_USER_DESC) - 1, sizeof(DEF_SVC1_CONTROL_POINT_USER_DESC) - 1, (uint8_t*)DEF_SVC1_CONTROL_POINT_USER_DESC}, 98 | }; 99 | 100 | /// @} USER_CONFIG 101 | -------------------------------------------------------------------------------- /Libraries/RTT/SEGGER_SYSVIEW_Int.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * SEGGER Microcontroller GmbH * 3 | * The Embedded Experts * 4 | ********************************************************************** 5 | * * 6 | * (c) 1995 - 2019 SEGGER Microcontroller GmbH * 7 | * * 8 | * www.segger.com Support: support@segger.com * 9 | * * 10 | ********************************************************************** 11 | * * 12 | * SEGGER SystemView * Real-time application analysis * 13 | * * 14 | ********************************************************************** 15 | * * 16 | * All rights reserved. * 17 | * * 18 | * SEGGER strongly recommends to not make any changes * 19 | * to or modify the source code of this software in order to stay * 20 | * compatible with the SystemView and RTT protocol, and J-Link. * 21 | * * 22 | * Redistribution and use in source and binary forms, with or * 23 | * without modification, are permitted provided that the following * 24 | * condition is met: * 25 | * * 26 | * o Redistributions of source code must retain the above copyright * 27 | * notice, this condition and the following disclaimer. * 28 | * * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 30 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * 31 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * 32 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * 33 | * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * 34 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * 36 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * 37 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 38 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * 40 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 41 | * DAMAGE. * 42 | * * 43 | ********************************************************************** 44 | * * 45 | * SystemView version: 3.20 * 46 | * * 47 | ********************************************************************** 48 | -------------------------- END-OF-HEADER ----------------------------- 49 | File : SEGGER_SYSVIEW_Int.h 50 | Purpose : SEGGER SystemView internal header. 51 | Revision: $Rev: 21281 $ 52 | */ 53 | 54 | #ifndef SEGGER_SYSVIEW_INT_H 55 | #define SEGGER_SYSVIEW_INT_H 56 | 57 | /********************************************************************* 58 | * 59 | * #include Section 60 | * 61 | ********************************************************************** 62 | */ 63 | 64 | #include "SEGGER_SYSVIEW.h" 65 | 66 | #ifdef __cplusplus 67 | extern "C" { 68 | #endif 69 | 70 | 71 | /********************************************************************* 72 | * 73 | * Private data types 74 | * 75 | ********************************************************************** 76 | */ 77 | // 78 | // Commands that Host can send to target 79 | // 80 | typedef enum { 81 | SEGGER_SYSVIEW_COMMAND_ID_START = 1, 82 | SEGGER_SYSVIEW_COMMAND_ID_STOP, 83 | SEGGER_SYSVIEW_COMMAND_ID_GET_SYSTIME, 84 | SEGGER_SYSVIEW_COMMAND_ID_GET_TASKLIST, 85 | SEGGER_SYSVIEW_COMMAND_ID_GET_SYSDESC, 86 | SEGGER_SYSVIEW_COMMAND_ID_GET_NUMMODULES, 87 | SEGGER_SYSVIEW_COMMAND_ID_GET_MODULEDESC, 88 | SEGGER_SYSVIEW_COMMAND_ID_HEARTBEAT = 127, 89 | // Extended commands: Commands >= 128 have a second parameter 90 | SEGGER_SYSVIEW_COMMAND_ID_GET_MODULE = 128 91 | } SEGGER_SYSVIEW_COMMAND_ID; 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif 98 | 99 | /*************************** End of file ****************************/ 100 | -------------------------------------------------------------------------------- /components/config/inc/user_profiles_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_profiles_config.h 5 | * 6 | * @brief Configuration file for the profiles used in the application. 7 | * 8 | * Copyright (c) 2015-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | #ifndef _USER_PROFILES_CONFIG_H_ 34 | #define _USER_PROFILES_CONFIG_H_ 35 | 36 | /** 37 | **************************************************************************************** 38 | * @defgroup APP_CONFIG 39 | * @ingroup APP 40 | * @brief Application configuration file 41 | * 42 | * This file contains the configuration of the profiles used by the application. 43 | * 44 | * @{ 45 | **************************************************************************************** 46 | */ 47 | 48 | /* 49 | * DEFINITIONS 50 | **************************************************************************************** 51 | */ 52 | 53 | /***************************************************************************************/ 54 | /* Used BLE profiles (used by "rwprf_config.h"). */ 55 | /***************************************************************************************/ 56 | 57 | //#define CFG_PRF_DISS 58 | #define CFG_PRF_CUST1 59 | 60 | /***************************************************************************************/ 61 | /* Profile application configuration section */ 62 | /***************************************************************************************/ 63 | 64 | /* 65 | **************************************************************************************** 66 | * DISS application profile configuration 67 | **************************************************************************************** 68 | */ 69 | 70 | #define APP_DIS_FEATURES (DIS_MANUFACTURER_NAME_CHAR_SUP | \ 71 | DIS_MODEL_NB_STR_CHAR_SUP | \ 72 | DIS_SYSTEM_ID_CHAR_SUP | \ 73 | DIS_SW_REV_STR_CHAR_SUP | \ 74 | DIS_FIRM_REV_STR_CHAR_SUP | \ 75 | DIS_PNP_ID_CHAR_SUP) 76 | 77 | /// Manufacturer Name (up to 18 chars) 78 | #define APP_DIS_MANUFACTURER_NAME ("Dialog Semi") 79 | #define APP_DIS_MANUFACTURER_NAME_LEN (11) 80 | 81 | /// Model Number String (up to 18 chars) 82 | #ifdef __DA14586__ 83 | #define APP_DIS_MODEL_NB_STR ("DA14586") 84 | #else 85 | #define APP_DIS_MODEL_NB_STR ("DA14531") 86 | #endif 87 | #define APP_DIS_MODEL_NB_STR_LEN (7) 88 | 89 | /// System ID - LSB -> MSB 90 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") 91 | #define APP_DIS_SYSTEM_ID_LEN (8) 92 | 93 | #define APP_DIS_SW_REV SDK_VERSION 94 | #define APP_DIS_FIRM_REV SDK_VERSION 95 | 96 | /// Serial Number 97 | #define APP_DIS_SERIAL_NB_STR ("1.0.0.0-LE") 98 | #define APP_DIS_SERIAL_NB_STR_LEN (10) 99 | 100 | /// Hardware Revision String 101 | #define APP_DIS_HARD_REV_STR ("DA14531") 102 | #define APP_DIS_HARD_REV_STR_LEN (7) 103 | 104 | /// Firmware Revision 105 | #define APP_DIS_FIRM_REV_STR SDK_VERSION 106 | #define APP_DIS_FIRM_REV_STR_LEN (sizeof(APP_DIS_FIRM_REV_STR) - 1) 107 | 108 | /// Software Revision String 109 | #define APP_DIS_SW_REV_STR SDK_VERSION 110 | #define APP_DIS_SW_REV_STR_LEN (sizeof(APP_DIS_SW_REV_STR) - 1) 111 | 112 | /// IEEE 113 | #define APP_DIS_IEEE ("\xFF\xEE\xDD\xCC\xBB\xAA") 114 | #define APP_DIS_IEEE_LEN (6) 115 | 116 | /** 117 | * PNP ID Value - LSB -> MSB 118 | * Vendor ID Source : 0x02 (USB Implementers Forum assigned Vendor ID value) 119 | * Vendor ID : 0x045E (Microsoft Corp) 120 | * Product ID : 0x0040 121 | * Product Version : 0x0300 122 | * e.g. #define APP_DIS_PNP_ID ("\x02\x5E\x04\x40\x00\x00\x03") 123 | */ 124 | #define APP_DIS_PNP_ID ("\x01\xD2\x00\x80\x05\x00\x01") 125 | #define APP_DIS_PNP_ID_LEN (7) 126 | 127 | /// @} APP_CONFIG 128 | 129 | #endif // _USER_PROFILES_CONFIG_H_ 130 | -------------------------------------------------------------------------------- /gcc/mem_DA14531.lds: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file mem_DA14531.lds 5 | * 6 | * @brief Common GNU LD linker script file - memory configuration. 7 | * 8 | * Copyright (C) 2018-2020 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | /* 16 | * This file needs to be run against C preprocessor before it is used by the linker program. 17 | * 18 | * ============================================================================================== 19 | * | System RAM | 20 | * ---------------------------------------------------------------------------------------------- 21 | * |+ 1st RAM block (16KB) + 2rd RAM block (12KB) + 3th RAM block (20KB) | 22 | * ---------------------------------------------------------------------------------------------- 23 | * | ^ ^ ^ ^ | 24 | * | | | | | | 25 | * | | RET_MEM_BASE_ADDR | | | 26 | * | | RAM_3_BASE_ADDR | | 27 | * | RAM_2_BASE_ADDR __SCT_BLE_BASE | 28 | * ============================================================================================== 29 | */ 30 | 31 | /* Macro to align val on the multiple of 4 equal or nearest higher */ 32 | #define ALIGN4_HI(val) (((val)+3) & (~(3))) 33 | 34 | #if !defined(CFG_RET_DATA_SIZE) 35 | #error "CFG_RET_DATA_SIZE is not defined!" 36 | #endif 37 | 38 | #if !defined(CFG_RET_DATA_UNINIT_SIZE) 39 | #error "CFG_RET_DATA_UNINIT_SIZE is not defined!" 40 | #endif 41 | 42 | #if !defined(RET_DATA_UNINIT_CHACHA_STATE_SIZE) 43 | #error "RET_DATA_UNINIT_CHACHA_STATE_SIZE is not defined!" 44 | #endif 45 | 46 | #if !defined(RET_DATA_UNINIT_TRNG_STATE_SIZE) 47 | #error "RET_DATA_UNINIT_TRNG_STATE_SIZE is not defined!" 48 | #endif 49 | 50 | /******************************************************************************************** 51 | * Memory area where retained data will be stored. 52 | ********************************************************************************************/ 53 | #define RET_MEM_SIZE (CFG_RET_DATA_UNINIT_SIZE + CFG_RET_DATA_SIZE + RET_HEAP_SIZE) 54 | 55 | /* Retained data base address */ 56 | #define RET_MEM_BASE_ADDR ALIGN4_HI(__SCT_BLE_BASE - RET_MEM_SIZE) 57 | 58 | /* chacha20_state base address */ 59 | #define CHACHA_STATE_BASE_ADDR ALIGN4_HI(ROM_DATA_BASE_ADDR - RET_DATA_UNINIT_CHACHA_STATE_SIZE) 60 | 61 | /* trng_state base address */ 62 | #define TRNG_STATE_BASE_ADDR ALIGN4_HI(ROM_DATA_BASE_ADDR - RET_DATA_UNINIT_CHACHA_STATE_SIZE - RET_DATA_UNINIT_TRNG_STATE_SIZE) 63 | 64 | /******************************************************************************************** 65 | * Free area resides between the Exchange memory and ROM data. 66 | ********************************************************************************************/ 67 | /* Free area base address */ 68 | #define FREE_AREA_BASE_ADDR ALIGN4_HI(__SCT_BLE_BASE + __SCT_EM_BLE_END) 69 | 70 | /* Free area size */ 71 | #define FREE_AREA_SIZE (ROM_DATA_BASE_ADDR - FREE_AREA_BASE_ADDR) - (RET_DATA_UNINIT_CHACHA_STATE_SIZE + RET_DATA_UNINIT_TRNG_STATE_SIZE) 72 | 73 | #if defined(CFG_CODE_LOCATION_OTP) && defined(CFG_CODE_LOCATION_EXT) 74 | #error "Only one of CFG_CODE_LOCATION_OTP and CFG_CODE_LOCATION_EXT must be defined!" 75 | #elif defined(CFG_CODE_LOCATION_OTP) 76 | #define CODE_LOCATION_OTP 1 77 | #define CODE_LOCATION_EXT 0 78 | #elif defined(CFG_CODE_LOCATION_EXT) 79 | #define CODE_LOCATION_OTP 0 80 | #define CODE_LOCATION_EXT 1 81 | #else 82 | #error "One of CFG_CODE_LOCATION_OTP and CFG_CODE_LOCATION_EXT must be defined!" 83 | #endif 84 | 85 | /* These defines are specific to DA14531, do not alter. */ 86 | #define SRAM_BASE_ADDR 0x07fc0000 87 | 88 | #define BOOT_VECTOR_AREA_SZ 0xC0 89 | #define PATCH_TABLE_AREA_SZ 0x50 90 | 91 | /* OTP memory size = 32K*/ 92 | #define OTP_MEM_SIZE (32 * 1024) 93 | 94 | /* OTP header section size = 64 bytes*/ 95 | #define OTP_HEADER_SIZE (64) 96 | 97 | /* OTP CS section size = 240 bytes*/ 98 | #define OTP_CS_SIZE (240) 99 | 100 | /* Useful OTP memory size*/ 101 | #define OTP_MEM_USEFUL_SIZE (OTP_MEM_SIZE - OTP_HEADER_SIZE - OTP_CS_SIZE) 102 | 103 | /* Base address of code (RAM base address + interrupt vector table size + patch table size)*/ 104 | #define CODE_AREA_BASE (SRAM_BASE_ADDR + BOOT_VECTOR_AREA_SZ + PATCH_TABLE_AREA_SZ) 105 | 106 | /* Max needs in RAM per application - excluding the retained data, the interrupt vector table and the patch table*/ 107 | #define CODE_AREA_MAX_SIZE (RET_MEM_BASE_ADDR - CODE_AREA_BASE) 108 | 109 | #if CODE_LOCATION_OTP 110 | #define CODE_AREA_SIZE (OTP_MEM_USEFUL_SIZE - (BOOT_VECTOR_AREA_SZ + PATCH_TABLE_AREA_SZ)) 111 | #elif CODE_LOCATION_EXT 112 | #define CODE_AREA_SIZE CODE_AREA_MAX_SIZE 113 | #endif 114 | 115 | 116 | MEMORY 117 | { 118 | LR_IROM1 (rwx) : ORIGIN = SRAM_BASE_ADDR, LENGTH = BOOT_VECTOR_AREA_SZ 119 | LR_IROM2 (rwx) : ORIGIN = SRAM_BASE_ADDR + BOOT_VECTOR_AREA_SZ, LENGTH = PATCH_TABLE_AREA_SZ 120 | LR_IROM3 (rwx) : ORIGIN = CODE_AREA_BASE, LENGTH = CODE_AREA_SIZE 121 | LR_RETAINED_RAM0 (rw) : ORIGIN = RET_MEM_BASE_ADDR, LENGTH = RET_MEM_SIZE 122 | /* After this there's only BLE Exchange Memory, externally defined by the __SCT_BLE_BASE address and with custom zeroing code in arch_rom.c */ 123 | 124 | /* Free area to be used by the application (change attribute to rw if used) */ 125 | LR_FREE (r) : ORIGIN = FREE_AREA_BASE_ADDR, LENGTH = FREE_AREA_SIZE 126 | /* Fixed area used by TRNG */ 127 | LR_RETAINED_TRNG_STATE (rw) : ORIGIN = TRNG_STATE_BASE_ADDR, LENGTH = RET_DATA_UNINIT_TRNG_STATE_SIZE 128 | /* Fixed area used by CHACHA20 */ 129 | LR_RETAINED_CHACHA_STATE (rw) : ORIGIN = CHACHA_STATE_BASE_ADDR, LENGTH = RET_DATA_UNINIT_CHACHA_STATE_SIZE 130 | } -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(${DEVICE_NAME} LANGUAGES C CXX ASM) 4 | 5 | set(CMAKE_VERBOSE_MAKEFILE ON) 6 | 7 | # Include Dialog SDK 8 | include(${CMAKE_SOURCE_DIR}/gcc/dialog-sdk.cmake) 9 | 10 | # Print include directories 11 | function(print_include_directories) 12 | message(STATUS "Include directories: ") 13 | get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) 14 | foreach(dir ${dirs}) 15 | message(STATUS "${dir}") 16 | endforeach() 17 | endfunction(print_include_directories) 18 | 19 | add_executable(${PROJECT_NAME} 20 | ${DIALOG_SDK_SOURCES} 21 | # Libraries 22 | Libraries/RTT/SEGGER_RTT.c 23 | Libraries/RTT/SEGGER_RTT_printf.c 24 | # Components 25 | components/debug/src/debug.c 26 | # Source 27 | src/user_custs_config.c 28 | src/user_custs1_def.c 29 | src/user_periph_setup.c 30 | src/printf_gcc.c 31 | src/interrupts.c 32 | src/user_app.c 33 | src/ble_handlers.c 34 | src/user_app.c 35 | ) 36 | 37 | set(GLOBAL_DEBUG_OPTIONS -mthumb -mcpu=cortex-m0plus -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -flto -Wall -Werror -g3) 38 | 39 | target_compile_definitions(${PROJECT_NAME} PRIVATE 40 | $<$:__DA14531__> 41 | $<$:GPIO_DRV_PIN_ALLOC_MON_DISABLED> 42 | -DDEBUG_SEGGER 43 | ) 44 | 45 | target_compile_options(${PROJECT_NAME} PRIVATE 46 | # C, C++, Assembly 47 | $<$:${GLOBAL_DEBUG_OPTIONS}> 48 | # C, C++ 49 | $<$:-include${CMAKE_SOURCE_DIR}/components/config/inc/da1458x_config_basic.h> 50 | $<$:-include${CMAKE_SOURCE_DIR}/components/config/inc/da1458x_config_advanced.h> 51 | $<$:-include${CMAKE_SOURCE_DIR}/components/config/inc/user_config.h> 52 | # C only 53 | $<$:-std=gnu11> 54 | $<$:-Wno-int-conversion> 55 | $<$:-Wno-unused-variable> 56 | $<$:-Wno-address> 57 | # -fstrict-volatile-bitfields 58 | # -Werror 59 | # -Wextra 60 | # -Wcast-align 61 | # -Wconversion 62 | # -Wsign-conversion 63 | # -Wshadow 64 | # -Wlogical-op 65 | # -Wsuggest-final-types 66 | # -Wsuggest-final-methods 67 | # -pedantic 68 | # -Wno-expansion-to-defined 69 | # -Wno-unused-parameter 70 | # -Wno-shadow 71 | # -Wno-sign-compare 72 | # C++ only 73 | $<$:-std=c++11> 74 | $<$:-fms-extensions> 75 | $<$:-fno-exceptions> 76 | $<$:-fno-rtti> 77 | $<$:-fno-use-cxa-atexit> 78 | $<$:-fno-threadsafe-statics> 79 | $<$:-Wold-style-cast> 80 | $<$:-Wsuggest-override> 81 | # Assembly 82 | $<$:-xassembler-with-cpp> 83 | ) 84 | 85 | set(USER_INCLUDES 86 | ${CMAKE_SOURCE_DIR}/include 87 | ${CMAKE_SOURCE_DIR}/components/config/inc 88 | ${CMAKE_SOURCE_DIR}/components/debug/inc 89 | ${CMAKE_SOURCE_DIR}/Libraries/RTT 90 | # GCC includes 91 | # ${GCC_TOOLCHAIN_PATH}/arm-none-eabi/include/ 92 | ) 93 | 94 | target_include_directories(${PROJECT_NAME} PRIVATE 95 | $<$:${DIALOG_SDK_INCLUDES}> 96 | $<$:${USER_INCLUDES}> 97 | ) 98 | 99 | # Linker file needs to be preprocessed 100 | set(LINKER_SCRIPT_IN "${PROJECT_SOURCE_DIR}/gcc/ldscript_DA14531.lds.S") 101 | set(LINKER_SCRIPT_OUT "ldscript.lds") 102 | 103 | # Linker script includes 104 | set(LINKER_SCRIPT_INCLUDES 105 | -I ${CMAKE_SOURCE_DIR}/components/config/inc 106 | -I ${PROJECT_SOURCE_DIR}/gcc/ 107 | -I ${DIALOG_SDK_PATH}/sdk/common_project_files 108 | ) 109 | 110 | link_directories( 111 | ${CMAKE_SOURCE_DIR}/gcc 112 | ) 113 | 114 | function(generate_linker_script target_name linker_script_includes linker_script_defs linker_script_input linker_script_output) 115 | # Check the input file 116 | if(NOT EXISTS ${linker_script_input}) 117 | message(FATAL_ERROR "Linker input file not found.") 118 | else() 119 | message(STATUS "Found linker input file: ${linker_script_input}") 120 | endif() 121 | 122 | add_custom_command(OUTPUT ${linker_script_output} 123 | COMMAND ${CMAKE_C_COMPILER} ${linker_script_includes} ${linker_script_defs} -E -P -c ${linker_script_input} -o ${linker_script_output} 124 | DEPENDS ${linker_script_input} 125 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 126 | COMMENT "Generating linker script: ${linker_script_output}" 127 | VERBATIM) 128 | 129 | add_custom_target(linkerscript DEPENDS ${linker_script_output} VERBATIM) 130 | 131 | # Add linker preprocessed file as dependency 132 | add_dependencies(${target_name} linkerscript) 133 | # Add dependency on linker input file 134 | set_target_properties(${target_name} PROPERTIES LINK_DEPENDS ${linker_script_input}) 135 | endfunction(generate_linker_script) 136 | 137 | generate_linker_script(${PROJECT_NAME} "${LINKER_SCRIPT_INCLUDES}" "-D__DA14531__" "${LINKER_SCRIPT_IN}" "${LINKER_SCRIPT_OUT}") 138 | 139 | target_link_directories(${PROJECT_NAME} PRIVATE 140 | ${DIALOG_SDK_PATH}/sdk/gcc 141 | ${DIALOG_SDK_PATH}/sdk/platform/system_library/output/Keil_5/ 142 | ${DIALOG_SDK_PATH}/sdk/common_project_files/scatterfiles/ 143 | ${DIALOG_SDK_PATH}/sdk/common_project_files/misc/ 144 | ) 145 | 146 | target_link_libraries(${PROJECT_NAME} PRIVATE 147 | :da14531.lib 148 | ) 149 | 150 | target_link_options(${PROJECT_NAME} PRIVATE 151 | ${GLOBAL_DEBUG_OPTIONS} 152 | "-T${LINKER_SCRIPT_OUT}" 153 | "-Xlinker" 154 | "--gc-sections" 155 | "--specs=nano.specs" 156 | "--specs=nosys.specs" 157 | "-v" 158 | "-Wl,--no-wchar-size-warning" # Suppress the warning from linking Dialog's system library 159 | "-Wl,-Map,${PROJECT_NAME}.map" # Produce map file 160 | ) 161 | 162 | # Post build actions 163 | 164 | add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD 165 | COMMAND ${CMAKE_SIZE} --format=berkeley "$" 166 | COMMENT "Print output application size" 167 | ) 168 | 169 | add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD 170 | COMMAND ${CMAKE_OBJCOPY} -Oihex "$" ${PROJECT_NAME}.hex 171 | COMMENT "Convert output to hex" 172 | ) 173 | 174 | add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD 175 | COMMAND ${CMAKE_OBJCOPY} -Obinary "$" ${PROJECT_NAME}.bin 176 | COMMENT "Convert output to binary" 177 | ) 178 | -------------------------------------------------------------------------------- /Libraries/RTT/SEGGER_SYSVIEW_Config_CM0.c: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * SEGGER Microcontroller GmbH * 3 | * The Embedded Experts * 4 | ********************************************************************** 5 | * * 6 | * (c) 1995 - 2019 SEGGER Microcontroller GmbH * 7 | * * 8 | * www.segger.com Support: support@segger.com * 9 | * * 10 | ********************************************************************** 11 | * * 12 | * SEGGER SystemView * Real-time application analysis * 13 | * * 14 | ********************************************************************** 15 | * * 16 | * All rights reserved. * 17 | * * 18 | * SEGGER strongly recommends to not make any changes * 19 | * to or modify the source code of this software in order to stay * 20 | * compatible with the SystemView and RTT protocol, and J-Link. * 21 | * * 22 | * Redistribution and use in source and binary forms, with or * 23 | * without modification, are permitted provided that the following * 24 | * condition is met: * 25 | * * 26 | * o Redistributions of source code must retain the above copyright * 27 | * notice, this condition and the following disclaimer. * 28 | * * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 30 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * 31 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * 32 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * 33 | * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * 34 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * 36 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * 37 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 38 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * 40 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 41 | * DAMAGE. * 42 | * * 43 | ********************************************************************** 44 | * * 45 | * SystemView version: 3.20 * 46 | * * 47 | ********************************************************************** 48 | -------------------------- END-OF-HEADER ----------------------------- 49 | 50 | File : SEGGER_SYSVIEW_Config_NoOS.c 51 | Purpose : Sample setup configuration of SystemView without an OS for Cortex-M0. 52 | Revision: $Rev: 18540 $ 53 | */ 54 | #include "SEGGER_SYSVIEW.h" 55 | #include "SEGGER_SYSVIEW_Conf.h" 56 | 57 | #include 58 | #include 59 | 60 | // SystemCoreClock can be used in most CMSIS compatible projects. 61 | // In non-CMSIS projects define SYSVIEW_CPU_FREQ. 62 | extern uint32_t SystemCoreClock; 63 | extern uint32_t SEGGER_SYSVIEW_TickCnt; 64 | 65 | // Frequency of the timestamp. Must match SEGGER_SYSVIEW_Conf.h 66 | #define SYSVIEW_TIMESTAMP_FREQ (SystemCoreClock) 67 | 68 | // System Frequency. SystemcoreClock is used in most CMSIS compatible projects. 69 | #define SYSVIEW_CPU_FREQ (SystemCoreClock) 70 | 71 | // The lowest RAM address used for IDs (pointers) 72 | #define SYSVIEW_RAM_BASE (0x10000000) 73 | 74 | /********************************************************************* 75 | * 76 | * _cbSendSystemDesc() 77 | * 78 | * Function description 79 | * Sends SystemView description strings. 80 | */ 81 | static void _cbSendSystemDesc(void) 82 | { 83 | SEGGER_SYSVIEW_SendSysDesc("N=" SEGGER_SYSVIEW_APP_NAME ",D=" SEGGER_SYSVIEW_DEVICE_NAME); 84 | SEGGER_SYSVIEW_SendSysDesc("I#15=SysTick,I#16=BLE_WAKEUP_LP,I#17=rwble_isr,I#18=UART,I#19=UART2,I#20=I2C,I#21=SPI,I#22=ADC,I#23=KEYBRD,I#24=BLE_RF_DIAG,I#25=RFCAL,I#26=GPIO0,I#27=GPIO1,I#28=GPIO2,I#29=GPIO3,I#30=GPIO4,I#31=SWTIM,I#32=WKUP_QUADEC,I#33=SWTIM1,I#34=RTC,I#35=DMA,I#36=XTAL32M_RDY"); 85 | } 86 | 87 | /********************************************************************* 88 | * 89 | * Global functions 90 | * 91 | ********************************************************************** 92 | */ 93 | void SEGGER_SYSVIEW_Conf(void) 94 | { 95 | systick_start(0x01000000, 0); 96 | SEGGER_SYSVIEW_Init(1000000, SYSVIEW_CPU_FREQ, 0, _cbSendSystemDesc); 97 | SEGGER_SYSVIEW_SetRAMBase(SYSVIEW_RAM_BASE); 98 | } 99 | 100 | /********************************************************************* 101 | * 102 | * SEGGER_SYSVIEW_X_GetTimestamp() 103 | * 104 | * Function description 105 | * Returns the current timestamp in ticks using the system tick 106 | * count and the SysTick counter. 107 | * All parameters of the SysTick have to be known and are set via 108 | * configuration defines on top of the file. 109 | * 110 | * Return value 111 | * The current timestamp. 112 | * 113 | * Additional information 114 | * SEGGER_SYSVIEW_X_GetTimestamp is always called when interrupts are 115 | * disabled. Therefore locking here is not required. 116 | */ 117 | U32 SEGGER_SYSVIEW_X_GetTimestamp(void) 118 | { 119 | U32 tickCount; 120 | U32 cycles; 121 | U32 cyclesPerTick; 122 | 123 | /* Handle SysTick value, SysTick is down-counting. */ 124 | cyclesPerTick = SysTick->LOAD + 1; 125 | cycles = (cyclesPerTick - SysTick->VAL); 126 | 127 | /* Load system tick count. */ 128 | tickCount = SEGGER_SYSVIEW_TickCnt; 129 | 130 | /* Handle systick overflow, if the bit is set it will clear automatically on register read. */ 131 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0) 132 | { 133 | /* Increase saved tick on overflow. */ 134 | ++SEGGER_SYSVIEW_TickCnt; 135 | /* Refresh tick count. */ 136 | ++tickCount; 137 | } 138 | 139 | /* Adjust cycles for past ticks. */ 140 | cycles += tickCount * cyclesPerTick; 141 | 142 | return cycles; 143 | } 144 | 145 | /********************************************************************* 146 | * 147 | * SEGGER_SYSVIEW_X_GetInterruptId() 148 | * 149 | * Function description 150 | * Return the currently active interrupt Id, 151 | * which ist the active vector taken from IPSR[5:0]. 152 | * 153 | * Return value 154 | * The current currently active interrupt Id. 155 | * 156 | * Additional information 157 | * This function is not used by default, as the active vector can be 158 | * read from ICSR instead on Cortex-M0. 159 | * For Cortex-M0+ devices, change SEGGER_SYSVIEW_GET_INTERRUPT_ID 160 | * in SEGGER_SYSVIEW_Conf.h to call this function instead. 161 | */ 162 | U32 SEGGER_SYSVIEW_X_GetInterruptId(void) 163 | { 164 | U32 Id = __get_IPSR(); 165 | Id &= 0x3F; 166 | 167 | return Id; 168 | } 169 | -------------------------------------------------------------------------------- /components/config/inc/da1458x_config_basic.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file da1458x_config_basic.h 5 | * 6 | * @brief Basic compile configuration file. 7 | * 8 | * Copyright (c) 2015-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | #ifndef _DA1458X_CONFIG_BASIC_H_ 34 | #define _DA1458X_CONFIG_BASIC_H_ 35 | 36 | #include "da1458x_stack_config.h" 37 | #include "user_profiles_config.h" 38 | 39 | /***************************************************************************************************************/ 40 | /* Integrated or external processor configuration */ 41 | /* -defined Integrated processor mode. Host application runs in DA14585 processor. Host application */ 42 | /* is the TASK_APP kernel task. */ 43 | /* -undefined External processor mode. Host application runs on an external processor. Communicates with */ 44 | /* BLE application through GTL protocol over a signalling iface (UART, SPI etc) */ 45 | /***************************************************************************************************************/ 46 | #define CFG_APP 47 | 48 | /****************************************************************************************************************/ 49 | /* Enables the BLE security functionality in TASK_APP. If not defined BLE security related code is compiled out.*/ 50 | /****************************************************************************************************************/ 51 | #define CFG_APP_SECURITY 52 | 53 | /****************************************************************************************************************/ 54 | /* Enables WatchDog timer. */ 55 | /****************************************************************************************************************/ 56 | #define CFG_WDOG 57 | 58 | /****************************************************************************************************************/ 59 | /* Determines maximum concurrent connections supported by application. It configures the heap memory allocated */ 60 | /* to service multiple connections. It is used for GAP central role applications. For GAP peripheral role it */ 61 | /* should be set to 1 for optimizing memory utilization. */ 62 | /* - MAX value for DA14531: 3 */ 63 | /****************************************************************************************************************/ 64 | #define CFG_MAX_CONNECTIONS (1) 65 | 66 | /****************************************************************************************************************/ 67 | /* Enables development/debug mode. For production mode builds it must be disabled. */ 68 | /* When enabled the following debugging features are enabled */ 69 | /* - Allows the emulation of the OTP mirroring to System RAM. No actual writing to RAM is done, but the */ 70 | /* exact same amount of time is spend as if the mirroring would take place. This is to mimic the */ 71 | /* behavior as if the System Code is already in OTP, and the mirroring takes place after waking up, */ 72 | /* but the (development) code still resides in an external source. */ 73 | /* - Validation of GPIO reservations. */ 74 | /* - Enables Debug module and sets code execution in breakpoint in Hardfault and NMI (Watchdog) handlers.*/ 75 | /* It allows developer to hot attach debugger and get debug information */ 76 | /****************************************************************************************************************/ 77 | #define CFG_DEVELOPMENT_DEBUG 78 | 79 | /****************************************************************************************************************/ 80 | /* UART Console Print. If CFG_PRINTF is defined, serial interface logging mechanism will be enabled. */ 81 | /* If CFG_PRINTF_UART2 is defined, then serial interface logging mechanism is implented using UART2, else UART1 */ 82 | /* will be used. */ 83 | /****************************************************************************************************************/ 84 | #undef CFG_PRINTF /* Do not use UART console. */ 85 | 86 | /****************************************************************************************************************/ 87 | /* UART1 Driver Implementation. If CFG_UART1_SDK is defined, UART1 ROM driver will be overriden and UART SDK */ 88 | /* driver will be used, else ROM driver will be used for UART1 module. */ 89 | /****************************************************************************************************************/ 90 | #undef CFG_UART1_SDK 91 | 92 | /****************************************************************************************************************/ 93 | /* Select external memory device for data storage */ 94 | /* SPI FLASH (#define CFG_SPI_FLASH_ENABLE) */ 95 | /* I2C EEPROM (#define CFG_I2C_EEPROM_ENABLE) */ 96 | /****************************************************************************************************************/ 97 | #undef CFG_SPI_FLASH_ENABLE 98 | #undef CFG_I2C_EEPROM_ENABLE 99 | 100 | /****************************************************************************************************************/ 101 | /* Enables/Disables the DMA Support for the following interfaces: */ 102 | /* - UART */ 103 | /* - SPI */ 104 | /* - I2C */ 105 | /* - ADC */ 106 | /****************************************************************************************************************/ 107 | #undef CFG_UART_DMA_SUPPORT 108 | #undef CFG_SPI_DMA_SUPPORT 109 | #undef CFG_I2C_DMA_SUPPORT 110 | #undef CFG_ADC_DMA_SUPPORT 111 | 112 | /****************************************************************************************************************/ 113 | /* Notify the SDK about the fixed power mode (currently used only for Bypass): */ 114 | /* - CFG_POWER_MODE_BYPASS = Bypass mode */ 115 | /****************************************************************************************************************/ 116 | #undef CFG_POWER_MODE_BYPASS 117 | 118 | #endif // _DA1458X_CONFIG_BASIC_H_ 119 | -------------------------------------------------------------------------------- /gcc/ldscript_DA14531.lds.S: -------------------------------------------------------------------------------- 1 | /* 2 | **************************************************************************************** 3 | * 4 | * @file ldscript_DA14531.lds.S 5 | * 6 | * @brief Common GNU LD linker script file. 7 | * 8 | * Copyright (C) 2018-2020 Dialog Semiconductor. 9 | * This computer program includes Confidential, Proprietary Information 10 | * of Dialog Semiconductor. All Rights Reserved. 11 | * 12 | **************************************************************************************** 13 | */ 14 | 15 | #include "da1458x_config_basic.h" 16 | #include "da1458x_config_advanced.h" 17 | #include "da1458x_scatter_config.h" 18 | 19 | #include "mem_DA14531.lds" 20 | 21 | #if defined(ENV_HEAP_SZ) 22 | ASSERT(ENV_HEAP_SZ >= __SCT_AUTO_HEAP_ENV_SIZE, "Configured ENV_HEAP_SZ is lower than __SCT_AUTO_HEAP_ENV_SIZE") 23 | #endif 24 | 25 | #if defined(DB_HEAP_SZ) 26 | ASSERT(DB_HEAP_SZ >= __SCT_AUTO_HEAP_DB_SIZE, "Configured DB_HEAP_SZ is lower than __SCT_AUTO_HEAP_DB_SIZE") 27 | #endif 28 | 29 | #if defined(MSG_HEAP_SZ) 30 | ASSERT(MSG_HEAP_SZ >= __SCT_AUTO_HEAP_MSG_SIZE, "Configured MSG_HEAP_SZ is lower than __SCT_AUTO_HEAP_MSG_SIZE") 31 | #endif 32 | 33 | __ER_IROM3_BASE__ = ORIGIN(LR_IROM3); 34 | __ER_IROM3_LENGTH__ = LENGTH(LR_IROM3); 35 | 36 | /* Set the entry instruction */ 37 | ENTRY(Reset_Handler) 38 | 39 | /* Sections layout */ 40 | SECTIONS 41 | { 42 | /* Reset vector at the beginning of RAM */ 43 | ER_IROM1 : 44 | { 45 | KEEP(*(.vectors)) 46 | KEEP(*(.otp_cs_booter)) 47 | 48 | . = BOOT_VECTOR_AREA_SZ; 49 | } > LR_IROM1 50 | 51 | ER_IROM2 : 52 | { 53 | KEEP(*(.patch_table)) 54 | . = PATCH_TABLE_AREA_SZ; 55 | } > LR_IROM2 56 | 57 | ER_IROM3 : 58 | { 59 | /* Move ISR implementations after patch_table */ 60 | KEEP(*(.isr_impl)) 61 | KEEP(*(.text.disp_heaplog)) 62 | *(.text*) 63 | 64 | . = ALIGN(4); 65 | 66 | KEEP(*(.init)) 67 | KEEP(*(.fini)) 68 | *(.rodata*) 69 | } > LR_IROM3 70 | 71 | .ARM.extab : 72 | { 73 | *(.ARM.extab* .gnu.linkonce.armextab.*) 74 | } > LR_IROM3 75 | 76 | __exidx_start = .; 77 | .ARM.exidx : 78 | { 79 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 80 | } > LR_IROM3 81 | __exidx_end = .; 82 | 83 | /* To copy multiple ROM to RAM sections, 84 | * define __STARTUP_COPY_MULTIPLE in startup_DA14531.S 85 | */ 86 | .copy.table : 87 | { 88 | . = ALIGN(4); 89 | __copy_table_start__ = .; 90 | LONG (__etext) 91 | LONG (__data_start__) 92 | LONG (__data_end__ - __data_start__) 93 | __copy_table_end__ = .; 94 | } > LR_IROM3 95 | 96 | /* To clear multiple BSS sections, 97 | * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_DA14531.S 98 | */ 99 | .zero.table : 100 | { 101 | . = ALIGN(4); 102 | __zero_table_start__ = .; 103 | LONG (__bss_start__) 104 | LONG (__bss_end__ - __bss_start__) 105 | 106 | LONG (__ret_data_start__) 107 | LONG (__ret_data_end__ - __ret_data_start__) 108 | 109 | __zero_table_end__ = .; 110 | } > LR_IROM3 111 | 112 | 113 | /* Location counter can end up 2byte aligned with narrow Thumb code but 114 | * __etext is assumed by startup code to be the LMA of a section in RAM 115 | * which must be 4byte aligned 116 | */ 117 | __etext = ALIGN(4); 118 | 119 | /* The initialised data section is stored immediately 120 | * at the end of the text section. 121 | */ 122 | .data : AT (__etext) 123 | { 124 | __data_start__ = .; 125 | *(vtable) 126 | *(.data*) 127 | 128 | . = ALIGN(4); 129 | /* preinit data */ 130 | PROVIDE_HIDDEN (__preinit_array_start = .); 131 | KEEP(*(.preinit_array)) 132 | PROVIDE_HIDDEN (__preinit_array_end = .); 133 | 134 | . = ALIGN(4); 135 | /* init data */ 136 | PROVIDE_HIDDEN (__init_array_start = .); 137 | KEEP(*(SORT(.init_array.*))) 138 | KEEP(*(.init_array)) 139 | PROVIDE_HIDDEN (__init_array_end = .); 140 | 141 | . = ALIGN(4); 142 | /* finit data */ 143 | PROVIDE_HIDDEN (__fini_array_start = .); 144 | KEEP(*(SORT(.fini_array.*))) 145 | KEEP(*(.fini_array)) 146 | PROVIDE_HIDDEN (__fini_array_end = .); 147 | 148 | KEEP(*(.jcr*)) 149 | . = ALIGN(4); 150 | /* All data end */ 151 | __data_end__ = .; 152 | } > LR_IROM3 153 | 154 | __code_area_end__ = .; 155 | 156 | .bss : 157 | { 158 | . = ALIGN(4); 159 | __bss_start__ = .; 160 | *(.bss*) 161 | *(COMMON) 162 | . = ALIGN(4); 163 | __bss_end__ = .; 164 | } > LR_IROM3 165 | 166 | ER_PRODTEST (NOLOAD): 167 | { 168 | . = ALIGN(4); 169 | *(prodtest_uninit) 170 | } > LR_IROM3 171 | 172 | ER_NZI (NOLOAD) : 173 | { 174 | . = ALIGN(4); 175 | __heap_mem_area_not_ret_start__ = .; 176 | *jump_table.o(heap_mem_area_not_ret) /* not retained HEAP */ 177 | __heap_mem_area_not_ret_end__ = .; 178 | } > LR_IROM3 179 | 180 | /* After the zero-init sections goes the non retained heap and stack */ 181 | .heap (NOLOAD): 182 | { 183 | __end__ = .; 184 | PROVIDE(end = .); 185 | *(.heap*) 186 | __HeapLimit = .; 187 | } > LR_IROM3 188 | 189 | /* .stack_dummy section does not contains any symbols. It is only 190 | * used for linker to calculate size of stack sections, and assign 191 | * values to stack symbols later. 192 | * COPY type does not allocate memory. 193 | */ 194 | .stack_dummy (COPY): 195 | { 196 | KEEP(*(.stack*)) 197 | } > LR_IROM3 198 | 199 | /* Execution region needed for stateful hibernation. */ 200 | ER_STATEFUL_HIBERNATION (NOLOAD) : 201 | { 202 | KEEP(*(.stateful_hibernation)) 203 | } > LR_IROM3 204 | 205 | /* Set stack top to end of LR_IROM3 before the retained section, 206 | * and stack limit moves down by size of stack_dummy section. 207 | */ 208 | __StackTop = ORIGIN(LR_IROM3) + LENGTH(LR_IROM3); 209 | __StackLimit = __StackTop - SIZEOF(.stack_dummy); 210 | PROVIDE(__stack = __StackTop); 211 | 212 | /* Check if data + heap + stack exceeds RAM limit */ 213 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") 214 | 215 | /* Exact address placement to force first section in LR_RETAINED_RAM0 alignment to single word boundary. 216 | * By default linker aligns it in two-word boundary even when LR_RETAINED_RAM0 starts at a word boundary. 217 | */ 218 | RET_DATA_UNINIT RET_MEM_BASE_ADDR (NOLOAD) : 219 | { 220 | . = ALIGN(4); 221 | __retention_mem_area_uninit_start__ = .; 222 | *(retention_mem_area_uninit) /* uninitialized application data */ 223 | . = ALIGN(4); 224 | __retention_mem_area_uninit_end__ = .; 225 | } > LR_RETAINED_RAM0 226 | 227 | RET_DATA (NOLOAD) : 228 | { 229 | __ret_data_start__ = .; 230 | . = ALIGN(4); 231 | *(retention_mem_area0) /* zero initialized SDK + application data */ 232 | . = ALIGN(4); 233 | __ret_data_end__ = .; 234 | } > LR_RETAINED_RAM0 235 | /********************************************************************************************* 236 | * Check if the user selected retained data (the zero initialized) size fits in the RET_DATA 237 | * executon region. 238 | * If the check fails, then the CFG_RET_DATA_SIZE value must be increased accordingly. 239 | * Note: If the selected size is equal to the value calculated by the linker, then the check 240 | * can be omitted. 241 | *********************************************************************************************/ 242 | ASSERT(CFG_RET_DATA_SIZE > SIZEOF(RET_DATA), "CFG_RET_DATA_SIZE value must be increased.") 243 | 244 | RET_HEAP (NOLOAD): 245 | { 246 | . = ALIGN(4); 247 | *jump_table.o(heap_env_area) 248 | __db_heap_start__ = .; 249 | *jump_table.o(heap_db_area) 250 | __db_heap_end__ = .; 251 | *jump_table.o(heap_msg_area) 252 | } > LR_RETAINED_RAM0 253 | 254 | #if defined (CFG_TRNG) 255 | RET_DATA_UNINIT_TRNG_STATE (NOLOAD) : 256 | { 257 | *trng.o(trng_state) /* flag to decide if TRNG must run or not in order to generate the seed number */ 258 | } > LR_RETAINED_TRNG_STATE 259 | #endif /* defined (CFG_TRNG) */ 260 | 261 | #if defined (CFG_USE_CHACHA20_RAND) 262 | RET_DATA_UNINIT_CHACHA_STATE (NOLOAD) : 263 | { 264 | *chacha20.o (chacha20_state) /* random state in case chacha20 is used */ 265 | } > LR_RETAINED_CHACHA_STATE 266 | #endif /* defined (CFG_USE_CHACHA20_RAND) */ 267 | } 268 | 269 | /* Include ROM symbol definitions */ 270 | INCLUDE da14531_symbols.lds 271 | -------------------------------------------------------------------------------- /components/config/inc/user_callback_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_callback_config.h 5 | * 6 | * @brief Callback functions configuration file. 7 | * 8 | * Copyright (c) 2015-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | #ifndef _USER_CALLBACK_CONFIG_H_ 34 | #define _USER_CALLBACK_CONFIG_H_ 35 | 36 | /* 37 | * INCLUDE FILES 38 | **************************************************************************************** 39 | */ 40 | 41 | #include "app_api.h" 42 | #include "app_bass.h" 43 | #include "app_findme.h" 44 | #include "app_proxr.h" 45 | #include "app_suotar.h" 46 | #include "app_callback.h" 47 | #include "app_prf_types.h" 48 | #if (BLE_APP_SEC) 49 | #include "app_bond_db.h" 50 | #endif // (BLE_APP_SEC) 51 | 52 | #include 53 | #include 54 | 55 | /* 56 | * FUNCTION DECLARATIONS 57 | **************************************************************************************** 58 | */ 59 | 60 | /** 61 | **************************************************************************************** 62 | * @brief Function to be called on the advertising completion event. 63 | * @param[in] uint8_t GAP Error code 64 | * @return void 65 | **************************************************************************************** 66 | */ 67 | void app_advertise_complete(const uint8_t); 68 | 69 | /** 70 | **************************************************************************************** 71 | * @brief SUOTAR session start or stop event handler. 72 | * @param[in] suotar_event SUOTAR_START/SUOTAR_STOP 73 | * @return void 74 | **************************************************************************************** 75 | */ 76 | void on_suotar_status_change(const uint8_t suotar_event); 77 | 78 | 79 | /* 80 | * LOCAL VARIABLE DEFINITIONS 81 | **************************************************************************************** 82 | */ 83 | 84 | #if (BLE_BATT_SERVER) 85 | static const struct app_bass_cb user_app_bass_cb = { 86 | .on_batt_level_upd_rsp = NULL, 87 | .on_batt_level_ntf_cfg_ind = NULL, 88 | }; 89 | #endif 90 | 91 | #if (BLE_FINDME_TARGET) 92 | static const struct app_findt_cb user_app_findt_cb = { 93 | .on_findt_alert_ind = default_findt_alert_ind_handler, 94 | }; 95 | #endif 96 | 97 | #if (BLE_PROX_REPORTER) 98 | static const struct app_proxr_cb user_app_proxr_cb = { 99 | .on_proxr_alert_ind = default_proxr_alert_ind_handler, 100 | }; 101 | #endif 102 | 103 | #if (BLE_SUOTA_RECEIVER) 104 | static const struct app_suotar_cb user_app_suotar_cb = { 105 | .on_suotar_status_change = on_suotar_status_change, 106 | }; 107 | #endif 108 | 109 | static const struct app_callbacks user_app_callbacks = { 110 | .app_on_connection = user_on_connection, 111 | .app_on_disconnect = user_on_disconnect, 112 | .app_on_update_params_rejected = NULL, 113 | .app_on_update_params_complete = NULL, 114 | .app_on_set_dev_config_complete = default_app_on_set_dev_config_complete, 115 | .app_on_adv_nonconn_complete = NULL, 116 | .app_on_adv_undirect_complete = NULL, 117 | .app_on_adv_direct_complete = NULL, 118 | .app_on_db_init_complete = default_app_on_db_init_complete, 119 | .app_on_scanning_completed = NULL, 120 | .app_on_adv_report_ind = NULL, 121 | .app_on_get_dev_name = default_app_on_get_dev_name, 122 | .app_on_get_dev_appearance = default_app_on_get_dev_appearance, 123 | .app_on_get_dev_slv_pref_params = default_app_on_get_dev_slv_pref_params, 124 | .app_on_set_dev_info = default_app_on_set_dev_info, 125 | .app_on_data_length_change = NULL, 126 | .app_on_update_params_request = default_app_update_params_request, 127 | .app_on_generate_static_random_addr = default_app_generate_static_random_addr, 128 | .app_on_svc_changed_cfg_ind = NULL, 129 | .app_on_get_peer_features = NULL, 130 | #if (BLE_APP_SEC) 131 | .app_on_pairing_request = default_app_on_pairing_request, 132 | .app_on_tk_exch = default_app_on_tk_exch, 133 | .app_on_irk_exch = NULL, 134 | .app_on_csrk_exch = NULL, 135 | .app_on_ltk_exch = default_app_on_ltk_exch, 136 | .app_on_pairing_succeeded = NULL, 137 | .app_on_encrypt_ind = NULL, 138 | .app_on_encrypt_req_ind = NULL, 139 | .app_on_security_req_ind = NULL, 140 | .app_on_addr_solved_ind = NULL, 141 | .app_on_addr_resolve_failed = NULL, 142 | .app_on_ral_cmp_evt = NULL, 143 | .app_on_ral_size_ind = NULL, 144 | .app_on_ral_addr_ind = NULL, 145 | #endif // (BLE_APP_SEC) 146 | }; 147 | 148 | #if (BLE_APP_SEC) 149 | static const struct app_bond_db_callbacks user_app_bond_db_callbacks = { 150 | .app_bdb_init = NULL, 151 | .app_bdb_get_size = NULL, 152 | .app_bdb_add_entry = NULL, 153 | .app_bdb_remove_entry = NULL, 154 | .app_bdb_search_entry = NULL, 155 | .app_bdb_get_number_of_stored_irks = NULL, 156 | .app_bdb_get_stored_irks = NULL, 157 | .app_bdb_get_device_info_from_slot = NULL, 158 | }; 159 | #endif // (BLE_APP_SEC) 160 | 161 | /* 162 | * "app_process_catch_rest_cb" symbol handling: 163 | * - Use #define if "user_catch_rest_hndl" is defined by the user 164 | * - Use const declaration if "user_catch_rest_hndl" is NULL 165 | */ 166 | #define app_process_catch_rest_cb user_catch_rest_hndl 167 | //static const catch_rest_event_func_t app_process_catch_rest_cb = NULL; 168 | 169 | static const struct default_app_operations user_default_app_operations = { 170 | .default_operation_adv = default_advertise_operation, 171 | }; 172 | 173 | static const struct arch_main_loop_callbacks user_app_main_loop_callbacks = { 174 | .app_on_init = app_on_init, 175 | 176 | // By default the watchdog timer is reloaded and resumed when the system wakes up. 177 | // The user has to take into account the watchdog timer handling (keep it running, 178 | // freeze it, reload it, resume it, etc), when the app_on_ble_powered() is being 179 | // called and may potentially affect the main loop. 180 | .app_on_ble_powered = NULL, 181 | 182 | // By default the watchdog timer is reloaded and resumed when the system wakes up. 183 | // The user has to take into account the watchdog timer handling (keep it running, 184 | // freeze it, reload it, resume it, etc), when the app_on_system_powered() is being 185 | // called and may potentially affect the main loop. 186 | .app_on_system_powered = app_on_system_powered, 187 | 188 | .app_before_sleep = NULL, 189 | .app_validate_sleep = app_validate_sleep, 190 | .app_going_to_sleep = app_going_to_sleep, 191 | .app_resume_from_sleep = app_resume_from_sleep, 192 | }; 193 | 194 | //place in this structure the app__db_create and app__enable functions 195 | //for SIG profiles that do not have this function already implemented in the SDK 196 | //or if you want to override the functionality. Check the prf_func array in the SDK 197 | //for your reference of which profiles are supported. 198 | static const struct prf_func_callbacks user_prf_funcs[] = 199 | { 200 | {TASK_ID_INVALID, NULL, NULL} // DO NOT MOVE. Must always be last 201 | }; 202 | 203 | #endif // _USER_CALLBACK_CONFIG_H_ 204 | -------------------------------------------------------------------------------- /Libraries/RTT/SEGGER.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * SEGGER Microcontroller GmbH * 3 | * The Embedded Experts * 4 | ********************************************************************** 5 | * * 6 | * (c) 1995 - 2019 SEGGER Microcontroller GmbH * 7 | * * 8 | * www.segger.com Support: support@segger.com * 9 | * * 10 | ********************************************************************** 11 | * * 12 | * SEGGER SystemView * Real-time application analysis * 13 | * * 14 | ********************************************************************** 15 | * * 16 | * All rights reserved. * 17 | * * 18 | * SEGGER strongly recommends to not make any changes * 19 | * to or modify the source code of this software in order to stay * 20 | * compatible with the SystemView and RTT protocol, and J-Link. * 21 | * * 22 | * Redistribution and use in source and binary forms, with or * 23 | * without modification, are permitted provided that the following * 24 | * condition is met: * 25 | * * 26 | * o Redistributions of source code must retain the above copyright * 27 | * notice, this condition and the following disclaimer. * 28 | * * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 30 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * 31 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * 32 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * 33 | * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * 34 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * 36 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * 37 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 38 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * 40 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 41 | * DAMAGE. * 42 | * * 43 | ********************************************************************** 44 | * * 45 | * SystemView version: 3.20 * 46 | * * 47 | ********************************************************************** 48 | ---------------------------------------------------------------------- 49 | File : SEGGER.h 50 | Purpose : Global types etc & general purpose utility functions 51 | Revision: $Rev: 18102 $ 52 | ---------------------------END-OF-HEADER------------------------------ 53 | */ 54 | 55 | #ifndef SEGGER_H // Guard against multiple inclusion 56 | #define SEGGER_H 57 | 58 | #include // For va_list. 59 | #include "SEGGER_types.h" // Type definitions: U8, U16, U32, I8, I16, I32 60 | 61 | #if defined(__cplusplus) 62 | extern "C" { /* Make sure we have C-declarations in C++ programs */ 63 | #endif 64 | 65 | /********************************************************************* 66 | * 67 | * Keywords/specifiers 68 | * 69 | ********************************************************************** 70 | */ 71 | 72 | #ifndef INLINE 73 | #if (defined(__ICCARM__) || defined(__RX) || defined(__ICCRX__)) 74 | // 75 | // Other known compilers. 76 | // 77 | #define INLINE inline 78 | #else 79 | #if (defined(_WIN32) && !defined(__clang__)) 80 | // 81 | // Microsoft VC6 and newer. 82 | // Force inlining without cost checking. 83 | // 84 | #define INLINE __forceinline 85 | #elif defined(__GNUC__) || defined(__clang__) 86 | // 87 | // Force inlining with GCC + clang 88 | // 89 | #define INLINE inline __attribute__((always_inline)) 90 | #elif (defined(__CC_ARM)) 91 | // 92 | // Force inlining with ARMCC (Keil) 93 | // 94 | #define INLINE __inline 95 | #else 96 | // 97 | // Unknown compilers. 98 | // 99 | #define INLINE 100 | #endif 101 | #endif 102 | #endif 103 | 104 | /********************************************************************* 105 | * 106 | * Function-like macros 107 | * 108 | ********************************************************************** 109 | */ 110 | 111 | #define SEGGER_COUNTOF(a) (sizeof((a))/sizeof((a)[0])) 112 | #define SEGGER_MIN(a,b) (((a) < (b)) ? (a) : (b)) 113 | #define SEGGER_MAX(a,b) (((a) > (b)) ? (a) : (b)) 114 | 115 | #ifndef SEGGER_USE_PARA // Some compiler complain about unused parameters. 116 | #define SEGGER_USE_PARA(Para) (void)Para // This works for most compilers. 117 | #endif 118 | 119 | #define SEGGER_ADDR2PTR(Type, Addr) (/*lint -e(923) -e(9078)*/((Type*)((PTR_ADDR)(Addr)))) // Allow cast from address to pointer. 120 | #define SEGGER_PTR2ADDR(p) (/*lint -e(923) -e(9078)*/((PTR_ADDR)(p))) // Allow cast from pointer to address. 121 | #define SEGGER_PTR2PTR(Type, p) (/*lint -e(740) -e(826) -e(9079) -e(9087)*/((Type*)(p))) // Allow cast from one pointer type to another (ignore different size). 122 | #define SEGGER_PTR_DISTANCE(p0, p1) (SEGGER_PTR2ADDR(p0) - SEGGER_PTR2ADDR(p1)) 123 | 124 | /********************************************************************* 125 | * 126 | * Defines 127 | * 128 | ********************************************************************** 129 | */ 130 | 131 | #define SEGGER_PRINTF_FLAG_ADJLEFT (1 << 0) 132 | #define SEGGER_PRINTF_FLAG_SIGNFORCE (1 << 1) 133 | #define SEGGER_PRINTF_FLAG_SIGNSPACE (1 << 2) 134 | #define SEGGER_PRINTF_FLAG_PRECEED (1 << 3) 135 | #define SEGGER_PRINTF_FLAG_ZEROPAD (1 << 4) 136 | #define SEGGER_PRINTF_FLAG_NEGATIVE (1 << 5) 137 | 138 | /********************************************************************* 139 | * 140 | * Types 141 | * 142 | ********************************************************************** 143 | */ 144 | 145 | typedef struct { 146 | char* pBuffer; 147 | int BufferSize; 148 | int Cnt; 149 | } SEGGER_BUFFER_DESC; 150 | 151 | typedef struct { 152 | unsigned int CacheLineSize; // 0: No Cache. Most Systems such as ARM9 use a 32 bytes cache line size. 153 | void (*pfDMB) (void); // Optional DMB function for Data Memory Barrier to make sure all memory operations are completed. 154 | void (*pfClean) (void *p, unsigned long NumBytes); // Optional clean function for cached memory. 155 | void (*pfInvalidate)(void *p, unsigned long NumBytes); // Optional invalidate function for cached memory. 156 | } SEGGER_CACHE_CONFIG; 157 | 158 | typedef struct SEGGER_SNPRINTF_CONTEXT_struct SEGGER_SNPRINTF_CONTEXT; 159 | 160 | struct SEGGER_SNPRINTF_CONTEXT_struct { 161 | void* pContext; // Application specific context. 162 | SEGGER_BUFFER_DESC* pBufferDesc; // Buffer descriptor to use for output. 163 | void (*pfFlush)(SEGGER_SNPRINTF_CONTEXT* pContext); // Callback executed once the buffer is full. Callback decides if the buffer gets cleared to store more or not. 164 | }; 165 | 166 | typedef struct { 167 | void (*pfStoreChar) (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, char c); 168 | int (*pfPrintUnsigned) (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, U32 v, unsigned Base, char Flags, int Width, int Precision); 169 | int (*pfPrintInt) (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, I32 v, unsigned Base, char Flags, int Width, int Precision); 170 | } SEGGER_PRINTF_API; 171 | 172 | typedef void (*SEGGER_pFormatter)(SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, const SEGGER_PRINTF_API* pApi, va_list* pParamList, char Lead, int Width, int Precision); 173 | 174 | typedef struct SEGGER_PRINTF_FORMATTER { 175 | struct SEGGER_PRINTF_FORMATTER* pNext; // Pointer to next formatter. 176 | SEGGER_pFormatter pfFormatter; // Formatter function. 177 | char Specifier; // Format specifier. 178 | } SEGGER_PRINTF_FORMATTER; 179 | 180 | typedef struct { 181 | U32 (*pfGetHPTimestamp)(void); // Mandatory, pfGetHPTimestamp 182 | int (*pfGetUID) (U8 abUID[16]); // Optional, pfGetUID 183 | } SEGGER_BSP_API; 184 | 185 | /********************************************************************* 186 | * 187 | * Utility functions 188 | * 189 | ********************************************************************** 190 | */ 191 | 192 | // 193 | // Memory operations. 194 | // 195 | void SEGGER_ARM_memcpy(void* pDest, const void* pSrc, int NumBytes); 196 | void SEGGER_memcpy (void* pDest, const void* pSrc, unsigned NumBytes); 197 | void SEGGER_memxor (void* pDest, const void* pSrc, unsigned NumBytes); 198 | 199 | // 200 | // String functions. 201 | // 202 | int SEGGER_atoi (const char* s); 203 | int SEGGER_isalnum (int c); 204 | int SEGGER_isalpha (int c); 205 | unsigned SEGGER_strlen (const char* s); 206 | int SEGGER_tolower (int c); 207 | int SEGGER_strcasecmp (const char* sText1, const char* sText2); 208 | int SEGGER_strncasecmp(const char *sText1, const char *sText2, unsigned Count); 209 | 210 | // 211 | // Buffer/printf related. 212 | // 213 | void SEGGER_StoreChar (SEGGER_BUFFER_DESC* pBufferDesc, char c); 214 | void SEGGER_PrintUnsigned(SEGGER_BUFFER_DESC* pBufferDesc, U32 v, unsigned Base, int Precision); 215 | void SEGGER_PrintInt (SEGGER_BUFFER_DESC* pBufferDesc, I32 v, unsigned Base, int Precision); 216 | int SEGGER_snprintf (char* pBuffer, int BufferSize, const char* sFormat, ...); 217 | int SEGGER_vsnprintf (char* pBuffer, int BufferSize, const char* sFormat, va_list ParamList); 218 | int SEGGER_vsnprintfEx (SEGGER_SNPRINTF_CONTEXT* pContext, const char* sFormat, va_list ParamList); 219 | 220 | int SEGGER_PRINTF_AddFormatter (SEGGER_PRINTF_FORMATTER* pFormatter, SEGGER_pFormatter pfFormatter, char c); 221 | void SEGGER_PRINTF_AddDoubleFormatter (void); 222 | void SEGGER_PRINTF_AddIPFormatter (void); 223 | void SEGGER_PRINTF_AddBLUEFormatter (void); 224 | void SEGGER_PRINTF_AddCONNECTFormatter(void); 225 | void SEGGER_PRINTF_AddSSLFormatter (void); 226 | void SEGGER_PRINTF_AddSSHFormatter (void); 227 | void SEGGER_PRINTF_AddHTMLFormatter (void); 228 | 229 | // 230 | // BSP abstraction API. 231 | // 232 | int SEGGER_BSP_GetUID (U8 abUID[16]); 233 | int SEGGER_BSP_GetUID32(U32* pUID); 234 | void SEGGER_BSP_SetAPI (const SEGGER_BSP_API* pAPI); 235 | void SEGGER_BSP_SeedUID (void); 236 | 237 | // 238 | // Other API. 239 | // 240 | void SEGGER_VERSION_GetString(char acText[8], unsigned Version); 241 | 242 | #if defined(__cplusplus) 243 | } /* Make sure we have C-declarations in C++ programs */ 244 | #endif 245 | 246 | #endif // Avoid multiple inclusion 247 | 248 | /*************************** End of file ****************************/ 249 | -------------------------------------------------------------------------------- /Libraries/RTT/SEGGER_RTT_ASM_ARMv7M.S: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * (c) SEGGER Microcontroller GmbH * 3 | * The Embedded Experts * 4 | * www.segger.com * 5 | ********************************************************************** 6 | 7 | -------------------------- END-OF-HEADER ----------------------------- 8 | 9 | File : SEGGER_RTT_ASM_ARMv7M.S 10 | Purpose : Assembler implementation of RTT functions for ARMv7M 11 | 12 | Additional information: 13 | This module is written to be assembler-independent and works with 14 | GCC and clang (Embedded Studio) and IAR. 15 | */ 16 | 17 | #define SEGGER_RTT_ASM // Used to control processed input from header file 18 | #include "SEGGER_RTT.h" 19 | 20 | /********************************************************************* 21 | * 22 | * Defines, fixed 23 | * 24 | ********************************************************************** 25 | */ 26 | 27 | #define _CCIAR 0 28 | #define _CCCLANG 1 29 | 30 | #if (defined __SES_ARM) || (defined __GNUC__) || (defined __clang__) 31 | #define _CC_TYPE _CCCLANG 32 | #define _PUB_SYM .global 33 | #define _EXT_SYM .extern 34 | #define _END .end 35 | #define _WEAK .weak 36 | #define _THUMB_FUNC .thumb_func 37 | #define _THUMB_CODE .code 16 38 | #define _WORD .word 39 | #define _SECTION(Sect, Type, AlignExp) .section Sect ##, "ax" 40 | #define _ALIGN(Exp) .align Exp 41 | #define _PLACE_LITS .ltorg 42 | #define _DATA_SECT_START 43 | #define _C_STARTUP _start 44 | #define _STACK_END __stack_end__ 45 | #define _RAMFUNC 46 | // 47 | // .text => Link to flash 48 | // .fast => Link to RAM 49 | // OtherSect => Usually link to RAM 50 | // Alignment is 2^x 51 | // 52 | #elif defined (__IASMARM__) 53 | #define _CC_TYPE _CCIAR 54 | #define _PUB_SYM PUBLIC 55 | #define _EXT_SYM EXTERN 56 | #define _END END 57 | #define _WEAK _WEAK 58 | #define _THUMB_FUNC 59 | #define _THUMB_CODE THUMB 60 | #define _WORD DCD 61 | #define _SECTION(Sect, Type, AlignExp) SECTION Sect ## : ## Type ## :REORDER:NOROOT ## (AlignExp) 62 | #define _ALIGN(Exp) alignrom Exp 63 | #define _PLACE_LITS 64 | #define _DATA_SECT_START DATA 65 | #define _C_STARTUP __iar_program_start 66 | #define _STACK_END sfe(CSTACK) 67 | #define _RAMFUNC SECTION_TYPE SHT_PROGBITS, SHF_WRITE | SHF_EXECINSTR 68 | // 69 | // .text => Link to flash 70 | // .textrw => Link to RAM 71 | // OtherSect => Usually link to RAM 72 | // NOROOT => Allows linker to throw away the function, if not referenced 73 | // Alignment is 2^x 74 | // 75 | #endif 76 | 77 | #if (_CC_TYPE == _CCIAR) 78 | NAME SEGGER_RTT_ASM_ARMv7M 79 | #else 80 | .syntax unified 81 | #endif 82 | 83 | #if defined (RTT_USE_ASM) && (RTT_USE_ASM == 1) 84 | #define SHT_PROGBITS 0x1 85 | 86 | /********************************************************************* 87 | * 88 | * Public / external symbols 89 | * 90 | ********************************************************************** 91 | */ 92 | 93 | _EXT_SYM __aeabi_memcpy 94 | _EXT_SYM __aeabi_memcpy4 95 | _EXT_SYM _SEGGER_RTT 96 | 97 | _PUB_SYM SEGGER_RTT_ASM_WriteSkipNoLock 98 | 99 | /********************************************************************* 100 | * 101 | * SEGGER_RTT_WriteSkipNoLock 102 | * 103 | * Function description 104 | * Stores a specified number of characters in SEGGER RTT 105 | * control block which is then read by the host. 106 | * SEGGER_RTT_WriteSkipNoLock does not lock the application and 107 | * skips all data, if the data does not fit into the buffer. 108 | * 109 | * Parameters 110 | * BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). 111 | * pBuffer Pointer to character array. Does not need to point to a \0 terminated string. 112 | * NumBytes Number of bytes to be stored in the SEGGER RTT control block. 113 | * MUST be > 0!!! 114 | * This is done for performance reasons, so no initial check has do be done. 115 | * 116 | * Return value 117 | * 1: Data has been copied 118 | * 0: No space, data has not been copied 119 | * 120 | * Notes 121 | * (1) If there is not enough space in the "Up"-buffer, all data is dropped. 122 | * (2) For performance reasons this function does not call Init() 123 | * and may only be called after RTT has been initialized. 124 | * Either by calling SEGGER_RTT_Init() or calling another RTT API function first. 125 | */ 126 | _SECTION(.text, CODE, 2) 127 | _ALIGN(2) 128 | _THUMB_FUNC 129 | SEGGER_RTT_ASM_WriteSkipNoLock: // unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pData, unsigned NumBytes) { 130 | // 131 | // Cases: 132 | // 1) RdOff <= WrOff => Space until wrap-around is sufficient 133 | // 2) RdOff <= WrOff => Space after wrap-around needed (copy in 2 chunks) 134 | // 3) RdOff < WrOff => No space in buf 135 | // 4) RdOff > WrOff => Space is sufficient 136 | // 5) RdOff > WrOff => No space in buf 137 | // 138 | // 1) is the most common case for large buffers and assuming that J-Link reads the data fast enough 139 | // 140 | // Register usage: 141 | // R0 Temporary needed as RdOff, register later on 142 | // R1 pData 143 | // R2 144 | // R3 register. Hold free for subroutine calls 145 | // R4 146 | // R5 pRing->pBuffer 147 | // R6 pRing (Points to active struct SEGGER_RTT_BUFFER_DOWN) 148 | // R7 WrOff 149 | // 150 | PUSH {R4-R7} 151 | ADD R3,R0,R0, LSL #+1 152 | LDR.W R0,=_SEGGER_RTT // pRing = &_SEGGER_RTT.aUp[BufferIndex]; 153 | ADD R0,R0,R3, LSL #+3 154 | ADD R6,R0,#+24 155 | LDR R0,[R6, #+16] // RdOff = pRing->RdOff; 156 | LDR R7,[R6, #+12] // WrOff = pRing->WrOff; 157 | LDR R5,[R6, #+4] // pRing->pBuffer 158 | CMP R7,R0 159 | BCC.N _CheckCase4 // if (RdOff <= WrOff) { => Case 1), 2) or 3) 160 | // 161 | // Handling for case 1, later on identical to case 4 162 | // 163 | LDR R3,[R6, #+8] // Avail = pRing->SizeOfBuffer - WrOff - 1u; => Space until wrap-around (assume 1 byte not usable for case that RdOff == 0) 164 | SUBS R4,R3,R7 // (Used in case we jump into case 2 afterwards) 165 | SUBS R3,R4,#+1 // 166 | CMP R3,R2 167 | BCC.N _CheckCase2 // if (Avail >= NumBytes) { => Case 1)? 168 | _Case4: 169 | ADDS R5,R7,R5 // pBuffer += WrOff 170 | ADDS R0,R2,R7 // v = WrOff + NumBytes 171 | // 172 | // 2x unrolling for the copy loop that is used most of the time 173 | // This is a special optimization for small SystemView packets and makes them even faster 174 | // 175 | _ALIGN(2) 176 | _LoopCopyStraight: // memcpy(pRing->pBuffer + WrOff, pData, NumBytes); 177 | LDRB R3,[R1], #+1 178 | STRB R3,[R5], #+1 // *pDest++ = *pSrc++ 179 | SUBS R2,R2,#+1 180 | BEQ _CSDone 181 | LDRB R3,[R1], #+1 182 | STRB R3,[R5], #+1 // *pDest++ = *pSrc++ 183 | SUBS R2,R2,#+1 184 | BNE _LoopCopyStraight 185 | _CSDone: 186 | #if _CORE_NEEDS_DMB // Do not slow down cores that do not need a DMB instruction here 187 | DMB // Cortex-M7 may delay memory writes and also change the order in which the writes happen. Therefore, make sure that all buffer writes are finished, before updating the in the struct 188 | #endif 189 | STR R0,[R6, #+12] // pRing->WrOff = WrOff + NumBytes; 190 | MOVS R0,#+1 191 | POP {R4-R7} 192 | BX LR // Return 1 193 | _CheckCase2: 194 | ADDS R0,R0,R3 // Avail += RdOff; => Space incl. wrap-around 195 | CMP R0,R2 196 | BCC.N _Case3 // if (Avail >= NumBytes) { => Case 2? => If not, we have case 3) (does not fit) 197 | // 198 | // Handling for case 2 199 | // 200 | ADDS R0,R7,R5 // v = pRing->pBuffer + WrOff => Do not change pRing->pBuffer here because 2nd chunk needs org. value 201 | SUBS R2,R2,R4 // NumBytes -= Rem; (Rem = pRing->SizeOfBuffer - WrOff; => Space until end of buffer) 202 | _LoopCopyBeforeWrapAround: // memcpy(pRing->pBuffer + WrOff, pData, Rem); => Copy 1st chunk 203 | LDRB R3,[R1], #+1 204 | STRB R3,[R0], #+1 // *pDest++ = *pSrc++ 205 | SUBS R4,R4,#+1 206 | BNE _LoopCopyBeforeWrapAround 207 | // 208 | // Special case: First check that assumed RdOff == 0 calculated that last element before wrap-around could not be used 209 | // But 2nd check (considering space until wrap-around and until RdOff) revealed that RdOff is not 0, so we can use the last element 210 | // In this case, we may use a copy straight until buffer end anyway without needing to copy 2 chunks 211 | // Therefore, check if 2nd memcpy is necessary at all 212 | // 213 | ADDS R4,R2,#+0 // Save (needed as counter in loop but must be written to after the loop). Also use this inst to update the flags to skip 2nd loop if possible 214 | BEQ.N _No2ChunkNeeded // if (NumBytes) { 215 | _LoopCopyAfterWrapAround: // memcpy(pRing->pBuffer, pData + Rem, NumBytes); 216 | LDRB R3,[R1], #+1 // pData already points to the next src byte due to copy loop increment before this loop 217 | STRB R3,[R5], #+1 // *pDest++ = *pSrc++ 218 | SUBS R2,R2,#+1 219 | BNE _LoopCopyAfterWrapAround 220 | _No2ChunkNeeded: 221 | #if _CORE_NEEDS_DMB // Do not slow down cores that do not need a DMB instruction here 222 | DMB // Cortex-M7 may delay memory writes and also change the order in which the writes happen. Therefore, make sure that all buffer writes are finished, before updating the in the struct 223 | #endif 224 | STR R4,[R6, #+12] // pRing->WrOff = NumBytes; => Must be written after copying data because J-Link may read control block asynchronously while writing into buffer 225 | MOVS R0,#+1 226 | POP {R4-R7} 227 | BX LR // Return 1 228 | _CheckCase4: 229 | SUBS R0,R0,R7 230 | SUBS R0,R0,#+1 // Avail = RdOff - WrOff - 1u; 231 | CMP R0,R2 232 | BCS.N _Case4 // if (Avail >= NumBytes) { => Case 4) == 1) ? => If not, we have case 5) == 3) (does not fit) 233 | _Case3: 234 | MOVS R0,#+0 235 | POP {R4-R7} 236 | BX LR // Return 0 237 | _PLACE_LITS 238 | 239 | #endif // defined (RTT_USE_ASM) && (RTT_USE_ASM == 1) 240 | _END 241 | 242 | /*************************** End of file ****************************/ 243 | -------------------------------------------------------------------------------- /gcc/dialog-sdk.cmake: -------------------------------------------------------------------------------- 1 | if("${DIALOG_SDK_PATH}" STREQUAL "") 2 | message(FATAL_ERROR "DIALOG_SDK_PATH not set") 3 | endif() 4 | 5 | if(NOT IS_ABSOLUTE ${DIALOG_SDK_PATH}) 6 | message(STATUS "DIALOG_SDK_PATH is not absolute") 7 | set(DIALOG_SDK_PATH "${PROJECT_SOURCE_DIR}/${DIALOG_SDK_PATH}") 8 | endif() 9 | 10 | if(NOT EXISTS ${DIALOG_SDK_PATH}) 11 | message(FATAL_ERROR "DIALOG_SDK_PATH does not exist (DIALOG_SDK_PATH: ${DIALOG_SDK_PATH})") 12 | endif() 13 | 14 | if(NOT IS_DIRECTORY ${DIALOG_SDK_PATH}) 15 | message(FATAL_ERROR "DIALOG_SDK_PATH is not a directory (DIALOG_SDK_PATH: ${DIALOG_SDK_PATH})") 16 | endif() 17 | 18 | # Include Dialog SDK 19 | set(DIALOG_SDK_INCLUDES 20 | ${DIALOG_SDK_PATH}/sdk/platform/include/CMSIS/5.6.0/Include 21 | ${DIALOG_SDK_PATH}/sdk/app_modules/api 22 | ${DIALOG_SDK_PATH}/sdk/ble_stack/controller/em 23 | ${DIALOG_SDK_PATH}/sdk/ble_stack/controller/llc 24 | ${DIALOG_SDK_PATH}/sdk/ble_stack/controller/lld 25 | ${DIALOG_SDK_PATH}/sdk/ble_stack/controller/llm 26 | ${DIALOG_SDK_PATH}/sdk/ble_stack/ea/api 27 | ${DIALOG_SDK_PATH}/sdk/ble_stack/em/api 28 | ${DIALOG_SDK_PATH}/sdk/ble_stack/hci/api 29 | ${DIALOG_SDK_PATH}/sdk/ble_stack/hci/src 30 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/att 31 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/att/attc 32 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/att/attm 33 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/att/atts 34 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/gap 35 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/gap/gapc 36 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/gap/gapm 37 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/gatt 38 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/gatt/gattc 39 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/gatt/gattm 40 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/l2c/l2cc 41 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/l2c/l2cm 42 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/smp 43 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/smp/smpc 44 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/smp/smpm 45 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles 46 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/anc 47 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/anc/ancc/api 48 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/anp 49 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/anp/anpc/api 50 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/anp/anps/api 51 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/bas/basc/api 52 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/bas/bass/api 53 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/bcs 54 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/bcs/bcsc/api 55 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/bcs/bcss/api 56 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/blp 57 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/blp/blpc/api 58 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/blp/blps/api 59 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/bms 60 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/bms/bmsc/api 61 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/bms/bmss/api 62 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/cpp 63 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/cpp/cppc/api 64 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/cpp/cpps/api 65 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/cscp 66 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/cscp/cscpc/api 67 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/cscp/cscps/api 68 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/cts 69 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/cts/ctsc/api 70 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/cts/ctss/api 71 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/custom 72 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/custom/custs/api 73 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/dis/disc/api 74 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/dis/diss/api 75 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/find 76 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/find/findl/api 77 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/find/findt/api 78 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/gatt/gatt_client/api 79 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/glp 80 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/glp/glpc/api 81 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/glp/glps/api 82 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/hogp 83 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/hogp/hogpbh/api 84 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/hogp/hogpd/api 85 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/hogp/hogprh/api 86 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/hrp 87 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/hrp/hrpc/api 88 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/hrp/hrps/api 89 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/htp 90 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/htp/htpc/api 91 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/htp/htpt/api 92 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/lan 93 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/lan/lanc/api 94 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/lan/lans/api 95 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/pasp 96 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/pasp/paspc/api 97 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/pasp/pasps/api 98 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/prox/proxm/api 99 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/prox/proxr/api 100 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/rscp 101 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/rscp/rscpc/api 102 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/rscp/rscps/api 103 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/scpp 104 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/scpp/scppc/api 105 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/scpp/scpps/api 106 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/suota/suotar/api 107 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/tip 108 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/tip/tipc/api 109 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/tip/tips/api 110 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/uds 111 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/uds/udsc/api 112 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/uds/udss/api 113 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/wss 114 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/wss/wssc/api 115 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/wss/wsss/api 116 | ${DIALOG_SDK_PATH}/sdk/ble_stack/rwble 117 | ${DIALOG_SDK_PATH}/sdk/ble_stack/rwble_hl 118 | ${DIALOG_SDK_PATH}/sdk/common_project_files 119 | ${DIALOG_SDK_PATH}/sdk/platform/arch 120 | ${DIALOG_SDK_PATH}/sdk/platform/arch/boot 121 | ${DIALOG_SDK_PATH}/sdk/platform/arch/boot/ARM 122 | ${DIALOG_SDK_PATH}/sdk/platform/arch/boot/GCC 123 | ${DIALOG_SDK_PATH}/sdk/platform/arch/compiler 124 | ${DIALOG_SDK_PATH}/sdk/platform/arch/compiler/ARM 125 | ${DIALOG_SDK_PATH}/sdk/platform/arch/compiler/GCC 126 | ${DIALOG_SDK_PATH}/sdk/platform/arch/ll 127 | ${DIALOG_SDK_PATH}/sdk/platform/arch/main 128 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/arch_console 129 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/common/api 130 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/crypto 131 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/dbg/api 132 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/gtl/api 133 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/gtl/src 134 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/h4tl/api 135 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/ke/api 136 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/ke/src 137 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/nvds/api 138 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/rf/api 139 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/rwip/api 140 | ${DIALOG_SDK_PATH}/sdk/platform/driver/adc 141 | ${DIALOG_SDK_PATH}/sdk/platform/driver/battery 142 | ${DIALOG_SDK_PATH}/sdk/platform/driver/ble 143 | ${DIALOG_SDK_PATH}/sdk/platform/driver/dma 144 | ${DIALOG_SDK_PATH}/sdk/platform/driver/gpio 145 | ${DIALOG_SDK_PATH}/sdk/platform/driver/hw_otpc 146 | ${DIALOG_SDK_PATH}/sdk/platform/driver/i2c 147 | ${DIALOG_SDK_PATH}/sdk/platform/driver/i2c_eeprom 148 | ${DIALOG_SDK_PATH}/sdk/platform/driver/pdm 149 | ${DIALOG_SDK_PATH}/sdk/platform/driver/reg 150 | ${DIALOG_SDK_PATH}/sdk/platform/driver/rtc 151 | ${DIALOG_SDK_PATH}/sdk/platform/driver/spi 152 | ${DIALOG_SDK_PATH}/sdk/platform/driver/spi_flash 153 | ${DIALOG_SDK_PATH}/sdk/platform/driver/spi_hci 154 | ${DIALOG_SDK_PATH}/sdk/platform/driver/syscntl 155 | ${DIALOG_SDK_PATH}/sdk/platform/driver/systick 156 | ${DIALOG_SDK_PATH}/sdk/platform/driver/timer 157 | ${DIALOG_SDK_PATH}/sdk/platform/driver/trng 158 | ${DIALOG_SDK_PATH}/sdk/platform/driver/uart 159 | ${DIALOG_SDK_PATH}/sdk/platform/driver/wkupct_quadec 160 | ${DIALOG_SDK_PATH}/sdk/platform/include 161 | ${DIALOG_SDK_PATH}/sdk/platform/system_library/include 162 | ${DIALOG_SDK_PATH}/third_party/hash 163 | ${DIALOG_SDK_PATH}/third_party/irng 164 | ${DIALOG_SDK_PATH}/third_party/rand 165 | ${DIALOG_SDK_PATH}/sdk/platform/utilities/otp_cs 166 | ${DIALOG_SDK_PATH}/sdk/platform/utilities/otp_hdr 167 | ) 168 | 169 | set(DIALOG_SDK_SOURCES 170 | ${DIALOG_SDK_PATH}/sdk/platform/arch/main/hardfault_handler.c 171 | ${DIALOG_SDK_PATH}/sdk/platform/arch/main/nmi_handler.c 172 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/arch_console/arch_console.c 173 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/nvds/src/nvds.c 174 | ${DIALOG_SDK_PATH}/sdk/platform/arch/main/jump_table.c 175 | ${DIALOG_SDK_PATH}/sdk/platform/arch/main/arch_sleep.c 176 | ${DIALOG_SDK_PATH}/sdk/platform/arch/main/arch_system.c 177 | ${DIALOG_SDK_PATH}/sdk/platform/arch/main/arch_rom.c 178 | ${DIALOG_SDK_PATH}/sdk/platform/arch/main/arch_main.c 179 | ${DIALOG_SDK_PATH}/sdk/platform/arch/main/arch_hibernation.c 180 | ${DIALOG_SDK_PATH}/third_party/rand/chacha20.c 181 | ${DIALOG_SDK_PATH}/third_party/hash/hash.c 182 | ${DIALOG_SDK_PATH}/sdk/platform/utilities/otp_cs/otp_cs.c 183 | ${DIALOG_SDK_PATH}/sdk/platform/utilities/otp_hdr/otp_hdr.c 184 | ${DIALOG_SDK_PATH}/sdk/platform/driver/syscntl/syscntl.c 185 | ${DIALOG_SDK_PATH}/sdk/platform/driver/gpio/gpio.c 186 | ${DIALOG_SDK_PATH}/sdk/platform/driver/wkupct_quadec/wkupct_quadec.c 187 | ${DIALOG_SDK_PATH}/sdk/platform/driver/battery/battery.c 188 | ${DIALOG_SDK_PATH}/sdk/platform/driver/adc/adc_531.c 189 | ${DIALOG_SDK_PATH}/sdk/platform/driver/trng/trng.c 190 | ${DIALOG_SDK_PATH}/sdk/platform/driver/spi/spi_531.c 191 | ${DIALOG_SDK_PATH}/sdk/platform/driver/spi_flash/spi_flash.c 192 | ${DIALOG_SDK_PATH}/sdk/platform/driver/i2c_eeprom/i2c_eeprom.c 193 | ${DIALOG_SDK_PATH}/sdk/platform/driver/systick/systick.c 194 | ${DIALOG_SDK_PATH}/sdk/platform/driver/uart/uart.c 195 | ${DIALOG_SDK_PATH}/sdk/platform/driver/hw_otpc/hw_otpc_531.c 196 | ${DIALOG_SDK_PATH}/sdk/platform/driver/dma/dma.c 197 | ${DIALOG_SDK_PATH}/sdk/platform/driver/i2c/i2c.c 198 | ${DIALOG_SDK_PATH}/sdk/platform/driver/timer/timer0.c 199 | ${DIALOG_SDK_PATH}/sdk/ble_stack/rwble/rwble.c 200 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/rwip/src/rwip.c 201 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/rf/src/ble_arp.c 202 | ${DIALOG_SDK_PATH}/sdk/platform/core_modules/rf/src/rf_531.c 203 | ${DIALOG_SDK_PATH}/sdk/ble_stack/host/att/attm/attm_db_128.c 204 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/custom/custom_common.c 205 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/custom/custs/src/custs1.c 206 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/custom/custs/src/custs1_task.c 207 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/prf.c 208 | ${DIALOG_SDK_PATH}/sdk/ble_stack/profiles/prf_utils.c 209 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_bond_db/app_bond_db.c 210 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_common/app.c 211 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_common/app_task.c 212 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_common/app_msg_utils.c 213 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_common/app_utils.c 214 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_custs/app_customs.c 215 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_custs/app_customs_task.c 216 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_custs/app_customs_common.c 217 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_default_hnd/app_default_handlers.c 218 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_diss/app_diss.c 219 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_diss/app_diss_task.c 220 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_easy/app_easy_msg_utils.c 221 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_easy/app_easy_timer.c 222 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_easy/app_easy_security.c 223 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_easy/app_easy_whitelist.c 224 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_entry/app_entry_point.c 225 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_findme/app_findme.c 226 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_findme/app_findme_task.c 227 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_proxr/app_proxr.c 228 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_proxr/app_proxr_task.c 229 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_sec/app_security.c 230 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_sec/app_security_task.c 231 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_suotar/app_suotar.c 232 | ${DIALOG_SDK_PATH}/sdk/app_modules/src/app_suotar/app_suotar_task.c 233 | ${DIALOG_SDK_PATH}/sdk/platform/arch/boot/system_DA14531.c 234 | ${DIALOG_SDK_PATH}/sdk/platform/arch/boot/GCC/ivtable_DA14531.S 235 | ${DIALOG_SDK_PATH}/sdk/platform/arch/boot/GCC/startup_DA14531.S 236 | ) 237 | -------------------------------------------------------------------------------- /Libraries/RTT/SEGGER_RTT_printf.c: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * SEGGER Microcontroller GmbH * 3 | * The Embedded Experts * 4 | ********************************************************************** 5 | * * 6 | * (c) 1995 - 2019 SEGGER Microcontroller GmbH * 7 | * * 8 | * www.segger.com Support: support@segger.com * 9 | * * 10 | ********************************************************************** 11 | * * 12 | * SEGGER SystemView * Real-time application analysis * 13 | * * 14 | ********************************************************************** 15 | * * 16 | * All rights reserved. * 17 | * * 18 | * SEGGER strongly recommends to not make any changes * 19 | * to or modify the source code of this software in order to stay * 20 | * compatible with the SystemView and RTT protocol, and J-Link. * 21 | * * 22 | * Redistribution and use in source and binary forms, with or * 23 | * without modification, are permitted provided that the following * 24 | * condition is met: * 25 | * * 26 | * o Redistributions of source code must retain the above copyright * 27 | * notice, this condition and the following disclaimer. * 28 | * * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 30 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * 31 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * 32 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * 33 | * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * 34 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * 36 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * 37 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 38 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * 40 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 41 | * DAMAGE. * 42 | * * 43 | ********************************************************************** 44 | * * 45 | * SystemView version: 3.20 * 46 | * * 47 | ********************************************************************** 48 | ---------------------------END-OF-HEADER------------------------------ 49 | File : SEGGER_RTT_printf.c 50 | Purpose : Replacement for printf to write formatted data via RTT 51 | Revision: $Rev: 17697 $ 52 | ---------------------------------------------------------------------- 53 | */ 54 | #include "SEGGER_RTT.h" 55 | #include "SEGGER_RTT_Conf.h" 56 | 57 | /********************************************************************* 58 | * 59 | * Defines, configurable 60 | * 61 | ********************************************************************** 62 | */ 63 | 64 | #ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE 65 | #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64) 66 | #endif 67 | 68 | #include 69 | #include 70 | 71 | 72 | #define FORMAT_FLAG_LEFT_JUSTIFY (1u << 0) 73 | #define FORMAT_FLAG_PAD_ZERO (1u << 1) 74 | #define FORMAT_FLAG_PRINT_SIGN (1u << 2) 75 | #define FORMAT_FLAG_ALTERNATE (1u << 3) 76 | 77 | /********************************************************************* 78 | * 79 | * Types 80 | * 81 | ********************************************************************** 82 | */ 83 | 84 | typedef struct { 85 | char* pBuffer; 86 | unsigned BufferSize; 87 | unsigned Cnt; 88 | 89 | int ReturnValue; 90 | 91 | unsigned RTTBufferIndex; 92 | } SEGGER_RTT_PRINTF_DESC; 93 | 94 | /********************************************************************* 95 | * 96 | * Function prototypes 97 | * 98 | ********************************************************************** 99 | */ 100 | 101 | /********************************************************************* 102 | * 103 | * Static code 104 | * 105 | ********************************************************************** 106 | */ 107 | /********************************************************************* 108 | * 109 | * _StoreChar 110 | */ 111 | static void _StoreChar(SEGGER_RTT_PRINTF_DESC * p, char c) { 112 | unsigned Cnt; 113 | 114 | Cnt = p->Cnt; 115 | if ((Cnt + 1u) <= p->BufferSize) { 116 | *(p->pBuffer + Cnt) = c; 117 | p->Cnt = Cnt + 1u; 118 | p->ReturnValue++; 119 | } 120 | // 121 | // Write part of string, when the buffer is full 122 | // 123 | if (p->Cnt == p->BufferSize) { 124 | if (SEGGER_RTT_Write(p->RTTBufferIndex, p->pBuffer, p->Cnt) != p->Cnt) { 125 | p->ReturnValue = -1; 126 | } else { 127 | p->Cnt = 0u; 128 | } 129 | } 130 | } 131 | 132 | /********************************************************************* 133 | * 134 | * _PrintUnsigned 135 | */ 136 | static void _PrintUnsigned(SEGGER_RTT_PRINTF_DESC * pBufferDesc, unsigned v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) { 137 | static const char _aV2C[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; 138 | unsigned Div; 139 | unsigned Digit; 140 | unsigned Number; 141 | unsigned Width; 142 | char c; 143 | 144 | Number = v; 145 | Digit = 1u; 146 | // 147 | // Get actual field width 148 | // 149 | Width = 1u; 150 | while (Number >= Base) { 151 | Number = (Number / Base); 152 | Width++; 153 | } 154 | if (NumDigits > Width) { 155 | Width = NumDigits; 156 | } 157 | // 158 | // Print leading chars if necessary 159 | // 160 | if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) { 161 | if (FieldWidth != 0u) { 162 | if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && (NumDigits == 0u)) { 163 | c = '0'; 164 | } else { 165 | c = ' '; 166 | } 167 | while ((FieldWidth != 0u) && (Width < FieldWidth)) { 168 | FieldWidth--; 169 | _StoreChar(pBufferDesc, c); 170 | if (pBufferDesc->ReturnValue < 0) { 171 | break; 172 | } 173 | } 174 | } 175 | } 176 | if (pBufferDesc->ReturnValue >= 0) { 177 | // 178 | // Compute Digit. 179 | // Loop until Digit has the value of the highest digit required. 180 | // Example: If the output is 345 (Base 10), loop 2 times until Digit is 100. 181 | // 182 | while (1) { 183 | if (NumDigits > 1u) { // User specified a min number of digits to print? => Make sure we loop at least that often, before checking anything else (> 1 check avoids problems with NumDigits being signed / unsigned) 184 | NumDigits--; 185 | } else { 186 | Div = v / Digit; 187 | if (Div < Base) { // Is our divider big enough to extract the highest digit from value? => Done 188 | break; 189 | } 190 | } 191 | Digit *= Base; 192 | } 193 | // 194 | // Output digits 195 | // 196 | do { 197 | Div = v / Digit; 198 | v -= Div * Digit; 199 | _StoreChar(pBufferDesc, _aV2C[Div]); 200 | if (pBufferDesc->ReturnValue < 0) { 201 | break; 202 | } 203 | Digit /= Base; 204 | } while (Digit); 205 | // 206 | // Print trailing spaces if necessary 207 | // 208 | if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == FORMAT_FLAG_LEFT_JUSTIFY) { 209 | if (FieldWidth != 0u) { 210 | while ((FieldWidth != 0u) && (Width < FieldWidth)) { 211 | FieldWidth--; 212 | _StoreChar(pBufferDesc, ' '); 213 | if (pBufferDesc->ReturnValue < 0) { 214 | break; 215 | } 216 | } 217 | } 218 | } 219 | } 220 | } 221 | 222 | /********************************************************************* 223 | * 224 | * _PrintInt 225 | */ 226 | static void _PrintInt(SEGGER_RTT_PRINTF_DESC * pBufferDesc, int v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) { 227 | unsigned Width; 228 | int Number; 229 | 230 | Number = (v < 0) ? -v : v; 231 | 232 | // 233 | // Get actual field width 234 | // 235 | Width = 1u; 236 | while (Number >= (int)Base) { 237 | Number = (Number / (int)Base); 238 | Width++; 239 | } 240 | if (NumDigits > Width) { 241 | Width = NumDigits; 242 | } 243 | if ((FieldWidth > 0u) && ((v < 0) || ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN))) { 244 | FieldWidth--; 245 | } 246 | 247 | // 248 | // Print leading spaces if necessary 249 | // 250 | if ((((FormatFlags & FORMAT_FLAG_PAD_ZERO) == 0u) || (NumDigits != 0u)) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u)) { 251 | if (FieldWidth != 0u) { 252 | while ((FieldWidth != 0u) && (Width < FieldWidth)) { 253 | FieldWidth--; 254 | _StoreChar(pBufferDesc, ' '); 255 | if (pBufferDesc->ReturnValue < 0) { 256 | break; 257 | } 258 | } 259 | } 260 | } 261 | // 262 | // Print sign if necessary 263 | // 264 | if (pBufferDesc->ReturnValue >= 0) { 265 | if (v < 0) { 266 | v = -v; 267 | _StoreChar(pBufferDesc, '-'); 268 | } else if ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN) { 269 | _StoreChar(pBufferDesc, '+'); 270 | } else { 271 | 272 | } 273 | if (pBufferDesc->ReturnValue >= 0) { 274 | // 275 | // Print leading zeros if necessary 276 | // 277 | if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) && (NumDigits == 0u)) { 278 | if (FieldWidth != 0u) { 279 | while ((FieldWidth != 0u) && (Width < FieldWidth)) { 280 | FieldWidth--; 281 | _StoreChar(pBufferDesc, '0'); 282 | if (pBufferDesc->ReturnValue < 0) { 283 | break; 284 | } 285 | } 286 | } 287 | } 288 | if (pBufferDesc->ReturnValue >= 0) { 289 | // 290 | // Print number without sign 291 | // 292 | _PrintUnsigned(pBufferDesc, (unsigned)v, Base, NumDigits, FieldWidth, FormatFlags); 293 | } 294 | } 295 | } 296 | } 297 | 298 | /********************************************************************* 299 | * 300 | * Public code 301 | * 302 | ********************************************************************** 303 | */ 304 | /********************************************************************* 305 | * 306 | * SEGGER_RTT_vprintf 307 | * 308 | * Function description 309 | * Stores a formatted string in SEGGER RTT control block. 310 | * This data is read by the host. 311 | * 312 | * Parameters 313 | * BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal") 314 | * sFormat Pointer to format string 315 | * pParamList Pointer to the list of arguments for the format string 316 | * 317 | * Return values 318 | * >= 0: Number of bytes which have been stored in the "Up"-buffer. 319 | * < 0: Error 320 | */ 321 | int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList) { 322 | char c; 323 | SEGGER_RTT_PRINTF_DESC BufferDesc; 324 | int v; 325 | unsigned NumDigits; 326 | unsigned FormatFlags; 327 | unsigned FieldWidth; 328 | char acBuffer[SEGGER_RTT_PRINTF_BUFFER_SIZE]; 329 | 330 | BufferDesc.pBuffer = acBuffer; 331 | BufferDesc.BufferSize = SEGGER_RTT_PRINTF_BUFFER_SIZE; 332 | BufferDesc.Cnt = 0u; 333 | BufferDesc.RTTBufferIndex = BufferIndex; 334 | BufferDesc.ReturnValue = 0; 335 | 336 | do { 337 | c = *sFormat; 338 | sFormat++; 339 | if (c == 0u) { 340 | break; 341 | } 342 | if (c == '%') { 343 | // 344 | // Filter out flags 345 | // 346 | FormatFlags = 0u; 347 | v = 1; 348 | do { 349 | c = *sFormat; 350 | switch (c) { 351 | case '-': FormatFlags |= FORMAT_FLAG_LEFT_JUSTIFY; sFormat++; break; 352 | case '0': FormatFlags |= FORMAT_FLAG_PAD_ZERO; sFormat++; break; 353 | case '+': FormatFlags |= FORMAT_FLAG_PRINT_SIGN; sFormat++; break; 354 | case '#': FormatFlags |= FORMAT_FLAG_ALTERNATE; sFormat++; break; 355 | default: v = 0; break; 356 | } 357 | } while (v); 358 | // 359 | // filter out field with 360 | // 361 | FieldWidth = 0u; 362 | do { 363 | c = *sFormat; 364 | if ((c < '0') || (c > '9')) { 365 | break; 366 | } 367 | sFormat++; 368 | FieldWidth = (FieldWidth * 10u) + ((unsigned)c - '0'); 369 | } while (1); 370 | 371 | // 372 | // Filter out precision (number of digits to display) 373 | // 374 | NumDigits = 0u; 375 | c = *sFormat; 376 | if (c == '.') { 377 | sFormat++; 378 | do { 379 | c = *sFormat; 380 | if ((c < '0') || (c > '9')) { 381 | break; 382 | } 383 | sFormat++; 384 | NumDigits = NumDigits * 10u + ((unsigned)c - '0'); 385 | } while (1); 386 | } 387 | // 388 | // Filter out length modifier 389 | // 390 | c = *sFormat; 391 | do { 392 | if ((c == 'l') || (c == 'h')) { 393 | sFormat++; 394 | c = *sFormat; 395 | } else { 396 | break; 397 | } 398 | } while (1); 399 | // 400 | // Handle specifiers 401 | // 402 | switch (c) { 403 | case 'c': { 404 | char c0; 405 | v = va_arg(*pParamList, int); 406 | c0 = (char)v; 407 | _StoreChar(&BufferDesc, c0); 408 | break; 409 | } 410 | case 'd': 411 | v = va_arg(*pParamList, int); 412 | _PrintInt(&BufferDesc, v, 10u, NumDigits, FieldWidth, FormatFlags); 413 | break; 414 | case 'u': 415 | v = va_arg(*pParamList, int); 416 | _PrintUnsigned(&BufferDesc, (unsigned)v, 10u, NumDigits, FieldWidth, FormatFlags); 417 | break; 418 | case 'x': 419 | case 'X': 420 | v = va_arg(*pParamList, int); 421 | _PrintUnsigned(&BufferDesc, (unsigned)v, 16u, NumDigits, FieldWidth, FormatFlags); 422 | break; 423 | case 's': 424 | { 425 | const char * s = va_arg(*pParamList, const char *); 426 | do { 427 | c = *s; 428 | s++; 429 | if (c == '\0') { 430 | break; 431 | } 432 | _StoreChar(&BufferDesc, c); 433 | } while (BufferDesc.ReturnValue >= 0); 434 | } 435 | break; 436 | case 'p': 437 | v = va_arg(*pParamList, int); 438 | _PrintUnsigned(&BufferDesc, (unsigned)v, 16u, 8u, 8u, 0u); 439 | break; 440 | case '%': 441 | _StoreChar(&BufferDesc, '%'); 442 | break; 443 | default: 444 | break; 445 | } 446 | sFormat++; 447 | } else { 448 | _StoreChar(&BufferDesc, c); 449 | } 450 | } while (BufferDesc.ReturnValue >= 0); 451 | 452 | if (BufferDesc.ReturnValue > 0) { 453 | // 454 | // Write remaining data, if any 455 | // 456 | if (BufferDesc.Cnt != 0u) { 457 | SEGGER_RTT_Write(BufferIndex, acBuffer, BufferDesc.Cnt); 458 | } 459 | BufferDesc.ReturnValue += (int)BufferDesc.Cnt; 460 | } 461 | return BufferDesc.ReturnValue; 462 | } 463 | 464 | /********************************************************************* 465 | * 466 | * SEGGER_RTT_printf 467 | * 468 | * Function description 469 | * Stores a formatted string in SEGGER RTT control block. 470 | * This data is read by the host. 471 | * 472 | * Parameters 473 | * BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal") 474 | * sFormat Pointer to format string, followed by the arguments for conversion 475 | * 476 | * Return values 477 | * >= 0: Number of bytes which have been stored in the "Up"-buffer. 478 | * < 0: Error 479 | * 480 | * Notes 481 | * (1) Conversion specifications have following syntax: 482 | * %[flags][FieldWidth][.Precision]ConversionSpecifier 483 | * (2) Supported flags: 484 | * -: Left justify within the field width 485 | * +: Always print sign extension for signed conversions 486 | * 0: Pad with 0 instead of spaces. Ignored when using '-'-flag or precision 487 | * Supported conversion specifiers: 488 | * c: Print the argument as one char 489 | * d: Print the argument as a signed integer 490 | * u: Print the argument as an unsigned integer 491 | * x: Print the argument as an hexadecimal integer 492 | * s: Print the string pointed to by the argument 493 | * p: Print the argument as an 8-digit hexadecimal integer. (Argument shall be a pointer to void.) 494 | */ 495 | int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...) { 496 | int r; 497 | va_list ParamList; 498 | 499 | va_start(ParamList, sFormat); 500 | r = SEGGER_RTT_vprintf(BufferIndex, sFormat, &ParamList); 501 | va_end(ParamList); 502 | return r; 503 | } 504 | /*************************** End of file ****************************/ 505 | -------------------------------------------------------------------------------- /components/config/inc/user_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file user_config.h 5 | * 6 | * @brief User configuration file. 7 | * 8 | * Copyright (c) 2015-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | #ifndef _USER_CONFIG_H_ 34 | #define _USER_CONFIG_H_ 35 | 36 | /* 37 | * INCLUDE FILES 38 | **************************************************************************************** 39 | */ 40 | 41 | #include "app_user_config.h" 42 | #include "arch_api.h" 43 | #include "app_default_handlers.h" 44 | #include "app_adv_data.h" 45 | #include "co_bt.h" 46 | 47 | /************************************************************************* 48 | * Privacy Capabilities and address configuration of local device: 49 | * - APP_CFG_ADDR_PUB No Privacy, Public BDA 50 | * - APP_CFG_ADDR_STATIC No Privacy, Random Static BDA 51 | * - APP_CFG_HOST_PRIV_RPA Host Privacy, RPA, Public Identity 52 | * - APP_CFG_HOST_PRIV_NRPA Host Privacy, NRPA (non-connectable ONLY) 53 | * - APP_CFG_CNTL_PRIV_RPA_PUB Controller Privacy, RPA or PUB, Public Identity 54 | * - APP_CFG_CNTL_PRIV_RPA_RAND Controller Privacy, RPA, Public Identity 55 | * 56 | * Select only one option for privacy / addressing configuration. 57 | ************************************************************************** 58 | */ 59 | #define USER_CFG_ADDRESS_MODE APP_CFG_ADDR_PUB 60 | 61 | /************************************************************************* 62 | * Controller Privacy Mode: 63 | * - APP_CFG_CNTL_PRIV_MODE_NETWORK Controler Privacy Network mode (default) 64 | * - APP_CFG_CNTL_PRIV_MODE_DEVICE Controler Privacy Device mode 65 | * 66 | * Select only one option for controller privacy mode configuration. 67 | ************************************************************************** 68 | */ 69 | #define USER_CFG_CNTL_PRIV_MODE APP_CFG_CNTL_PRIV_MODE_NETWORK 70 | 71 | 72 | /****************************************** 73 | * Default sleep mode. Possible values are: 74 | * 75 | * - ARCH_SLEEP_OFF 76 | * - ARCH_EXT_SLEEP_ON 77 | * - ARCH_EXT_SLEEP_OTP_COPY_ON 78 | * 79 | ****************************************** 80 | */ 81 | static const sleep_state_t app_default_sleep_mode = ARCH_SLEEP_OFF; 82 | 83 | /* 84 | **************************************************************************************** 85 | * 86 | * Advertising configuration 87 | * 88 | **************************************************************************************** 89 | */ 90 | static const struct advertise_configuration user_adv_conf = { 91 | 92 | .addr_src = APP_CFG_ADDR_SRC(USER_CFG_ADDRESS_MODE), 93 | 94 | /// Minimum interval for advertising 95 | .intv_min = MS_TO_BLESLOTS(20), // 687.5ms 96 | 97 | /// Maximum interval for advertising 98 | .intv_max = MS_TO_BLESLOTS(40), // 687.5ms 99 | 100 | /** 101 | * Advertising channels map: 102 | * - ADV_CHNL_37_EN: Advertising channel map for channel 37. 103 | * - ADV_CHNL_38_EN: Advertising channel map for channel 38. 104 | * - ADV_CHNL_39_EN: Advertising channel map for channel 39. 105 | * - ADV_ALL_CHNLS_EN: Advertising channel map for channel 37, 38 and 39. 106 | */ 107 | .channel_map = ADV_ALL_CHNLS_EN, 108 | 109 | /************************* 110 | * Advertising information 111 | ************************* 112 | */ 113 | 114 | /// Host information advertising data (GAPM_ADV_NON_CONN and GAPM_ADV_UNDIRECT) 115 | /// Advertising mode : 116 | /// - GAP_NON_DISCOVERABLE: Non discoverable mode 117 | /// - GAP_GEN_DISCOVERABLE: General discoverable mode 118 | /// - GAP_LIM_DISCOVERABLE: Limited discoverable mode 119 | /// - GAP_BROADCASTER_MODE: Broadcaster mode 120 | .mode = GAP_GEN_DISCOVERABLE, 121 | 122 | /// Host information advertising data (GAPM_ADV_NON_CONN and GAPM_ADV_UNDIRECT) 123 | /// - ADV_ALLOW_SCAN_ANY_CON_ANY: Allow both scan and connection requests from anyone 124 | .adv_filt_policy = ADV_ALLOW_SCAN_ANY_CON_ANY, 125 | 126 | /// Address of peer device 127 | .peer_addr = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6}, 128 | 129 | /// Address type of peer device (0=public/1=random) 130 | .peer_addr_type = 0, 131 | }; 132 | 133 | /* 134 | **************************************************************************************** 135 | * 136 | * Advertising or scan response data for the following cases: 137 | * 138 | * - ADV_IND: Connectable undirected advertising event. 139 | * - The maximum length of the user defined advertising data shall be 28 bytes. 140 | * - The Flags data type are written by the related ROM function, hence the user shall 141 | * not include them in the advertising data. The related ROM function adds 3 bytes in 142 | * the start of the advertising data that are to be transmitted over the air. 143 | * - The maximum length of the user defined response data shall be 31 bytes. 144 | * 145 | * - ADV_NONCONN_IND: Non-connectable undirected advertising event. 146 | * - The maximum length of the user defined advertising data shall be 31 bytes. 147 | * - The Flags data type may be omitted, hence the user can use all the 31 bytes for 148 | * data. 149 | * - The scan response data shall be empty. 150 | * 151 | * - ADV_SCAN_IND: Scannable undirected advertising event. 152 | * - The maximum length of the user defined advertising data shall be 31 bytes. 153 | * - The Flags data type may be omitted, hence the user can use all the 31 bytes for 154 | * data. 155 | * - The maximum length of the user defined response data shall be 31 bytes. 156 | **************************************************************************************** 157 | */ 158 | /// Advertising data 159 | #define USER_ADVERTISE_DATA "" 160 | 161 | /// Advertising data length - maximum 28 bytes, 3 bytes are reserved to set 162 | #define USER_ADVERTISE_DATA_LEN (sizeof(USER_ADVERTISE_DATA)-1) 163 | 164 | /// Scan response data 165 | #define USER_ADVERTISE_SCAN_RESPONSE_DATA "" 166 | 167 | /// Scan response data length- maximum 31 bytes 168 | #define USER_ADVERTISE_SCAN_RESPONSE_DATA_LEN (sizeof(USER_ADVERTISE_SCAN_RESPONSE_DATA)-1) 169 | 170 | /* 171 | **************************************************************************************** 172 | * 173 | * Device name. 174 | * 175 | * - If there is space left in the advertising or scan response data the device name is 176 | * copied there. The device name can be anytime read by a connected peer, if the 177 | * application supports it. 178 | * - The Bluetooth device name can be up to 248 bytes. 179 | * 180 | **************************************************************************************** 181 | */ 182 | /// Device name 183 | #define USER_DEVICE_NAME "github.com/stawiski" 184 | 185 | /// Device name length 186 | #define USER_DEVICE_NAME_LEN (sizeof(USER_DEVICE_NAME)-1) 187 | 188 | /* 189 | **************************************************************************************** 190 | * 191 | * GAPM configuration 192 | * 193 | **************************************************************************************** 194 | */ 195 | static const struct gapm_configuration user_gapm_conf = { 196 | /// Device Role: Central, Peripheral, Observer, Broadcaster or All roles. (@see enum gap_role) 197 | .role = GAP_ROLE_PERIPHERAL, 198 | 199 | /// Maximal MTU. Shall be set to 23 if Legacy Pairing is used, 65 if Secure Connection is used, 200 | /// more if required by the application 201 | .max_mtu = 23, 202 | 203 | /// Device Address Type 204 | .addr_type = APP_CFG_ADDR_TYPE(USER_CFG_ADDRESS_MODE), 205 | /// Duration before regenerate the random private address when privacy is enabled 206 | .renew_dur = 15000, // 15000 * 10ms = 150s is the minimum value 207 | 208 | /*********************** 209 | * Privacy configuration 210 | *********************** 211 | */ 212 | 213 | /// Private static address 214 | // NOTE: The address shall comply with the following requirements: 215 | // - the two most significant bits of the address shall be equal to 1, 216 | // - all the remaining bits of the address shall NOT be equal to 1, 217 | // - all the remaining bits of the address shall NOT be equal to 0. 218 | // In case the {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} null address is used, a 219 | // random static address will be automatically generated. 220 | .addr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 221 | 222 | /// Device IRK used for resolvable random BD address generation (LSB first) 223 | .irk = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, 224 | 225 | /**************************** 226 | * ATT database configuration 227 | **************************** 228 | */ 229 | 230 | /// Attribute database configuration (@see enum gapm_att_cfg_flag) 231 | /// 7 6 5 4 3 2 1 0 232 | /// +-----+-----+----+-----+-----+----+----+----+ 233 | /// | DBG | RFU | SC | PCP | APP_PERM |NAME_PERM| 234 | /// +-----+-----+----+-----+-----+----+----+----+ 235 | /// - Bit [0-1]: Device Name write permission requirements for peer device (@see device_name_write_perm) 236 | /// - Bit [2-3]: Device Appearance write permission requirements for peer device (@see device_appearance_write_perm) 237 | /// - Bit [4] : Slave Preferred Connection Parameters present 238 | /// - Bit [5] : Service change feature present in GATT attribute database. 239 | /// - Bit [6] : Reserved 240 | /// - Bit [7] : Enable Debug Mode 241 | .att_cfg = GAPM_MASK_ATT_SVC_CHG_EN, 242 | 243 | /// GAP service start handle 244 | .gap_start_hdl = 0, 245 | 246 | /// GATT service start handle 247 | .gatt_start_hdl = 0, 248 | 249 | /************************************************** 250 | * Data packet length extension configuration (4.2) 251 | ************************************************** 252 | */ 253 | 254 | /// Maximal MPS 255 | .max_mps = 0, 256 | 257 | /// Maximal Tx octets (connInitialMaxTxOctets value, as defined in 4.2 Specification) 258 | .max_txoctets = 0, 259 | 260 | /// Maximal Tx time (connInitialMaxTxTime value, as defined in 4.2 Specification) 261 | .max_txtime = 0, 262 | }; 263 | 264 | /* 265 | **************************************************************************************** 266 | * 267 | * Parameter update configuration 268 | * 269 | **************************************************************************************** 270 | */ 271 | static const struct connection_param_configuration user_connection_param_conf = { 272 | /// Connection interval minimum measured in ble double slots (1.25ms) 273 | /// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots 274 | .intv_min = MS_TO_DOUBLESLOTS(100), 275 | 276 | /// Connection interval maximum measured in ble double slots (1.25ms) 277 | /// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots 278 | .intv_max = MS_TO_DOUBLESLOTS(200), 279 | 280 | /// Latency measured in connection events 281 | .latency = 0, 282 | 283 | /// Supervision timeout measured in timer units (10 ms) 284 | /// use the macro MS_TO_TIMERUNITS to convert from milliseconds (ms) to timer units 285 | .time_out = MS_TO_TIMERUNITS(1250), 286 | 287 | /// Minimum Connection Event Duration measured in ble double slots (1.25ms) 288 | /// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots 289 | .ce_len_min = MS_TO_DOUBLESLOTS(0), 290 | 291 | /// Maximum Connection Event Duration measured in ble double slots (1.25ms) 292 | /// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots 293 | .ce_len_max = MS_TO_DOUBLESLOTS(0), 294 | }; 295 | 296 | /* 297 | **************************************************************************************** 298 | * 299 | * Default handlers configuration (applies only for @app_default_handlers.c) 300 | * 301 | **************************************************************************************** 302 | */ 303 | static const struct default_handlers_configuration user_default_hnd_conf = { 304 | // Configure the advertise operation used by the default handlers 305 | // Possible values: 306 | // - DEF_ADV_FOREVER 307 | // - DEF_ADV_WITH_TIMEOUT 308 | .adv_scenario = DEF_ADV_FOREVER, 309 | 310 | // Configure the advertise period in case of DEF_ADV_WITH_TIMEOUT. 311 | // It is measured in timer units (3 min). Use MS_TO_TIMERUNITS macro to convert 312 | // from milliseconds (ms) to timer units. 313 | .advertise_period = MS_TO_TIMERUNITS(180000), 314 | 315 | // Configure the security start operation of the default handlers 316 | // if the security is enabled (CFG_APP_SECURITY) 317 | // Possible values: 318 | // - DEF_SEC_REQ_NEVER 319 | // - DEF_SEC_REQ_ON_CONNECT 320 | .security_request_scenario = DEF_SEC_REQ_NEVER 321 | }; 322 | 323 | /* 324 | **************************************************************************************** 325 | * 326 | * Central configuration (not used by current example) 327 | * 328 | **************************************************************************************** 329 | */ 330 | static const struct central_configuration user_central_conf = { 331 | /// GAPM requested operation: 332 | /// - GAPM_CONNECTION_DIRECT: Direct connection operation 333 | /// - GAPM_CONNECTION_AUTO: Automatic connection operation 334 | /// - GAPM_CONNECTION_SELECTIVE: Selective connection operation 335 | /// - GAPM_CONNECTION_NAME_REQUEST: Name Request operation (requires to start a direct 336 | /// connection) 337 | .code = GAPM_CONNECTION_DIRECT, 338 | 339 | /// Own BD address source of the device: 340 | .addr_src = APP_CFG_ADDR_SRC(USER_CFG_ADDRESS_MODE), 341 | 342 | /// Scan interval 343 | .scan_interval = 0x180, 344 | 345 | /// Scan window size 346 | .scan_window = 0x160, 347 | 348 | /// Minimum of connection interval 349 | .con_intv_min = 100, 350 | 351 | /// Maximum of connection interval 352 | .con_intv_max = 100, 353 | 354 | /// Connection latency 355 | .con_latency = 0, 356 | 357 | /// Link supervision timeout 358 | .superv_to = 0x1F4, 359 | 360 | /// Minimum CE length 361 | .ce_len_min = 0, 362 | 363 | /// Maximum CE length 364 | .ce_len_max = 0x5, 365 | 366 | /************************************************************************************** 367 | * Peer device information (maximum number of peers = 8) 368 | ************************************************************************************** 369 | */ 370 | 371 | /// BD Address of device 372 | .peer_addr_0 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 373 | 374 | /// Address type of the device 0=public/1=random 375 | .peer_addr_0_type = 0, 376 | 377 | /// BD Address of device 378 | .peer_addr_1 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 379 | 380 | /// Address type of the device 0=public/1=random 381 | .peer_addr_1_type = 0, 382 | 383 | /// BD Address of device 384 | .peer_addr_2 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 385 | 386 | /// Address type of the device 0=public/1=random 387 | .peer_addr_2_type = 0, 388 | 389 | /// BD Address of device 390 | .peer_addr_3 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 391 | 392 | /// Address type of the device 0=public/1=random 393 | .peer_addr_3_type = 0, 394 | 395 | /// BD Address of device 396 | .peer_addr_4 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 397 | 398 | /// Address type of the device 0=public/1=random 399 | .peer_addr_4_type = 0, 400 | 401 | /// BD Address of device 402 | .peer_addr_5 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 403 | 404 | /// Address type of the device 0=public/1=random 405 | .peer_addr_5_type = 0, 406 | 407 | /// BD Address of device 408 | .peer_addr_6 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 409 | 410 | /// Address type of the device 0=public/1=random 411 | .peer_addr_6_type = 0, 412 | 413 | /// BD Address of device 414 | .peer_addr_7 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 415 | 416 | /// Address type of the device 0=public/1=random 417 | .peer_addr_7_type = 0, 418 | }; 419 | 420 | /* 421 | **************************************************************************************** 422 | * 423 | * Security related configuration 424 | * 425 | **************************************************************************************** 426 | */ 427 | static const struct security_configuration user_security_conf = { 428 | // IO Capabilities 429 | #if defined (USER_CFG_FEAT_IO_CAP) 430 | .iocap = USER_CFG_FEAT_IO_CAP, 431 | #else 432 | .iocap = GAP_IO_CAP_NO_INPUT_NO_OUTPUT, 433 | #endif 434 | 435 | // OOB Capabilities 436 | #if defined (USER_CFG_FEAT_OOB) 437 | .oob = USER_CFG_FEAT_OOB, 438 | #else 439 | .oob = GAP_OOB_AUTH_DATA_NOT_PRESENT, 440 | #endif 441 | 442 | // Authentication Requirements 443 | #if defined (USER_CFG_FEAT_AUTH_REQ) 444 | .auth = USER_CFG_FEAT_AUTH_REQ, 445 | #else 446 | .auth = GAP_AUTH_NONE, 447 | #endif 448 | 449 | // LTK size 450 | #if defined (USER_CFG_FEAT_KEY_SIZE) 451 | .key_size = USER_CFG_FEAT_KEY_SIZE, 452 | #else 453 | .key_size = KEY_LEN, 454 | #endif 455 | 456 | // Initiator key distribution 457 | #if defined (USER_CFG_FEAT_INIT_KDIST) 458 | .ikey_dist = USER_CFG_FEAT_INIT_KDIST, 459 | #else 460 | .ikey_dist = GAP_KDIST_NONE, 461 | #endif 462 | 463 | // Responder key distribution 464 | #if defined (USER_CFG_FEAT_RESP_KDIST) 465 | .rkey_dist = USER_CFG_FEAT_RESP_KDIST, 466 | #else 467 | .rkey_dist = GAP_KDIST_ENCKEY, 468 | #endif 469 | 470 | // Security requirements (minimum security level) 471 | #if defined (USER_CFG_FEAT_SEC_REQ) 472 | .sec_req = USER_CFG_FEAT_SEC_REQ, 473 | #else 474 | .sec_req = GAP_NO_SEC, 475 | #endif 476 | }; 477 | 478 | #endif // _USER_CONFIG_H_ 479 | -------------------------------------------------------------------------------- /Libraries/RTT/SEGGER_SYSVIEW.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * SEGGER Microcontroller GmbH * 3 | * The Embedded Experts * 4 | ********************************************************************** 5 | * * 6 | * (c) 1995 - 2019 SEGGER Microcontroller GmbH * 7 | * * 8 | * www.segger.com Support: support@segger.com * 9 | * * 10 | ********************************************************************** 11 | * * 12 | * SEGGER SystemView * Real-time application analysis * 13 | * * 14 | ********************************************************************** 15 | * * 16 | * All rights reserved. * 17 | * * 18 | * SEGGER strongly recommends to not make any changes * 19 | * to or modify the source code of this software in order to stay * 20 | * compatible with the SystemView and RTT protocol, and J-Link. * 21 | * * 22 | * Redistribution and use in source and binary forms, with or * 23 | * without modification, are permitted provided that the following * 24 | * condition is met: * 25 | * * 26 | * o Redistributions of source code must retain the above copyright * 27 | * notice, this condition and the following disclaimer. * 28 | * * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 30 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * 31 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * 32 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * 33 | * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * 34 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * 36 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * 37 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 38 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * 40 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 41 | * DAMAGE. * 42 | * * 43 | ********************************************************************** 44 | * * 45 | * SystemView version: 3.20 * 46 | * * 47 | ********************************************************************** 48 | -------------------------- END-OF-HEADER ----------------------------- 49 | File : SEGGER_SYSVIEW.h 50 | Purpose : System visualization API. 51 | Revision: $Rev: 21292 $ 52 | */ 53 | 54 | #ifndef SEGGER_SYSVIEW_H 55 | #define SEGGER_SYSVIEW_H 56 | 57 | /********************************************************************* 58 | * 59 | * #include Section 60 | * 61 | ********************************************************************** 62 | */ 63 | 64 | #include "SEGGER.h" 65 | #include "SEGGER_SYSVIEW_ConfDefaults.h" 66 | 67 | #ifdef __cplusplus 68 | extern "C" { 69 | #endif 70 | 71 | 72 | /********************************************************************* 73 | * 74 | * Defines, fixed 75 | * 76 | ********************************************************************** 77 | */ 78 | 79 | #define SEGGER_SYSVIEW_MAJOR 3 80 | #define SEGGER_SYSVIEW_MINOR 10 81 | #define SEGGER_SYSVIEW_REV 0 82 | #define SEGGER_SYSVIEW_VERSION ((SEGGER_SYSVIEW_MAJOR * 10000) + (SEGGER_SYSVIEW_MINOR * 100) + SEGGER_SYSVIEW_REV) 83 | 84 | #define SEGGER_SYSVIEW_INFO_SIZE 9 // Minimum size, which has to be reserved for a packet. 1-2 byte of message type, 0-2 byte of payload length, 1-5 bytes of timestamp. 85 | #define SEGGER_SYSVIEW_QUANTA_U32 5 // Maximum number of bytes to encode a U32, should be reserved for each 32-bit value in a packet. 86 | 87 | #define SEGGER_SYSVIEW_LOG (0u) 88 | #define SEGGER_SYSVIEW_WARNING (1u) 89 | #define SEGGER_SYSVIEW_ERROR (2u) 90 | #define SEGGER_SYSVIEW_FLAG_APPEND (1u << 6) 91 | 92 | #define SEGGER_SYSVIEW_PREPARE_PACKET(p) (p) + 4 93 | // 94 | // SystemView events. First 32 IDs from 0 .. 31 are reserved for these 95 | // 96 | #define SYSVIEW_EVTID_NOP 0 // Dummy packet. 97 | #define SYSVIEW_EVTID_OVERFLOW 1 98 | #define SYSVIEW_EVTID_ISR_ENTER 2 99 | #define SYSVIEW_EVTID_ISR_EXIT 3 100 | #define SYSVIEW_EVTID_TASK_START_EXEC 4 101 | #define SYSVIEW_EVTID_TASK_STOP_EXEC 5 102 | #define SYSVIEW_EVTID_TASK_START_READY 6 103 | #define SYSVIEW_EVTID_TASK_STOP_READY 7 104 | #define SYSVIEW_EVTID_TASK_CREATE 8 105 | #define SYSVIEW_EVTID_TASK_INFO 9 106 | #define SYSVIEW_EVTID_TRACE_START 10 107 | #define SYSVIEW_EVTID_TRACE_STOP 11 108 | #define SYSVIEW_EVTID_SYSTIME_CYCLES 12 109 | #define SYSVIEW_EVTID_SYSTIME_US 13 110 | #define SYSVIEW_EVTID_SYSDESC 14 111 | #define SYSVIEW_EVTID_MARK_START 15 112 | #define SYSVIEW_EVTID_MARK_STOP 16 113 | #define SYSVIEW_EVTID_IDLE 17 114 | #define SYSVIEW_EVTID_ISR_TO_SCHEDULER 18 115 | #define SYSVIEW_EVTID_TIMER_ENTER 19 116 | #define SYSVIEW_EVTID_TIMER_EXIT 20 117 | #define SYSVIEW_EVTID_STACK_INFO 21 118 | #define SYSVIEW_EVTID_MODULEDESC 22 119 | 120 | #define SYSVIEW_EVTID_INIT 24 121 | #define SYSVIEW_EVTID_NAME_RESOURCE 25 122 | #define SYSVIEW_EVTID_PRINT_FORMATTED 26 123 | #define SYSVIEW_EVTID_NUMMODULES 27 124 | #define SYSVIEW_EVTID_END_CALL 28 125 | #define SYSVIEW_EVTID_TASK_TERMINATE 29 126 | 127 | #define SYSVIEW_EVTID_EX 31 128 | // 129 | // SystemView extended events. Sent with ID 31. 130 | // 131 | #define SYSVIEW_EVTID_EX_MARK 0 132 | #define SYSVIEW_EVTID_EX_NAME_MARKER 1 133 | // 134 | // Event masks to disable/enable events 135 | // 136 | #define SYSVIEW_EVTMASK_NOP (1 << SYSVIEW_EVTID_NOP) 137 | #define SYSVIEW_EVTMASK_OVERFLOW (1 << SYSVIEW_EVTID_OVERFLOW) 138 | #define SYSVIEW_EVTMASK_ISR_ENTER (1 << SYSVIEW_EVTID_ISR_ENTER) 139 | #define SYSVIEW_EVTMASK_ISR_EXIT (1 << SYSVIEW_EVTID_ISR_EXIT) 140 | #define SYSVIEW_EVTMASK_TASK_START_EXEC (1 << SYSVIEW_EVTID_TASK_START_EXEC) 141 | #define SYSVIEW_EVTMASK_TASK_STOP_EXEC (1 << SYSVIEW_EVTID_TASK_STOP_EXEC) 142 | #define SYSVIEW_EVTMASK_TASK_START_READY (1 << SYSVIEW_EVTID_TASK_START_READY) 143 | #define SYSVIEW_EVTMASK_TASK_STOP_READY (1 << SYSVIEW_EVTID_TASK_STOP_READY) 144 | #define SYSVIEW_EVTMASK_TASK_CREATE (1 << SYSVIEW_EVTID_TASK_CREATE) 145 | #define SYSVIEW_EVTMASK_TASK_INFO (1 << SYSVIEW_EVTID_TASK_INFO) 146 | #define SYSVIEW_EVTMASK_TRACE_START (1 << SYSVIEW_EVTID_TRACE_START) 147 | #define SYSVIEW_EVTMASK_TRACE_STOP (1 << SYSVIEW_EVTID_TRACE_STOP) 148 | #define SYSVIEW_EVTMASK_SYSTIME_CYCLES (1 << SYSVIEW_EVTID_SYSTIME_CYCLES) 149 | #define SYSVIEW_EVTMASK_SYSTIME_US (1 << SYSVIEW_EVTID_SYSTIME_US) 150 | #define SYSVIEW_EVTMASK_SYSDESC (1 << SYSVIEW_EVTID_SYSDESC) 151 | #define SYSVIEW_EVTMASK_USER_START (1 << SYSVIEW_EVTID_USER_START) 152 | #define SYSVIEW_EVTMASK_USER_STOP (1 << SYSVIEW_EVTID_USER_STOP) 153 | #define SYSVIEW_EVTMASK_IDLE (1 << SYSVIEW_EVTID_IDLE) 154 | #define SYSVIEW_EVTMASK_ISR_TO_SCHEDULER (1 << SYSVIEW_EVTID_ISR_TO_SCHEDULER) 155 | #define SYSVIEW_EVTMASK_TIMER_ENTER (1 << SYSVIEW_EVTID_TIMER_ENTER) 156 | #define SYSVIEW_EVTMASK_TIMER_EXIT (1 << SYSVIEW_EVTID_TIMER_EXIT) 157 | #define SYSVIEW_EVTMASK_STACK_INFO (1 << SYSVIEW_EVTID_STACK_INFO) 158 | #define SYSVIEW_EVTMASK_MODULEDESC (1 << SYSVIEW_EVTID_MODULEDESC) 159 | 160 | #define SYSVIEW_EVTMASK_INIT (1 << SYSVIEW_EVTID_INIT) 161 | #define SYSVIEW_EVTMASK_NAME_RESOURCE (1 << SYSVIEW_EVTID_NAME_RESOURCE) 162 | #define SYSVIEW_EVTMASK_PRINT_FORMATTED (1 << SYSVIEW_EVTID_PRINT_FORMATTED) 163 | #define SYSVIEW_EVTMASK_NUMMODULES (1 << SYSVIEW_EVTID_NUMMODULES) 164 | #define SYSVIEW_EVTMASK_END_CALL (1 << SYSVIEW_EVTID_END_CALL) 165 | #define SYSVIEW_EVTMASK_TASK_TERMINATE (1 << SYSVIEW_EVTID_TASK_TERMINATE) 166 | 167 | #define SYSVIEW_EVTMASK_EX (1 << SYSVIEW_EVTID_EX) 168 | 169 | #define SYSVIEW_EVTMASK_ALL_INTERRUPTS ( SYSVIEW_EVTMASK_ISR_ENTER \ 170 | | SYSVIEW_EVTMASK_ISR_EXIT \ 171 | | SYSVIEW_EVTMASK_ISR_TO_SCHEDULER) 172 | #define SYSVIEW_EVTMASK_ALL_TASKS ( SYSVIEW_EVTMASK_TASK_START_EXEC \ 173 | | SYSVIEW_EVTMASK_TASK_STOP_EXEC \ 174 | | SYSVIEW_EVTMASK_TASK_START_READY \ 175 | | SYSVIEW_EVTMASK_TASK_STOP_READY \ 176 | | SYSVIEW_EVTMASK_TASK_CREATE \ 177 | | SYSVIEW_EVTMASK_TASK_INFO \ 178 | | SYSVIEW_EVTMASK_STACK_INFO \ 179 | | SYSVIEW_EVTMASK_TASK_TERMINATE) 180 | 181 | /********************************************************************* 182 | * 183 | * Structures 184 | * 185 | ********************************************************************** 186 | */ 187 | 188 | typedef struct { 189 | U32 TaskID; 190 | const char* sName; 191 | U32 Prio; 192 | U32 StackBase; 193 | U32 StackSize; 194 | } SEGGER_SYSVIEW_TASKINFO; 195 | 196 | typedef struct SEGGER_SYSVIEW_MODULE_STRUCT SEGGER_SYSVIEW_MODULE; 197 | 198 | struct SEGGER_SYSVIEW_MODULE_STRUCT { 199 | const char* sModule; 200 | U32 NumEvents; 201 | U32 EventOffset; 202 | void (*pfSendModuleDesc)(void); 203 | SEGGER_SYSVIEW_MODULE* pNext; 204 | }; 205 | 206 | typedef void (SEGGER_SYSVIEW_SEND_SYS_DESC_FUNC)(void); 207 | 208 | 209 | /********************************************************************* 210 | * 211 | * Global data 212 | * 213 | ********************************************************************** 214 | */ 215 | 216 | #ifdef EXTERN 217 | #undef EXTERN 218 | #endif 219 | 220 | #ifndef SEGGER_SYSVIEW_C // Defined in SEGGER_SYSVIEW.c which includes this header beside other C-files 221 | #define EXTERN extern 222 | #else 223 | #define EXTERN 224 | #endif 225 | 226 | EXTERN uint32_t SEGGER_SYSVIEW_TickCnt; 227 | EXTERN uint32_t SEGGER_SYSVIEW_InterruptId; 228 | 229 | #undef EXTERN 230 | 231 | /********************************************************************* 232 | * 233 | * API functions 234 | * 235 | ********************************************************************** 236 | */ 237 | 238 | typedef struct { 239 | U64 (*pfGetTime) (void); 240 | void (*pfSendTaskList) (void); 241 | } SEGGER_SYSVIEW_OS_API; 242 | 243 | /********************************************************************* 244 | * 245 | * Control and initialization functions 246 | */ 247 | void SEGGER_SYSVIEW_Init (U32 SysFreq, U32 CPUFreq, const SEGGER_SYSVIEW_OS_API *pOSAPI, SEGGER_SYSVIEW_SEND_SYS_DESC_FUNC pfSendSysDesc); 248 | void SEGGER_SYSVIEW_SetRAMBase (U32 RAMBaseAddress); 249 | void SEGGER_SYSVIEW_Start (void); 250 | void SEGGER_SYSVIEW_Stop (void); 251 | void SEGGER_SYSVIEW_GetSysDesc (void); 252 | void SEGGER_SYSVIEW_SendTaskList (void); 253 | void SEGGER_SYSVIEW_SendTaskInfo (const SEGGER_SYSVIEW_TASKINFO* pInfo); 254 | void SEGGER_SYSVIEW_SendSysDesc (const char* sSysDesc); 255 | int SEGGER_SYSVIEW_IsStarted (void); 256 | int SEGGER_SYSVIEW_GetChannelID (void); 257 | 258 | /********************************************************************* 259 | * 260 | * Event recording functions 261 | */ 262 | void SEGGER_SYSVIEW_RecordVoid (unsigned int EventId); 263 | void SEGGER_SYSVIEW_RecordU32 (unsigned int EventId, U32 Para0); 264 | void SEGGER_SYSVIEW_RecordU32x2 (unsigned int EventId, U32 Para0, U32 Para1); 265 | void SEGGER_SYSVIEW_RecordU32x3 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2); 266 | void SEGGER_SYSVIEW_RecordU32x4 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3); 267 | void SEGGER_SYSVIEW_RecordU32x5 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4); 268 | void SEGGER_SYSVIEW_RecordU32x6 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4, U32 Para5); 269 | void SEGGER_SYSVIEW_RecordU32x7 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4, U32 Para5, U32 Para6); 270 | void SEGGER_SYSVIEW_RecordU32x8 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4, U32 Para5, U32 Para6, U32 Para7); 271 | void SEGGER_SYSVIEW_RecordU32x9 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4, U32 Para5, U32 Para6, U32 Para7, U32 Para8); 272 | void SEGGER_SYSVIEW_RecordU32x10 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4, U32 Para5, U32 Para6, U32 Para7, U32 Para8, U32 Para9); 273 | void SEGGER_SYSVIEW_RecordString (unsigned int EventId, const char* pString); 274 | void SEGGER_SYSVIEW_RecordSystime (void); 275 | void SEGGER_SYSVIEW_RecordEnterISR (void); 276 | void SEGGER_SYSVIEW_RecordExitISR (void); 277 | void SEGGER_SYSVIEW_RecordExitISRToScheduler (void); 278 | void SEGGER_SYSVIEW_RecordEnterTimer (U32 TimerId); 279 | void SEGGER_SYSVIEW_RecordExitTimer (void); 280 | void SEGGER_SYSVIEW_RecordEndCall (unsigned int EventID); 281 | void SEGGER_SYSVIEW_RecordEndCallU32 (unsigned int EventID, U32 Para0); 282 | 283 | void SEGGER_SYSVIEW_OnIdle (void); 284 | void SEGGER_SYSVIEW_OnTaskCreate (U32 TaskId); 285 | void SEGGER_SYSVIEW_OnTaskTerminate (U32 TaskId); 286 | void SEGGER_SYSVIEW_OnTaskStartExec (U32 TaskId); 287 | void SEGGER_SYSVIEW_OnTaskStopExec (void); 288 | void SEGGER_SYSVIEW_OnTaskStartReady (U32 TaskId); 289 | void SEGGER_SYSVIEW_OnTaskStopReady (U32 TaskId, unsigned int Cause); 290 | void SEGGER_SYSVIEW_MarkStart (unsigned int MarkerId); 291 | void SEGGER_SYSVIEW_MarkStop (unsigned int MarkerId); 292 | void SEGGER_SYSVIEW_Mark (unsigned int MarkerId); 293 | void SEGGER_SYSVIEW_NameMarker (unsigned int MarkerId, const char* sName); 294 | 295 | void SEGGER_SYSVIEW_NameResource (U32 ResourceId, const char* sName); 296 | 297 | int SEGGER_SYSVIEW_SendPacket (U8* pPacket, U8* pPayloadEnd, unsigned int EventId); 298 | 299 | /********************************************************************* 300 | * 301 | * Event parameter encoding functions 302 | */ 303 | U8* SEGGER_SYSVIEW_EncodeU32 (U8* pPayload, U32 Value); 304 | U8* SEGGER_SYSVIEW_EncodeData (U8* pPayload, const char* pSrc, unsigned int Len); 305 | U8* SEGGER_SYSVIEW_EncodeString (U8* pPayload, const char* s, unsigned int MaxLen); 306 | U8* SEGGER_SYSVIEW_EncodeId (U8* pPayload, U32 Id); 307 | U32 SEGGER_SYSVIEW_ShrinkId (U32 Id); 308 | 309 | 310 | /********************************************************************* 311 | * 312 | * Middleware module registration 313 | */ 314 | void SEGGER_SYSVIEW_RegisterModule (SEGGER_SYSVIEW_MODULE* pModule); 315 | void SEGGER_SYSVIEW_RecordModuleDescription (const SEGGER_SYSVIEW_MODULE* pModule, const char* sDescription); 316 | void SEGGER_SYSVIEW_SendModule (U8 ModuleId); 317 | void SEGGER_SYSVIEW_SendModuleDescription (void); 318 | void SEGGER_SYSVIEW_SendNumModules (void); 319 | 320 | /********************************************************************* 321 | * 322 | * printf-Style functions 323 | */ 324 | #ifndef SEGGER_SYSVIEW_EXCLUDE_PRINTF // Define in project to avoid warnings about variable parameter list 325 | void SEGGER_SYSVIEW_PrintfHostEx (const char* s, U32 Options, ...); 326 | void SEGGER_SYSVIEW_PrintfTargetEx (const char* s, U32 Options, ...); 327 | void SEGGER_SYSVIEW_PrintfHost (const char* s, ...); 328 | void SEGGER_SYSVIEW_PrintfTarget (const char* s, ...); 329 | void SEGGER_SYSVIEW_WarnfHost (const char* s, ...); 330 | void SEGGER_SYSVIEW_WarnfTarget (const char* s, ...); 331 | void SEGGER_SYSVIEW_ErrorfHost (const char* s, ...); 332 | void SEGGER_SYSVIEW_ErrorfTarget (const char* s, ...); 333 | #endif 334 | 335 | void SEGGER_SYSVIEW_Print (const char* s); 336 | void SEGGER_SYSVIEW_Warn (const char* s); 337 | void SEGGER_SYSVIEW_Error (const char* s); 338 | 339 | /********************************************************************* 340 | * 341 | * Run-time configuration functions 342 | */ 343 | void SEGGER_SYSVIEW_EnableEvents (U32 EnableMask); 344 | void SEGGER_SYSVIEW_DisableEvents (U32 DisableMask); 345 | 346 | /********************************************************************* 347 | * 348 | * Application-provided functions 349 | */ 350 | void SEGGER_SYSVIEW_Conf (void); 351 | U32 SEGGER_SYSVIEW_X_GetTimestamp (void); 352 | U32 SEGGER_SYSVIEW_X_GetInterruptId (void); 353 | 354 | void SEGGER_SYSVIEW_X_StartComm (void); 355 | void SEGGER_SYSVIEW_X_OnEventRecorded (unsigned NumBytes); 356 | 357 | #ifdef __cplusplus 358 | } 359 | #endif 360 | 361 | /********************************************************************* 362 | * 363 | * Compatibility API defines 364 | */ 365 | #define SEGGER_SYSVIEW_OnUserStart SEGGER_SYSVIEW_MarkStart 366 | #define SEGGER_SYSVIEW_OnUserStop SEGGER_SYSVIEW_MarkStop 367 | 368 | #endif 369 | 370 | /*************************** End of file ****************************/ 371 | -------------------------------------------------------------------------------- /components/config/inc/da1458x_config_advanced.h: -------------------------------------------------------------------------------- 1 | /** 2 | **************************************************************************************** 3 | * 4 | * @file da1458x_config_advanced.h 5 | * 6 | * @brief Advanced compile configuration file. 7 | * 8 | * Copyright (c) 2014-2019 Dialog Semiconductor. All rights reserved. 9 | * 10 | * This software ("Software") is owned by Dialog Semiconductor. 11 | * 12 | * By using this Software you agree that Dialog Semiconductor retains all 13 | * intellectual property and proprietary rights in and to this Software and any 14 | * use, reproduction, disclosure or distribution of the Software without express 15 | * written permission or a license agreement from Dialog Semiconductor is 16 | * strictly prohibited. This Software is solely for use on or in conjunction 17 | * with Dialog Semiconductor products. 18 | * 19 | * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE 20 | * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE 23 | * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL 24 | * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, 25 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 26 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 27 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 28 | * OF THE SOFTWARE. 29 | * 30 | **************************************************************************************** 31 | */ 32 | 33 | #ifndef _DA1458X_CONFIG_ADVANCED_H_ 34 | #define _DA1458X_CONFIG_ADVANCED_H_ 35 | 36 | #include "da1458x_stack_config.h" 37 | 38 | /****************************************************************************************************************/ 39 | /* Low Power clock selection. */ 40 | /* -LP_CLK_XTAL32 External XTAL32 oscillator */ 41 | /* -LP_CLK_RCX20 Internal RCX20 clock */ 42 | /* -LP_CLK_FROM_OTP Use the selection in the corresponding field of OTP Header */ 43 | /****************************************************************************************************************/ 44 | #define CFG_LP_CLK LP_CLK_RCX20 45 | 46 | /****************************************************************************************************************/ 47 | /* Periodic wakeup period to poll GTL iface. Time in msec. */ 48 | /****************************************************************************************************************/ 49 | #define CFG_MAX_SLEEP_DURATION_PERIODIC_WAKEUP_MS 500 // 0.5s 50 | 51 | /****************************************************************************************************************/ 52 | /* Periodic wakeup period if GTL iface is not enabled. Time in msec. */ 53 | /****************************************************************************************************************/ 54 | #define CFG_MAX_SLEEP_DURATION_EXTERNAL_WAKEUP_MS 600000 // 600s 55 | 56 | /****************************************************************************************************************/ 57 | /* Wakeup from external processor running host application. */ 58 | /****************************************************************************************************************/ 59 | #undef CFG_EXTERNAL_WAKEUP 60 | 61 | /****************************************************************************************************************/ 62 | /* Wakeup external processor when a message is sent to GTL */ 63 | /****************************************************************************************************************/ 64 | #undef CFG_WAKEUP_EXT_PROCESSOR 65 | 66 | /****************************************************************************************************************/ 67 | /* Enables True Random Number Generator. A true random number, generated at system initialization, is used to */ 68 | /* seed the C standard library random number generator. The following supported options provide a trade-off */ 69 | /* between code size and start-up latency. */ 70 | /* - undefined (or 0): TRNG is disabled. */ 71 | /* - 32: Enables TRNG with 32 Bytes Buffer. */ 72 | /* - 64: Enables TRNG with 64 Bytes Buffer. */ 73 | /* - 128: Enables TRNG with 128 Bytes Buffer. */ 74 | /* - 256: Enables TRNG with 256 Bytes Buffer. */ 75 | /* - 512: Enables TRNG with 512 Bytes Buffer. */ 76 | /* - 1024: Enables TRNG with 1024 Bytes Buffer. */ 77 | /****************************************************************************************************************/ 78 | #define CFG_TRNG (32) 79 | 80 | /****************************************************************************************************************/ 81 | /* Creation of private and public keys using Elliptic Curve Diffie Hellman algorithms. */ 82 | /* - defined: Creation of ECDH keys and secure connection feature is enabled. */ 83 | /* - undefined: Creation of ECDH keys and secure connection feature is disabled. If application does not */ 84 | /* support secure connections, it is reccomended to undefine CFG_ENABLE_SMP_SECURE in order to */ 85 | /* enable faster start-up time and reduce code size. */ 86 | /****************************************************************************************************************/ 87 | #undef CFG_ENABLE_SMP_SECURE 88 | 89 | /****************************************************************************************************************/ 90 | /* Uses ChaCha20 random number generator instead of the C standard library random number generator. */ 91 | /****************************************************************************************************************/ 92 | #undef CFG_USE_CHACHA20_RAND 93 | 94 | /****************************************************************************************************************/ 95 | /* Custom heap sizes */ 96 | /****************************************************************************************************************/ 97 | #define DB_HEAP_SZ 2048 98 | // #define ENV_HEAP_SZ 4928 99 | // #define MSG_HEAP_SZ 3880 100 | // #define NON_RET_HEAP_SZ 2048 101 | 102 | /****************************************************************************************************************/ 103 | /* NVDS configuration */ 104 | /* - CFG_NVDS_TAG_BD_ADDRESS Default bdaddress. If bdaddress is written in OTP header this value is */ 105 | /* ignored */ 106 | /* - CFG_NVDS_TAG_LPCLK_DRIFT Low power clock drift. Permitted values in ppm are: */ 107 | /* + DRIFT_20PPM */ 108 | /* + DRIFT_30PPM */ 109 | /* + DRIFT_50PPM */ 110 | /* + DRIFT_75PPM */ 111 | /* + DRIFT_100PPM */ 112 | /* + DRIFT_150PPM */ 113 | /* + DRIFT_250PPM */ 114 | /* + DRIFT_500PPM Default value (500 ppm) */ 115 | /* - CFG_NVDS_TAG_BLE_CA_TIMER_DUR Channel Assessment Timer duration (Multiple of 10ms) */ 116 | /* - CFG_NVDS_TAG_BLE_CRA_TIMER_DUR Channel Reassessment Timer duration (Multiple of CA timer duration) */ 117 | /* - CFG_NVDS_TAG_BLE_CA_MIN_RSSI Minimum RSSI Threshold */ 118 | /* - CFG_NVDS_TAG_BLE_CA_NB_PKT Number of packets to receive for statistics */ 119 | /* - CFG_NVDS_TAG_BLE_CA_NB_BAD_PKT Number of bad packets needed to remove a channel */ 120 | /****************************************************************************************************************/ 121 | #define CFG_NVDS_TAG_BD_ADDRESS {0x03, 0x69, 0x70, 0xCA, 0xEA, 0x80} 122 | 123 | #define CFG_NVDS_TAG_LPCLK_DRIFT DRIFT_500PPM 124 | #define CFG_NVDS_TAG_BLE_CA_TIMER_DUR 2000 125 | #define CFG_NVDS_TAG_BLE_CRA_TIMER_DUR 6 126 | #define CFG_NVDS_TAG_BLE_CA_MIN_RSSI 0x40 127 | #define CFG_NVDS_TAG_BLE_CA_NB_PKT 100 128 | #define CFG_NVDS_TAG_BLE_CA_NB_BAD_PKT 50 129 | 130 | /****************************************************************************************************************/ 131 | /* Enables the logging of heap memories usage. The feature can be used in development/debug mode. */ 132 | /* Application must be executed in Keil debugger environment and "da14531.lib" must be replaced with */ 133 | /* "da14531_with_heap_logging.lib" in project structure under sdk_arch. Developer must stop execution */ 134 | /* and type disp_heaplog in debugger's command window. Heap memory statistics will be displayed on window */ 135 | /****************************************************************************************************************/ 136 | #undef CFG_LOG_HEAP_USAGE 137 | 138 | /****************************************************************************************************************/ 139 | /* Enables the BLE statistics measurement feature. */ 140 | /****************************************************************************************************************/ 141 | #undef CFG_BLE_METRICS 142 | 143 | /****************************************************************************************************************/ 144 | /* Output the Hardfault arguments to serial/UART interface. */ 145 | /****************************************************************************************************************/ 146 | #undef CFG_PRODUCTION_DEBUG_OUTPUT 147 | 148 | /****************************************************************************************************************/ 149 | /* Maximum supported TX data packet length (supportedMaxTxOctets value, as defined in 4.2 Specification). */ 150 | /* Range: 27 - 251 octets. */ 151 | /* NOTE 1: Even number of octets are not supported. A selected even number will be automatically converted to */ 152 | /* the next odd one. */ 153 | /* NOTE 2: The supportedMaxTxTime value is automatically calculated by the ROM code, according to the following */ 154 | /* equation: */ 155 | /* supportedMaxTxTime = (supportedMaxTxOctets + 11 + 3 ) * 8 */ 156 | /* Range: 328 - 2120 usec. */ 157 | /****************************************************************************************************************/ 158 | #define CFG_MAX_TX_PACKET_LENGTH (251) 159 | 160 | /****************************************************************************************************************/ 161 | /* Maximum supported RX data packet length (supportedMaxRxOctets value, as defined in 4.2 Specification). */ 162 | /* Range: 27 - 251 octets. */ 163 | /* NOTE 1: Even number of octets are not supported. A selected even number will be automatically converted to */ 164 | /* the next odd one. */ 165 | /* NOTE 2: The supportedMaxRxTime value is automatically calculated by the ROM code, according to the following */ 166 | /* equation: */ 167 | /* supportedMaxRxTime = (supportedMaxRxOctets + 11 + 3 ) * 8 */ 168 | /* Range: 328 - 2120 usec. */ 169 | /****************************************************************************************************************/ 170 | #define CFG_MAX_RX_PACKET_LENGTH (251) 171 | 172 | /****************************************************************************************************************/ 173 | /* Select external application/host transport layer: */ 174 | /* - 0 = GTL (auto) */ 175 | /* - 1 = HCI (auto) */ 176 | /* - 8 = GTL (fixed) */ 177 | /* - 9 = HCI (fixed) */ 178 | /****************************************************************************************************************/ 179 | #define CFG_USE_H4TL (0) 180 | 181 | /****************************************************************************************************************/ 182 | /* Duplicate filter max value for the scan report list. The maximum value shall be 100. */ 183 | /****************************************************************************************************************/ 184 | #define CFG_BLE_DUPLICATE_FILTER_MAX (10) 185 | 186 | /****************************************************************************************************************/ 187 | /* Duplicate filter flag for the scan report list. This flag controls what will be reported if the */ 188 | /* CFG_BLE_DUPLICATE_FILTER_MAX number is exceeded. */ 189 | /* - If the flag is defined, the extra devices are considered to be in the list and will not be reported. */ 190 | /****************************************************************************************************************/ 191 | #undef CFG_BLE_DUPLICATE_FILTER_FOUND 192 | 193 | /****************************************************************************************************************/ 194 | /* Resolving list maximum size. */ 195 | /****************************************************************************************************************/ 196 | #define CFG_LLM_RESOLVING_LIST_MAX LLM_RESOLVING_LIST_MAX 197 | 198 | /****************************************************************************************************************/ 199 | /* Enables automatic data packet length negotiation. */ 200 | /* NOTE: Enable only if peer device supports data length extension!! */ 201 | /****************************************************************************************************************/ 202 | #undef AUTO_DATA_LENGTH_NEGOTIATION_UPON_NEW_CONNECTION 203 | 204 | /****************************************************************************************************************/ 205 | /* Maximum retention memory in bytes. The base address of the retention data is calculated from the selected */ 206 | /* size. */ 207 | /****************************************************************************************************************/ 208 | #define CFG_RET_DATA_SIZE (2048) 209 | 210 | /****************************************************************************************************************/ 211 | /* Maximum uninitialized retained data required by the application. */ 212 | /****************************************************************************************************************/ 213 | #define CFG_RET_DATA_UNINIT_SIZE (0) 214 | 215 | /****************************************************************************************************************/ 216 | /* The Keil scatter file may be provided by the user. If the user provides his own scatter file, the system has */ 217 | /* to be aware which RAM blocks has to retain. The 4th RAM block is always retained, since it contains the ROM */ 218 | /* data. */ 219 | /* - CFG_RETAIN_RAM_1_BLOCK: if defined, the 1st RAM block must be retained. */ 220 | /* - CFG_RETAIN_RAM_2_BLOCK: if defined, the 2nd RAM block must be retained. */ 221 | /* - CFG_RETAIN_RAM_3_BLOCK: if defined, the 3rd RAM block must be retained. */ 222 | /* */ 223 | /* If the CFG_CUSTOM_SCATTER_FILE flag is undefined, the system knows which blocks to retain based on the */ 224 | /* default SDK scatter file. */ 225 | /****************************************************************************************************************/ 226 | #undef CFG_CUSTOM_SCATTER_FILE 227 | #ifdef CFG_CUSTOM_SCATTER_FILE 228 | #define CFG_RETAIN_RAM_1_BLOCK 229 | #define CFG_RETAIN_RAM_2_BLOCK 230 | #define CFG_RETAIN_RAM_3_BLOCK 231 | #endif 232 | 233 | /****************************************************************************************************************/ 234 | /* Code location selection. */ 235 | /* - CFG_CODE_LOCATION_EXT: Code is loaded from SPI flash / I2C EEPROM / UART */ 236 | /* - CFG_CODE_LOCATION_OTP: Code is burned in the OTP */ 237 | /* The above options are mutually exclusive and exactly one of them must be enabled. */ 238 | /****************************************************************************************************************/ 239 | #define CFG_CODE_LOCATION_EXT 240 | #undef CFG_CODE_LOCATION_OTP 241 | 242 | /****************************************************************************************************************/ 243 | /* Temperature range selection. */ 244 | /* - CFG_HIGH_TEMPERATURE: Device is configured to operate at high temperature range (-40C to +105C). */ 245 | /* - CFG_AMB_TEMPERATURE: Device is configured to operate at ambient temperature range (-40C to +40C). */ 246 | /* - CFG_MID_TEMPERATURE: Device is configured to operate at mid temperature range (-40C to +60C). */ 247 | /* - CFG_EXT_TEMPERATURE: Device is configured to operate at ext temperature range (-40C to +85C). */ 248 | /* NOTE 1: High temperature support is not compatible with power optimizations. User shall undefine the */ 249 | /* CFG_POWER_OPTIMIZATIONS flag, if device is to support the high temperature range feature. */ 250 | /****************************************************************************************************************/ 251 | #define CFG_AMB_TEMPERATURE 252 | 253 | /****************************************************************************************************************/ 254 | /* Disable quadrature decoder on start up. The quadrature decoder is by default enabled on system power up and */ 255 | /* it may count events. This leads to WKUP_QUADEC_IRQn pending interrupts. */ 256 | /****************************************************************************************************************/ 257 | #define CFG_DISABLE_QUADEC_ON_START_UP 258 | 259 | #endif // _DA1458X_CONFIG_ADVANCED_H_ 260 | --------------------------------------------------------------------------------