MultiTimer开源定时器(多任务回调)----链表分析

本文介绍了MultiTimer开源定时器的使用,通过示例代码展示了如何初始化和启动两个定时器:timer1为1秒循环定时任务,timer2为50毫秒延迟调用。每个定时器都关联了特定的回调函数,如timer1_callback和timer2_callback。在main函数中,通过timer_loop()不断更新定时器状态,并在HAL_SYSTICK_Callback中处理1ms时钟滴答。
摘要由CSDN通过智能技术生成
/*
 * Copyright (c) 2016 https://blog.csdn.net/Wekic
 * All rights reserved
 */
 
#ifndef _MULTI_TIMER_H_
#define _MULTI_TIMER_H_

#include "stdint.h"
#include "stddef.h"

typedef struct Timer {
    uint32_t timeout;         //超时时间
    uint32_t repeat;          //重置时间
    void (*timeout_cb)(void); //回调任务函数
    struct Timer* next;       //下一个任务
}Timer;

#ifdef __cplusplus  
extern "C" {  
#endif  

void timer_init(struct Timer* handle, void(*timeout_cb)(), uint32_t timeout, uint32_t repeat);
int  timer_start(struct Timer* handle);
void timer_stop(struct Timer* handle);
void timer_ticks(void);
void timer_loop(void);

// void timer_again(struct Timer* handle);
// void timer_set_repeat(struct Timer* handle, uint32_t repeat);

#ifdef __cplusplus
} 
#endif

#endif
/*
 * Copyright (c) 2020 https://blog.csdn.net/Wekic
 * All rights reserved
 */

#include "multi_timer.h"

//timer handle list head.
static struct Timer* head_hand
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值