示例#1
0
文件: midipult.c 项目: wesen/midipult
int main(void) {
  io_init();

  init_buttons();
  init_potis();

  DDRPOTI_SEL_PORT = 0xFF;
  PORTPOTI_SEL_PORT = 0xFF;
  DDRA = 0x00;
  PORTA = 0xFF;
  ADMUX = 0;

  int i;
  for (i =0 ; i < 100; i++) {
    ask_buttons();
    ask_potis();
  }
  
  for (;;) {
    
    ask_buttons();

    midi_buttons();
    
    ask_potis();
    midi_potis();
  }
}
void io_setup (void)
{
    int io_result = IO_FAIL;

    /* Initialise the IO layer */
    io_init(&io_data);

    /* Register the IO devices on this platform */
    io_result = register_io_dev_sh(&sh_dev_con);
    assert(io_result == IO_SUCCESS);

    io_result = register_io_dev_fip(&fip_dev_con);
    assert(io_result == IO_SUCCESS);

    io_result = register_io_dev_memmap(&memmap_dev_con);
    assert(io_result == IO_SUCCESS);

    /* Open connections to devices and cache the handles */
    io_result = io_dev_open(sh_dev_con, sh_dev_spec, &sh_dev_handle);
    assert(io_result == IO_SUCCESS);

    io_result = io_dev_open(fip_dev_con, fip_dev_spec, &fip_dev_handle);
    assert(io_result == IO_SUCCESS);

    io_result = io_dev_open(memmap_dev_con, memmap_dev_spec,
                            &memmap_dev_handle);
    assert(io_result == IO_SUCCESS);

    /* Ignore improbable errors in release builds */
    (void)io_result;
}
示例#3
0
void main(void)
{
	clear_all_ram();		//clear ram
	system_initial();		//system init
	time_tcc_pro();			//8ms
	io_init(); 				//seems ok
	_asm{eni}  // enable global interrupt by howie
	_asm{wdtc} //watch dog interrupt clear by howie,clear watch dog in while
	b16ad_init();
	ad_init(); 				// adc init by howie.
	//pwm2_init();
	//while(1);
	while(1)
	{
		while(1)
		{
			IOC70|=0B00000010;//setting P71 floating 设置4脚浮空
			b16ad_init();//输出初始化电平状态
			if(adc_value >= ADC_004V)
			{
				Charger();
			}
		}
	}
}
示例#4
0
static int mavis_init_in(mavis_ctx * mcx)
{
    int i;

    DebugIn(DEBUG_MAVIS);

    mcx->lastdump = mcx->startup_time = time(NULL);

    if (!mcx->path)
	logmsg("Warning: %s: module lacks path definition", MAVIS_name);
    else if (!mcx->argv[0]) {
	mcx->argv[0] = Xstrdup(basename(mcx->path));
	mcx->argv[1] = NULL;
    }

    if (mcx->child_min > mcx->child_max)
	mcx->child_min = mcx->child_max;

    if (!mcx->io_context_parent)
	mcx->io_context_local = mcx->io = io_init();
    mcx->cx = Xcalloc(mcx->child_max, sizeof(struct context *));
    mcx->cx_stat = Xcalloc(mcx->child_max, sizeof(struct context_stat));
    for (i = 0; i < mcx->child_min; i++)
	fork_child(mcx, i);

    mcx->backlog_serial = RB_tree_new(compare_serial, NULL);
    mcx->backlog_app_ctx = RB_tree_new(compare_app_ctx, NULL);
    mcx->backlog_fifo = RB_tree_new(compare_fifo, free_payload);
    mcx->outgoing = RB_tree_new(compare_app_ctx, free_payload);
    mcx->junkcontexts = RB_tree_new(compare_ctx, free_context);

    DebugOut(DEBUG_MAVIS);
    return MAVIS_INIT_OK;
}
示例#5
0
文件: main.c 项目: sli92/netcon
int main(void)
{
    uint32_t lasttick = 0x00;
    uint32_t current = 0x00;

    /* Watchdog deaktivieren */
    PCA0MD &= ~(1 << 6);

    sysclk_init();
    io_init();
    uart_init();
    clock_init();

    IE |= (1 << 7);

    while(1 > 0) {
        current = get_clock();
        if((current - lasttick) > CLOCK_TICKS_PER_SECOND) {
            lasttick = current;
            uart_puts("Second\n");
        }
    }

    return 0;
}
示例#6
0
//-----------------------------------------------------------
void init()
{
    // power save stuff
    ACSR |= (1<<ACD); //analog comparator off
  
    //switch is input with pullup
    SWITCH_DDR &= ~(1<<SWITCH_PIN);
    SWITCH_PORT |= (1<<SWITCH_PIN);

    //trigger is input with no pullup
    TRIGGER_INPUT_DDR &= ~(1<<TRIGGER_INPUT_PIN);
    TRIGGER_INPUT_PORT &= ~(1<<TRIGGER_INPUT_PIN);

    timer_init();
    mcp4802_init();
    adc_init();
    io_init();

    /*
    Set up Interrupt for trigger input 

    PCINT0 to PCINT7 refer to the PCINT0 interrupt, PCINT8 to PCINT14 refer to the PCINT1 interrupt 
    and PCINT15 to PCINT23 refer to the PCINT2 interrupt
    -->
    TRIGGER_INPUT_PIN = PD7 = PCINT23 = pcint2 pin change interrupt for trigger
    */
    //interrupt trigger	(pin change)

    PCICR |= (1<<PCIE2);   //Enable PCINT2
    PCMSK2 |= (1<<PCINT23); //Trigger on change of PCINT23 (PD7)
    
       
    sei();
}
示例#7
0
文件: main.c 项目: erossi/opengarden
/*! Sleep function.
 *
 * Which IO line is in use is recorded in the progs struct.
 *
 * \note Incompatible with MONOSTABLE valve.
 */
void go_to_sleep(uint8_t valve, struct debug_t *debug)
{
	if (valve == BISTABLE) {
		set_sleep_mode(SLEEP_MODE_PWR_SAVE);
		/* shut down everything */
		i2c_shut();
		io_shut();
		led_shut();
		/* start sleep procedure */
		sleep_enable();
		sleep_bod_disable();
		sleep_cpu();
		sleep_disable();
		/* restart everything */
		led_init();
		io_init();
		i2c_init();
	} else {
		set_sleep_mode(SLEEP_MODE_IDLE);
		/* start sleep procedure */
		sleep_enable();
		sleep_cpu();
		sleep_disable();
	}
}
示例#8
0
void init(void) {
	// set up watchdog
	wd_init();

	// set up serial
	serial_init();

	// set up inputs and outputs
	io_init();

	// set up timers
	timer_init();

	// read PID settings from EEPROM
	heater_init();

	// set up default feedrate
	current_position.F = startpoint.F = next_target.target.F = SEARCH_FEEDRATE_Z;

	// start up analog read interrupt loop, if anything uses analog as determined by ANALOG_MASK in your config.h
	analog_init();

	// set up temperature inputs
	temp_init();

	// enable interrupts
	sei();

	// reset watchdog
	wd_reset();

	// say hi to host
	serial_writestr_P(PSTR("Start\nok\n"));

}
示例#9
0
文件: main.c 项目: ysei/psx2vectrex
/// Program main
int main() {
    uint8_t x = 0x80, y = 0x80;
    uint8_t butt;

    usart_init(F_CPU/16/19200-1);
    printf_P(PSTR("\033[2J\033[HVECTROXNIK B%s (C)SVO 2013 PRESS @\n"), BUILDNUM);

    io_init();
    digipot_init();
    mando_init();
    spi_init();

    sei();

    mando_config();

    for(;;) {
        _delay_ms(1);

        mando_poll();
        mando_get_analog(&x, &y);
        digipot_set(x, y);

        mando_get_buttons(&butt);

        //printf_P(PSTR("%02x\n"), butt);

        BUTTASS(BUTT1, butt & 1);
        BUTTASS(BUTT2, butt & 2);
        BUTTASS(BUTT3, butt & 4);
        BUTTASS(BUTT4, butt & 8);

    }
}
示例#10
0
文件: tcp.c 项目: leonlee/tome
/*-------------------------------------------------------------------------*\
* Creates a master tcp object 
\*-------------------------------------------------------------------------*/
static int global_create(lua_State *L)
{
    t_socket sock;
    const char *err = NULL;
    int fd = luaL_optnumber(L, 1, -1);
    if (fd < 1)
        err = inet_trycreate(&sock, SOCK_STREAM);
    else
        sock = fd;
    /* try to allocate a system socket */
    if (!err) { 
        /* allocate tcp object */
        p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
        if (fd >= 1)
            auxiliar_setclass(L, "tcp{client}", -1);
        else
        auxiliar_setclass(L, "tcp{master}", -1);
        /* initialize remaining structure fields */
        socket_setnonblocking(&sock);
        tcp->sock = sock;
        io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv, 
                (p_error) socket_ioerror, &tcp->sock);
        timeout_init(&tcp->tm, -1, -1);
        buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
        return 1;
    } else {
        lua_pushnil(L);
        lua_pushstring(L, err);
        return 2;
    }
}
示例#11
0
/*-------------------------------------------------------------------------*\
* Waits for and returns a client object attempting connection to the
* server object
\*-------------------------------------------------------------------------*/
static int meth_accept(lua_State *L)
{
    p_tcp server = (p_tcp) auxiliar_checkclass(L, "tcp{server}", 1);
    p_timeout tm = timeout_markstart(&server->tm);
    t_socket sock;
    const char *err = inet_tryaccept(&server->sock, server->family, &sock, tm);
    /* if successful, push client socket */
    if (err == NULL) {
        p_tcp clnt = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
        auxiliar_setclass(L, "tcp{client}", -1);
        /* initialize structure fields */
        memset(clnt, 0, sizeof(t_tcp));
        socket_setnonblocking(&sock);
        clnt->sock = sock;
        io_init(&clnt->io, (p_send) socket_send, (p_recv) socket_recv,
                (p_error) socket_ioerror, &clnt->sock);
        timeout_init(&clnt->tm, -1, -1);
        buffer_init(&clnt->buf, &clnt->io, &clnt->tm);
        clnt->family = server->family;
        return 1;
    } else {
        lua_pushnil(L);
        lua_pushstring(L, err);
        return 2;
    }
}
示例#12
0
文件: main.c 项目: simonwrafter/LUR7
int main(void) {
	io_init();
	//adc_init();
	init_interrupt();
	TCCR1A = 0;        		// set entire TCCR1A register to 0
    TCCR1B = 0;
    TIMSK1 = (1 << TOIE1);  // enable Timer1 overflow interrupt
    TCCR1B |= (1 << CS12);  // Set CS12 prescaler (100). Prescaler set to 256. 16 000 000 CPU speed / 256 = 62 500. Each bit is 1/62500 s = 16 us
    interrupts_on();

	while (1) {
		;;
		//lightAll();
		//update7seg(0);
		//bin_to_7seg(2, 0);

		//set_output(OUT1, 1);
		//set_output(OUT2, 1);
		//set_output(OUT3, 1);
		//set_output(OUT4, 1);
		//set_output(OUT5, 1);
		//set_output(OUT6, 1);
		//set_output(OUT7, 1);
	}
	return 0;
}
示例#13
0
文件: io_task.c 项目: gxliu/MQX-3.7.0
void io_task
   (
      uint_32 initial_data
   )
{
    
    puts("*****************************\n");
    puts("IO Task running\n");

    io_init();

    /* Run in 100ms loop to read buttons state  */
    while(1)
    {
    
       /* IO Task is running, wait for timeout */
        _time_delay(100);
    
        switch_poll();
        
        /* blink by LED1 to signalize io_task is running */
        if(timeout == 0) {
            timeout = 1;
            ioctl(file_leds, GPIO_IOCTL_WRITE_LOG1, NULL);
        }
        else {
            timeout = 0;
            ioctl(file_leds, GPIO_IOCTL_WRITE_LOG0, NULL);
        } 
    }
}
示例#14
0
// Note: No else on last one...
void NJavaHandler::setKind(const char *tname)
{
  io_type=N_JAVA_IO_GENERIC;
  char *name=aDefaultStringHelper.removeSpaces2(aDefaultStringHelper.toLower(tname));
  if(!strcmp(name,"java")) io_type=N_JAVA_IO_GENERIC;
  io_init(io_type);
}
示例#15
0
文件: elev.c 项目: torje/heisprosjekt
int elev_init(void) {
    int i;

    // Init hardware
    if (!io_init())
        return 0;

    // Zero all floor button lamps
    for (i = 0; i < N_FLOORS; ++i) {
        if (i != 0)
            elev_set_button_lamp(BUTTON_CALL_DOWN, i, 0);

        if (i != N_FLOORS - 1)
            elev_set_button_lamp(BUTTON_CALL_UP, i, 0);

        elev_set_button_lamp(BUTTON_COMMAND, i, 0);
    }

    // Clear stop lamp, door open lamp, and set floor indicator to ground floor.
    elev_set_stop_lamp(0);
    elev_set_door_open_lamp(0);
    elev_set_floor_indicator(0);

    // Return success.
    return 1;
}
示例#16
0
/**
* @brief Converts raw cell patterns from io_line to glyphs in io_parsed
* @param void
* @return bool - true if all raw cells were valid, false otherwise
*/
bool io_convert_line(void) {
	int line_index = 0;
	int parse_index = 0;
	glyph_t* curr_glyph = NULL;
	
	// Iterate through io_line, find matching glyph for each cell pattern as long
	// as it isn't END_OF_TEXT, and add to io_parsed
	for (line_index = 0, parse_index = 0;
		line_index - 2 < MAX_BUF_SIZE;
		line_index++, parse_index++) {
		
		if (io_line[line_index] == END_OF_TEXT) {
			break;
		}
		
		curr_glyph = get_glyph(lang_script, io_line, &line_index);
		if (curr_glyph == NULL) {
			return false;
		} else {
			//log_msg("[IO] Parsed glyph[%d]: %s pattern:%x\n\r", parse_index, curr_glyph->sound, curr_glyph->pattern);
            log_msg("[IO] Parsed glyph[%d]: %s(0x%x)\n\r", parse_index, curr_glyph->sound,curr_glyph->pattern);
			
			io_parsed[parse_index] = curr_glyph;
		}
	}

	// If control returns from loop then matching glyphs were found for all
	// raw cells, add a NULL terminator and return true
	io_parsed[line_index] = NULL;
    io_init();
    log_msg("[IO] line index[%d]: \n\r", line_index);
    
	return true;
}
示例#17
0
void Setup()
{
	debug_level = 2;

	//set clock to max for init 32MHz
	ClockSetSource(x32MHz);
	//disable 2MHZ osc
	OSC.CTRL = 0b00000010;

	//save power
	turnoff_subsystems();

	EnableInterrupts();

	//init basic peripherals
	led_init();
	uart_init_buffers();
	uart_init();
	time_init();
	buzzer_init();
	battery_init();
	buttons_init();

	//basic power control
	mems_power_init();
	io_init();
	SD_EN_INIT;

	//load configuration
	cfg_load();

	_delay_ms(100);
}
示例#18
0
static void init(void)
{
	ACSR = _BV(ACD); // Disable Analog Comparator (power save)

	//motion_init();

	TCCR0 = _BV(CS02) | _BV(CS00); // clk / 256 
	TIMSK = _BV(TOIE0);

	io_init();

	// init twi
	if (!TWIM_Init())
	{
		while (1);
	}

	ds1631_init(I2C_ADRESSE_DS1631); // Init twi temperature sensor

	spi_init(); // initialize spi port
	can_read_addr();
	can_init(); // initialize can communication

	sei(); // turn on interrupts
	wdt_enable(WDTO_250MS);

#ifndef NO_NETVAR
	switch_netvars_init();
	lamp_out_init();
#endif
}
示例#19
0
int main ()
{
	io_init();
	RT_TASK test[3];
	mlockall(MCL_CURRENT|MCL_FUTURE);
	char name[10];
	long i;
	for (i = 1; i <= 3; i++) {
		sprintf(name, "test%lu", i);
    	rt_task_create(&test[i-1], name, 0, i, T_CPU(1)|T_JOINABLE);
    	rt_task_start(&test[i-1], &periodicTest, (void*) i);
    }
    
   
    
    
	pthread_t disturbances[10];
    
    for (i = 0; i < 10; i++) {
    	pthread_create(&disturbances[i], NULL, disturbance, NULL);
    }
	for (i = 0; i < 10; i++) {
		pthread_join(disturbances[i], NULL);
	}

	wait_for_ctrl_c();
	
	return 0;
}
示例#20
0
int main(int argc, char ** argv)
{
	int i;

	DCC_LOG_INIT();
	DCC_LOG_CONNECT();

	DCC_LOG(LOG_TRACE, "1. cm3_udelay_calibrate()");
	/* calibrate usecond delay loop */
	cm3_udelay_calibrate();

	DCC_LOG(LOG_TRACE, "2. io_init()");
	io_init();

	DCC_LOG(LOG_TRACE, "3. thinkos_init()");
	thinkos_init(THINKOS_OPT_PRIORITY(0) | THINKOS_OPT_ID(32));

	tmr_sem = thinkos_sem_alloc(0);
	DCC_LOG1(LOG_TRACE, "tmr_sem=%d", tmr_sem);

	oneshot_timer_init(168000000 / 2);
	periodic_timer_init(2);

	for (i = 0; ; ++i) {
		if ((i & 0x7) == 0)
			DCC_LOG3(LOG_TRACE, "i=%d IRQ=%d TMR=%d", i, irq_count, tmr_count);
		thinkos_sem_wait(tmr_sem);
		thinkos_sem_wait(tmr_sem);
//		if (irq_count != tmr_count)
//			DCC_LOG2(LOG_TRACE, "IRQ=%d TMR=%d", irq_count, tmr_count);
//		thinkos_sleep((1 + (i % 9)) * 100);
	}

	return 0;
}
示例#21
0
/*-------------------------------------------------------------------------*\
* Creates a serial object 
\*-------------------------------------------------------------------------*/
static int global_create(lua_State *L) {
    const char* path = luaL_checkstring(L, 1);

    /* allocate unix object */
    p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix));

    /* open serial device */
    t_socket sock = open(path, O_NOCTTY|O_RDWR, 00700);

    /*printf("open %s on %d\n", path, sock);*/

    if (sock < 0)  {
        lua_pushnil(L);
        lua_pushstring(L, socket_strerror(errno));
        lua_pushnumber(L, errno);
        return 3;
    }
    /* set its type as client object */
    auxiliar_setclass(L, "serial{client}", -1);
    /* initialize remaining structure fields */
    socket_setnonblocking(&sock);
    un->sock = sock;
    io_init(&un->io, (p_send) socket_write, (p_recv) socket_read, 
            (p_error) socket_ioerror, &un->sock);
    timeout_init(&un->tm, -1, -1);
    buffer_init(&un->buf, &un->io, &un->tm);
    return 1;
}
示例#22
0
/*-------------------------------------------------------------------------*\
* Creates a master tcp object
\*-------------------------------------------------------------------------*/
static int tcp_create(lua_State *L, int family) {
    p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
    memset(tcp, 0, sizeof(t_tcp));
    /* set its type as master object */
    auxiliar_setclass(L, "tcp{master}", -1);
    /* if family is AF_UNSPEC, we leave the socket invalid and
     * store AF_UNSPEC into family. This will allow it to later be
     * replaced with an AF_INET6 or AF_INET socket upon first use. */
    tcp->sock = SOCKET_INVALID;
    tcp->family = family;
    io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv,
            (p_error) socket_ioerror, &tcp->sock);
    timeout_init(&tcp->tm, -1, -1);
    buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
    if (family != AF_UNSPEC) {
        const char *err = inet_trycreate(&tcp->sock, family, SOCK_STREAM, 0);
        if (err != NULL) {
            lua_pushnil(L);
            lua_pushstring(L, err);
            return 2;
        }
        socket_setnonblocking(&tcp->sock);
    }
    return 1;
}
示例#23
0
/*-------------------------------------------------------------------------*\
* Creates a master tcp object 
\*-------------------------------------------------------------------------*/
static int global_create(lua_State *L)
{
    short family;
    const char *af_opts[] = {"AF_INET", "AF_INET6"};
    const char *def_af = "AF_INET";
    const char *err;
    t_socket sock;

    switch(luaL_checkoption(L, 1, def_af, af_opts)) {
        case 0 : family = PF_INET   ; break;
        case 1 : family = PF_INET6  ; break;
        default: family = PF_INET ; break;
    }

    /* try to allocate a system socket */
    err = inet_trycreate(&sock, SOCK_STREAM, family);
    if (!err) { 
        /* allocate tcp object */
        p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
        /* set its type as master object */
        auxiliar_setclass(L, "tcp{master}", -1);
        /* initialize remaining structure fields */
        socket_setnonblocking(&sock);
        tcp->sock = sock;
        io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv, 
                (p_error) socket_ioerror, &tcp->sock);
        timeout_init(&tcp->tm, -1, -1);
        buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
        return 1;
    } else {
        lua_pushnil(L);
        lua_pushstring(L, err);
        return 2;
    }
}
示例#24
0
文件: main.c 项目: wulfskin/mod-rob
void firmware_init(){
	// Initialize firmware
	dxl_initialize(0,1);		//initialize dynamixel communication
	serial_initialize(57600);		//initialize serial communication
	
	//initialize sensors
	sensor_init(SENSOR_FRONT,SENSOR_DISTANCE);
	sensor_init(SENSOR_FRONTLEFT,SENSOR_IR);
	sensor_init(SENSOR_FRONTRIGHT,SENSOR_IR);
	sensor_init(SENSOR_BACKLEFT,SENSOR_IR);
	sensor_init(SENSOR_BACKRIGHT,SENSOR_IR);
	
	//initialize I/O
	io_init();
	io_set_interrupt(BTN_START, &reset_state); //assign callback function when start button is pressed 
	
	// Activate general interrupts
	sei();
	
	// Set motors to wheel mode
	motor_set_mode(254, MOTOR_WHEEL_MODE);
	
	// Set serial communication through ZigBee
	serial_set_zigbee();
	
}
示例#25
0
/*-------------------------------------------------------------------------*\
* Creates a master tcp object
\*-------------------------------------------------------------------------*/
static int tcp_create(lua_State *L, int family) {
    t_socket sock;
    const char *err = inet_trycreate(&sock, family, SOCK_STREAM);
    /* try to allocate a system socket */
    if (!err) {
        /* allocate tcp object */
        p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
        memset(tcp, 0, sizeof(t_tcp));
        /* set its type as master object */
        auxiliar_setclass(L, "tcp{master}", -1);
        /* initialize remaining structure fields */
        socket_setnonblocking(&sock);
        if (family == PF_INET6) {
            int yes = 1;
            setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
                (void *)&yes, sizeof(yes));
        }
        tcp->sock = sock;
        io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv,
                (p_error) socket_ioerror, &tcp->sock);
        timeout_init(&tcp->tm, -1, -1);
        buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
        tcp->family = family;
        return 1;
    } else {
        lua_pushnil(L);
        lua_pushstring(L, err);
        return 2;
    }
}
示例#26
0
文件: io.c 项目: zhez/tig
bool
io_done(struct io *io)
{
	pid_t pid = io->pid;

	if (io->pipe != -1)
		close(io->pipe);
	free(io->buf);
	io_init(io);

	while (pid > 0) {
		int status;
		pid_t waiting = waitpid(pid, &status, 0);

		if (waiting < 0) {
			if (errno == EINTR)
				continue;
			io->error = errno;
			return FALSE;
		}

		if (WEXITSTATUS(status)) {
			io->status = WEXITSTATUS(status);
		}

		return waiting == pid &&
		       !WIFSIGNALED(status) &&
		       !io->status;
	}

	return TRUE;
}
示例#27
0
int elev_init(void) {
    int init_success = io_init();
    if (!init_success){
        return 0;
    }

    for (int f = 0; f < N_FLOORS; f++) {
        for (elev_button_type_t b = 0; b < N_BUTTONS; b++){
            elev_set_button_lamp(b, f, 0);
        }
    }

    //drive down to valid floor 
    if (elev_get_floor_sensor_signal() == -1){
        elev_set_motor_direction(DIRN_DOWN);
    }
    while (elev_get_floor_sensor_signal() == -1)
    {
        ///Keep driving down until reached a floor 
    }
    elev_set_motor_direction(DIRN_STOP);

    elev_set_stop_lamp(0);
    elev_set_door_open_lamp(0);
    elev_set_floor_indicator(elev_get_floor_sensor_signal());
    
    return 1;
}
示例#28
0
文件: main.c 项目: kringle/sannsys15
int main(int argc, char **argv)
{

	io_init();
	
	pthread_t thread_1;
	pthread_t thread_2;
	pthread_t thread_3;
	

	pthread_create(&thread_1, NULL,thread1,(void *) 1);
	pthread_create(&thread_2, NULL,thread2,(void *) 2);
	pthread_create(&thread_3, NULL,thread3,(void *) 3);
	
	int i;
	pthread_t disturbPtrs[10];

	for ( i = 0 ; i < 10 ; i++ ) {
		pthread_create(&disturbPtrs[i], NULL, disturb,(void*) i );
	}

	for ( i = 0 ; i < 10 ; i++ ) {
		pthread_join(disturbPtrs[i],NULL);
	}

	pthread_join(thread_1,NULL);
	pthread_join(thread_2,NULL);
	pthread_join(thread_3,NULL);

	return 0;
}
示例#29
0
文件: dse.c 项目: CeperaCPP/fis-gtm
int main(int argc, char *argv[])
{
	DCL_THREADGBL_ACCESS;

	GTM_THREADGBL_INIT;
	set_blocksig();
	gtm_imagetype_init(DSE_IMAGE);
	gtm_wcswidth_fnptr = gtm_wcswidth;
	gtm_env_init();	/* read in all environment variables */
	licensed = TRUE;
	TREF(transform) = TRUE;
	op_open_ptr = op_open;
	patch_curr_blk = get_dir_root();
	err_init(util_base_ch);
	GTM_ICU_INIT_IF_NEEDED;	/* Note: should be invoked after err_init (since it may error out) and before CLI parsing */
	sig_init(generic_signal_handler, dse_ctrlc_handler, suspsigs_handler);
	atexit(util_exit_handler);
	SET_LATCH_GLOBAL(&defer_latch, LOCK_AVAILABLE);
	get_page_size();
	stp_init(STP_INITSIZE);
	rts_stringpool = stringpool;
	getjobname();
	INVOKE_INIT_SECSHR_ADDRS;
	getzdir();
	prealloc_gt_timers();
	initialize_pattern_table();
	gvinit();
	region_init(FALSE);
	INIT_GBL_ROOT(); /* Needed for GVT initialization */
	getjobnum();
	util_out_print("!/File  !_!AD", TRUE, DB_LEN_STR(gv_cur_region));
	util_out_print("Region!_!AD!/", TRUE, REG_LEN_STR(gv_cur_region));
	cli_lex_setup(argc, argv);
	CREATE_DUMMY_GBLDIR(gd_header, original_header, gv_cur_region, gd_map, gd_map_top);
	gtm_chk_dist(argv[0]);
#	ifdef DEBUG
	if ((gtm_white_box_test_case_enabled && (WBTEST_SEMTOOLONG_STACK_TRACE == gtm_white_box_test_case_number) ))
	{
		sgmnt_addrs     * csa;
		node_local_ptr_t cnl;
		csa = &FILE_INFO(gv_cur_region)->s_addrs;
		cnl = csa->nl;
		cnl->wbox_test_seq_num  = 1; /*Signal the first step and wait here*/
		while (2 != cnl->wbox_test_seq_num) /*Wait for another process to get hold of the semaphore and signal next step*/
			LONG_SLEEP(10);
	}
#	endif
	if (argc < 2)
                display_prompt();
	io_init(TRUE);
	while (1)
	{
		if (!dse_process(argc))
			break;
		display_prompt();
	}
	dse_exit();
	REVERT;
}
示例#30
0
文件: config.c 项目: meloun/lnx_myweb
/*USER INIT FUNCTION, called in main.c*/
int user_init (HTTP_INFO *info)
{
	sys_init (info);
	net_init (info);
	io_init (info); //init variables from conf file
	pm_init (info);
	return 0;
}