예제 #1
0
int main( void ) 
{
  uint8_t init_cpt;
  /* init peripherals */
  timer_init(); 
  modem_init();
  adc_init();
#ifdef CTL_BRD_V1_1  
  adc_buf_channel(ADC_CHANNEL_BAT, &buf_bat);
#endif
  spi_init();
  link_fbw_init();
  gps_init();
  nav_init();
  ir_init();
  estimator_init();
#	ifdef PAPABENCH_SINGLE
		fbw_init();
#	endif

  /* start interrupt task */
  //sei(); /*Fadia*/

  /* Wait 0.5s (for modem init ?) */
  init_cpt = 30;
  _Pragma("loopbound min 31 max 31")
  while (init_cpt) {
    if (timer_periodic())
      init_cpt--;
  }

  /*  enter mainloop */
#ifndef NO_MAINLOOP
  while( 1 ) {
#endif
    if(timer_periodic()) {
      periodic_task();
#		if PAPABENCH_SINGLE
			fbw_schedule();
#		endif
	}
    if (gps_msg_received) 
    {
	/*receive_gps_data_task()*/
	parse_gps_msg();
	send_gps_pos();
        send_radIR();
        send_takeOff();
    }
    if (link_fbw_receive_complete) {
      link_fbw_receive_complete = FALSE;
      radio_control_task();
    }
#ifndef NO_MAINLOOP
  } 
#endif
  return 0;
}
예제 #2
0
int main( void )
{
	fbw_init();
#ifndef NO_MAINLOOP
  while( 1 ) 
  {
#endif
	fbw_schedule();
    if(timer_periodic()) 
    {
      _1Hz++;
      _20Hz++;
      if (_1Hz >= 60) 
      {
	_1Hz = 0;
      }
      if (_20Hz >= 3) 
      {
	_20Hz = 0;
      }
    }
#ifndef NO_MAINLOOP
  } 
#endif
  return 0;
}
int main( void )
{
	led_init();
	timer_init();
	uart_init();
	servo_init();
	ppm_init();
	adc_init();
	input_init();

	sei();

	puts( "$Id: mainloop.c,v 2.14 2003/03/25 17:44:05 tramm Exp $\r\n" );

	while( 1 )
	{
		input_task();
		user_task();

		if( ppm_valid )
		{
			ppm_output();
			ppm_valid = 0;
		}

		/* Every 32768 microseconds */
		if( timer_periodic() == 0 )
			continue;

		adc_output();

	}
}
예제 #4
0
파일: main.c 프로젝트: CheBuzz/paparazzi
int main( void ) {
  /* init peripherals */
  timer_init();
  uart_init();
  soft_uart_init();
  adc_init();
  sei();

  /*  enter mainloop */
  while( 1 ) {
    if(timer_periodic())
      periodic_task();
    if (soft_uart_error) {
      LINK_TMTC_SEND_ERROR(soft_uart_error);
      soft_uart_error = 0;
    }
    if (soft_uart_got_byte) {
      input_buf[input_buf_idx] = soft_uart_byte;
      input_buf_idx++;
      if (input_buf_idx >= INPUT_BUF_LEN) {
	LINK_TMTC_SEND_DATA(input_buf, input_buf_idx);
	input_buf_idx = 0;
      }
      soft_uart_got_byte = FALSE;
    }
    if (adc_got_val) {
      saved_valim = adc_alim;
      adc_got_val = FALSE;
    }
  }
  return 0;
}
예제 #5
0
파일: scheduler.c 프로젝트: BwRy/sel4test
/*
 * Test that thread suspending works when idling the system.
 * Note: This test non-deterministically fails. If you find only this test
 * try re-running the test suite.
 */
static int
test_thread_suspend(env_t env)
{
    helper_thread_t t1;
    volatile seL4_Word counter;
    ZF_LOGD("test_thread_suspend\n");
    create_helper_thread(env, &t1);

    set_helper_priority(&t1, 100);
    start_helper(env, &t1, (helper_fn_t) counter_func, (seL4_Word) &counter, 0, 0, 0);

    timer_periodic(env->timer->timer, 10 * NS_IN_MS);
    timer_start(env->timer->timer);
    sel4_timer_handle_single_irq(env->timer);

    seL4_Word old_counter;

    /* Let the counter thread run. We might have a pending interrupt, so
     * wait twice. */
    wait_for_timer_interrupt(env);
    wait_for_timer_interrupt(env);

    old_counter = counter;

    /* Let it run again. */
    wait_for_timer_interrupt(env);

    /* Now, counter should have moved. */
    test_check(counter != old_counter);
    old_counter = counter;

    /* Suspend the thread, and wait again. */
    seL4_TCB_Suspend(t1.thread.tcb.cptr);
    wait_for_timer_interrupt(env);

    /* Counter should not have moved. */
    test_check(counter == old_counter);
    old_counter = counter;

    /* Check once more for good measure. */
    wait_for_timer_interrupt(env);

    /* Counter should not have moved. */
    test_check(counter == old_counter);
    old_counter = counter;

    /* Resume the thread and check it does move. */
    seL4_TCB_Resume(t1.thread.tcb.cptr);
    wait_for_timer_interrupt(env);
    test_check(counter != old_counter);

    /* Done. */
    timer_stop(env->timer->timer);
    sel4_timer_handle_single_irq(env->timer);
    cleanup_helper(env, &t1);

    return sel4test_get_result();
}
예제 #6
0
파일: main.c 프로젝트: jm--/seL4Tron
static void
start_periodic_timer() {
    //setup periodic timer
    UNUSED int err = timer_periodic(timer->timer, 10 * NS_IN_MS);
    assert(err == 0);

    //start timer (no-op for PIT)
    err = timer_start(timer->timer);
    assert(err == 0);

    //Ack IRQ for good measure
    sel4_timer_handle_single_irq(timer);
}
예제 #7
0
RTC_SET_TIME_ISR(software, r, time) {
	int32_t ret;
	struct rtc_software *rtc = (struct rtc_software *) r;
	ret = timer_stop(rtc->timer);
	if (ret < 0) {
		return -1;
	}
	/* TODO: Set nsec not supported */
	ret = timer_periodic(rtc->timer, 1000000UL);
	if (ret < 0) {
		return -1;
	}
	rtc->sec = time->tv_sec;
	return 0;
}
예제 #8
0
파일: interrupt.c 프로젝트: BwRy/sel4test
static int
test_interrupt(env_t env)
{

    int error = timer_periodic(env->timer->timer, 10 * NS_IN_MS);
    timer_start(env->timer->timer);
    sel4_timer_handle_single_irq(env->timer);
    test_check(error == 0);

    for (int i = 0; i < 3; i++) {
        wait_for_timer_interrupt(env);
    }

    timer_stop(env->timer->timer);
    sel4_timer_handle_single_irq(env->timer);

    return sel4test_get_result();
}
예제 #9
0
void pre_init(void) {
    struct pico_ip4 netmask, ipaddr, gw, multicast, zero = {0};
    pico_device_eth *pico_driver;
    memset(&io_ops, 0, sizeof(io_ops));
    io_ops.dma_manager = (ps_dma_man_t) {
        .cookie = NULL,
        .dma_alloc_fn = malloc_dma_alloc,
        .dma_free_fn = malloc_dma_free,
        .dma_pin_fn = malloc_dma_pin,
        .dma_unpin_fn = malloc_dma_unpin,
        .dma_cache_op_fn = malloc_dma_cache_op
    };

    /* Initialise the PicoTCP stack */
    pico_stack_init();

    /* Create a driver. This utilises preallocated buffers, backed up by malloc above */
    pico_driver = pico_eth_create_no_malloc("eth0", ethdriver_init, NULL, io_ops, &_picotcp_driver);
    assert(pico_driver);

    pico_string_to_ipv4("0.0.0.0", &gw.addr);
    pico_string_to_ipv4(server_ip_addr, &ipaddr.addr);
    pico_string_to_ipv4(multicast_addr, &multicast.addr);
    pico_string_to_ipv4("255.255.255.0", &netmask.addr);

    pico_ipv4_link_add(pico_driver, ipaddr, netmask);
    pico_ipv4_route_add(zero, zero, gw, 1, NULL);

    if (pico_ipv4_is_multicast(multicast.addr)) {
        ZF_LOGE("Multicast not yet implemented\n");
        // PicoTCP usually deals with multicast at the socket layer, using pico_socket_setoption.
        // It can be done at the igmp level too by using igmp_state_change. See the picoTCP documentation
        // Eg: pico_igmp_state_change(&ipaddr, &multicast, .... );
    }

    /* Start the timer for tcp */
    // TCP runs off a tick for handling events and timeouts.
    timer_periodic(0, NS_IN_MS * PICO_TICK_MS);

    start_tcpecho();

}
예제 #10
0
int32_t rtc_software_connect(struct rtc *r, struct timer *timer) {
	int32_t ret;
	struct rtc_software *rtc = (struct rtc_software *) r;
	rtc->timer = timer;
	rtc->sec = 0;
	ret = timer_setOverflowCallback(rtc->timer, rtc_software_timerCallback, rtc);
	if (ret < 0) {
		goto rtc_software_connect_error0;
	}
	/* Start Timer */
	ret = timer_periodic(rtc->timer, 1000000UL);
	if (ret < 0) {
		goto rtc_software_connect_error1;
	}
	return 0;
rtc_software_connect_error1:
	timer_setOverflowCallback(rtc->timer, NULL, NULL);
rtc_software_connect_error0:
	return -1;
}
예제 #11
0
파일: main.c 프로젝트: fliedpig/ALF-llvm
int main( void )
{
	fbw_init();
  while( ! term ) 
  {
	fbw_schedule();
    if(timer_periodic()) 
    {
      _1Hz++;
      _20Hz++;
      if (_1Hz >= 60) 
      {
	_1Hz = 0;
      }
      if (_20Hz >= 3) 
      {
	_20Hz = 0;
      }
    }
  } 
  return 0;
}
예제 #12
0
파일: main.c 프로젝트: abdulmajeed90/NetAVR
int
main(void)
{
    // Initialise system clock
    clock_init();

    // Initialise serial communication
    tty_init(115200UL);

    // Initialise timers
#ifndef WITH_DEBUG
    timer_set(display_status, 1);
#endif

    printf("----------------------------------------------\n");
    printf("Copyright (c) 2011 - Roy van Dam <*****@*****.**>\n");
    printf("NetAVR 0.1-CURRENT (%s %s)\n", __TIME__, __DATE__);
    printf("----------------------------------------------\n\n");

    // Initialise ethernet controller
    eth_init(mac_address);

    // Initialise network stack
    net_init(mac_address, ip_address, netmask, default_router);

    // Bind UDP daemons
    udp_bind(7, echo_udp);  // Echo server

    while(true) {
        // Handle network traffic
        net_periodic();

        // Handle expired timers
        timer_periodic();
    }

    return 0;
}
예제 #13
0
/* Set interrupt interval, in milliseconds. */
void clock_set_interval_in_ms(uint32_t interval)
{
	timer_periodic(0, ((uint64_t)interval)*NS_IN_MS);
}
예제 #14
0
파일: cpumon.c 프로젝트: AdamRLukaitis/prex
int
main(int argc, char *argv[])
{
	device_t dev;
	int last_mhz = 0;
	int i, j;
	static char bar[21];

	/* Boost current prioriy */
	thread_setpri(thread_self(), 50);

	if (device_open("cpufreq", 0, &dev))
		panic("open error: cpufreq");

	/* Clear screen */
	printf("\33[2J");

	printf("CPU voltage monitor\n");
	device_ioctl(dev, CFIOC_GET_INFO, &cf_info);
	if (cf_info.freq == 0 || cf_info.volts == 0)
		panic("Invalid cpu power/speed");

	/*
	 * Setup periodic timer for 10msec period
	 */
	timer_periodic(thread_self(), 100, 10);
	for (;;) {
		/*
		 * Wait next period
		 */
		timer_waitperiod();
		device_ioctl(dev, CFIOC_GET_INFO, &cf_info);
		if (cf_info.freq != last_mhz) {
			printf("\33[s"); /* save cursor */

			/*
			 * Display speed
			 */
			printf("\nSpeed: %4dMHz  0|", cf_info.freq);
			j = cf_info.freq * 100 / cf_info.maxfreq;
			for (i = 0; i < 20; i++)
				bar[i] = (i <= j / 5) ? '*' : '-';
			bar[i] = '\0';
			printf("%s|100", bar);

			/*
			 * Display power
			 */
			printf("\nPower: %4dmV   0|", cf_info.volts);
			j = cf_info.volts * 100 / cf_info.maxvolts;
			for (i = 0; i < 20; i++)
				bar[i] = (i <= j / 5) ? '*' : '-';
			bar[i] = '\0';
			printf("%s|100", bar);

			printf("\33[u"); /* restore cursor */
			last_mhz = cf_info.freq;
		}
	}
	return 0;
}
예제 #15
0
파일: cpumon.c 프로젝트: AndrewD/prex
int
main(int argc, char *argv[])
{
	device_t cpu_dev;
	int last_mhz = 0;
	int i, j;
	static char bar[21];

	/* Boost current prioriy */
	thread_setprio(thread_self(), 50);

	if (device_open("cpu", 0, &cpu_dev))
		panic("open error: cpu");

	/* Clear screen */
	printf("\33[2J");

	printf("CPU voltage monitor\n");
	device_ioctl(cpu_dev, CPUIOC_GET_INFO, &cpu_info);
	if (cpu_info.clock_ctrl == 0)
		panic("DVS not supported by cpu");
	if (cpu_info.speed == 0 || cpu_info.power == 0)
		panic("Invalid cpu power/speed");

	/*
	 * Setup periodic timer for 10msec period
	 */
	timer_periodic(thread_self(), 100, 10);
	for (;;) {
		/*
		 * Wait next period
		 */
		timer_waitperiod();
		device_ioctl(cpu_dev, CPUIOC_GET_STAT, &cpu_stat);
		if (cpu_stat.speed != last_mhz) {
			printf("\33[s"); /* save cursor */

			/*
			 * Display speed
			 */
			printf("\nSpeed: %4dMHz  0|", cpu_stat.speed);
			j = cpu_stat.speed * 100 / cpu_info.speed;
			for (i = 0; i < 20; i++)
				bar[i] = (i <= j / 5) ? '*' : '-';
			bar[i] = '\0';
			printf(bar);
			printf("|100");

			/*
			 * Display power
			 */
			printf("\nPower: %4dmV   0|", cpu_stat.power);
			j = cpu_stat.power * 100 / cpu_info.power;
			for (i = 0; i < 20; i++)
				bar[i] = (i <= j / 5) ? '*' : '-';
			bar[i] = '\0';
			printf(bar);
			printf("|100");

			printf("\33[u"); /* restore cursor */
			last_mhz = cpu_stat.speed;
		}
	}
	return 0;
}
예제 #16
0
void post_init() {
    /* timeout once a second */
    int ret;
    ret = timer_periodic(0, 1000000000);
    printf("periodic timer started\n");
}
예제 #17
0
/* Set interrupt interval, in milliseconds. */
void clock_set_interval_in_ms(uint32_t interval)
{
    timer_periodic(timer_drv, ((uint64_t)interval)*NS_IN_MS);
    the_interval = interval;
}