Exemple #1
0
/*---------------------------------------------------------------------
 * Resume the tick mechanism.  Update the expiration time for all
 * ticking timers.
 *-------------------------------------------------------------------*/
void
TIM_resume( void )
{
  #if ESCHER_SYS_MAX_XTUML_TIMERS > 0
  ETimer_t * cursor = animate;
  ETimer_time_t t;      /* difference between now and start of pause */
  t = ETimer_msec_time() - start_of_pause;
  while ( cursor != 0 ) {
    cursor->expiration += t;
    cursor = cursor->next;
  }
  paused = false;
  #endif   /* if ESCHER_SYS_MAX_XTUML_TIMERS > 0 */
}
Exemple #2
0
/*=====================================================================
 * BridgePoint Primitive:
 * <was_running_flag> = TIM_timer_reset_time(
 *   microseconds:<integer_var>,
 *   timer_inst_ref:<timer_inst_ref_var> )
 * Try to change expiration of an existing timer.
 * If successful, return true.
 *===================================================================*/
bool
TIM_timer_reset_time(
  const Escher_uSec_t ee_microseconds,
  Escher_Timer_t * const ee_timer_inst_ref )
{
  /* Insert implementation specific code here.  */
  ETimer_t * t = (ETimer_t *) ee_timer_inst_ref;
  bool rc = false;
  if ( ( t != 0 ) && ( t->expiration > 0UL ) ) {
    t->expiration = ETimer_msec_time() + ee_microseconds/USEC_CONVERT + 1UL;
    rc = true;
  }
  return ( rc );
}
Exemple #3
0
/*=====================================================================
 * BridgePoint Primitive:
 * <integer_var> = TIM::timer_remaining_time(
 *   timer_inst_ref:<timer_inst_ref_var> )
 * Return the remaining time of the specified timer.
 *===================================================================*/
Escher_uSec_t
TIM_timer_remaining_time(
  const Escher_Timer_t * const ee_timer_inst_ref )
{
  /* Insert implementation specific code here.  */
  Escher_uSec_t t = 0UL;
  if ( ee_timer_inst_ref != 0 ) {
    t = ETimer_msec_time();
    t = ( ((ETimer_t *) ee_timer_inst_ref)->expiration > t ) ?
      USEC_CONVERT * ( ((ETimer_t *) ee_timer_inst_ref)->expiration - t ) :
      0UL;
  }
  return ( t );  
}
Exemple #4
0
/*---------------------------------------------------------------------
 * This is the repetitively invoked timer poller.
 * This routine needs to be run periodically.
 *-------------------------------------------------------------------*/
void
TIM_tick( void )
{
#if ESCHER_SYS_MAX_XTUML_TIMERS > 0
  /*-----------------------------------------------------------------*/
  /* Check to see if there are timers in the ticking timers list.    */
  /*-----------------------------------------------------------------*/
  if ( animate != 0 ) {
    if ( animate->expiration <= ETimer_msec_time() ) {
      timer_fire( animate );
    }
  }
#endif   /* if ESCHER_SYS_MAX_XTUML_TIMERS > 0 */
}
Exemple #5
0
/*---------------------------------------------------------------------
 * This is the repetitively invoked timer poller.
 * This routine needs to be run periodically.
 *-------------------------------------------------------------------*/
void
TIM_tick( void )
{
#if ESCHER_SYS_MAX_XTUML_TIMERS > 0
  /*-----------------------------------------------------------------*/
  /* Check to see if there are timers in the ticking timers list.    */
  /*-----------------------------------------------------------------*/
  #ifdef ESCHER_TASKING_SystemC
  Escher_mutex_lock( SEMAPHORE_FLAVOR_TIMER );
  #endif
  if ( animate != 0 ) {
    if ( animate->expiration <= ETimer_msec_time() ) {
      timer_fire( animate );
    }
  }
  #ifdef ESCHER_TASKING_SystemC
  Escher_mutex_unlock( SEMAPHORE_FLAVOR_TIMER );
  #endif
#endif   /* if ESCHER_SYS_MAX_XTUML_TIMERS > 0 */
}
Exemple #6
0
/*---------------------------------------------------------------------
 * Get a timer instance from the inanimate list, provide the
 * expiration time and insert it into its proper location among
 * the currently ticking timers.
 *-------------------------------------------------------------------*/
static ETimer_t *
timer_start(
  const ETimer_time_t duration,
  Escher_xtUMLEvent_t * const event
)
{
  ETimer_t * t;
  t = inanimate;
  if ( t != 0 ) {
    inanimate = inanimate->next;
    t->event = event;
    /*---------------------------------------------------------------*/
    /* Calculate the timer expiration time.                          */
    /* Note:  Add one to the duration to make sure that delay is     */
    /* at least as long as duration.                                 */
    /*---------------------------------------------------------------*/
    t->expiration = ETimer_msec_time() + duration + 1UL;
    timer_insert_sorted( t );
  }
  return ( t );
}
Exemple #7
0
/*---------------------------------------------------------------------
 * Generate delayed event to the application.
 * Deactivate fired timer.
 *-------------------------------------------------------------------*/
void
TIM::timer_fire(
  ETimer_t * const t
)
{
  ((sys_events*) t->event->thismodule)->Escher_SendEvent( t->event );
  t->expiration = ( t->recurrence == 0 ) ? 0 : t->expiration + t->recurrence;
  if ( 0 != t->recurrence ) {
    Escher_xtUMLEvent_t * e = ((sys_events*) t->event->thismodule)->Escher_AllocatextUMLEvent();
    ((sys_sets*) t->event->thismodule)->Escher_memmove( e, t->event, sizeof( Escher_xtUMLEvent_t ) );
    t->event = e;
    animate = animate->next;      /* Remove from front of list.    */
    timer_insert_sorted( t );
  } else {
  animate = animate->next;        /* Remove from active list.      */
  t->next = inanimate;            /* Connect to inactive list.     */
  inanimate = t;
  }
  if ( animate != 0 ) {
    sc_xtuml_timer_event->notify( animate->expiration - ETimer_msec_time(), SC_MS );
  }
}
Exemple #8
0
/*=====================================================================
 * BridgePoint Primitive:
 * <timestamp_var> = TIM::current_clock()
 * This bridge returns a system dependent time value.
 *===================================================================*/
Escher_TimeStamp_t
TIM_current_clock( void )
{
  /* Insert implementation specific code here.  */
  return ( ETimer_msec_time() );
}