91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-02
  • 語言: 其他
  • 標簽: arduino??

資源簡介

arduino,中斷用的函數庫,可以進行定時器作用。為了說明這個問題,再舉一例子。假設你有一個朋友來拜訪你,但是由于不知道何時到達,你只能在大門等待,于是什么事情也干不了。如果在門口裝一個門鈴,你就不必在門口等待而去干其它的工作,朋友來了按門鈴通知你,你這時才中斷你的工作去開門,這樣就避免等待和浪費時間。計算機也是一樣,例如鍵盤輸入,如果不采用中斷技術,CPU將不斷掃描鍵盤有否輸入,經常處于等待狀態,效率極低。而采用了中斷方式,CPU可以進行其它的工作,只鍵盤有按鍵并發出中斷請求時,才予以響應,暫時中斷當前工作轉去執行讀取鍵盤按鍵,讀完成后又返回執行原來的程序。這樣就大大地提高了計算機系統的效率。

資源截圖

代碼片段和文件信息

/*
??MsTimer2.h?-?Using?timer2?with?1ms?resolution
??Javier?Valencia?
??
??History:
?? 29/May/09?-?V0.5?added?support?for?Atmega1280?(thanks?to?Manuel?Negri)
?? 19/Mar/09?-?V0.4?added?support?for?ATmega328P?(thanks?to?Jerome?Despatis)
?? 11/Jun/08?-?V0.3?
?? changes?to?allow?working?with?different?CPU?frequencies
?? added?support?for?ATMega128?(using?timer2)
?? compatible?with?ATMega48/88/168/8
10/May/08?-?V0.2?added?some?security?tests?and?volatile?keywords
9/May/08?-?V0.1?released?working?on?ATMEGA168?only


??This?library?is?free?software;?you?can?redistribute?it?and/or
??modify?it?under?the?terms?of?the?GNU?Lesser?General?Public
??License?as?published?by?the?Free?Software?Foundation;?either
??version?2.1?of?the?License?or?(at?your?option)?any?later?version.

??This?library?is?distributed?in?the?hope?that?it?will?be?useful
??but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
??MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the?GNU
??Lesser?General?Public?License?for?more?details.

??You?should?have?received?a?copy?of?the?GNU?Lesser?General?Public
??License?along?with?this?library;?if?not?write?to?the?Free?Software
??Foundation?Inc.?51?Franklin?St?Fifth?Floor?Boston?MA??02110-1301??USA
*/

#include?

unsigned?long?MsTimer2::msecs;
void?(*MsTimer2::func)();
volatile?unsigned?long?MsTimer2::count;
volatile?char?MsTimer2::overflowing;
volatile?unsigned?int?MsTimer2::tcnt2;

void?MsTimer2::set(unsigned?long?ms?void?(*f)())?{
float?prescaler?=?0.0;

#if?defined?(__AVR_ATmega168__)?||?defined?(__AVR_ATmega48__)?||?defined?(__AVR_ATmega88__)?||?defined?(__AVR_ATmega328P__)?||?(__AVR_ATmega1280__)
TIMSK2?&=?~(1< TCCR2A?&=?~((1< TCCR2B?&=?~(1< ASSR?&=?~(1< TIMSK2?&=?~(1<
if?((F_CPU?>=?1000000UL)?&&?(F_CPU?<=?16000000UL))?{ //?prescaler?set?to?64
TCCR2B?|=?(1< TCCR2B?&=?~((1< prescaler?=?64.0;
}?else?if?(F_CPU? TCCR2B?|=?(1< TCCR2B?&=?~((1< prescaler?=?8.0;
}?else?{?//?F_CPU?>?16Mhz?prescaler?set?to?128
TCCR2B?|=?((1< TCCR2B?&=?~(1< prescaler?=?128.0;
}
#elif?defined?(__AVR_ATmega8__)
TIMSK?&=?~(1< TCCR2?&=?~((1< TIMSK?&=?~(1< ASSR?&=?~(1<
if?((F_CPU?>=?1000000UL)?&&?(F_CPU?<=?16000000UL))?{ //?prescaler?set?to?64
TCCR2?|=?(1< TCCR2?&=?~((1< prescaler?=?64.0;
}?else?if?(F_CPU? TCCR2?|=?(1< TCCR2?&=?~((1< prescaler?=?8.0;
}?else?{?//?F_CPU?>?16Mhz?prescaler?set?to?128
TCCR2?|=?((1< TCCR2?&=?~(1< prescaler?=?128.0;
}
#elif?defined?(__AVR_ATmega128__)
TIMSK?&=?~(1< TCCR2?&=?~((1< TIMSK?&=?~(1<
if?((F_CPU?>=?1000000UL)?&&?(F_CPU?<=?16000000UL))?{ //?pre

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2009-05-29?12:49??MsTimer2\
?????文件?????????353??2008-06-12?10:11??MsTimer2\MsTimer2.h
?????文件????????4706??2009-05-29?12:48??MsTimer2\MsTimer2.cpp
?????目錄???????????0??2008-05-19?21:20??MsTimer2\examples\
?????目錄???????????0??2009-05-29?12:50??MsTimer2\examples\FlashLed\
?????文件?????????289??2008-05-09?21:12??MsTimer2\examples\FlashLed\FlashLed.pde

評論

共有 條評論