1 /* 2 * Copyright (c) 2024 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @brief File containing timer specific definitons for the 9 * Zephyr OS layer of the Wi-Fi driver. 10 */ 11 12 #include <stdio.h> 13 #include <string.h> 14 15 #include <zephyr/kernel.h> 16 #include <zephyr/sys/printk.h> 17 #include <zephyr/drivers/gpio.h> 18 19 #include "timer.h" 20 timer_expiry_function(struct k_work * work)21static void timer_expiry_function(struct k_work *work) 22 { 23 struct timer_list *timer; 24 25 timer = (struct timer_list *)CONTAINER_OF(work, struct timer_list, work.work); 26 27 timer->function(timer->data); 28 } 29 init_timer(struct timer_list * timer)30void init_timer(struct timer_list *timer) 31 { 32 k_work_init_delayable(&timer->work, timer_expiry_function); 33 } 34 mod_timer(struct timer_list * timer,int msec)35void mod_timer(struct timer_list *timer, int msec) 36 { 37 k_work_schedule(&timer->work, K_MSEC(msec)); 38 } 39 del_timer_sync(struct timer_list * timer)40void del_timer_sync(struct timer_list *timer) 41 { 42 k_work_cancel_delayable(&timer->work); 43 } 44