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