⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.h

📁 usb 转 232 ISP AMEGA8源程序
💻 H
字号:
/* * Name: timer.h * Project: AVR-Doper * Author: Christian Starkjohann <cs@obdev.at> * Creation Date: 2006-06-26 * Tabsize: 4 * Copyright: (c) 2006 by Christian Starkjohann, all rights reserved. * License: Proprietary, see documentation. * Revision: $Id: timer.h 223 2006-07-18 09:28:13Z cs $ *//*General Description:This module implements functions to control timing behavior. It is based ona timer interrupt.*/#ifndef __timer_h_included__#define __timer_h_included__#include <avr/io.h> /* for TCNT0 */#include "utils.h"extern volatile uchar   timerTimeoutCnt;extern volatile uchar   timerLongTimeoutCnt;/* ------------------------------------------------------------------------- */#define TIMER_TICK_US       5.33333333333333333333void timerMsDelay(uchar ms);    /* 1 ms precision, based on hardware timer */void timerSetupTimeout(uchar msDuration);#define TIMER_US_DELAY(us)  timerTicksDelay((uchar)((us)/TIMER_TICK_US))/* ------------------------------------------------------------------------- */static inline void timerTicksDelay(uchar ticks){char    d, until = TCNT0 + ticks;    do{        d = TCNT0 - until;  /* enforce 8 bit arithmetics */    }while(d < 0);}static inline uchar   timerTimeoutOccurred(void){    return timerTimeoutCnt == 0;}static inline void    timerSetupLongTimeout(uchar ms100Duration){    timerLongTimeoutCnt = ms100Duration;}static inline uchar   timerLongTimeoutOccurred(void){    return timerLongTimeoutCnt == 0;}/* ------------------------------------------------------------------------- */#endif /* __timer_h_included__ */

⌨️ 快捷键说明

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