nRF5 SDK v11.0.0
Functions
UART/RTT logging

Library to output logging information over SEGGER's Real Time Transfer (RTT), UART, or raw UART. More...

Functions

uint32_t NRF_LOG_INIT (void)
 Macro for initializing the logger. More...
 
void NRF_LOG (const char *msg)
 Macro for logging null-terminated strings. More...
 
void NRF_LOG_PRINTF (const char *format_msg,...)
 Macro for logging a printf string. More...
 
void NRF_LOG_HEX (uint32_t value)
 Macro for logging an integer value as HEX. More...
 
void NRF_LOG_HEX_CHAR (uint8_t c)
 Macro for logging a single character as HEX. More...
 
int NRF_LOG_HAS_INPUT (void)
 Macro for checking if data is available in the input buffer. More...
 
uint32_t NRF_LOG_READ_INPUT (char *p_char)
 Macro for reading one character from the input buffer. More...
 

Detailed Description

Library to output logging information over SEGGER's Real Time Transfer (RTT), UART, or raw UART.

This library provides macros that call the respective functions depending on which protocol is used. Define LOG_USES_RTT=1 to enable logging over RTT, NRF_LOG_USES_UART=1 to enable logging over UART, or NRF_LOG_USES_RAW_UART=1 to enable logging over raw UART. One of these defines must be set for any of the macros to have effect. If you choose to not output information, all logging macros can be left in the code without any cost; they will just be ignored.

Function Documentation

void NRF_LOG ( const char *  msg)

Macro for logging null-terminated strings.

This function is more efficient than using printf. The null termination will not be logged.

Parameters
msgNull-terminated string.
int NRF_LOG_HAS_INPUT ( void  )

Macro for checking if data is available in the input buffer.

Note
When NRF_LOG_USES_UART is set to 1, this macro is non-blocking. If too much data is sent, some characters might be skipped.
Return values
1If characters are available to read.
0If no characters are available.
void NRF_LOG_HEX ( uint32_t  value)

Macro for logging an integer value as HEX.

The output data is formatted as, for example, 0x89ABCDEF. This function is more efficient than printf.

Note
When NRF_LOG_USES_UART is set to 1, this macro is non-blocking. If too much data is sent, some characters might be skipped.
Parameters
valueInteger value to be printed as HEX.
void NRF_LOG_HEX_CHAR ( uint8_t  c)

Macro for logging a single character as HEX.

The output string is formatted as, for example, AA.

Note
When NRF_LOG_USES_UART is set to 1, this macro is non-blocking. If too much data is sent, some characters might be skipped.
Parameters
cCharacter.
uint32_t NRF_LOG_INIT ( void  )

Macro for initializing the logger.

Return values
NRF_SUCCESSIf initialization was successful.
NRF_ERROROtherwise.
void NRF_LOG_PRINTF ( const char *  format_msg,
  ... 
)

Macro for logging a printf string.

Printf requires more processor time than other logging functions. Therefore, applications that require logging but need it to interfere as little as possible with the execution, should avoid using printf.

Note
When NRF_LOG_USES_UART is set to 1, this macro is non-blocking. If too much data is sent, some characters might be skipped.
Parameters
format_msgPrintf format string.
...Additional arguments replacing format specifiers in format_msg.
uint32_t NRF_LOG_READ_INPUT ( char *  p_char)

Macro for reading one character from the input buffer.

Parameters
[out]p_charPointer where to store the character.
Return values
NRF_SUCCESSIf the character was read out.
NRF_ERROR_INVALID_DATAIf no character could be read.

Documentation feedback | Developer Zone | Updated