LL01/code_boot_out/qm/common/logic_timer.h
2025-04-26 16:03:23 +08:00

99 lines
3.4 KiB
C

/** ##########################################################################
** Filename : logic_timer.h
** Project :
** Module :
** Processor :
** Version : 1.0
** Compiler :
** Date/Time :
** Abstract :
** Contents :
** Note :
**
** (c) Copyright dmdz Co.,Ltd
** --------------------------------------------------------------------------
** R E V I S I O N H I S T O R Y
** --------------------------------------------------------------------------
** Date Ver Author Description
** -20191106- --V01-- --LYJ--- --初版--
** -20230602- --V1.0-- --mingyea--- --修改--
** #########################################################################*/
#ifndef LOGIC_TIMER__H
#define LOGIC_TIMER__H
/*lint -e749 */ /* 枚舉 not referenced*/
/*lint -e750 */ /* 宏 not referenced*/
/*lint -e751 */ /* 變量 not referenced*/
/*lint -e752 */ /* 函數 not referenced*/
/*lint -e753 */ /* 枚舉 not referenced*/
/*lint -e754 */ /* 結構體成員 not referenced*/
/*---------------------------------------------------------------------------
- I N C L U D E F I L E S
----------------------------------------------------------------------------*/
#include "common_types.h"
#include "common_cfg.h"
/*---------------------------------------------------------------------------
- D E F I N E S / M A C R O S
----------------------------------------------------------------------------*/
#define LOGIC_TIMER_STATUS_STOP 0u
#define LOGIC_TIMER_STATUS_RUNNING 1u
#define LOGIC_TIMER_STATUS_DELETE 2u
#define LOGIC_TIMER_FALSE 0u
#define LOGIC_TIMER_TRUE 1u
/*---------------------------------------------------------------------------
- T Y P E D E F I N I T I O N S
----------------------------------------------------------------------------*/
typedef u16 logic_timer_t;
typedef struct
{
logic_timer_t get_offset_time;
logic_timer_t current_time;
logic_timer_t delay_time;
u8 state;
/* bool_t abort_en;*/
void (*p_func)(void) ;
}logic_timer_s;
/*---------------------------------------------------------------------------
- G L O B A L V A R I A B L E S
- only configuration table allowed here,variables are not allowed!
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
- C O N S T A N T S
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
- F U N C T I O N P R O T O T Y P E
----------------------------------------------------------------------------*/
/* 時間以邏輯定時器週期為基準*/
void logic_timer_start(logic_timer_s* delay_cb, void (*p_fun)(void),logic_timer_t delay_tick);
/* 超時返回 TRUE, 否則返回FALSE;*/
u8 logic_timer_out(logic_timer_s* delay_cb);
void logic_timer_abort(logic_timer_s* delay_cb);
/* 時間以被調的任務週期為基準, tick_counts 倍 , 不適用於任務週期不確定的任務調用*/
void logic_timer_tick_start(logic_timer_t *tick_counter, logic_timer_t tick_counts);
u8 logic_timer_tick_time_out(logic_timer_t *tick_counter);
void logic_timer_tick_abort(logic_timer_t *tick_counter);
void logic_timer_tick_init (void);
void logic_timer_tick_count(void);
logic_timer_t logic_timer_get_tick(void);
#endif /* LOGIC_TIMER__H */
/* [] END OF FILE */