nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
nrf_profiler.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef _NRF_PROFILER_H_
8#define _NRF_PROFILER_H_
9
18#include <zephyr/types.h>
19#include <zephyr/sys/util.h>
20#include <zephyr/sys/__assert.h>
21
22#ifndef CONFIG_NRF_PROFILER_MAX_NUMBER_OF_APP_EVENTS
24#define CONFIG_NRF_PROFILER_MAX_NUMBER_OF_APP_EVENTS 0
25#endif
26
27#ifndef CONFIG_NRF_PROFILER_NUMBER_OF_INTERNAL_EVENTS
29#define CONFIG_NRF_PROFILER_NUMBER_OF_INTERNAL_EVENTS 0
30#endif
31
33#define NRF_PROFILER_MAX_NUMBER_OF_APPLICATION_AND_INTERNAL_EVENTS \
34 ((CONFIG_NRF_PROFILER_MAX_NUMBER_OF_APP_EVENTS) + \
35 (CONFIG_NRF_PROFILER_NUMBER_OF_INTERNAL_EVENTS))
36
42};
43
46extern struct nrf_profiler_event_enabled_bm _nrf_profiler_event_enabled_bm;
47
48
51extern uint8_t nrf_profiler_num_events;
52
53
65};
66
67
71#ifdef CONFIG_NRF_PROFILER
73 uint8_t *payload;
75 uint8_t payload_start[CONFIG_NRF_PROFILER_CUSTOM_EVENT_BUF_LEN];
76#endif
77};
78
79
87#ifdef CONFIG_NRF_PROFILER
89#else
90static inline int nrf_profiler_init(void) {return 0; }
91#endif
92
93
96#ifdef CONFIG_NRF_PROFILER
98#else
99static inline void nrf_profiler_term(void) {}
100#endif
101
108#ifdef CONFIG_NRF_PROFILER
109const char *nrf_profiler_get_event_descr(size_t nrf_profiler_event_id);
110#else
111static inline const char *nrf_profiler_get_event_descr(size_t nrf_profiler_event_id)
112{
113 return NULL;
114}
115#endif
116
123static inline bool is_profiling_enabled(size_t nrf_profiler_event_id)
124{
125 if (IS_ENABLED(CONFIG_NRF_PROFILER)) {
126 __ASSERT_NO_MSG(nrf_profiler_event_id <
128 return atomic_test_bit(_nrf_profiler_event_enabled_bm.flags, nrf_profiler_event_id);
129 }
130 return false;
131}
132
145#ifdef CONFIG_NRF_PROFILER
146uint16_t nrf_profiler_register_event_type(const char *name, const char * const *args,
147 const enum nrf_profiler_arg *arg_types,
148 uint8_t arg_cnt);
149#else
150static inline uint16_t nrf_profiler_register_event_type(const char *name,
151 const char * const *args, const enum nrf_profiler_arg *arg_types,
152 uint8_t arg_cnt) {return 0; }
153#endif
154
155
160#ifdef CONFIG_NRF_PROFILER
162#else
163static inline void nrf_profiler_log_start(struct log_event_buf *buf) {}
164#endif
165
174#ifdef CONFIG_NRF_PROFILER
175void nrf_profiler_log_encode_uint32(struct log_event_buf *buf, uint32_t data);
176#else
177static inline void nrf_profiler_log_encode_uint32(struct log_event_buf *buf,
178 uint32_t data) {}
179#endif
180
189#ifdef CONFIG_NRF_PROFILER
190void nrf_profiler_log_encode_int32(struct log_event_buf *buf, int32_t data);
191#else
192static inline void nrf_profiler_log_encode_int32(struct log_event_buf *buf,
193 int32_t data) {}
194#endif
195
204#ifdef CONFIG_NRF_PROFILER
205void nrf_profiler_log_encode_uint16(struct log_event_buf *buf, uint16_t data);
206#else
207static inline void nrf_profiler_log_encode_uint16(struct log_event_buf *buf,
208 uint16_t data) {}
209#endif
210
219#ifdef CONFIG_NRF_PROFILER
220void nrf_profiler_log_encode_int16(struct log_event_buf *buf, int16_t data);
221#else
222static inline void nrf_profiler_log_encode_int16(struct log_event_buf *buf,
223 int16_t data) {}
224#endif
225
234#ifdef CONFIG_NRF_PROFILER
235void nrf_profiler_log_encode_uint8(struct log_event_buf *buf, uint8_t data);
236#else
237static inline void nrf_profiler_log_encode_uint8(struct log_event_buf *buf,
238 uint8_t data) {}
239#endif
240
249#ifdef CONFIG_NRF_PROFILER
250void nrf_profiler_log_encode_int8(struct log_event_buf *buf, int8_t data);
251#else
252static inline void nrf_profiler_log_encode_int8(struct log_event_buf *buf,
253 int8_t data) {}
254#endif
255
266#ifdef CONFIG_NRF_PROFILER
267void nrf_profiler_log_encode_string(struct log_event_buf *buf, const char *string);
268#else
269static inline void nrf_profiler_log_encode_string(struct log_event_buf *buf,
270 const char *string) {}
271#endif
272
273
284#ifdef CONFIG_NRF_PROFILER
286 const void *mem_address);
287#else
288static inline void nrf_profiler_log_add_mem_address(struct log_event_buf *buf,
289 const void *mem_address) {}
290#endif
291
292
306#ifdef CONFIG_NRF_PROFILER
307void nrf_profiler_log_send(struct log_event_buf *buf, uint16_t event_type_id);
308#else
309static inline void nrf_profiler_log_send(struct log_event_buf *buf,
310 uint16_t event_type_id) {}
311#endif
312
313
318#endif /* _NRF_PROFILER_H_ */
void nrf_profiler_log_encode_uint8(struct log_event_buf *buf, uint8_t data)
Encode and add uint8_t data type to a buffer.
#define NRF_PROFILER_MAX_NUMBER_OF_APPLICATION_AND_INTERNAL_EVENTS
Definition: nrf_profiler.h:33
nrf_profiler_arg
Data types for profiling.
Definition: nrf_profiler.h:56
@ NRF_PROFILER_ARG_U8
Definition: nrf_profiler.h:57
@ NRF_PROFILER_ARG_STRING
Definition: nrf_profiler.h:63
@ NRF_PROFILER_ARG_TIMESTAMP
Definition: nrf_profiler.h:64
@ NRF_PROFILER_ARG_S32
Definition: nrf_profiler.h:62
@ NRF_PROFILER_ARG_U32
Definition: nrf_profiler.h:61
@ NRF_PROFILER_ARG_U16
Definition: nrf_profiler.h:59
@ NRF_PROFILER_ARG_S16
Definition: nrf_profiler.h:60
@ NRF_PROFILER_ARG_S8
Definition: nrf_profiler.h:58
void nrf_profiler_log_send(struct log_event_buf *buf, uint16_t event_type_id)
Send data from the buffer to the host.
void nrf_profiler_log_start(struct log_event_buf *buf)
Initialize a buffer for the data of an event.
void nrf_profiler_term(void)
Terminate the Profiler.
static bool is_profiling_enabled(size_t nrf_profiler_event_id)
Check if profiling is enabled for a given event type.
Definition: nrf_profiler.h:123
void nrf_profiler_log_encode_uint32(struct log_event_buf *buf, uint32_t data)
Encode and add uint32_t data type to a buffer.
void nrf_profiler_log_add_mem_address(struct log_event_buf *buf, const void *mem_address)
Encode and add the event's address in memory to the buffer.
const char * nrf_profiler_get_event_descr(size_t nrf_profiler_event_id)
Retrieve the description of an event type.
void nrf_profiler_log_encode_int32(struct log_event_buf *buf, int32_t data)
Encode and add int32_t data type to a buffer.
int nrf_profiler_init(void)
Initialize the Profiler.
uint16_t nrf_profiler_register_event_type(const char *name, const char *const *args, const enum nrf_profiler_arg *arg_types, uint8_t arg_cnt)
Register an event type.
void nrf_profiler_log_encode_string(struct log_event_buf *buf, const char *string)
Encode and add string to a buffer.
void nrf_profiler_log_encode_uint16(struct log_event_buf *buf, uint16_t data)
Encode and add uint16_t data type to a buffer.
void nrf_profiler_log_encode_int16(struct log_event_buf *buf, int16_t data)
Encode and add int16_t data type to a buffer.
uint8_t nrf_profiler_num_events
Number of event types registered in the Profiler.
void nrf_profiler_log_encode_int8(struct log_event_buf *buf, int8_t data)
Encode and add int8_t data type to a buffer.
uint8_t * payload
Definition: nrf_profiler.h:73
uint8_t payload_start[CONFIG_NRF_PROFILER_CUSTOM_EVENT_BUF_LEN]
Definition: nrf_profiler.h:75
Buffer required for data that is sent with the event.
Definition: nrf_profiler.h:70
atomic_t flags[ATOMIC_BITMAP_SIZE(((0)+(0)))]
Definition: nrf_profiler.h:41
Bitmask indicating event is enabled. This structure is private to nrf_profiler and should not be refe...
Definition: nrf_profiler.h:40