Exemplo n.º 1
0
void av_update(struct IC *p,bvtype *isused)
{
  int i,j;
  if((p->z.flags&(VKONST|VAR))==VAR){
    i=p->z.v->index;
    if(p->z.flags&DREFOBJ) i+=vcount-rcount;    
    if(i<0||i>=vcount){
      printf("i=%d\n",i);pric2(stdout,p); ierror(0);
    }
    if(p->z.flags&DREFOBJ){
      if(!(p->z.v->flags&DNOTTYPESAFE))
	BCLR(isused,i);
    }else{
      if(ISSCALAR(p->z.v->vtyp->flags)||(p->code==ASSIGN&&zmeqto(p->q2.val.vmax,szof(p->z.v->vtyp))))
	BCLR(isused,i);
    }
    /*  bei Zuweisung an p wird *p aktiv    */
    if(i<rcount) BSET(isused,i+vcount-rcount);
  }
  for(j=0;j<p->use_cnt;j++){
    i=p->use_list[j].v->index;
    if(p->use_list[j].flags&DREFOBJ) i+=vcount-rcount;
    if(i<0||i>=vcount) continue;
    BSET(isused,i);
  }  
}
void ScrollHoriz()
{
	auto oldX = v_screenposx;

	auto diffX = v_player->x - v_screenposx;
	int newX;

	if(diffX < 144)
		newX = max(v_player->x - 144, v_limitleft2);
	else if(diffX < 160)
	{
		v_scrshiftx = 0;
		return;
	}
	else
		newX = min(v_limitright2, min(diffX - 160, 16) + v_screenposx);

	auto oldX = v_screenposx;
	v_screenposx = newX;
	v_scrshiftx = (newX - oldX) << 8;

	if(((v_screenposx & 0x10) ^ v_screenscrollx16) == 0)
	{
		v_screenscrollx16 ^= 0x10;

		if(v_screenposx < oldX)
			BSET(v_bgscroll1, Scrolled_L); // back
		else
			BSET(v_bgscroll1, Scrolled_R); // forward
	}
}
Exemplo n.º 3
0
void
saucy_print_automorphism(int *gamma, int gap_mode)
{
	int i, j;

	/* Print the automorphism */
	for (i = 0; i < n; ++i) {

		/* Mark elements we've already seen */
		if (BISSET(bit_contents, i)) continue;
		BSET(bit_contents, i);

		/* Skip fixed elements */
		if (gamma[i] == i) continue;
		printf("(%d", gap_mode ? i+1 : i);

		/* Mark and print elements in this orbit */
		for (j = gamma[i]; j != i; j = gamma[j]) {
			BSET(bit_contents, j);
			putchar(gap_mode ? ',' : ' ');
			printf("%d", gap_mode ? j+1 : j);
		}

		/* Finish off the orbit */
		printf(")");
	}

	/* Clean up after ourselves */
	if (!gap_mode) printf("\n");
	BWIPE(bit_contents, n);
}
Exemplo n.º 4
0
Arquivo: lcd.c Projeto: Micha500/gt3b
// send cnt bits to LCD controller, only low bits of "bits" are used
// use timer4 to get 600kHz clock for driving WR/ signal
// timer is used in one-pulse mode and is started after each WR/ change,
//   so there will always be minimal required length of pulse also
//   when interrupted by some interrupt
static void lcd_send_bits(u8 cnt, u16 bits) {
    // shift bits to high-bits
    bits <<= (u8)(16 - cnt);
    WR0;
    BSET(TIM4_CR1, 0);			// start timer
    WR0;				// optimize hack
    do {
	if (bits & 0x8000) {
	    DATA1;
	}
	else {
	    DATA0;
	}
	bits <<= 1;			// to next bit
	while (!BCHK(TIM4_SR, 0));	// wait for timer
	WR1;
	BRES(TIM4_SR, 0);		// clear intr flag
	BSET(TIM4_CR1, 0);		// start timer
	if (!--cnt)  break;
	while (!BCHK(TIM4_SR, 0));	// wait for timer
	WR0;
	BRES(TIM4_SR, 0);		// clear intr flag
	BSET(TIM4_CR1, 0);		// start timer
    } while (1);
    while (!BCHK(TIM4_SR, 0));		// wait for timer
    BRES(TIM4_SR, 0);			// clear intr flag
}
Exemplo n.º 5
0
unsigned long int
x86_nop_xfer (char *xferstr)
{
        int                     bw = 0; /* bitfield walker */
        unsigned char           tgt;    /* resulting instruction */

        /* in a valid xferstr we trust */
        for (tgt = 0 ; xferstr != NULL && xferstr[0] != '\0' ; ++xferstr) {
                switch (xferstr[0]) {
                case ('0'):
                        BSET (tgt, 1, 0, bw);
                        break;
                case ('1'):
                        BSET (tgt, 1, 1, bw);
                        break;
                case ('r'):
                        BSET (tgt, 3, x86_nop_rwreg (), bw);
                        break;
                case ('.'):
                        break;  /* ignore */
                default:
                        fprintf (stderr, "on steroids, huh?\n");
                        exit (EXIT_FAILURE);
                        break;
                }
        }

        if (bw != 8) {
                fprintf (stderr, "invalid bitwalker: bw = %d\n", bw);
                exit (EXIT_FAILURE);
        }

        return (tgt);
}
Exemplo n.º 6
0
/* node_dynamic_reset: clean a pynode, getting rid of all
 * data dynamically created for it. */
static void node_dynamic_reset(bNode *node, int unlink_text)
{
	bNodeType *tinfo, *tinfo_default;
	Material *ma;

	tinfo = node->typeinfo;
	tinfo_default = node_dynamic_find_typeinfo(&node_all_shaders, NULL);

	if ((tinfo == tinfo_default) && unlink_text) {
		ID *textID = node->id;
	/* already at default (empty) state, which happens if this node's
	 * script failed to parse at the first stage: definition. We're here
	 * because its text was removed from Blender. */
		for (ma= G.main->mat.first; ma; ma= ma->id.next) {
			if (ma->nodetree) {
				bNode *nd;
				for (nd= ma->nodetree->nodes.first; nd; nd = nd->next) {
					if (nd->id == textID) {
						nd->id = NULL;
						nd->custom1 = 0;
						nd->custom1 = BSET(nd->custom1, NODE_DYNAMIC_NEW);
						BLI_strncpy(nd->name, "Dynamic", 8);
						return;
					}
				}
			}
		}
	}

	node_dynamic_rem_all_links(tinfo);
	node_dynamic_free_typeinfo_sockets(tinfo);

	/* reset all other XXX shader nodes sharing this typeinfo */
	for (ma= G.main->mat.first; ma; ma= ma->id.next) {
		if (ma->nodetree) {
			bNode *nd;
			for (nd= ma->nodetree->nodes.first; nd; nd = nd->next) {
				if (nd->typeinfo == tinfo) {
					node_dynamic_free_storage_cb(nd);
					node_dynamic_free_sockets(nd);
					//node_dynamic_update_socket_links(nd, ma->nodetree);
					nd->typeinfo = tinfo_default;
					if (unlink_text) {
						nd->id = NULL;
						nd->custom1 = 0;
						nd->custom1 = BSET(nd->custom1, NODE_DYNAMIC_NEW);
						BLI_strncpy(nd->name, "Dynamic", 8);
					}
				}
			}
		}
	}

	/* XXX hardcoded for shaders: */
	if (tinfo->id) { BLI_remlink(&node_all_shaders, tinfo); }
	node_dynamic_free_typeinfo(tinfo);
}
Exemplo n.º 7
0
static void
update_theta(void)
{
	int i, j, x, y, z;

	/* Update all cell representatives */
	for (i = 0; i < n; ++i) {

		/* Look for the start of an orbit */
		if (i >= gamma[i]) continue;

		/* Find the cell rep for the two elements */
		for (x = i; x != theta[x]; x = theta[x]);
		for (y = gamma[i]; y != theta[y]; y = theta[y]);

		/* Pick the cell with the smaller representative */
		z = (x < y) ? x : y;

		/* Update the old root's cell representatives */
		theta[x] = theta[y] = z;
	}

	/* Clear out last automorphism if we've already saved max */
	if (saved == max_saved) {
		--saved;
		BWIPE(FIX(saved), n);
		BWIPE(MCR(saved), n);
	}

	/* Look for orbits in gamma and update fix and mcr */
	for (i = 0; i < n; ++i) {

		/* Find the start of an orbit, and save it as an mcr */
		if (BISSET(bit_contents, i)) continue;
		BSET(bit_contents, i);
		BSET(MCR(saved), i);

		/* If the element is fixed, save as fixed and continue */
		if (gamma[i] == i) {
			BSET(FIX(saved), i);
			continue;
		}

		/* Find all other elements in the orbit */
		for (j = gamma[i]; j != i; j = gamma[j]) {
			BSET(bit_contents, j);
		}
	}

	/* Clean up */
	BWIPE(bit_contents, n);
	++saved;
}
Exemplo n.º 8
0
void ptsstop(TTY tp, int fl)
{
	if (!fl)
	{
		fl = TIOCPKT_STOP;
		BSET(tp->state, PF_STOPPED);
	}
	else	
		BCLR(tp->state, PF_STOPPED);
	BSET(tp->send, fl);
	ptc_select(tp);
}
Exemplo n.º 9
0
void pwm_set_chan(char chan, char pol, char clk, char cae, char ctl)
{
	
	if (pol >= 0)
		BSET(PWMPOL,chan,pol);
	if (clk >= 0)
		BSET(PWMCLK,chan,clk);
	if (cae >= 0)
		BSET(PWMCAE,chan,cae);
	if (ctl >= 0)
		BSET(PWMCTL,chan,ctl);
		
}
Exemplo n.º 10
0
Arquivo: ppm.c Projeto: eknl/gt3b
// calculate length of SYNC signal (substract previous channel values)
// also sets flag for ppm_interrupt to use new values
// also starts TIM3 at first call
void ppm_calc_sync(void) {
    // ARR must be set to computed value - 1, that is why we are substracting
    //   5000, it is quicker way to "add 5000" and then substract 1 from result
    *(u16 *)(&ppm_values[0]) =
	(u16)(((10 * (u32)PPM_FRAME_LENGTH - ppm_microsecs01) * PPM_MUL_SYNC
	       - PPM(500)) / PPM(1000));
    ppm_microsecs01 = 0;
    // for first ppm values, enable timer
    if (ppm_enabled)  return;
    ppm_enabled = 1;
    BSET(TIM3_EGR, 0);    // generate update event
    BSET(TIM3_CR1, 0);    // enable timer
}
Exemplo n.º 11
0
ALIST_API ControlPartCode ALSetFocus(ControlPartCode focusPart, ALHandle hAL)
{	ControlPartCode	result;
	Boolean			oldFocus;
	CGrafPtr			savePort;
	WindowPtr		winRef;

	if (hAL == nil || *hAL == nil)
		return kControlFocusNoPart;

	// Keep track of the old state of things.
	oldFocus = (BTST((*hAL)->flags, alFFocused) != 0);

	switch (focusPart) {
	case kControlFocusNoPart:		// Turn off all focusing.
		BCLR((*hAL)->flags, alFFocused);
		result = kControlFocusNoPart;
		break;
	case kControlFocusNextPart:		// Switch the state from off/on to on/off.
	case kControlFocusPrevPart:
		if (BTST((*hAL)->flags, alFFocused)) {
			// Turn off the focus.
			BCLR((*hAL)->flags, alFFocused);
			result = kControlFocusNoPart;
		} else {
			// Turn on the focus.
			BSET((*hAL)->flags, alFFocused);
			result = kControlListBoxPart;
		}
		break;
	case kControlListBoxPart:			// Turn on focusing.
		BSET((*hAL)->flags, alFFocused);
		result = kControlListBoxPart;
		break;
	default:	// simply return the state of focus
			result = (BTST((*hAL)->flags, alFFocused)) ? kControlListBoxPart : kControlFocusNoPart;
			break;
	}

	// If the focus changed, redraw if the alFDrawFocus feature is turned on.
	if ( BTST((*hAL)->features, alFDrawFocus) && oldFocus != (BTST((*hAL)->flags, alFFocused) != 0)) {
	  GDHandle        saveDevice;
	  
	  GetGWorld(&savePort, &saveDevice);
	  ALGetInfo(alWindow, &winRef, hAL);
	  SetPortWindowPort(winRef);
	  _ALDrawListBorder(hAL);
	  SetGWorld(savePort, saveDevice);
	}

	return result;
} // ALSetFocus
Exemplo n.º 12
0
ALIST_API short ALFeatureFlag(unsigned long feature, short action, ALHandle hAL)
{	ALPtr	pAL;
	short	status;

	if (hAL == nil || *hAL == nil)
		return alBitClear;

	pAL = *hAL;

	// get current status of the specified feature
	status = BTST(pAL->features, feature) ? alBitSet : alBitClear;

	// if action is alBitToggle, invert flag
	if (action == alBitToggle)
		action = 1 - status;

	// reset flag according to action
	if (action == alBitClear) {
		BCLR(pAL->features, feature);
		if ( feature == alFInhibitRedraw )
			// If we're enabling drawing, recalculate what's visible.
			_ALCalcVisibleCells( hAL );
	} else if ( action == alBitSet )
		BSET(pAL->features, feature);

	// return old status
	return status;
} // ALFeatureFlag
Exemplo n.º 13
0
/*
 * initialize - hand-craft a cache entry for startup, otherwise get ready
 */
static struct sset *
initialize(struct vars * v,
		   struct dfa * d,
		   chr *start)
{
	struct sset *ss;
	int			i;

	/* is previous one still there? */
	if (d->nssused > 0 && (d->ssets[0].flags & STARTER))
		ss = &d->ssets[0];
	else
	{							/* no, must (re)build it */
		ss = getvacant(v, d, start, start);
		if (ss == NULL)
			return NULL;
		for (i = 0; i < d->wordsper; i++)
			ss->states[i] = 0;
		BSET(ss->states, d->cnfa->pre);
		ss->hash = HASH(ss->states, d->wordsper);
		assert(d->cnfa->pre != d->cnfa->post);
		ss->flags = STARTER | LOCKED | NOPROGRESS;
		/* lastseen dealt with below */
	}

	for (i = 0; i < d->nssused; i++)
		d->ssets[i].lastseen = NULL;
	ss->lastseen = start;		/* maybe untrue, but harmless */
	d->lastpost = NULL;
	d->lastnopr = NULL;
	return ss;
}
Exemplo n.º 14
0
void Task_WindOut(void)
{
	BSET(AWS_DDR, AWS_PIN);
	BeginCritical();
	// Fast PWM 8 bit
	TCCR1A = BV(COM1A1) | BV(COM1B1) | BV(WGM10);
	TCCR1B = BV(WGM12) | BV(CS11);
	// Enable PWM pins
	AWA_DDR |= BV(AWA_DDR_COS) | BV(AWA_DDR_SIN);
	EndCritical();

   for (;;) {
		delay_ms(80);
		//
		// Dimension for 5 ms pulses (100 Hz) at 60 Kts 
		// 60 kts - 100 revs /
		if (Nav_AWS < 5)
			windPulse = 0;
		else
			windPulse = 2000 / Nav_AWS;

		register int deg = Nav_AWA/10;
		BeginCritical();
		AWA_SIN = trigint_sin8u(deg * 45 + (deg * 51 / 100));
		deg = (90 - deg + 360) % 360;
		AWA_COS = trigint_sin8u(deg * 45 + (deg * 51 / 100));
		EndCritical();
	}
}
Exemplo n.º 15
0
Arquivo: input.c Projeto: eknl/gt3b
static void input_loop(void) {

    // read initial ADC values
    BSET(ADC_CR1, 0);			// start conversion
    while (!BCHK(ADC_CSR, 7))  pause();	// wait for end of conversion
    read_ADC();

    // put initial values to all buffers
    ADC_BUFINIT(0);
    ADC_BUFINIT(1);
    ADC_BUFINIT(2);
    adc_battery = adc_battery_last;
    adc_battery_filt = (u32)adc_battery * ADC_BAT_FILT;

    // task CALC must be awaked to compute values before PPM will take on
    awake(CALC);
    input_initialized = 1;

    while (1) {
	// read ADC only when EOC flag (only for first it will not be ready)
	if (BCHK(ADC_CSR, 7))
	    read_ADC();
	read_keys();
	stop();
    }
}
Exemplo n.º 16
0
Arquivo: lcd.c Projeto: Micha500/gt3b
// initialize LCD pins and LCD controller
void lcd_init(void) {
    // set direction of pins
    IO_OPF(C, 3);  // CS/ pin
    IO_OP(E, 5);   // DATA pin
    IO_OP(F, 4);   // WR/ pin
    IO_OP(D, 2);   // Backlight pin

    // set default values to pins
    CS1;
    WR1;
    DATA1;
    LCD_BCK0;

    // initialize timer 4 used to time WR/ signal
    BSET(CLK_PCKENR1, 4);     // enable clock to TIM4
    TIM4_CR1 = 0b00001100;    // no auto-reload, one-pulse,URS-overflow, disable
    TIM4_IER = 0;             // no interrupts
    TIM4_PSCR = 0;            // prescaler = 1
    TIM4_ARR = 24;            // it will be about 600kHz for WR/ signal
    TIM4_CNTR = 0;	      // reset timer value

    // initialize HT1621B
    lcd_command(HT_BIAS_13 | (0b10 << HT_BIAS_SHIFT));  // BIAS 1/3, 4 COMs
    lcd_command(HT_RC_256K);  // clock RC 256kHz
    lcd_command(HT_SYS_DIS);  // OSC+BIAS off
    lcd_command(HT_WDT_DIS);  // disable WDT
    lcd_command(HT_SYS_EN);   // OSC on
    lcd_command(HT_LCD_ON);   // BIAS on

    // initialize LCD task, will be used when sending following lcd_command-s
    build(LCD);
    activate(LCD, lcd_loop);
    sleep(LCD);		      // no work yet
}
Exemplo n.º 17
0
Arquivo: input.c Projeto: eknl/gt3b
static void read_ADC(void) {
    u16 *buf = adc_buffer[adc_buffer_pos];
    u8  dead;

    ADC_NEWVAL(0);
    ADC_NEWVAL(1);
    ADC_NEWVAL(2);
    adc_battery_last = ADC_DB3R;

    adc_buffer_pos++;
    adc_buffer_pos &= 3;

    BRES(ADC_CSR, 7);		// remove EOC flag
    BSET(ADC_CR1, 0);		// start new conversion

    // average battery voltage and check battery low
    // ignore very low, which means that it is supplied from SWIM connector
    adc_battery_filt = adc_battery_filt * (ADC_BAT_FILT - 1); // splitted - compiler hack
    adc_battery_filt = (adc_battery_filt + (ADC_BAT_FILT / 2)) / ADC_BAT_FILT
		       + adc_battery_last;
    adc_battery = (u16)((adc_battery_filt + (ADC_BAT_FILT / 2)) / ADC_BAT_FILT);
    // start checking battery after 5s from power on
    if (time_sec >= 5) {
	// wakeup task only when something changed
	if (adc_battery > 50 && adc_battery < battery_low_raw) {
	    // bat low
	    if (!menu_battery_low) {
		menu_battery_low = 1;
		awake(MENU);
	    }
	}
	else {
	    // bat OK, but apply some hysteresis to not switch quickly ON/OFF
	    if (menu_battery_low && adc_battery > battery_low_raw + 100) {
		menu_battery_low = 0;
		awake(MENU);
	    }
	}
    }

    // wakeup MENU task when showing battery or at calibrate
    if (menu_wants_adc)
	awake(MENU);

    // reset inactivity timer when some steering or throttle applied
    dead = cg.steering_dead_zone;
    if (dead < 20)  dead = 20;  // use some minimal dead zone for this check
    if (adc_steering_last < (cg.calib_steering_mid - dead) ||
        adc_steering_last > (cg.calib_steering_mid + dead))
	    reset_inactivity_timer();
    else {
	dead = cg.throttle_dead_zone;
	if (dead < 20)  dead = 20;  // use some minimal dead zone for this check
	if (adc_throttle_last < (cg.calib_throttle_mid - dead) ||
	    adc_throttle_last > (cg.calib_throttle_mid + dead))
		reset_inactivity_timer();
    }
}
Exemplo n.º 18
0
ALIST_API long ALAddRowUnder( long count, long superRow, ALHandle hAL )
{	long			result;
	ALCell		tempCell;
	unsigned long	superRowOffset, offset;
	short		saveRedrawState;

	if ( count < 0 || hAL == nil || *hAL == nil || superRow < (*hAL)->dataBounds.top || superRow >= (*hAL)->dataBounds.bottom )
		return 0;

	// Make sure the list is heirarchical.
	if ( !BTST( (*hAL)->features, alFHeirarchical ) )
		return 0;

	saveRedrawState = ALFeatureFlag( alFInhibitRedraw, alBitSet, hAL );

	result = ALAddRow( count, superRow + 1, hAL );

	ALFeatureFlag( alFInhibitRedraw, saveRedrawState, hAL );

	if ( result > 0 ) {
		tempCell.h = (**hAL).dataBounds.left;
		tempCell.v = superRow;
		superRowOffset = _ALCalcOffsetFromCell( &tempCell, &(*hAL)->dataBounds );

		// Mark the superRow as an alSsuperrow, if it wasn't already.
		if ( !BTST( (*(*hAL)->hSelected)[ superRowOffset ], alSsuperrow ) ) {
			BSET( (*(*hAL)->hSelected)[ superRowOffset ], alSsuperrow );

			// The row defaults to being expanded.
			BSET( (*(*hAL)->hSelected)[ superRowOffset ], alSexpanded );
		}

		// Set the level of all the added rows to one greater than the superRows level.
		for ( tempCell.v = superRow + 1; tempCell.v <= superRow + count; tempCell.v++ ) {
			offset = _ALCalcOffsetFromCell(&tempCell, &(*hAL)->dataBounds);
			(*(*hAL)->hLevels)[ offset ] = (*(*hAL)->hLevels)[ superRowOffset ] + 1;
		}

		// Redraw the entire list.
		if ( !BTST((*hAL)->features, alFInhibitRedraw) )
			ALUpdate( nil, hAL );
	}

	return result;
}
Exemplo n.º 19
0
bool dig_write(pin_t pin, digstate_t state) 
{
	const portid_t pid = pin_pid[pin];
	if(pid == PID_INVALID) {
		return FALSE;
	}
	BSET(*pid_port[pid], pin_offset[pin], (state == HIGH) ? 1 : 0);
	return TRUE;
}
Exemplo n.º 20
0
bool dig_mode(pin_t pin, digmode_t mode) 
{
	const portid_t pid = pin_pid[pin];
	if(pid == PID_INVALID) {
		return FALSE;
	}
	BSET(*pid_ddr[pid], pin_offset[pin], (mode == OUTPUT) ? 1 : 0);
	return TRUE;
}
Exemplo n.º 21
0
ALIST_API OSErr ALExpandRow(long rowNum, Boolean expandChildren, ALHandle hAL)
{	ALCell		tempCell;
	unsigned long	superRowOffset, offset;

	// Sanity check.
	if (hAL == nil || *hAL == nil || rowNum < (**hAL).dataBounds.top || rowNum >= (**hAL).dataBounds.bottom)
		return paramErr;

	// Make sure the list is heirarchical.
	if ( !BTST( (*hAL)->features, alFHeirarchical ) )
		return false;

	// The left-most cell contains the heirarchical data.
	tempCell.h = (**hAL).dataBounds.left;
	tempCell.v = rowNum;

	superRowOffset = _ALCalcOffsetFromCell(&tempCell, &(*hAL)->dataBounds);

	// Mark the row as expanded.
	BSET((*(*hAL)->hSelected)[superRowOffset], alSexpanded);

	// Check if it's a heirarchical row.
	if ( BTST((*(*hAL)->hSelected)[superRowOffset], alSsuperrow) ) {
		if ( expandChildren ) {
			// Mark all children as expanded.
			for ( tempCell.v++; tempCell.v < (*hAL)->dataBounds.bottom; tempCell.v++ ) {
				offset = _ALCalcOffsetFromCell( &tempCell, &(*hAL)->dataBounds );
				if ( (*(*hAL)->hLevels)[ offset ] > (*(*hAL)->hLevels)[ superRowOffset ] )
					BSET( (*(*hAL)->hSelected)[ offset ], alSexpanded );
				else
					break;
			}
		}

		// Recalculate the visible cells.
		_ALCalcVisibleCells( hAL );

		// Redraw the entire list.
		if ( !BTST((*hAL)->features, alFInhibitRedraw) )
			ALUpdate( nil, hAL );
	}

	return noErr;
}
Exemplo n.º 22
0
/* node_dynamic_init_cb callback: called when a pynode is created.
 * The pynode type is passed via node->custom2. It can be:
 *  0: for loaded empty nodes
 *  NODE_DYNAMIC_MENU: for the default Dynamic node type
 *  > NODE_DYNAMIC_MENU: for the new types defined by scripts
*/
static void node_dynamic_init_cb(bNode *node) {
	int type = node->custom2;

	node->custom2 = 0;

	if (type >= NODE_DYNAMIC_MENU) {
		node->custom1 = 0;

		if (type == NODE_DYNAMIC_MENU) {
			node->custom1 = BSET(node->custom1, NODE_DYNAMIC_NEW);
			return;
		}

		node->custom1 = BSET(node->custom1, NODE_DYNAMIC_ADDEXIST);
		node->id = node->typeinfo->id;
	}

	node_dynamic_setup(node);
}
Exemplo n.º 23
0
UINT32 cnetcard_init(CNETCARD *cnetcard)
{
    cstring_init(CNETCARD_NAME(cnetcard), NULL_PTR);
    cstring_init(CNETCARD_IPV4STR(cnetcard), NULL_PTR);
    cstring_init(CNETCARD_MACSTR(cnetcard), NULL_PTR);
    BSET(CNETCARD_MACADDR(cnetcard), 0, 6);
    CNETCARD_IPV4VAL(cnetcard) = 0;
    CNETCARD_STATE(cnetcard)   = CNETCARD_ERR_STATE;
    return (0);
}
Exemplo n.º 24
0
Arquivo: ppm.c Projeto: eknl/gt3b
// initialize PPM pin and timer 3
void ppm_init(void) {
    IO_OP(D, 0);	// PPM output pin, TIM3_CH2

    // initialize timer3 used to generate PPM signal
    BSET(CLK_PCKENR1, 6);     // enable master clock to TIM3
    TIM3_CCMR2 = 0b01111000;  // PWM2, OC2 preload, output mode
    TIM3_CCER1 = 0b00010000;  // polarity active-high, OC2 enable
    TIM3_PSCR = PPM_PSC_SYNC;
    TIM3_IER = 1;             // update interrupt enable
    TIM3_CR1 = 0b10000000;    // auto-reload, URS-all, counter-disable
    ppm_set_channels(3);
}
Exemplo n.º 25
0
int ttwait(TTY tp)
{
	while (qsize(&tp->outq) != 0 && ISSET(tp->state,ST_COPEN) &&
	       ISSET(tp->state,ST_SOPEN))
  {
		BSET(tp->state,ST_DRAIN);
		/* Wait until output is empty */
		if (Block(&tp->outq,-1l,0)==2)
			return RP_EINTR;
	}
	return RPDONE;
}
Exemplo n.º 26
0
Arquivo: ppm.c Projeto: eknl/gt3b
// set number of channels
void ppm_set_channels(u8 n) {
    // disable PPM generation till new values will not be set
    ppm_enabled = 0;
    BRES(TIM3_CR1, 0);	// disable timer
    BSET(PD_ODR, 0);	// set PPM pin to 1

    // start with generating 20ms SYNC signal
    TIM3_CCR2H = hi8(PPM_300US_SYNC);
    TIM3_CCR2L = hi8(PPM_300US_SYNC);
    TIM3_ARRH = hi8(PPM_MUL_SYNC * 20);
    TIM3_ARRL = lo8(PPM_MUL_SYNC * 20);

    channels = n;
    channels2 = (u8)(n << 1);  // also 2* value for compare in ppm_interrupt
}
Exemplo n.º 27
0
void av_change(struct IC *p,bvtype *use,bvtype *def)
/*  Berechnet die Aenderungen, die sich durch IC p an use und def ergeben.  */
{
    int i,j,n=-1;
    int g1,g2;

    /*  Wenn eine Quelle==Ziel, dann wird dadurch kein neuer use erzeugt,   */
    /*  um z.B. unbenutzte Induktionsvariablen in Schleifen zu eliminieren. */
    g1=compare_objs(&p->q1,&p->z,p->typf);
    g2=compare_objs(&p->q2,&p->z,p->typf);
    if(!g1&&(p->q1.flags&(VAR|DREFOBJ))==VAR) n=p->q1.v->index;
    if(!g2&&(p->q2.flags&(VAR|DREFOBJ))==VAR) n=p->q2.v->index;

    for(j=0;j<p->use_cnt;j++){
        i=p->use_list[j].v->index;
        if(p->use_list[j].flags&DREFOBJ) i+=vcount-rcount;
        if(i>=vcount) continue;
        if(i!=n&&!BTST(def,i)) BSET(use,i);
    }

    /*  Ein Wert wird nicht zerstoert, wenn es kein elementarer Typ ist und */
    /*  die Groesse kleiner als die Variable (steht in alle solchen ICs in  */
    /*  q2.val.max.                                                         */
    if((p->z.flags&(VAR|DREFOBJ))==VAR&&(ISSCALAR(p->z.v->vtyp->flags)||p->z.v->vtyp->flags==0||zmeqto(p->q2.val.vmax,szof(p->z.v->vtyp)))){
        i=p->z.v->index;
        if(i>=vcount) ierror(0);
        if(g1&&g2&&!BTST(use,i)) BSET(def,i);
        /*  Wenn p geaendert wird, wird auch *p geaendert   */
        if(i<rcount&&!BTST(def,i+vcount-rcount)) BSET(use,i+vcount-rcount);
    }
    if((p->z.flags&(VAR|DREFOBJ))==(VAR|DREFOBJ)&&g1&&g2&&!(p->z.v->flags&DNOTTYPESAFE)){
        i=p->z.v->index+vcount-rcount;
        if(i>=vcount) ierror(0);
        if(!BTST(use,i)) BSET(def,i);
    }
}
Exemplo n.º 28
0
void Task_SoftUartOut(void)
{
   // Timer2 4800 baud soft uart timer
   OCR2 = TCNT2_TOP;
   BSET(TIMSK, OCIE2);
   TCCR2 = BV(CS21)|BV(WGM21); // F_CPU/8 - CTC Mode

   SoftUartInInit();

	BSET(SUART1_TXDDR, SUART1_TXPIN);
	BSET(SUART2_TXDDR, SUART2_TXPIN);
	BSET(VHF_DDR, VHF_UART);

	stOut[0].buf = NmeaFiOut;
	AvrXFlushFifo(pNmeaFiOut);
	pNmeaFiOut->size = (uint8_t)(sizeof(NmeaFiOut) - sizeof(AvrXFifo) + 1);

	stOut[1].buf = NmIIFiOut;
	AvrXFlushFifo(pNmIIFiOut);
	pNmIIFiOut->size = (uint8_t)sizeof(NmIIFiOut) - sizeof(AvrXFifo) + 1;

	stOut[2].buf = NmeaGpsOut;
	AvrXFlushFifo(pNmeaGpsOut);
	pNmeaGpsOut->size = (uint8_t)(sizeof(NmeaGpsOut) - sizeof(AvrXFifo) + 1);

	register uint8_t i;
	for (;;) {
		AvrXWaitSemaphore(&suOut);
		for (i = 0; i < 3; i++) {
			if (0 == stOut[i].state && FIFO_ERR!= AvrXPeekFifo((pAvrXFifo) stOut[i].buf)) {
				stOut[i].ch = AvrXPullFifo((pAvrXFifo) stOut[i].buf);
				stOut[i].state = 10;
			}
		}
	}
}
Exemplo n.º 29
0
static void SoftUartInInit(void)
{
	BSET(SUART1_RXPU, SUART1_RXPIN);
	BSET(SUART2_RXPU, SUART2_RXPIN);
	BSET(SUART3_RXPU, SUART3_RXPIN);
	BSET(SUART4_RXPU, SUART4_RXPIN);

	WindBuf[2] = 1; WindBuf[3] = sizeof(WindBuf)  - sizeof(NmeaBuf);
	DepthBuf[2]= 2; DepthBuf[3]= sizeof(DepthBuf) - sizeof(NmeaBuf);
	VdoBuf[2]  = 3; VdoBuf[3]  = sizeof(VdoBuf)   - sizeof(NmeaBuf);
	RdrBuf[2]  = 4; RdrBuf[3]  = sizeof(RdrBuf)   - sizeof(NmeaBuf);
	GpsBuf[2]  = 5; GpsBuf[3]  = sizeof(GpsBuf)   - sizeof(NmeaBuf);
	stIn[0].buf = WindBuf;
	stIn[1].buf = DepthBuf;
	stIn[2].buf = VdoBuf;
	stIn[3].buf = RdrBuf;

#if 1
	// Extern Ints 0,1,2
	MCUCR |= BV(ISC11)|BV(ISC01);
	//BCLR(MCUCSR, ISC2);
	GICR |= BV(INT0)|BV(INT1)|BV(INT2);
#endif
}
Exemplo n.º 30
0
static void
descend_left(void)
{
	int temp;

	/* Remember that this cell is the target at this level */
	start[lev] = target;

	/* Update greatest common ancestor with zeta */
	if (!have_zeta) ++anc;

	/* Move the minimum label to the front */
	temp = lab[target_min];
	lab[target_min] = lab[target];
	lab[target] = temp;

	/* Remember that we fixed this element at this level */
	fixed[lev] = temp;
	BSET(bit_fixed, temp);

	/* Split the cell */
	ptn[target] = ++lev; ++cells;

	/* Update cell fronts */
	for (temp = target+1; temp <= target + clen[target]; ++temp) {
		cfront[lab[temp]] = target + 1;
	}

	/* If |target| = 2, then skip target completely */
	if (clen[target] == 1) {
		nextnon[prevnon[target]] = nextnon[target];
		prevnon[nextnon[target]] = prevnon[target];
	}
	/* Otherwise, fix pointers to deal with nonsingle after target */
	else {
		nextnon[target+1] = nextnon[target];
		prevnon[target+1] = prevnon[target];
		nextnon[prevnon[target]] = target+1;
		prevnon[nextnon[target]] = target+1;
	}

	/* Update cell lengths */
	clen[target+1] = clen[target] - 1;
	clen[target] = 0;

	/* Now go and do some work */
	refine();
}