C/C++ API Reference
Loading...
Searching...
No Matches
config.h
1// Copyright 2020 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14
15// Configurable options for the tokenized trace module.
16#pragma once
17
18#ifdef __cplusplus
19#include <cstddef>
20#include <cstdint>
21#else
22#include <stddef.h>
23#include <stdint.h>
24#endif // __cplusplus
25
27
31#ifndef PW_TRACE_CONFIG_ARG_LABEL_SIZE_BYTES
32#define PW_TRACE_CONFIG_ARG_LABEL_SIZE_BYTES 20
33#endif // PW_TRACE_CONFIG_ARG_LABEL_SIZE_BYTES
34
37#ifndef PW_TRACE_QUEUE_SIZE_EVENTS
38#define PW_TRACE_QUEUE_SIZE_EVENTS 5
39#endif // PW_TRACE_QUEUE_SIZE_EVENTS
40
41// --- Config options for time source ----
42
44#ifndef PW_TRACE_TIME_TYPE
45#define PW_TRACE_TIME_TYPE uint32_t
46#endif // PW_TRACE_TIME_TYPE
47
51
55
62#ifndef PW_TRACE_GET_TIME_DELTA
63#define PW_TRACE_GET_TIME_DELTA(last_time, current_time) \
64 ((current_time) - (last_time))
65#ifdef __cplusplus
66
67#include <type_traits>
68
69#include "pw_varint/varint.h"
70
71static_assert(
72 std::is_unsigned<PW_TRACE_TIME_TYPE>::value,
73 "Default time delta implementation only works for unsigned time types.");
74#endif // __cplusplus
75#endif // PW_TRACE_GET_TIME_DELTA
76
77// --- Config options for callbacks ----
78
80#ifndef PW_TRACE_CONFIG_MAX_EVENT_CALLBACKS
81#define PW_TRACE_CONFIG_MAX_EVENT_CALLBACKS 2
82#endif // PW_TRACE_CONFIG_MAX_EVENT_CALLBACKS
83
85#ifndef PW_TRACE_CONFIG_MAX_SINKS
86#define PW_TRACE_CONFIG_MAX_SINKS 2
87#endif // PW_TRACE_CONFIG_MAX_SINKS
88
89// --- Config options for optional trace buffer ---
90
93#ifndef PW_TRACE_BUFFER_SIZE_BYTES
94#define PW_TRACE_BUFFER_SIZE_BYTES 256
95#endif // PW_TRACE_BUFFER_SIZE_BYTES
96
99#ifndef PW_TRACE_BUFFER_MAX_BLOCK_SIZE_BYTES
102#ifndef PW_TRACE_BUFFER_MAX_DATA_SIZE_BYTES
103#define PW_TRACE_BUFFER_MAX_DATA_SIZE_BYTES (32)
104#endif // PW_TRACE_BUFFER_MAX_BLOCK_SIZE_BYTES
105
106#ifndef PW_TRACE_BUFFER_MAX_HEADER_SIZE_BYTES
107#define PW_TRACE_BUFFER_MAX_HEADER_SIZE_BYTES \
108 (pw::varint::kMaxVarint64SizeBytes) + /* worst case delta time varint */ \
109 (sizeof(uint32_t)) + /* trace token size */ \
110 (pw::varint::kMaxVarint64SizeBytes) + /* worst case trace id varint */
111#endif // PW_TRACE_BUFFER_MAX_HEADER_SIZE_BYTES
112
113#define PW_TRACE_BUFFER_MAX_BLOCK_SIZE_BYTES \
114 PW_TRACE_BUFFER_MAX_HEADER_SIZE_BYTES + PW_TRACE_BUFFER_MAX_DATA_SIZE_BYTES
115#endif // PW_TRACE_BUFFER_MAX_BLOCK_SIZE_BYTES
116
#define PW_TRACE_TIME_TYPE
The type for trace time.
Definition: config.h:45
size_t pw_trace_GetTraceTimeTicksPerSecond(void)
uint32_t pw_trace_GetTraceTime(void)