Пример #1
0
void sure_2416_setup() {
	
	//serial_print_str("Setting up 2416\n");
	
	make_output(sure_2416_cs1_port, sure_2416_cs1_pin);
	make_output(sure_2416_data_port, sure_2416_data_pin);
	make_output(sure_2416_wr_port, sure_2416_wr_pin);
	make_output(sure_2416_rd_port, sure_2416_rd_pin);

	set_pin(sure_2416_wr_port, sure_2416_wr_pin);
	set_pin(sure_2416_rd_port, sure_2416_rd_pin);
	set_pin(sure_2416_cs1_port, sure_2416_cs1_pin);  

}
Пример #2
0
void mrf24j40_setup_io() {

        #ifndef __PIC32MX__	
	        make_input(mrf24j40_int_port, mrf24j40_int_pin);
	        set_pin(mrf24j40_cs_port, mrf24j40_cs_pin);	// keep high
	        make_output(mrf24j40_cs_port, mrf24j40_cs_pin);
        #endif	
        #ifdef __PIC32MX__
        	SPI_init();			// init SPI default (2 on PIC32-PINGUINO)
        						// only called here for test
        						// will be called later in main32.c
        	#ifndef PIC32_PINGUINO_220
				//pinmode(13,OUTPUT); // CLK
				//pinmode(11,OUTPUT); // SDO
				//pinmode(12,INPUT);	// SDI				
				ZIGRESETOUT;		// macro for RESET
				ZIGCSOUT;			// macro for CS
				ZIGINTIN;			// interrupt (not yet implemented)
        	#else
				ZIGRESETOUT;		// macro for RESET
				ZIGCSOUT;			// macro for CS
			#endif
        	ZIGRESET=0;
        	ZIGCS=1;
        	ZIGRESET=1;
        	Delayms(100);
		#endif        	
}
Пример #3
0
void ht1632_setup_io() {
	
	make_output(ht1632_cs1_port, ht1632_cs1_pin);
	
	#if ht1632_displays > 1
		make_output(ht1632_cs2_port, ht1632_cs2_pin);
	#endif	
	#if ht1632_displays > 2
		make_output(ht1632_cs3_port, ht1632_cs3_pin);
	#endif	
	#if ht1632_displays > 3
		make_output(ht1632_cs4_port, ht1632_cs4_pin);
	#endif	
	
	
	make_output(ht1632_data_port, ht1632_data_pin);
	make_output(ht1632_wr_port, ht1632_wr_pin);
	make_output(ht1632_rd_port, ht1632_rd_pin);

	set_pin(ht1632_wr_port, ht1632_wr_pin);
	set_pin(ht1632_rd_port, ht1632_rd_pin);
	set_pin(ht1632_cs1_port, ht1632_cs1_pin);  
	#if ht1632_displays > 1
		set_pin(ht1632_cs2_port, ht1632_cs2_pin);  
	#endif	
	#if ht1632_displays > 2
		set_pin(ht1632_cs3_port, ht1632_cs3_pin);  
	#endif	
	#if ht1632_displays > 3
		set_pin(ht1632_cs4_port, ht1632_cs4_pin);  
	#endif	

}
Пример #4
0
void gps_init(Stream *outstr)
{
    cond_init(&wait_gps); 
    monitor_pos = monitor_raw = false; 
    uint16_t baud; 
    GET_PARAM(GPS_BAUD, &baud);
    in = uart_rx_init(baud, FALSE);
    out = outstr;
    THREAD_START(nmeaListener, STACK_GPSLISTENER);
    make_output(GPSON); 
    set_port(GPSON);
}
Пример #5
0
corrobj::corrobj(char *parfile)
{
    read(parfile);

    // Initialize the htm index
    htm = new htmInterface( (size_t) par.depth );
    spatialIndex = &htm->index();

    binobj = new binner(par);

    make_output();
    make_edge_output();
}
Пример #6
0
short
gen_cb(int fd, pid_t pid, int policynr, const char *name, int code,
    const char *emulation, void *args, int argsize, void *cbarg)
{
	char output[_POSIX2_LINE_MAX];
	struct policy *policy;
	struct intercept_pid *ipid;
	struct filterq *pflq = NULL;
	short action = ICPOLICY_PERMIT;
	short future;
	int off, done = 0, dolog = 0;
	size_t len;

	if (policynr == -1)
		goto out;

	if ((policy = systrace_findpolnr(policynr)) == NULL)
		errx(1, "%s:%d: find %d", __func__, __LINE__,
		    policynr);

	ipid = intercept_getpid(pid);
	ipid->uflags = 0;

	make_output(output, sizeof(output),
	    ipid->name != NULL ? ipid->name : policy->name,
	    pid, ipid->ppid, policynr,
	    policy->name, policy->nfilters, emulation, name, code,
	    NULL, NULL);

	off = strlen(output);
	len = sizeof(output) - off;
	if (len > 0)
		snprintf(output + off, len, ", args: %d", argsize);

	if ((pflq = systrace_policyflq(policy, emulation, name)) == NULL)
		errx(1, "%s:%d: no filter queue", __func__, __LINE__);

	do {
		/* Fast-path checking */
		if ((action = policy->kerneltable[code]) != ICPOLICY_ASK)
			goto out;

		action = filter_evaluate(NULL, pflq, ipid);

		if (action != ICPOLICY_ASK)
			goto haveresult;
		/*
		 * At this point, we have to ask the user, but we may check
		 * if the policy has been updated in the meanwhile.
		 */
		if (systrace_updatepolicy(fd, policy) == -1)
			done = 1;
	} while (!done);

	if (policy->flags & POLICY_UNSUPERVISED) {
		action = ICPOLICY_NEVER;
		dolog = 1;
		goto haveresult;
	}

	action = filter_ask(fd, NULL, pflq, policynr, emulation, name,
	    output, &future, ipid);
	if (future != ICPOLICY_ASK)
		systrace_modifypolicy(fd, policynr, name, future);

	if (policy->flags & POLICY_DETACHED) {
		if (intercept_detach(fd, pid) == -1)
			err(1, "intercept_detach");
	} else if (action == ICPOLICY_KILL) {
		kill(pid, SIGKILL);
		return (ICPOLICY_NEVER);
	}

 haveresult:
	if (ipid->uflags & SYSCALL_LOG)
		dolog = 1;
	if (dolog)
		log_msg(LOG_WARNING, "%s user: %s, prog: %s",
		    action < ICPOLICY_NEVER ? "permit" : "deny",
		    ipid->username, output);
 out:
	return (action);
}
Пример #7
0
short
trans_cb(int fd, pid_t pid, int policynr,
    const char *name, int code, const char *emulation,
    void *args, int argsize,
    struct intercept_replace *repl,
    struct intercept_tlq *tls, void *cbarg)
{
	short action, future;
	struct policy *policy;
	struct intercept_pid *ipid;
	struct intercept_tlq alitls;
	struct intercept_translate alitl[SYSTRACE_MAXALIAS];
	struct systrace_alias *alias = NULL;
	struct filterq *pflq = NULL;
	const char *binname = NULL;
	char output[_POSIX2_LINE_MAX];
	pid_t ppid;
	int done = 0, dolog = 0;

	action = ICPOLICY_PERMIT;

	if (policynr == -1)
		goto out;

	if ((policy = systrace_findpolnr(policynr)) == NULL)
		errx(1, "%s:%d: find %d", __func__, __LINE__,
		    policynr);

	ipid = intercept_getpid(pid);
	ipid->uflags = 0;
	binname = ipid->name != NULL ? ipid->name : policy->name;
	ppid = ipid->ppid;

	/* Required to set up replacements */
	do {
		make_output(output, sizeof(output), binname, pid, ppid,
		    policynr, policy->name, policy->nfilters,
		    emulation, name, code, tls, repl);

		/* Fast-path checking */
		if ((action = policy->kerneltable[code]) != ICPOLICY_ASK)
			goto out;

		pflq = systrace_policyflq(policy, emulation, name);
		if (pflq == NULL)
			errx(1, "%s:%d: no filter queue", __func__, __LINE__);

		action = filter_evaluate(tls, pflq, ipid);
		if (action != ICPOLICY_ASK)
			goto done;

		/* Do aliasing here */
		if (!noalias)
			alias = systrace_find_alias(emulation, name);
		if (alias != NULL) {
			int i;

			/* Set up variables for further filter actions */
			tls = &alitls;
			emulation = alias->aemul;
			name = alias->aname;

			/* Create an aliased list for filter_evaluate */
			TAILQ_INIT(tls);
			for (i = 0; i < alias->nargs; i++) {
				memcpy(&alitl[i], alias->arguments[i], 
				    sizeof(struct intercept_translate));
				TAILQ_INSERT_TAIL(tls, &alitl[i], next);
			}

			if ((pflq = systrace_policyflq(policy,
			    alias->aemul, alias->aname)) == NULL)
				errx(1, "%s:%d: no filter queue",
				    __func__, __LINE__);

			action = filter_evaluate(tls, pflq, ipid);
			if (action != ICPOLICY_ASK)
				goto done;

			make_output(output, sizeof(output), binname, pid, ppid,
			    policynr, policy->name, policy->nfilters,
			    alias->aemul, alias->aname, code, tls, NULL);
		}

		/*
		 * At this point, we have to ask the user, but we may check
		 * if the policy has been updated in the meanwhile.
		 */
		if (systrace_updatepolicy(fd, policy) == -1)
			done = 1;
	} while (!done);

	if (policy->flags & POLICY_UNSUPERVISED) {
		action = ICPOLICY_NEVER;
		dolog = 1;
		goto out;
	}

	action = filter_ask(fd, tls, pflq, policynr, emulation, name,
	    output, &future, ipid);
	if (future != ICPOLICY_ASK)
		filter_modifypolicy(fd, policynr, emulation, name, future);

	if (policy->flags & POLICY_DETACHED) {
		if (intercept_detach(fd, pid) == -1)
			err(1, "intercept_detach");
		return (action);
	} else if (action == ICPOLICY_KILL) {
		kill(pid, SIGKILL);
		return (ICPOLICY_NEVER);
	}
 done:
	if (ipid->uflags & SYSCALL_LOG)
		dolog = 1;

 out:
	if (dolog)
		log_msg(LOG_WARNING, "%s user: %s, prog: %s",
		    action < ICPOLICY_NEVER ? "permit" : "deny",
		    ipid->username, output);

 	/* Argument replacement in intercept might still fail */

	return (action);
}
Пример #8
0
int main(int argc, char **argv) {


	short	pine = 0,
		output = 1,
		hist = 0,
		vol = 0,
		ahull = 0,
		ofn = 0,
		ifn = 0;
	int	option;
	double	alpha = 0;
	int	main_out_form=0, alpha_out_form=0;
	simplex *root;
	fg 	*faces_gr;

	mult_up = 1;

	while ((option = getopt(argc, argv, "i:m:rs:do:X:a:Af:")) != EOF) {
		switch (option) {
		case 'm' :
			sscanf(optarg,"%lf",&mult_up);
			DEBEXP(-4,mult_up);
			break;
		case 'a' :
			vd = ahull = 1;
			switch(optarg[0]) {
				case 'a': sscanf(optarg+1,"%lf",&alpha); break;
				case '\0': break;
				default: tell_options();
			 }
			break;
		default :
			tell_options();
			exit(1);
		}
	}

	INFILE = stdin;
	OUTFILE = stdout;
	DFILE = stderr;
	read_next_site(-1);
	if (dim > MAXDIM) panic("dimension bound MAXDIM exceeded"); 

	point_size = site_size = sizeof(Coord)*dim;

	shuf = &noshuffle;
	get_site_n = read_next_site;

	root = build_convex_hull(get_next_site, site_numm, dim, vd);

	out_func* aof = out_funcs[alpha_out_form];
	
	if (alpha==0) alpha=find_alpha(root);
	alph_test(0,0,&alpha);
	make_output(root, visit_outside_ashape, afacets_print, aof, OUTFILE);

	free_hull_storage();

	exit(0);
}
Пример #9
0
void ht1632_set_pixel(uns8 x, uns8 y, uns8 colour) {

uns8 common, panel, led_in_panel, inverted_x, out, mem_addr, bit_in_mem_addr, count, data;

	// first calculate memory address
	
	// y location on panels is top left based
	
	common = 15 - y;
	
/* Previous calculations:
	panel = x / 8;	// which panel of the three is it that we need to change?
	led_in_panel = x - (panel * 8); 
	inverted_x = 7 - led_in_panel;
	out = panel * 8 + led_in_panel; //inverted_x;
	mem_addr = out * 4 + common / 4;
*/
	bit_in_mem_addr = common & 0b00000011;
	

	mem_addr = x * 4 + common / 4;


	clear_pin(ht1632_cs1_port, ht1632_cs1_pin);

	// send WR command

	// send 1
	set_pin  (ht1632_data_port, ht1632_data_pin);
	// pulse wr
	clear_pin(ht1632_wr_port, ht1632_wr_pin);
	set_pin  (ht1632_wr_port, ht1632_wr_pin);
	
	// send 0
	clear_pin  (ht1632_data_port, ht1632_data_pin);
	// pulse wr
	clear_pin(ht1632_wr_port, ht1632_wr_pin);
	set_pin  (ht1632_wr_port, ht1632_wr_pin);

	// send 1
	set_pin  (ht1632_data_port, ht1632_data_pin);
	// pulse wr
	clear_pin(ht1632_wr_port, ht1632_wr_pin);
	set_pin  (ht1632_wr_port, ht1632_wr_pin);

	// write mem addr, bits 6 -> 0
	for(count = 0 ; count < 7 ; count++) {
		if (test_bit(mem_addr, 6)) {
			set_pin(ht1632_data_port, ht1632_data_pin);
		} else { 
			clear_pin(ht1632_data_port, ht1632_data_pin);
		}

		//change_pin_var(ht1632_data_port, ht1632_data_pin, test_bit(mem_addr, 6));
		// pulse rd
		clear_pin(ht1632_wr_port, ht1632_wr_pin);
		set_pin  (ht1632_wr_port, ht1632_wr_pin);

		// shift mem addr along
		mem_addr = mem_addr << 1;
	}

	// Retrieve 4 bits
	// read clocked out on falling edge of RD
	
	make_input(ht1632_data_port, ht1632_data_pin);

	for(count = 0 ; count < 4 ; count++) {
		// pulse rd
		clear_pin(ht1632_rd_port, ht1632_rd_pin);

		data = data >> 1;
		data.3 = test_pin(ht1632_data_port, ht1632_data_pin);

		set_pin  (ht1632_rd_port, ht1632_rd_pin);

	}

	make_output(ht1632_data_port, ht1632_data_pin);

	// now we have the data, we need to change the bit
	if (colour) {
		set_bit(data, bit_in_mem_addr);
	} else {
		clear_bit(data, bit_in_mem_addr);
	}	
	
	// Now write it back out again
	
	// write data, bits 0 -> 3 (different from mem addr format)
	for(count = 0 ; count < 4 ; count++) {
		//change_pin_var(ht1632_data_port, ht1632_data_pin, test_bit(data, 0));
		if (test_bit(data, 0)) {
			set_pin(ht1632_data_port, ht1632_data_pin);
		} else { 
			clear_pin(ht1632_data_port, ht1632_data_pin);
		}

		// pulse wr
		clear_pin(ht1632_wr_port, ht1632_wr_pin);
		set_pin  (ht1632_wr_port, ht1632_wr_pin);
		// shift data along
		data = data >> 1;
	}
	
	
	// reset CS
	// don't think this is necessary
//	set_pin(ht1632_cs1_port, ht1632_cs1_pin);
//	clear_pin(ht1632_cs1_port, ht1632_cs1_pin);
	set_pin  (ht1632_cs1_port, ht1632_cs1_pin);
	
	
}