xref: /btstack/chipset/sx128x/hal_timer.h (revision 2fca4dad957cd7b88f4657ed51e89c12615dda72)
1e812ac9cSMatthias Ringwald /*
2e812ac9cSMatthias Ringwald  * Copyright (C) 2020 BlueKitchen GmbH
3e812ac9cSMatthias Ringwald  *
4e812ac9cSMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5e812ac9cSMatthias Ringwald  * modification, are permitted provided that the following conditions
6e812ac9cSMatthias Ringwald  * are met:
7e812ac9cSMatthias Ringwald  *
8e812ac9cSMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9e812ac9cSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10e812ac9cSMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11e812ac9cSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12e812ac9cSMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13e812ac9cSMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14e812ac9cSMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15e812ac9cSMatthias Ringwald  *    from this software without specific prior written permission.
16e812ac9cSMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17e812ac9cSMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18e812ac9cSMatthias Ringwald  *    monetary gain.
19e812ac9cSMatthias Ringwald  *
20e812ac9cSMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21e812ac9cSMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22e812ac9cSMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*2fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
24*2fca4dadSMilanka Ringwald  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25e812ac9cSMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26e812ac9cSMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27e812ac9cSMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28e812ac9cSMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29e812ac9cSMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30e812ac9cSMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31e812ac9cSMatthias Ringwald  * SUCH DAMAGE.
32e812ac9cSMatthias Ringwald  *
33e812ac9cSMatthias Ringwald  * Please inquire about commercial licensing options at
34e812ac9cSMatthias Ringwald  * [email protected]
35e812ac9cSMatthias Ringwald  *
36e812ac9cSMatthias Ringwald  */
37e812ac9cSMatthias Ringwald 
38e812ac9cSMatthias Ringwald /*
39e812ac9cSMatthias Ringwald  *  hci_event.h
40e812ac9cSMatthias Ringwald  */
41e812ac9cSMatthias Ringwald 
42e812ac9cSMatthias Ringwald #ifndef HAL_TIMER_H
43e812ac9cSMatthias Ringwald #define HCI_TIMER_H
44e812ac9cSMatthias Ringwald 
45e812ac9cSMatthias Ringwald #include "bluetooth.h"
46e812ac9cSMatthias Ringwald 
47e812ac9cSMatthias Ringwald #include <stdint.h>
48e812ac9cSMatthias Ringwald #include <stdarg.h>
49e812ac9cSMatthias Ringwald 
50e812ac9cSMatthias Ringwald #if defined __cplusplus
51e812ac9cSMatthias Ringwald extern "C" {
52e812ac9cSMatthias Ringwald #endif
53e812ac9cSMatthias Ringwald 
54e812ac9cSMatthias Ringwald /*
55e812ac9cSMatthias Ringwald  * @brief Initialize 32.768 kHz timer, usually low power and used by RTC and in deep sleep
56e812ac9cSMatthias Ringwald  */
57e812ac9cSMatthias Ringwald void hal_timer_init(void);
58e812ac9cSMatthias Ringwald 
59e812ac9cSMatthias Ringwald /*
60e812ac9cSMatthias Ringwald  * @brief Set Timer Callback
61e812ac9cSMatthias Ringwald  * @param callback
62e812ac9cSMatthias Ringwald  */
63e812ac9cSMatthias Ringwald void hal_timer_set_callback(void (*callback)(void));
64e812ac9cSMatthias Ringwald 
65e812ac9cSMatthias Ringwald /**
66e812ac9cSMatthias Ringwald  * @brief Get current ticks
67e812ac9cSMatthias Ringwald  * @return num_ticks
68e812ac9cSMatthias Ringwald  */
69e812ac9cSMatthias Ringwald uint16_t hal_timer_get_ticks(void);
70e812ac9cSMatthias Ringwald 
71e812ac9cSMatthias Ringwald /**
72e812ac9cSMatthias Ringwald  * @brief Stop Timer
73e812ac9cSMatthias Ringwald  */
74e812ac9cSMatthias Ringwald void hal_timer_stop(void);
75e812ac9cSMatthias Ringwald 
76e812ac9cSMatthias Ringwald /**
77e812ac9cSMatthias Ringwald  * @brief Start Timer and fire at given timeout
78e812ac9cSMatthias Ringwald  * @param timeout_ticks timeout in ticks
79e812ac9cSMatthias Ringwald  */
80e812ac9cSMatthias Ringwald void hal_timer_start(uint16_t timeout_ticks);
81e812ac9cSMatthias Ringwald 
82e812ac9cSMatthias Ringwald #if defined __cplusplus
83e812ac9cSMatthias Ringwald }
84e812ac9cSMatthias Ringwald #endif
85e812ac9cSMatthias Ringwald #endif // HAL_TIMER_H
86