ble_ancs_c Apple Notification Service client ble_ans_c Alert Notification Service Client ble_bas Battery Service ble_bas_c Battery Service Client ble_bps Blood Pressure Service ble_cscs Cycling Speed and Cadence Service ble_cts_c Current Time Service client ble_dfu Buttonless DFU Service ble_dis Device Information Service ble_dis_c Device Information Service Client ble_escs Eddystone Configuration Service ble_gls Glucose Service ble_hids Human Interface Device Service ble_hrs Heart Rate Service ble_hrs_c Heart Rate Service Client ble_hts Health Thermometer Service ble_ias Immediate Alert Service ble_ias_c Immediate Alert Service Client ble_ipsp Internet Protocol Support Profile ble_lbs LED Button Service Server ble_lbs_c LED Button Service Client ble_lls Link Loss Service ble_nus Nordic UART Service ble_nus_c Nordic UART Service Client ble_rscs Running Speed and Cadence Service ble_rscs_c Running Speed and Cadence Service Client ble_tps TX Power Service eddystone experimental_ble_lns Location and Navigation Service experimental_ble_ots Object Transfer Service experimental_gatts_c GATT Service Client experimental_nrf_ble_cgms Continuous Glucose Monitoring Service experimental_nrf_ble_ots_c Object Transfer Service Client nrf_ble_bms Bond Management Service
nRF5 SDK: sd_power_system_off()
- Emulated System OFF Mode
- Debug Interface Mode
- Debug Mode
UART Output
<info> app: Current Time service client started. <debug> app: pm_whitelist_get returns 0 addr in whitelist and 0 irk whitelist <info> app: Fast advertising <debug> app: pm_whitelist_get returns 0 addr in whitelist and 0 irk whitelist <info> app: Slow advertising <debug> ble_cts_c: BLE event handler called with event 0x26 <debug> ble_cts_c: BLE event handler called with event 0x10 <info> app: Connected. <debug> ble_cts_c: BLE event handler called with event 0x12 <debug> ble_cts_c: BLE event handler called with event 0x12 <debug> ble_cts_c: BLE event handler called with event 0x12 <debug> ble_cts_c: BLE event handler called with event 0x19 <debug> app: pm_whitelist_get returns 0 addr in whitelist and 0 irk whitelist <info> app: Fast advertising <debug> ble_cts_c: BLE event handler called with event 0x11 <info> app: Disconnected. <debug> app: pm_whitelist_get returns 0 addr in whitelist and 0 irk whitelist <info> app: Slow advertising <debug> ble_cts_c: BLE event handler called with event 0x26
Screenshots
sd_power_system_off() doesn’t power off: it’s in Debug Mode!!
|
|
|
|
Forum
sd_power_system_off returns immediately and forces reset
Why does nRF52 hrs sdk11 example sd_power_off return 6?
Problem with emulated System OFF mode with NRF52
/* components/softdevice/s132/headers/nrf_error.h */ /* SoC error base */ #define NRF_ERROR_SOC_BASE_NUM (0x2000) /* components/softdevice/s132/headers/nrf_error_soc.h */ /* Power off should not return */ #define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) /* components/softdevice/s132/headers/nrf_soc.h */ /**@brief Puts the chip in System OFF mode. * * @retval ::NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN */ SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void));
nRF52832 Breakout Board V2.1
Installing automatically
Installing manually
Building and programming an application
nRF Connect for Desktop
nRF Connect for Desktop Download
Developing with Zephyr – Installing west
Nordic: West (Zephyr’s meta-tool) – Moving to West
Software Development Kit > nRF5 SDK v17.1.0 > Libraries > Logger module (nRF5 SDK v17.1.0)
Software Development Kit > nRF5 SDK v17.1.0 > API Reference > SDK common libraries > Logger module (nRF5 SDK v17.1.0)
UART driver – legacy layer (nRF5 SDK v17.1.0)
a
![]() |
![]() |
b
|
![]() |
Pins
![]() |
![]() |
Pin Assignments
![]() |
![]() |
Freeze, Hang, Restart
My device is freezing and restarting
UART / UARTE
Understand UART, UARTE and getting it to work with PPI
UART and UARTE difference
How to properly switch between UART pins and baud rates with nRF52 (UARTE)
No, sorry if that wasn’t clear. UARTE is Universal asynchronous receiver/transmitter (UART) with EasyDMA, so if you don’t want DMA you will have to use the UART peripheral.
| UART library, Serial Port library | |
| UART driver | provides APIs on a higher level than the HAL |
| Hardware Abstraction Layer (HAL) | simplyfy reading and writing the registers |
| UART peripheral | writing to and reading from the registers (UART = legacy peripherals, UARTE = peripherals using EasyDMA) |
Example: zerphyr/samples/bluetooth/peripheral_csc
*** Booting Zephyr OS build v2.7.99-ncs1-1 *** Bluetooth initialized Advertising successfully started Indicate VND attr 0x2ba80 (UUID 12345678-1234-5678-1234-56789abcdef1) [00:00:02.145,019] <inf> fs_nvs: 6 Sectors of 4096 bytes [00:00:02.145,050] <inf> fs_nvs: alloc wra: 0, fb0 [00:00:02.145,050] <inf> fs_nvs: data wra: 0, 5c [00:00:02.146,728] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002) [00:00:02.146,759] <inf> bt_hci_core: HW Variant: nRF52x (0x0002) [00:00:02.146,759] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 2.7 Build 99 [00:00:02.147,094] <inf> bt_hci_core: No ID address. App must call settings_load() [00:00:06.002,380] <inf> bt_hci_core: Identity: ED:CA:07:92:F1:2E (random) [00:00:06.002,410] <inf> bt_hci_core: HCI: version 5.3 (0x0c) revision 0x0000, manufacturer 0x05f1 [00:00:06.002,410] <inf> bt_hci_core: LMP: version 5.3 (0x0c) subver 0xffff Updated MTU: TX: 23 RX: 23 bytes Connected Passkey for 4E:57:AA:0F:73:AE (random): 175962 [00:01:33.121,582] <inf> hrs: HRS notifications enabled [00:02:13.982,208] <inf> bas: BAS Notifications enabled Disconnected (reason 0x13) [00:04:31.009,704] <inf> bas: BAS Notifications disabled [00:04:31.009,765] <inf> hrs: HRS notifications disabled
![]() |
![]() |
Youtube
Ellisys Bluetooth Video Series (Playlist)
Machine Learning: Support Vector Regression (SVR)
ONLINE SUPPORT VECTOR REGRESSION
github.com/MeirionHughes/libsvr, native binding of online svr
Cypherbridge Systems uSSH Secure Shell SDK
nRF5 SDK: Boards
Using the SDK with other boards (v0.9.2)
Using the SDK with other boards (v15.2.0)
|
$ grep -r BOARD_PCA10040 . ./components/boards/boards.h:#elif defined(BOARD_PCA10040) ./examples/peripheral/blinky/pca10040/s132/ses/blinky_pca10040_s132.emProject: c_preprocessor_definitions=" BOARD_PCA10040; BSP_DEFINES_ONLY; CONFIG_GPIO_AS_PINRESET; FLOAT_ABI_HARD; INITIALIZE_USER_SECTIONS; NO_VTOR_CONFIG; NRF52; NRF52832_XXAA; NRF52_PAN_74; NRF_SD_BLE_API_VERSION=6; S132; SOFTDEVICE_PRESENT;" $ grep -r "CFLAGS += -DBOARD_PCA10040" . ./examples/peripheral/blinky/pca10040e/mbr/armgcc/Makefile:CFLAGS += -DBOARD_PCA10040
nRF5 SDK Preprocessor Magic
#include <stdint.h>
#include <stddef.h>
typedef uint32_t ret_code_t;
typedef uint32_t (*nrf_log_timestamp_func_t)(void);
typedef enum
{
NRF_LOG_SEVERITY_NONE,
NRF_LOG_SEVERITY_ERROR,
NRF_LOG_SEVERITY_WARNING,
NRF_LOG_SEVERITY_INFO,
NRF_LOG_SEVERITY_DEBUG,
NRF_LOG_SEVERITY_INFO_RAW, /* Artificial level to pass information about skipping string postprocessing.*/
} nrf_log_severity_t;
typedef struct
{
const char * p_module_name; ///< Module or instance name.
uint8_t info_color_id; ///< Color code of info messages.
uint8_t debug_color_id; ///< Color code of debug messages.
nrf_log_severity_t compiled_lvl; ///< Compiled highest severity level.
nrf_log_severity_t initial_lvl; ///< Severity level for given module or instance set on backend initialization.
} nrf_log_module_const_data_t;
#define _CONST const
#define CONCAT_2(p1, p2) CONCAT_2_(p1, p2)
#define CONCAT_2_(p1, p2) p1##p2
#define CONCAT_3(p1, p2, p3) CONCAT_3_(p1, p2, p3)
#define CONCAT_3_(p1, p2, p3) p1##p2##p3
#define STRINGIFY_(val) #val
#define STRINGIFY(val) STRINGIFY_(val)
#define GET_VA_ARG_1(...) GET_VA_ARG_1_(__VA_ARGS__, )
#define GET_VA_ARG_1_(a1, ...) a1
#define GET_ARGS_AFTER_1(...) GET_ARGS_AFTER_1_(__VA_ARGS__, )
#define GET_ARGS_AFTER_1_(a1, ...) __VA_ARGS__
#define NRF_SECTION_ITEM_REGISTER(section_name, section_var) \
section_var __attribute__ ((section("." STRINGIFY(section_name)))) __attribute__((used))
#define NRF_LOG_ITEM_DATA(_name) CONCAT_3(m_nrf_log_,_name,_logs_data)
#define NRF_LOG_ITEM_DATA_DYNAMIC(_name) CONCAT_2(NRF_LOG_ITEM_DATA(_name),_dynamic)
#define NRF_LOG_ITEM_DATA_FILTER(_name) CONCAT_2(NRF_LOG_ITEM_DATA(_name),_filter)
#define NRF_LOG_ITEM_DATA_CONST(_name) CONCAT_2(NRF_LOG_ITEM_DATA(_name),_const)
#define NRF_LOG_DYNAMIC_SECTION_NAME(_module_name) CONCAT_2(log_dynamic_data_,_module_name)
#define NRF_LOG_FILTER_SECTION_NAME(_module_name) CONCAT_2(log_filter_data_,_module_name)
#define NRF_LOG_CONST_SECTION_NAME(_module_name) CONCAT_2(log_const_data_,_module_name)
#define NRF_LOG_INTERNAL_CONST_ITEM_REGISTER( \
_name, _str_name, _info_color, _debug_color, _initial_lvl, _compiled_lvl) \
NRF_SECTION_ITEM_REGISTER(NRF_LOG_CONST_SECTION_NAME(_name), \
_CONST nrf_log_module_const_data_t NRF_LOG_ITEM_DATA_CONST(_name)) = { \
.p_module_name = _str_name, \
.info_color_id = (_info_color), \
.debug_color_id = (_debug_color), \
.compiled_lvl = (nrf_log_severity_t)(_compiled_lvl), \
.initial_lvl = (nrf_log_severity_t)(_initial_lvl), \
}
#define NRF_LOG_INTERNAL_ITEM_REGISTER( \
_name, _str_name, _info_color, _debug_color, _initial_lvl, _compiled_lvl) \
NRF_LOG_INTERNAL_CONST_ITEM_REGISTER(_name, \
_str_name, \
_info_color, \
_debug_color, \
_initial_lvl, \
_compiled_lvl)
#define NRF_LOG_INTERNAL_MODULE_REGISTER() \
NRF_LOG_INTERNAL_ITEM_REGISTER(NRF_LOG_MODULE_NAME, \
STRINGIFY(NRF_LOG_MODULE_NAME), \
NRF_LOG_INFO_COLOR, \
NRF_LOG_DEBUG_COLOR, \
NRF_LOG_INITIAL_LEVEL, \
COMPILED_LOG_LEVEL)
#define NRF_LOG_MODULE_REGISTER() NRF_LOG_INTERNAL_MODULE_REGISTER()
#define NRF_LOG_INTERNAL_INIT(...) \
nrf_log_init(GET_VA_ARG_1(__VA_ARGS__), \
GET_VA_ARG_1(GET_ARGS_AFTER_1(__VA_ARGS__, LOG_TIMESTAMP_DEFAULT_FREQUENCY)))
#define NRF_LOG_INIT(...) NRF_LOG_INTERNAL_INIT(__VA_ARGS__)
#define NRF_LOG_MODULE_NAME app
#define NRF_LOG_INFO_COLOR NRF_LOG_COLOR_DEFAULT
#define NRF_LOG_DEBUG_COLOR NRF_LOG_COLOR_DEFAULT
#define NRF_LOG_INITIAL_LEVEL NRF_LOG_LEVEL
#define NRF_LOG_LEVEL NRF_LOG_DEFAULT_LEVEL
#define COMPILED_LOG_LEVEL NRF_LOG_LEVEL
#define LOG_TIMESTAMP_DEFAULT_FREQUENCY NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY
#define NRF_LOG_COLOR_DEFAULT 0
#define NRF_LOG_DEFAULT_LEVEL 3
#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0
NRF_LOG_MODULE_REGISTER();
ret_code_t nrf_log_init(nrf_log_timestamp_func_t timestamp_func, uint32_t timestamp_freq)
{
(void)NRF_LOG_ITEM_DATA_CONST(app);
return 0;
}
static void log_init(void)
{
ret_code_t err_code = NRF_LOG_INIT(NULL);
}
int main(int argc, char *argv[])
{
log_init();
return 0;
}
const nrf_log_module_const_data_t m_nrf_log_app_logs_data_const
__attribute__ ((section("." "log_const_data_app")))
__attribute__((used)) = {
.p_module_name = "app",
.info_color_id = (0),
.debug_color_id = (0),
.compiled_lvl = (nrf_log_severity_t)(3),
.initial_lvl = (nrf_log_severity_t)(3),
};
ret_code_t nrf_log_init(nrf_log_timestamp_func_t timestamp_func, uint32_t timestamp_freq)
{
(void)m_nrf_log_app_logs_data_const;
return 0;
}
static void log_init(void)
{
ret_code_t err_code = nrf_log_init(
((void *)0),
0
);
}
int main(int argc, char *argv[])
{
log_init();
return 0;
}
Segger Embedded Studio (SES) Cheat-Sheet
Programmiersprache C (C95, C99, C11, C18)
C99 Definition
NULL Pointer
C Programming/stdint.h
inttypes.h – fixed size integer types
stdint.h – integer types
Include
| NULL | stddef.h |
| size_t | stddef.h |
| uint32_t | stdint.h |
| stddef.h | NULL, size_t |
| stdbool.h | bool, true, false |
| stdint.h | uint32_t |
| limits.h | INT_MIN, UINT_MAX |
| inttypes.h | PRId32, PRIx32 |
Varianten der Programmiersprache C
Präprozessor
Stop on Preprocessor
Can gcc output C code after preprocessing?
$ gcc -E test.c
Concatenation
struct command
{
char *name;
void (*function) (void);
};
#define COMMAND(NAME) { #NAME, NAME ## _command }
struct command commands[] =
{
COMMAND (quit),
COMMAND (help),
…
};
/* === RESULT === */
struct command commands[] =
{
{ "quit", quit_command },
{ "help", help_command },
…
};
Variadic macro __VA_ARGS__
Variadic Macros
Variadic macro
#define MYLOG(FormatLiteral, ...) \
fprintf (stderr, "%s(%u): " FormatLiteral "\n", \
__FILE__, __LINE__, __VA_ARGS__)
Structs
struct (C programming language)
Struct initialization
Designated Initializer
Designated Initializers
Why does C++11 not support designated initializer lists as C99?
/* Forward declare a type "point" to be a struct. */
typedef struct point point;
/* Declare the struct with integer members x, y */
struct point {
int x;
int y;
};
/* Define a variable p of type point, and
initialize its first two members in place */
point p = {
1,
2
};
/* Define a variable p of type point, an
set members using designated initializers*/
point p = {
.y = 2,
.x = 1
};
Zephyr Project – Linux Foundation Project
Project Ressources – Videos
Zephyr: Thoughts and First Steps, Erich Styger @McuOnEclipse
Documentation
Zephyr Project Documentation
Getting Started Guide
Application Development – Building an Application
Application Development – Run an Application
LVGL
Boards
ESP32
STM32 Minimum Development Board (Blue Pill Board, Black Pill Board)
ST Nucleo F103RB
ST Nucleo F411RE
ST Nucleo G474RE
Device Tree
github.com/zephyrproject-rtos/zephyr/blob/master/dts/arm/st/g4/stm32g4.dtsi
github.com/zephyrproject-rtos/zephyr/blob/master/dts/arm/st/g4/stm32g474.dtsi
GoMCU
GoMCU – Zephyr
YouTube Playlist















