1 /*
2  * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef _PICO_TIMEOUT_HELPER_H
8 #define _PICO_TIMEOUT_HELPER_H
9 
10 #include "pico/time.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 typedef struct timeout_state {
17     absolute_time_t next_timeout;
18     uint64_t param;
19 } timeout_state_t;
20 
21 typedef bool (*check_timeout_fn)(timeout_state_t *ts);
22 
23 check_timeout_fn init_single_timeout_until(timeout_state_t *ts, absolute_time_t target);
24 check_timeout_fn init_per_iteration_timeout_us(timeout_state_t *ts, uint64_t per_iteration_timeout_us);
25 
26 #ifdef __cplusplus
27 }
28 #endif
29 
30 #endif