1 // Copyright 2021 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 // Configuration macros for the tokenizer module.
15 #pragma once
16 
17 #include <assert.h>
18 
19 // For the embOS backend of the SystemClock, there is no way to determine the
20 // system timer's tick interval/frequency. By default most ports happen to be at
21 // 1ms intervals (i.e. 1kHz), however this can be tuned for different
22 // applications.
23 // The resulting clock period is defined in seconds = 1 / denominator.
24 // For example the default is configured to 1/1000 seconds per clock tick.
25 #ifndef PW_CHRONO_EMBOS_CFG_CLOCK_PERIOD_SECONDS_DENOMINATOR
26 #define PW_CHRONO_EMBOS_CFG_CLOCK_PERIOD_SECONDS_DENOMINATOR 1000
27 #endif  // PW_CHRONO_EMBOS_CFG_CLOCK_PERIOD_SECONDS_DENOMINATOR
28 
29 static_assert(PW_CHRONO_EMBOS_CFG_CLOCK_PERIOD_SECONDS_DENOMINATOR >= 1,
30               "the denominator must be positive and cannot be fractional");
31 
32 // Because the SystemClock::now() implementation requires the user to invoke it
33 // more than once per overflow period, the max timeout is set to ensure that
34 // blocking indefinitely on a single primitive will meet this constraint with
35 // margin (i.e. more than twice per overflow).
36 #ifndef PW_CHRONO_EMBOS_CFG_MAX_TIMEOUT
37 #define PW_CHRONO_EMBOS_CFG_MAX_TIMEOUT (0x7FFFFFFF / 3)
38 #endif  // PW_CHRONO_EMBOS_CFG_MAX_TIMEOUT
39 
40 static_assert((PW_CHRONO_EMBOS_CFG_MAX_TIMEOUT > 0) &&
41                   (PW_CHRONO_EMBOS_CFG_MAX_TIMEOUT <= 0x7FFFFFFF),
42               "Invalid MAX timeout configuration");
43