32 #ifndef __STC8x_TIMER_H_
33 #define __STC8x_TIMER_H_
44 #if (PER_LIB_MCU_MUODEL == STC8Ax)
46 #elif (PER_LIB_MCU_MUODEL == STC8Cx)
48 #elif (PER_LIB_MCU_MUODEL == STC8Fx)
50 #elif (PER_LIB_MCU_MUODEL == STC8Gx)
52 #elif (PER_LIB_MCU_MUODEL == STC8Hx)
61 #ifndef PER_LIB_MCU_MUODEL
64 #define PER_LIB_MCU_MUODEL STC8Ax
68 #ifndef PER_LIB_TIMER_CTRL
71 #define PER_LIB_TIMER_CTRL 1
75 #ifndef PER_LIB_TIMER_INIT_CTRL
78 #define PER_LIB_TIMER_INIT_CTRL 1
81 #ifndef PER_LIB_TIMER_WORK_CTRL
84 #define PER_LIB_TIMER_WORK_CTRL 1
87 #ifndef PER_LIB_TIMER_NVIC_CTRL
90 #define PER_LIB_TIMER_NVIC_CTRL 1
141 #if (PER_LIB_MCU_MUODEL == STC8Cx ||PER_LIB_MCU_MUODEL == STC8Gx || PER_LIB_MCU_MUODEL == STC8Hx)
156 #if (PER_LIB_TIMER_CTRL == 1)
158 #if (PER_LIB_TIMER_INIT_CTRL == 1)
232 #if (PER_LIB_TIMER_NVIC_CTRL == 1)
291 #define TIMER2_CLEAR_FLAG() do{ AUXINTIF &= 0xFE; }while(0)
299 #define TIMER3_CLEAR_FLAG() do{ AUXINTIF &= 0xFD; }while(0)
307 #define TIMER4_CLEAR_FLAG() do{ AUXINTIF &= 0xFB; }while(0)
315 #define NVIC_TIMER0_PRI(pri) \
317 IPH = (IPH & 0xFD) | (pri & 0x02) ; \
318 IP = (IP & 0xFD) | ((pri & 0x01) << 1); \
327 #define NVIC_TIMER1_PRI(pri) \
329 IPH = (IPH & 0xF7) | ((pri & 0x02) << 2); \
330 IP = (IP & 0xF7) | ((pri & 0x01) << 3); \
339 #define NVIC_TIMER0_CTRL(run) do{ ET0 = run; }while(0)
347 #define NVIC_TIMER1_CTRL(run) do{ ET1 = run; }while(0)
355 #define NVIC_TIMER2_CTRL(run) do{ IE2 = (IE2 & 0xFB) | (run << 2); }while(0)
363 #define NVIC_TIMER3_CTRL(run) do{ IE2 = (IE2 & 0xDF) | (run << 5); }while(0)
371 #define NVIC_TIMER4_CTRL(run) do{ IE2 = (IE2 & 0xBF) | (run << 6); }while(0)
376 #if (PER_LIB_TIMER_WORK_CTRL == 1)
382 #define TIMER0_WORK_CTRL(run) do{ TR0 = run; }while(0)
390 #define TIMER1_WORK_CTRL(run) do{ TR1 = run; }while(0)
399 #define TIMER2_WORK_CTRL(run) do{AUXR = (AUXR & 0xEF) | (run << 4); }while(0)
407 #define TIMER3_WORK_CTRL(run) do{ T4T3M = (T4T3M & 0xF7) | (run << 3)}while(0)
415 #define TIMER4_WORK_CTRL(run) do{ T4T3M = (T4T3M & 0x7F) | (run << 7)}while(0)
421 #define TIMER0_CLEAR_CNT() do{T0L = 0; T0H = 0;}while(0)
427 #define TIMER1_CLEAR_CNT() do{T1L = 0; T1H = 0;}while(0)
433 #define TIMER2_CLEAR_CNT() do{T2L = 0; T2H = 0;}while(0)
439 #define TIMER3_CLEAR_CNT() do{T3L = 0; T3H = 0;}while(0)
445 #define TIMER4_CLEAR_CNT() do{T4L = 0; T4H = 0;}while(0)
453 #define TIMER0_RELOAD_CNT() \
455 T0L = (uint8_t)(G_Time0_CntValue); \
456 T0H = (uint8_t)(G_Time0_CntValue >> 8); \
466 #define TIMER1_RELOAD_CNT() \
468 T1L = (uint8_t)(G_Time1_CntValue); \
469 T1H = (uint8_t)(G_Time1_CntValue >> 8); \
499 #if (PER_LIB_MCU_MUODEL == STC8Ax || PER_LIB_MCU_MUODEL == STC8Fx)
501 #elif (PER_LIB_MCU_MUODEL == STC8Cx || PER_LIB_MCU_MUODEL == STC8Gx || PER_LIB_MCU_MUODEL == STC8Hx)
513 #if (PER_LIB_MCU_MUODEL == STC8Ax || PER_LIB_MCU_MUODEL == STC8Fx)
515 #elif (PER_LIB_MCU_MUODEL == STC8Cx || PER_LIB_MCU_MUODEL == STC8Gx || PER_LIB_MCU_MUODEL == STC8Hx)
527 #if (PER_LIB_MCU_MUODEL == STC8Ax || PER_LIB_MCU_MUODEL == STC8Fx)
529 #elif (PER_LIB_MCU_MUODEL == STC8Cx || PER_LIB_MCU_MUODEL == STC8Gx || PER_LIB_MCU_MUODEL == STC8Hx)
NVICPri_Type
Definition: ELL_CORE.h:99
BOOL
Definition: ELL_CORE.h:50
FSCSTATE
Definition: ELL_CORE.h:65
unsigned long uint32_t
Definition: ELL_TYPE.h:74
unsigned int uint16_t
Definition: ELL_TYPE.h:73
unsigned char uint8_t
Definition: ELL_TYPE.h:72
FSCSTATE TIMER3_Set_Time(uint32_t time)
定时器3设置定时时间函数。
FSCSTATE NVIC_TIMER3_Init(BOOL run)
定时器3中断初始化函数。
FSCSTATE TIMER2_Set_Time(uint32_t time)
定时器2设置定时时间函数。
FSCSTATE TIMER3_Init(const TIMER_InitType *timerx)
定时器3初始化函数。
TIMERMode_Type
Definition: STC8x_TIMER.h:112
@ TIMER_8BitAutoReload
Definition: STC8x_TIMER.h:115
@ TIMER_16BitAutoReloadNoMask
Definition: STC8x_TIMER.h:116
@ TIMER_16BitAutoReload
Definition: STC8x_TIMER.h:113
@ TIMER_16Bit
Definition: STC8x_TIMER.h:114
FSCSTATE TIMER5_Wake_Up_Power(uint16_t value, BOOL run)
调电唤醒定时器5初始化函数。
TIMERType_Type
Definition: STC8x_TIMER.h:100
@ TIMER_Type_Counter
Definition: STC8x_TIMER.h:102
@ TIMER_Type_Timer
Definition: STC8x_TIMER.h:101
TIMERTCycle_Type
Definition: STC8x_TIMER.h:126
@ TIMER_TCY_12T
Definition: STC8x_TIMER.h:128
@ TIMER_TCY_1T
Definition: STC8x_TIMER.h:127
FSCSTATE NVIC_TIMER2_Init(BOOL run)
定时器2中断初始化函数。
FSCSTATE NVIC_TIMER4_Init(BOOL run)
定时器4中断初始化函数。
FSCSTATE TIMER1_Init(const TIMER_InitType *timerx)
定时器1初始化函数。
FSCSTATE TIMER1_Set_Time(uint32_t time)
定时器1设置定时时间函数。
FSCSTATE TIMER0_Set_Time(uint32_t time)
定时器0设置定时时间函数。
FSCSTATE TIMER4_Init(const TIMER_InitType *timerx)
定时器4初始化函数。
FSCSTATE NVIC_TIMER1_Init(NVICPri_Type pri, BOOL run)
定时器1中断初始化函数。
FSCSTATE NVIC_TIMER0_Init(NVICPri_Type pri, BOOL run)
定时器0中断初始化函数。
FSCSTATE TIMER2_Init(const TIMER_InitType *timerx)
定时器2初始化函数。
FSCSTATE TIMER0_Init(const TIMER_InitType *timerx)
定时器0初始化函数。
FSCSTATE TIMER4_Set_Time(uint32_t time)
定时器4设置定时时间函数。
定时器初始化结构体句柄,初始化时请定义该句柄,并用其地址来传参。
Definition: STC8x_TIMER.h:140
TIMERTCycle_Type TCycle
Definition: STC8x_TIMER.h:146
BOOL Run
Definition: STC8x_TIMER.h:149
uint8_t SysClkDiv
Definition: STC8x_TIMER.h:142
BOOL ClkOut
Definition: STC8x_TIMER.h:147
TIMERType_Type Type
Definition: STC8x_TIMER.h:144
uint32_t Time
Definition: STC8x_TIMER.h:148
TIMERMode_Type Mode
Definition: STC8x_TIMER.h:145