The period cannot be less than timer resolution. Also the timer accuracy is +- 1 tick, that means if period is [1;2) of tick the timer can expire right after setting, but it doesn't break the algorithm, so I didn't limit period to be more than 2*resolution.
Signed-off-by: Ivan Khoronzhuk <[email protected]> --- example/timer/odp_timer_test.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 94619e4..e081daf 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -252,7 +252,7 @@ static void print_usage(void) * @param argv Argument vector * @param args Test arguments */ -static void parse_args(int argc, char *argv[], test_args_t *args) +static int parse_args(int argc, char *argv[], test_args_t *args) { int opt; int long_index; @@ -311,6 +311,12 @@ static void parse_args(int argc, char *argv[], test_args_t *args) break; } } + + if (args->period_us > args->resolution_us) + return 0; + + EXAMPLE_ERR("Error: period must be more then timer resolution\n"); + return -1; } @@ -371,7 +377,10 @@ int main(int argc, char *argv[]) } memset(gbls, 0, sizeof(test_globals_t)); - parse_args(argc, argv, &gbls->args); + if (parse_args(argc, argv, &gbls->args)) { + EXAMPLE_ERR("Error: Argumets are incorrect.\n"); + return -1; + } memset(thread_tbl, 0, sizeof(thread_tbl)); -- 1.9.1 _______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
