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

📄 timer_soft.html

📁 at89c5132,at89c51snd1的usb与keyboard驱动程序。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<TR> <TD VALIGN=MIDDLE><PRE> *  This function is less accurate than timeoutxy but the speed is faster. </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> * ---------------------------------------------------------------------------- </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  REQUIREMENTS: </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  The <A HREF="#gl_soft_timer_tick">gl_soft_timer_tick</A> must be updated correctly ,  according crystal & x2 mode </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * / </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define std_timeout16s ( timer )     (  (  (  ( Uint16 )  ( timer ) - ( Uint16 ) <A HREF="#gl_soft_timer_tick">gl_soft_timer_tick</A> ) <= ( Uint16 ) 32767 ) ?FALSE:TRUE )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define std_timeout16l ( timer )     (  (  (  ( Uint16 )  ( timer ) - ( Uint16 )  ( gl_soft_timer_tick>>8 )  ) <= ( Uint16 ) 32767 ) ?FALSE:TRUE )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define std_timeout8s ( timer )      (  (  (  ( Uint8 )  ( timer ) - ( Uint8 ) <A HREF="#gl_soft_timer_tick">gl_soft_timer_tick</A> ) <= ( Uint8 ) 127 ) ?FALSE:TRUE )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define std_timeout8l ( timer )      (  (  (  ( Uint8 )  ( timer ) - ( Uint8 )  ( gl_soft_timer_tick>>8 )  ) <= ( Uint8 ) 127 ) ?FALSE:TRUE )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define std_timeout ( timer )       std_timeout16s ( timer )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define std_timeout16 ( timer )     std_timeout16s ( timer )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define std_timeout8 ( timer )      std_timeout8s ( timer )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE></PRE></TD><TR> <TD VALIGN=MIDDLE><PRE></PRE></TD><TR> <TD VALIGN=MIDDLE><PRE></PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>/ * M *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  NAME: reset_timerxy </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> * ---------------------------------------------------------------------------- </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  PARAMS: </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  timer:    timer to reset </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  return:   the new value of timer </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> * ---------------------------------------------------------------------------- </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  PURPOSE: </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  Force a timeout on timer. </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  x=8 or 16 or nothing for default  ( number of bits of the variable ,  default=16 )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  y=s for short or l for long or nothing for default  ( default=short )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> * ---------------------------------------------------------------------------- </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  EXAMPLE: </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  my_timer=set_timer ( TIMER_1_S ) ; </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  reset_timer ( my_timer ) ; </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  if  ( timeout ( my_timer )  )  ... // Always true due to reset_timer </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> * ---------------------------------------------------------------------------- </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  NOTE: </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  Use  ( x-1 )  bits value for a correct usage of soft timers. </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  Be careful that scheduler roll over must be shortest than 2^ ( x-1 )  ms. </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> * ---------------------------------------------------------------------------- </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  REQUIREMENTS: </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  The <A HREF="#gl_soft_timer_tick">gl_soft_timer_tick</A> must be updated correctly ,  according crystal & x2 mode </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * / </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define reset_timer16s ( timer )     (  ( timer ) = ( Uint16 ) gl_soft_timer_tick-1 )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define reset_timer16l ( timer )     (  ( timer ) = ( Uint16 )  ( gl_soft_timer_tick>>8 ) -1 )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define reset_timer8s ( timer )      (  ( timer ) = ( Uint8 ) gl_soft_timer_tick- ( Uint8 ) 1 )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define reset_timer8l ( timer )      (  ( timer ) = ( Uint8 )  ( gl_soft_timer_tick>>8 ) - ( Uint8 ) 1 )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define reset_timer ( timer )       reset_timer16s ( timer )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define reset_timer16 ( timer )     reset_timer16s ( timer )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>#define reset_timer8 ( timer )      reset_timer8s ( timer )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE></PRE></TD><TR> <TD VALIGN=MIDDLE><PRE></PRE></TD><TR> <TD VALIGN=MIDDLE><PRE>/ * M *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  NAME: update_timerxy </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> * ---------------------------------------------------------------------------- </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  PARAMS: </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  timer:    variable used for timer ,  type xy </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  delay:    delay in ms </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  return:   the new value of timer </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> * ---------------------------------------------------------------------------- </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  PURPOSE: </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  Update a timer ,  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  when a timeout occurs ,  to keep accuracy </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  when an event occurs ,  to delay a timeout keeping time past </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  x=8 or 16 or nothing for default  ( number of bits of the variable ,  default=16 )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  y=s for short or l for long or nothing for default  ( default=short )  </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> * ---------------------------------------------------------------------------- </PRE></TD><TR> <TD VALIGN=MIDDLE><PRE> *  EXAMPLE: </PRE></TD></TABLE><P>Set a timer variable.x=8 or 16 or nothing for default (number of bits of the variable, default=16)y=s for short or l for long or nothing for default (default=short)<P><TABLE BORDER="0"  WIDTH="100 %"  BGCOLOR="#FFD0D0"  CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>delay: delay in ms before timeoutreturn:   value to store in the timer variable (x bits)</PRE></TD></TABLE><H4> Example </H4><PRE>my_timer=set_timer(TIMER_4_S); // <=> my_timer=set_timer16s(4000);</PRE><H4> Note </H4><P>Use (x-1) bits value for a correct usage of soft timers.Be careful that scheduler roll over must be shortest than (x-1) ms.<HR><H2> Functions </H2><A NAME="init_soft_timers"></A><H3> init_soft_timers </H3><TABLE BORDER="0"  WIDTH="100 %"  BGCOLOR="#D6E8FF"  CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>void <A HREF="#init_soft_timers">init_soft_timers</A>  ( void )  </PRE></TD></TABLE><P>This function initialise the soft timer library.<P><TABLE BORDER="0"  WIDTH="100 %"  BGCOLOR="#FFD0D0"  CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>return:   none</PRE></TD></TABLE><H4> Example </H4><PRE>init_soft_timer();</PRE><HR><A NAME="reload_TH0"></A><H3> reload_TH0 </H3><TABLE BORDER="0"  WIDTH="100 %"  BGCOLOR="#D6E8FF"  CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Byte <A HREF="#reload_TH0">reload_TH0</A> ( void )  </PRE></TD></TABLE><P>This function calculate the value to load in TH0 when FOSC is custom (FOSCis not a precomputed value).This function update REMINDER_INC_MS to keep accuracy of timers.<P><TABLE BORDER="0"  WIDTH="100 %"  BGCOLOR="#FFD0D0"  CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>return:   value to load on TH0</PRE></TD></TABLE><HR><A NAME="tempo"></A><H3> tempo </H3><TABLE BORDER="0"  WIDTH="100 %"  BGCOLOR="#D6E8FF"  CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>void <A HREF="#tempo">tempo</A> ( Uint16 delay )  </PRE></TD></TABLE><P>This function manages the temporization.<P><TABLE BORDER="0"  WIDTH="100 %"  BGCOLOR="#FFD0D0"  CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>delay: tempo value in msreturn:   none</PRE></TD></TABLE><H4> Example </H4><PRE>tempo(TIMER_1_S); // Wait 1 sec.</PRE><HR><A NAME="Timer0_interrupt"></A><H3> Timer0_interrupt </H3><TABLE BORDER="0"  WIDTH="100 %"  BGCOLOR="#D6E8FF"  CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>Interrupt  ( void <A HREF="#Timer0_interrupt">Timer0_interrupt</A> ( void )  , IRQ_T0 )  </PRE></TD></TABLE><P>This function is the interrupt program for the timer 0.<P><TABLE BORDER="0"  WIDTH="100 %"  BGCOLOR="#FFD0D0"  CELLPADDING="6"><TR> <TD VALIGN=MIDDLE><PRE>return:   none</PRE></TD></TABLE><HR></BODY></HTML>

⌨️ 快捷键说明

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