2 Star 1 Fork 2

赵章博/b_timer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
b_timer.h 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
赵章博 提交于 7个月前 . init
/******************************************************************************
* @brief 软件定时器<依赖于b_list模块>
* Change Logs:
* Date Author Email Notes
* 2023-06-06 子恒 3393018959@qq.com NULL
* 2023-06-13 子恒 3393018959@qq.com 初版完成
******************************************************************************/
#ifndef __B_TIMER_H__
#define __B_TIMER_H__
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "b_list.h"
#define TIMER_TICKCNT_MAX 0xFFFFFFFF
//#define TIMER_MEASURE_MAX 10
#define B_CONCAT(p1, p2) LIST_CONCAT(p1, p2)
typedef enum
{
B_TIMER_MODE_SINGLE_SHOT,
B_TIMER_MODE_REPEATED
} b_timer_mode_t;
typedef void (*b_timerout_handler_t)(void);
typedef struct{
void * list_next;
uint32_t end_val;
uint32_t repeat_period;
b_timerout_handler_t handler;
uint8_t active;
}b_timer_t;
typedef b_timer_t * b_timer_id_t;
#define _B_TIMER_DEF(timer_id) \
static b_timer_t B_CONCAT(timer_id,_data) = { \
.active = 0, \
}; \
const b_timer_id_t timer_id = &B_CONCAT(timer_id,_data)
extern uint32_t b_get_sys_timer(void);
extern void timer_update(void);
extern uint8_t b_timer_create(b_timer_id_t const * p_timer,
b_timer_mode_t mode,
b_timerout_handler_t timeout_handler);
extern uint8_t b_timer_start(b_timer_id_t const * p_timer, uint32_t timeout_ticks);
extern uint8_t b_timer_stop(b_timer_id_t const * p_timer);
#ifdef TIMER_MEASURE_MAX
extern void b_measure_start(void);
extern uint8_t b_measure_stop(uint8_t id);
extern uint32_t b_measure_get(uint8_t id);
#endif
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/zhao-zhangbo/b_timer.git
git@gitee.com:zhao-zhangbo/b_timer.git
zhao-zhangbo
b_timer
b_timer
master

搜索帮助