timer.h

来自「ST7540 Demo 下位机C程序」· C头文件 代码 · 共 56 行

H
56
字号
//*********************************************************************************
//*               ST 7538 DEMOBOARD SOFTWARE 	  timer.h                           *
//*                                                                               *
//*               timer constants/functions            V1.2                       *
//*********************************************************************************

#ifndef __TIMER_H__
#define __TIMER_H__

// timer
// Xtal frequency in Hz

#define XTAL	8000000
// Timeout Resolution in ms
#define TIMEOUT_RESOLUTION 1

#define TIMER_STEP   ((XTAL)*(TIMEOUT_RESOLUTION)/8000)


#define OCF1 (0x40)
#define TOF  (0x20)
#define OCF2 (0x08)

/**********************************************************************************
* TIMER_Init initializates the HW timer and enable the interrupt
**********************************************************************************/
void TIMER_Init(void);


//Numer of maximum Timeouts
#define TIMEOUT_NUM		10

//functions
/**********************************************************************************
*TIMEOUT_Init initializes (close) all the SW timeouts (which depend on 1ms timer)
**********************************************************************************/
void TIMEOUT_Init(void);
/**********************************************************************************
*TIMEOUT_Open opens a timeout with a user selected period (in ms) and returns the tout number
**********************************************************************************/
unsigned char TIMEOUT_Open(unsigned short period);
/**********************************************************************************
*TIMEOUT_Close closes a timeout 
**********************************************************************************/
void TIMEOUT_Close(unsigned char timer);
/**********************************************************************************
*TIMEOUT_Expired checks if the timeout is expired. returns "1" if timeout if tout is expired,
*"0" otherwise
**********************************************************************************/
unsigned char TIMEOUT_Expired(unsigned char timer);
/**********************************************************************************
*TIMEOUT_Refresh restart the timer updating the stop time
**********************************************************************************/
void __stack_call TIMEOUT_Refresh(unsigned char timer);

#endif // __TIMER_H__

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?