Ejemplo n.º 1
0
/**
   Function called from tone timer and switch the tone on/off.
\param
   Timer  - TimerID of timer that exipres
\param
   nArg   - Argument of timer including the TAPI_CONNECTION structure
           (as integer pointer)
\return
   none
\remarks
   Only for compability reasons
*/
IFX_void_t Tone_PredefOnTimer(Timer_ID Timer, IFX_int32_t nArg)
{
   VINETIC_CHANNEL *pCh = (VINETIC_CHANNEL *) nArg;
   VINETIC_DEVICE  *pDev     = (VINETIC_DEVICE *)pCh->pParent;
   TAPI_CONNECTION *pChannel = &pDev->TapiDev.pChannelCon[pCh->nChannel-1];
   IFX_uint32_t     nTime;
   IFX_uint16_t     nDscr;

   if (pChannel->TapiTgToneData.nToneState == TAPI_CT_IDLE)
   {
      /* error: tone already stopped */
      LOG(TAPI_DRV,DBG_LEVEL_HIGH,
         ("\n\rVINETIC IFX_ERROR: No Tone is played yet!\n\r"));
      return;
   }
   else if (pChannel->TapiTgToneData.nToneState == TAPI_CT_ACTIVE)
   {
      /* data to stop tone generator(s) (COR8_OFF) | (PTG_OFF) | (ALL_TG_OFF) */
      nDscr = 0;
      /* calculate off-time for timer */
      nTime = pChannel->TapiTgToneData.nOffTime / 4;
      if (nTime == 0)
      {
         nTime = pChannel->TapiTgToneData.nOnTime / 4;
         pChannel->TapiTgToneData.nToneState = TAPI_CT_ACTIVE;
      }
      else
      {
         pChannel->TapiTgToneData.nToneState = 2;
      }
   }
   else  /* pChannel->TapiTgToneData.nToneState == 2 */
   {
      /* data to start tone generator 1 */
      nDscr = (DSCR_COR8)|(DSCR_PTG)|(DSCR_TG1_EN);
      if (pChannel->TapiTgToneData.bUseSecondTG)
      {
         /* also start tone generator 2*/
         nDscr |= DSCR_TG2_EN;
      }
      /* calculate on-time for timer */
      nTime = pChannel->TapiTgToneData.nOnTime / 4;
      /* change tone state */
      pChannel->TapiTgToneData.nToneState = TAPI_CT_ACTIVE;
   }
   /* check time for smallest timer interval */
   if (nTime < 20)
   {
      nTime = 20;
   }
   if (pChannel->TapiTgToneData.nOffTime != 0)
   {
      /* call target function to set tone generator(s) */
      RegModify (pDev, CMD1_SOP|(pChannel->nChannel), SOP_OFFSET_DSCR,
                (DSCR_COR8)|(DSCR_PTG)|(DSCR_TG1_EN|DSCR_TG2_EN), nDscr);
   }
   /* set tone timer */
   TAPI_SetTime_Timer(Timer, nTime, IFX_FALSE, IFX_TRUE);
}
Ejemplo n.º 2
0
static void     RegMenuItem( a_window *wnd, gui_ctl_id id, int row, int piece )
{
    reg_window              *reg = WndReg( wnd );
    int                     i;
    unsigned                bit;
    mad_modify_list const   *possible;
    int                     num_possible;
    address                 addr;
    bool                    valid_reg;

    i = GetRegIdx( reg, row, piece >>1 );
    switch( id ) {
    case MENU_INITIALIZE:
        valid_reg = i != -1 && reg->info[i].info != NULL &&
                    MADRegSetDisplayModify( reg->data, reg->info[i].info,
                                            &possible, &num_possible ) == MS_OK;
        WndMenuEnable( wnd, MENU_REGISTER_MODIFY, valid_reg );
        WndMenuEnable( wnd, MENU_REGISTER_INSPECT, valid_reg );
        bit = MADRegSetDisplayToggle( reg->data, 0, 0 );
        for( i = 0; i < reg->num_toggles; ++i ) {
            WndMenuCheck( wnd, MENU_REGISTER_TOGGLES + i, ( bit & 1 ) != 0 );
            bit >>= 1;
        }
        break;
    case MENU_REGISTER_INSPECT:
        if( MADRegInspectAddr( reg->info[i].info, &DbgRegs->mr, &addr ) == MS_OK ) {
            PushAddr( addr );
            WndInspectExprSP( "" );
        }
        break;
    case MENU_REGISTER_MODIFY:
        RegModify( wnd, row, piece );
        break;
    default:
        bit = 1 << ( id - MENU_REGISTER_TOGGLES );
        MADRegSetDisplayToggle( reg->data, bit, bit );
        RegResize( wnd );
        WndZapped( wnd );
    }
}