gonzui


Format: Advanced Search

mtkernel_3/kernel/tkernel/timer.hbare sourcepermlink (0.02 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.00
    4:  *
    5:  *    Copyright (C) 2006-2019 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.1.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2019/12/11.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      timer.h
   16:  *      System Timer Module Definition
   17:  */
   18: 
   19: #ifndef _TIMER_
   20: #define _TIMER_
   21: 
   22: #include "longlong.h"
   23: 
   24: /*
   25:  * SYSTIM internal expression and conversion
   26:  */
   27: typedef D       LSYSTIM;      /* SYSTIM int. expression */
   28: 
   29: Inline LSYSTIM knl_toLSYSTIM( CONST SYSTIM *time )
   30: {
   31:         LSYSTIM                ltime;
   32: 
   33:         hilo_ll(ltime, time->hi, time->lo);
   34: 
   35:         return ltime;
   36: }
   37: 
   38: Inline SYSTIM knl_toSYSTIM( LSYSTIM ltime )
   39: {
   40:         SYSTIM         time;
   41: 
   42:         ll_hilo(time.hi, time.lo, ltime);
   43: 
   44:         return time;
   45: }
   46: 
   47: /*
   48:  * Absolute time (can be considered the lower 32bit of SYSTIM)
   49:  */
   50: typedef UW      ABSTIM;
   51: 
   52: #define ABSTIM_DIFF_MIN  (0x7FFFFFFF)
   53: 
   54: Inline BOOL knl_abstim_reached( ABSTIM curtim, ABSTIM evttim )
   55: {
   56:         return (ABSTIM)(curtim - evttim) <= (ABSTIM)ABSTIM_DIFF_MIN;
   57: }
   58: 
   59: /*
   60:  * Definition of timer event block 
   61:  */
   62: typedef void    (*CBACK)(void *);  /* Type of callback function */
   63: 
   64: typedef struct timer_event_block {
   65:         QUEUE  queue;           /* Timer event queue */
   66:         ABSTIM time;           /* Event time */
   67:         CBACK  callback;        /* Callback function */
   68:         void   *arg;             /* Argument to be sent to callback function */
   69: } TMEB;
   70: 
   71: /*
   72:  * Current time (Software clock)
   73:  */
   74: IMPORT LSYSTIM  knl_current_time;        /* System operation time */
   75: IMPORT LSYSTIM  knl_real_time_ofs;       /* Difference from actual time */
   76: 
   77: /*
   78:  * Time-event queue
   79:  */
   80: IMPORT QUEUE    knl_timer_queue;
   81: 
   82: /*
   83:  * Register time-event onto timer queue
   84:  */
   85: IMPORT void knl_timer_insert( TMEB *evt, TMO tmout, CBACK cback, void *arg );
   86: IMPORT void knl_timer_insert_reltim( TMEB *event, RELTIM tmout, CBACK callback, void *arg );
   87: IMPORT void knl_timer_insert_abs( TMEB *evt, ABSTIM time, CBACK cback, void *arg );
   88: 
   89: /*
   90:  * Delete from time-event queue
   91:  */
   92: Inline void knl_timer_delete( TMEB *event )
   93: {
   94:         QueRemove(&event->queue);
   95: }
   96: 
   97: #endif /* _TIMER_ */