/* ** =================================================================== ** Method : TickTimer_Init (bean TimerInt) ** ** Description : ** This method is internal. It is used by Processor Expert ** only. ** =================================================================== */ void TickTimer_Init(void) { CmpHighVal = 3124; /* Compare register value for high speed CPU mode */ SetCV(CmpHighVal); /* Store appropriate value to the compare register according to the selected high speed CPU mode */ SetPV(3); /* Set prescaler register according to the selected high speed CPU mode */ HWEnDi(); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : PIT_1ms_Init (component TimerInt) ** ** Description : ** Initializes the associated peripheral(s) and the beans ** internal variables. The method is called automatically as a ** part of the application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void PIT_1ms_Init(void) { /* PIT0_CTRL: SLAVE=0,??=0,??=0,??=0,??=0,??=0,CLKSEL=0,??=0,PRESCALER=0,PRF=0,PRIE=1,CNT_EN=0 */ setReg(PIT0_CTRL,0x02); /* Set up control register */ SetCV((word)0xC350); /* Store appropriate value to the compare register according to the selected high speed CPU mode */ SetPV((byte)0x01); /* Set prescaler register according to the selected high speed CPU mode */ HWEnDi(); /* Enable/disable device according to status flags */ }
bool ON_BezierCage::Create( const ON_3dPoint* box_corners, int order0, int order1, int order2 ) { int i, j, k; double r,s,t; if ( 0 == box_corners ) return false; for( i = 0; i < 8; i++ ) { if ( !box_corners[i].IsValid() ) return false; } // create trilinear "cube" to make it easy // to calculate CV locations. ON_BezierCage cube(3,0,2,2,2); cube.SetCV(0,0,0,box_corners[0]); cube.SetCV(1,0,0,box_corners[1]); cube.SetCV(1,1,0,box_corners[2]); cube.SetCV(0,1,0,box_corners[3]); cube.SetCV(0,0,1,box_corners[4]); cube.SetCV(1,0,1,box_corners[5]); cube.SetCV(1,1,1,box_corners[6]); cube.SetCV(0,1,1,box_corners[7]); if ( 2 == order0 && 2 == order1 && 2 == order2 ) { operator=(cube); } else { if (!Create(3,0,order0,order1,order2)) return false; const int d0 = Degree(0); const int d1 = Degree(1); const int d2 = Degree(2); for (i = 0; i <= d0; i++) { r = ((double)i)/((double)d0); for (j = 0; j <= d1; j++) { s = ((double)j)/((double)d1); for (k = 0; k <= d2; k++) { t = ((double)k)/((double)d2); SetCV(i,j,k,cube.PointAt(r,s,t)); } } } } return IsValid(); }
bool ON_NurbsCurve::Morph( const ON_SpaceMorph& morph ) { DestroyCurveTree(); ON_BOOL32 bIsClosed = IsClosed(); ON_BOOL32 bIsPeriodic = IsPeriodic(); morph.MorphPointList( m_dim, m_is_rat, m_cv_count, m_cv_stride, m_cv ); if ( bIsPeriodic ) { int i, deg = m_order-1; for ( i = 0; i < deg; i++ ) SetCV( m_cv_count-deg+i, ON::intrinsic_point_style, CV(i) ); } else if ( bIsClosed ) { SetCV( m_cv_count-1, ON::intrinsic_point_style, CV(0) ); } return true; }
/* ** =================================================================== ** Method : TickTimer_SetPeriodMS (bean TimerInt) ** ** Description : ** This method sets the new period of the generated events. ** The period is expressed in miliseconds as a 16-bit ** unsigned integer number. ** This method is available only if runtime setting type ** 'from interval' is selected in the Timing dialog box in ** Runtime setting area. ** Parameters : ** NAME - DESCRIPTION ** Time - Period to set [in miliseconds] ** (1 to 20 milliseconds) ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** ERR_MATH - Overflow during evaluation ** ERR_RANGE - Parameter out of range ** =================================================================== */ byte TickTimer_SetPeriodMS(word Time) { dlong rtval; /* Result of two 32-bit numbers multiplication */ word rtword; /* Result of 64-bit number division */ if ((Time > 20) || (Time < 1)) /* Is the given value out of range? */ return ERR_RANGE; /* If yes then error */ PE_Timer_LngMul((dword)Time,204734464,&rtval); /* Multiply given value and high speed CPU mode coefficient */ if (PE_Timer_LngHi2(rtval[0],rtval[1],&rtword)) /* Is the result greater or equal than 65536 ? */ rtword = 65535; /* If yes then use maximal possible value */ CmpHighVal = rtword; /* Store result (compare register value for high speed CPU mode) to the variable CmpHighVal */ SetCV(CmpHighVal); /* Store appropriate value to the compare register according to the selected high speed CPU mode */ return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : TickTimer_SetFreqHz (bean TimerInt) ** ** Description : ** This method sets the new frequency of the generated ** events. The frequency is expressed in Hz as a 16-bit ** unsigned integer number. ** This method is available only if runtime setting type ** 'from interval' is selected in the Timing dialog box in ** Runtime setting area. ** Parameters : ** NAME - DESCRIPTION ** Freq - Frequency to set [in Hz] ** (50 to 1000 Hz) ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_SPEED - This device does not work in ** the active speed mode ** ERR_MATH - Overflow during evaluation ** ERR_RANGE - Parameter out of range ** =================================================================== */ byte TickTimer_SetFreqHz(word Freq) { dlong rtval; /* Result of two 32-bit numbers division */ word rtword; /* Result of 64-bit number division */ if ((Freq > 1000) || (Freq < 50)) /* Is the given value out of range? */ return ERR_RANGE; /* If yes then error */ rtval[1] = 799744000 / (dword)Freq; /* Divide high speed CPU mode coefficient by the given value */ rtval[0] = 0; /* Convert result to the type dlong */ if (PE_Timer_LngHi1(rtval[0],rtval[1],&rtword)) /* Is the result greater or equal than 65536 ? */ rtword = 65535; /* If yes then use maximal possible value */ CmpHighVal = rtword; /* Store result (compare register value for high speed CPU mode) to the variable CmpHighVal */ SetCV(CmpHighVal); /* Store appropriate value to the compare register according to the selected high speed CPU mode */ return ERR_OK; /* OK */ }
/* ** =================================================================== ** Method : TI1_Init (component TimerInt) ** ** Description : ** Initializes the associated peripheral(s) and the beans ** internal variables. The method is called automatically as a ** part of the application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void TI1_Init(void) { /* TMR2_CTRL: CM=0,PCS=0,SCS=0,ONCE=0,LENGTH=1,DIR=0,Co_INIT=0,OM=4 */ setReg(TMR2_CTRL,36); /* Stop timer, use alternating compare registers */ /* TMR2_SCR: TCF=0,TCFIE=1,TOF=0,TOFIE=0,IEF=0,IEFIE=0,IPS=0,INPUT=0,Capture_Mode=0,MSTR=0,EEOF=0,VAL=0,FORCE=0,OPS=0,OEN=0 */ setReg(TMR2_SCR,16384); /* Enable compare interrupt */ setReg(TMR2_CNTR,0); /* Reset counter register */ setReg(TMR2_LOAD,0); /* Reset load register */ setReg(TMR2_CMP1,31999); /* Set up compare 1 register */ setReg(TMR2_CMP2,31999); /* Set up compare 2 register */ /* TMR2_COMSCR: DBG_EN=0,??=0,??=0,??=0,??=0,??=0,??=0,TCF2EN=0,TCF1EN=0,TCF2=0,TCF1=0,CL2=1,CL1=2 */ setReg(TMR2_COMSCR,6); /* Compare load control */ SetCV((word)31999); /* Store appropriate value to the compare register according to the selected high speed CPU mode */ SetPV((byte)8); /* Set prescaler register according to the selected high speed CPU mode */ setRegBitGroup(TMR2_CTRL,CM,1); /* Run counter */ }
/* ** =================================================================== ** Method : FC81_Init (component FreeCntr8) ** ** Description : ** Initializes the associated peripheral(s) and the beans ** internal variables. The method is called automatically as a ** part of the application initialization code. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void FC81_Init(void) { /* TMR0_CTRL: CM=0,PCS=0,SCS=0,ONCE=0,LENGTH=1,DIR=0,Co_INIT=0,OM=4 */ setReg(TMR0_CTRL,36); /* Stop timer, use alternating compare registers */ /* TMR0_SCTRL: TCF=0,TCFIE=1,TOF=0,TOFIE=0,IEF=0,IEFIE=0,IPS=0,INPUT=0,CAPTURE_MODE=0,MSTR=0,EEOF=0,VAL=0,FORCE=0,OPS=0,OEN=0 */ setReg(TMR0_SCTRL,16384); setReg(TMR0_CNTR,0); /* Reset counter register */ setReg(TMR0_LOAD,0); /* Reset load register */ setReg(TMR0_COMP1,255); /* Set up compare 1 register */ setReg(TMR0_COMP2,255); /* Set up compare 2 register */ /* TMR0_CSCTRL: DBG_EN=0,FAULT=0,ALT_LOAD=0,??=0,??=0,??=0,??=0,TCF2EN=0,TCF1EN=0,TCF2=0,TCF1=0,CL2=1,CL1=2 */ setReg(TMR0_CSCTRL,6); /* Enable compare 1 interrupt */ TTicks = 0; /* Counter of timer ticks */ TOvf = FALSE; /* Counter overflow flag */ SetCV((word)255); /* Store appropriate value to the compare register according to the selected high speed CPU mode */ SetPV((byte)8); /* Set prescaler register according to the selected high speed CPU mode */ setRegBitGroup(TMR0_CTRL,CM,1); /* Run counter */ }