1 // Copyright 2020 The Pigweed Authors
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
7 // https://www.apache.org/licenses/LICENSE-2.0
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
14 // Configuration macros for the tokenizer module.
21 // For the ThreadX backend of the SystemClock, there is no way to determine the
22 // system timer's tick interval/frequency. By default most ports happen to be at
23 // 10ms intervals (i.e. 100Hz), however this can be tuned for different
25 // The resulting clock period is defined in seconds = numerator / denominator.
26 // For example the default is configured to 1/100 seconds per clock tick.
27 #ifndef PW_CHRONO_THREADX_CFG_CLOCK_PERIOD_SECONDS_NUMERATOR
28 #define PW_CHRONO_THREADX_CFG_CLOCK_PERIOD_SECONDS_NUMERATOR 1
29 #endif // PW_CHRONO_THREADX_CFG_CLOCK_PERIOD_SECONDS_NUMERATOR
30 #ifndef PW_CHRONO_THREADX_CFG_CLOCK_PERIOD_SECONDS_DENOMINATOR
31 #define PW_CHRONO_THREADX_CFG_CLOCK_PERIOD_SECONDS_DENOMINATOR 100
32 #endif // PW_CHRONO_THREADX_CFG_CLOCK_PERIOD_SECONDS_DENOMINATOR
34 static_assert(PW_CHRONO_THREADX_CFG_CLOCK_PERIOD_SECONDS_NUMERATOR >= 1,
35 "the numerator must be positive and cannot be fractional");
36 static_assert(PW_CHRONO_THREADX_CFG_CLOCK_PERIOD_SECONDS_DENOMINATOR >= 1,
37 "the denominator must be positive and cannot be fractional");
39 // Because the SystemClock::now() implementation requires the user to invoke it
40 // more than once per overflow period, the max timeout is set to ensure that
41 // blocking indefinitely on a single primitive will meet this constraint with
42 // margin (i.e. more than twice per overflow).
43 #ifndef PW_CHRONO_THREADX_CFG_MAX_TIMEOUT
44 #define PW_CHRONO_THREADX_CFG_MAX_TIMEOUT ((TX_WAIT_FOREVER - 1) / 3)
45 #endif // PW_CHRONO_THREADX_CFG_MAX_TIMEOUT
47 static_assert((PW_CHRONO_THREADX_CFG_MAX_TIMEOUT > 0) &&
48 (PW_CHRONO_THREADX_CFG_MAX_TIMEOUT <= (TX_WAIT_FOREVER - 1)),
49 "the timeout must be greater than 0 and less than the sentinel");