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

📄 timer128_8h-source.html

📁 ATMEL的AVR单片机库文件
💻 HTML
📖 第 1 页 / 共 3 页
字号:
00093 <span class="comment">// 3 = CLOCK/64     tics= 57625.25Hz    8bitoverflow=  225.220Hz    16bit=   0.880Hz</span>00094 <span class="comment">// 4 = CLOCK/256    tics= 14414.063Hz   8bitoverflow=   56.305Hz    16bit=   0.220Hz</span>00095 <span class="comment">// 5 = CLOCK/1024   tics=  3603.516Hz   8bitoverflow=   14.076Hz    16bit=   0.055Hz</span>00096 <span class="comment">// 6 = External Clock on T(x) pin (falling edge)</span>00097 <span class="comment">// 7 = External Clock on T(x) pin (rising edge)</span>00098 00099 <span class="comment">// for 32.768KHz crystal on timer 2 (use for real-time clock)</span>00100 <span class="comment">// 0 = STOP</span>00101 <span class="comment">// 1 = CLOCK        tics= 32.768kHz 8bitoverflow= 128Hz</span>00102 <span class="comment">// 2 = CLOCK/8      tics= 4096kHz       8bitoverflow=  16Hz</span>00103 <span class="comment">// 3 = CLOCK/64     tics= 512Hz         8bitoverflow=   2Hz</span>00104 <span class="comment">// 4 = CLOCK/256    tics= 128Hz         8bitoverflow=   0.5Hz</span>00105 <span class="comment">// 5 = CLOCK/1024   tics= 32Hz          8bitoverflow=   0.125Hz</span>00106 <a name="l00107"></a><a class="code" href="timer128_8h.html#a0">00107</a> <span class="preprocessor">#define TIMER_CLK_STOP          0x00    </span><span class="comment">///&lt; Timer Stopped</span><a name="l00108"></a><a class="code" href="timer128_8h.html#a1">00108</a> <span class="comment"></span>#define TIMER_CLK_DIV1          0x01    <span class="comment">///&lt; Timer clocked at F_CPU</span><a name="l00109"></a><a class="code" href="timer128_8h.html#a2">00109</a> <span class="comment"></span>#define TIMER_CLK_DIV8          0x02    <span class="comment">///&lt; Timer clocked at F_CPU/8</span><a name="l00110"></a><a class="code" href="timer128_8h.html#a3">00110</a> <span class="comment"></span>#define TIMER_CLK_DIV64         0x03    <span class="comment">///&lt; Timer clocked at F_CPU/64</span><a name="l00111"></a><a class="code" href="timer128_8h.html#a4">00111</a> <span class="comment"></span>#define TIMER_CLK_DIV256        0x04    <span class="comment">///&lt; Timer clocked at F_CPU/256</span><a name="l00112"></a><a class="code" href="timer128_8h.html#a5">00112</a> <span class="comment"></span>#define TIMER_CLK_DIV1024       0x05    <span class="comment">///&lt; Timer clocked at F_CPU/1024</span><a name="l00113"></a><a class="code" href="timer128_8h.html#a6">00113</a> <span class="comment"></span>#define TIMER_CLK_T_FALL        0x06    <span class="comment">///&lt; Timer clocked at T falling edge</span><a name="l00114"></a><a class="code" href="timer128_8h.html#a7">00114</a> <span class="comment"></span>#define TIMER_CLK_T_RISE        0x07    <span class="comment">///&lt; Timer clocked at T rising edge</span><a name="l00115"></a><a class="code" href="timer128_8h.html#a8">00115</a> <span class="comment"></span>#define TIMER_PRESCALE_MASK     0x07    <span class="comment">///&lt; Timer Prescaler Bit-Mask</span>00116 <span class="comment"></span><a name="l00117"></a><a class="code" href="timer128_8h.html#a9">00117</a> <span class="preprocessor">#define TIMERRTC_CLK_STOP       0x00    </span><span class="comment">///&lt; RTC Timer Stopped</span><a name="l00118"></a><a class="code" href="timer128_8h.html#a10">00118</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV1       0x01    <span class="comment">///&lt; RTC Timer clocked at F_CPU</span><a name="l00119"></a><a class="code" href="timer128_8h.html#a11">00119</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV8       0x02    <span class="comment">///&lt; RTC Timer clocked at F_CPU/8</span><a name="l00120"></a><a class="code" href="timer128_8h.html#a12">00120</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV32      0x03    <span class="comment">///&lt; RTC Timer clocked at F_CPU/32</span><a name="l00121"></a><a class="code" href="timer128_8h.html#a13">00121</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV64      0x04    <span class="comment">///&lt; RTC Timer clocked at F_CPU/64</span><a name="l00122"></a><a class="code" href="timer128_8h.html#a14">00122</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV128     0x05    <span class="comment">///&lt; RTC Timer clocked at F_CPU/128</span><a name="l00123"></a><a class="code" href="timer128_8h.html#a15">00123</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV256     0x06    <span class="comment">///&lt; RTC Timer clocked at F_CPU/256</span><a name="l00124"></a><a class="code" href="timer128_8h.html#a16">00124</a> <span class="comment"></span>#define TIMERRTC_CLK_DIV1024    0x07    <span class="comment">///&lt; RTC Timer clocked at F_CPU/1024</span><a name="l00125"></a><a class="code" href="timer128_8h.html#a17">00125</a> <span class="comment"></span>#define TIMERRTC_PRESCALE_MASK  0x07    <span class="comment">///&lt; RTC Timer Prescaler Bit-Mask</span>00126 <span class="comment"></span>00127 <span class="comment">// default prescale settings for the timers</span>00128 <span class="comment">// these settings are applied when you call</span>00129 <span class="comment">// timerInit or any of the timer&lt;x&gt;Init</span><a name="l00130"></a><a class="code" href="timer128_8h.html#a18">00130</a> <span class="preprocessor">#define TIMER0PRESCALE      TIMERRTC_CLK_DIV64  </span><span class="comment">///&lt; timer 0 prescaler default</span><a name="l00131"></a><a class="code" href="timer128_8h.html#a19">00131</a> <span class="comment"></span>#define TIMER1PRESCALE      TIMER_CLK_DIV64     <span class="comment">///&lt; timer 1 prescaler default</span><a name="l00132"></a><a class="code" href="timer128_8h.html#a20">00132</a> <span class="comment"></span>#define TIMER2PRESCALE      TIMER_CLK_DIV8      <span class="comment">///&lt; timer 2 prescaler default</span><a name="l00133"></a><a class="code" href="timer128_8h.html#a21">00133</a> <span class="comment"></span>#define TIMER3PRESCALE      TIMER_CLK_DIV64     <span class="comment">///&lt; timer 3 prescaler default</span>00134 <span class="comment"></span>00135 <span class="comment">// interrupt macros for attaching user functions to timer interrupts</span>00136 <span class="comment">// use these with timerAttach( intNum, function )</span>00137 <span class="comment">// timer 0</span>00138 <span class="preprocessor">#define TIMER0OVERFLOW_INT          0</span>00139 <span class="preprocessor"></span><span class="preprocessor">#define TIMER0OUTCOMPARE_INT        1</span>00140 <span class="preprocessor"></span><span class="comment">// timer 1</span>00141 <span class="preprocessor">#define TIMER1OVERFLOW_INT          2</span>00142 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1OUTCOMPAREA_INT       3</span>00143 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1OUTCOMPAREB_INT       4</span>00144 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1OUTCOMPAREC_INT       5</span>00145 <span class="preprocessor"></span><span class="preprocessor">#define TIMER1INPUTCAPTURE_INT      6</span>00146 <span class="preprocessor"></span><span class="comment">// timer 2</span>00147 <span class="preprocessor">#define TIMER2OVERFLOW_INT          7</span>00148 <span class="preprocessor"></span><span class="preprocessor">#define TIMER2OUTCOMPARE_INT        8</span>00149 <span class="preprocessor"></span><span class="comment">// timer 3</span>00150 <span class="preprocessor">#define TIMER3OVERFLOW_INT          9</span>00151 <span class="preprocessor"></span><span class="preprocessor">#define TIMER3OUTCOMPAREA_INT       10</span>00152 <span class="preprocessor"></span><span class="preprocessor">#define TIMER3OUTCOMPAREB_INT       11</span>00153 <span class="preprocessor"></span><span class="preprocessor">#define TIMER3OUTCOMPAREC_INT       12</span>00154 <span class="preprocessor"></span><span class="preprocessor">#define TIMER3INPUTCAPTURE_INT      13</span>00155 <span class="preprocessor"></span>00156 <span class="preprocessor">#define TIMER_NUM_INTERRUPTS        14</span>00157 <span class="preprocessor"></span>00158 <span class="comment">// type of interrupt handler to use for timers</span>00159 <span class="comment">// *do not change unless you know what you're doing</span>00160 <span class="comment">// Value may be SIGNAL or INTERRUPT</span>00161 <span class="preprocessor">#ifndef TIMER_INTERRUPT_HANDLER</span>00162 <span class="preprocessor"></span><span class="preprocessor">#define TIMER_INTERRUPT_HANDLER     SIGNAL</span>00163 <span class="preprocessor"></span><span class="preprocessor">#endif</span>00164 <span class="preprocessor"></span>00165 <span class="comment">// functions</span>00166 <span class="keywordtype">void</span> delay(<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> us);00167 00168 <span class="comment">// initializes timing system</span>00169 <span class="comment">// runs all timer init functions</span>00170 <span class="comment">// sets all timers to default prescale values #defined in systimer.c</span>00171 <span class="keywordtype">void</span> <a class="code" href="timer_8c.html#a7">timerInit</a>(<span class="keywordtype">void</span>);00172 00173 <span class="comment">// default initialization routines for each timer</span>00174 <span class="keywordtype">void</span> <a class="code" href="timer_8c.html#a8">timer0Init</a>(<span class="keywordtype">void</span>);00175 <span class="keywordtype">void</span> <a class="code" href="timer_8c.html#a9">timer1Init</a>(<span class="keywordtype">void</span>);00176 <span class="keywordtype">void</span> timer2Init(<span class="keywordtype">void</span>);00177 <span class="keywordtype">void</span> timer3Init(<span class="keywordtype">void</span>);00178 00179 <span class="comment">// Clock prescaler set/get commands for each timer/counter</span>00180 <span class="comment">// For setting the prescaler, you should use one of the #defines</span>00181 <span class="comment">// above like TIMER_CLK_DIVx, where [x] is the division rate</span>00182 <span class="comment">// you want.</span>00183 <span class="comment">// When getting the current prescaler setting, the return value</span>00184 <span class="comment">// will be the [x] division value currently set.</span>00185 <span class="keywordtype">void</span> <a class="code" href="timer128_8h.html#a44">timer0SetPrescaler</a>(u08 prescale);      <span class="comment">///&lt; set timer0 prescaler division index</span>00186 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="timer128_8h.html#a45">timer1SetPrescaler</a>(u08 prescale);      <span class="comment">///&lt; set timer1 prescaler division index</span>00187 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="timer128_8h.html#a46">timer2SetPrescaler</a>(u08 prescale);      <span class="comment">///&lt; set timer2 prescaler division index</span>00188 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="timer128_8h.html#a47">timer3SetPrescaler</a>(u08 prescale);      <span class="comment">///&lt; set timer3 prescaler division index</span>00189 <span class="comment"></span>u16  <a class="code" href="timer_8c.html#a12">timer0GetPrescaler</a>(<span class="keywordtype">void</span>);              <span class="comment">///&lt; get timer0 prescaler division rate</span>00190 <span class="comment"></span>u16  <a class="code" href="timer_8c.html#a13">timer1GetPrescaler</a>(<span class="keywordtype">void</span>);              <span class="comment">///&lt; get timer1 prescaler division rate</span>00191 <span class="comment"></span>u16  <a class="code" href="timer128_8c.html#a20">timer2GetPrescaler</a>(<span class="keywordtype">void</span>);              <span class="comment">///&lt; get timer2 prescaler division rate</span>

⌨️ 快捷键说明

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