(1) 在main .c中增加如下函数
uint32_t get_rtc_counter(void)
{
return NRF_RTC1->COUNTER;
}
(2) main.c中改变如下函数:
原始调用如下:
uint32_t err_code = NRF_LOG_INIT();
改变之后如下:
uint32_t err_code = NRF_LOG_INIT(get_rtc_counter);
(3) sdk_config.h中改变如下宏定义:
原始宏定义如下:
#define NRF_LOG_USES_TIMESTAMP 0
改变之后如下:
#define NRF_LOG_USES_TIMESTAMP 1
(4) 修改之后的结果如下:
The result will be to change logs from this:
<info> app: Setting vector table to bootloader: 0x000F1000
<info> app: Setting vector table to main app: 0x00026000
<info> app: Buttonless DFU Application started.
<info> app: RTC 8211
<info> app: Received indication state 1
<info> app: Received indication state 0
to this:
[00:00:00.000,000] <info> app: Setting vector table to bootloader: 0x000F1000
[00:00:00.000,000] <info> app: Setting vector table to main app: 0x00026000
[00:00:00.440,002] <info> app: Buttonless DFU Application started.
[00:00:00.440,032] <info> app: RTC 14419
[00:00:22.580,566] <info> app: Received indication state 1
[00:00:30.905,548] <info> app: Received indication state 0