コード例 #1
0
ファイル: timeval.c プロジェクト: David-B55/ovs
static void
do_init_time(void)
{
    struct timespec ts;

    coverage_init();

    init_clock(&monotonic_clock, (!clock_gettime(CLOCK_MONOTONIC, &ts)
                                  ? CLOCK_MONOTONIC
                                  : CLOCK_REALTIME));
    init_clock(&wall_clock, CLOCK_REALTIME);
    boot_time = timespec_to_msec(&monotonic_clock.cache);
}
コード例 #2
0
void SystemInit(void)
{
    /* If desired, switch off the unused RAM to lower consumption by the use of RAMON register.
       It can also be done in the application main() function. */

    /* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required
       to enable the use of peripherals" found at Product Anomaly document for your device found at
       https://www.nordicsemi.com/. The side effect of executing these instructions in the devices
       that do not need it is that the new peripherals in the second generation devices (LPCOMP for
       example) will not be available. */
    if (is_manual_peripheral_setup_needed())
    {
        *(uint32_t volatile *)0x40000504 = 0xC007FFDF;
        *(uint32_t volatile *)0x40006C18 = 0x00008000;
    }

    /* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG
       register is incorrect" found at Product Anomaly document four your device found at
       https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. */
    if (is_disabled_in_debug_needed())
    {
        NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos;
    }

    // Start the external 32khz crystal oscillator.
    init_clock();
}
コード例 #3
0
ファイル: main.c プロジェクト: galedric/RailPi
void main() {
	uint16 i = 0;
	uint8  j = 0;
	
	init_clock();
	init_pwm();
	init_ports();
	//init_uart();
	
	pwm = 0;
	pwm_ctl(true);
	
	HBR1 = 1;
	HBR2 = 0;
	
	while(1) {
		while(pwm > 0) {
			for(j = 0; j < 16; j++)
			for(i = 1; i; i++);
			pwm -= 2;
		}
		while(pwm < 64) {
			for(j = 0; j < 16; j++)
			for(i = 1; i; i++);
			pwm += 2;
		}
		/*if(HBR1) {
			HBR1 = 0;
			HBR2 = 1;
		} else {
			HBR2 = 0;
			HBR1 = 1;
		}*/
	}
}
コード例 #4
0
ファイル: main.c プロジェクト: adalu838/datateknikreal
/* main */ 
int main(void)
{
    /* initialise kernel */ 
    si_kernel_init(); 
    
    /* initialise UI channel */ 
    si_ui_init(); 

    /* initialise variables */         
    init_clock();

    /* initialise display */
    display_init();

    /* create tasks */ 
    si_task_create(clock_task, &Clock_Stack[STACK_SIZE-1], 20); 
    si_task_create(set_task, &Set_Stack[STACK_SIZE-1], 15);
    si_task_create(alarm_task, &Alarm_Stack[STACK_SIZE-1], 10);

    /* start the kernel */ 
    si_kernel_start(); 

    /* will never be here! */ 
    return 0; 
}
コード例 #5
0
ファイル: main.c プロジェクト: Pungsnigel/DAT015-assignments
void main (void)
{
	init_clock();
	while(1)
	{
		switch (get_key())
		{
		case 0:
			motor_start();
			break;
		case 1:
			motor_stop();
			break;
		case 2:
			drill_down();
			break;
		case 3:
			drill_up();
			break;
		case 4:
			step();
			break;
		case 5:
			drill_hole();
			break;
		case 6:
			ref_pos();
			break;
		case 7:
			do_auto(pattern);
			break;
		}
	}
}
コード例 #6
0
/*
 *  ターゲットシステム依存の初期化
 */
void
sys_initialize()
{
    int i;

    init_vector();			/* SRAMのリマップ。LPC2388共通 */

    init_clock();			/* PLLの設定。システム固有 */

    init_uart0();			/* UART0の初期化。システム固有 */

    init_IRQ();				/* VICを初期化する。LPC2388共通 */

    		/* 必要なペリフェラルの電源を入れる(システム固有) */
			/* なお、UART0とTIMER3はLPC2388共通で必要 */
	PCONP |= 0x00800008;	/* bit3:UART0, bit23:TIMER3 */

			/* UART0のピンを設定 (LPC2388共通) */
	PINSEL0 &= ~0xF0;			/* bit 4-7だけをクリア */
	PINSEL0 |= 0x50;			/* UART入出力を割り当て */

    /*
     *  ARMのベクタテーブルへ割込みハンドラを登録(どのARMv4システムでも要求される)
     */
    arm_install_handler(IRQ_Number,IRQ_Handler);

    /*
     * Memory Acceleration Moduleの設定 ( NXP社 UM10211 chapter 7 )
     * Flashメモリのプリフェッチを使ってプログラム実行を高速化する
     */
    MAMCR = 0;		/* 念のためMAMをオフにする */
    MAMTIM = 4;		/* UM10211によれば、60MHz以上で動作するときは4に設定する */
    MAMCR = 2;		/* MAM機能をオンにする */

}
コード例 #7
0
ファイル: ping_main.c プロジェクト: stevew817/ElecanismsTeam
int16_t main(void) {
	//initialize all system clocks
    init_clock();
	//initialize serial communications
    init_uart();
	//initialize pin driving library (to be able to use the &D[x] defs)
	init_pin();
	//initialize the UI library
    init_ui();
	//initialize the timer module
    init_timer();
	//initialize the OC module (used by the servo driving code)
	init_oc();
	
    imu_init()
	//Set servo control pins as output
	pin_digitalOut(PAN_PIN);
	pin_digitalOut(TILT_PIN);
	pin_digitalOut(SONIC_OUT_PIN);
	pin_digitalIn(SONIC_IN_PIN);
	
	//Set LED off
	led_off(LED);
	//Configure blinking rate for LED when connected
    timer_setPeriod(LED_TIM, 0.2);
    timer_start(LED_TIM);
	

    //Configure timer for reciever timeout
    timer_setPeriod(DIST_TIM, 0.05);


	//configure PWM on sonic output pin
	oc_pwm(PWM_OC, SONIC_OUT_PIN, NULL, SONIC_FREQ, 0x0000);
	
	//According to HobbyKing documentation: range .8 through 2.2 msec
	//Set servo control pins as OC outputs on their respective timers
	oc_servo(SERVO1_OC, PAN_PIN, 	SERVO1_TIM, SERVO_PERIOD, SERVO_MIN, SERVO_MAX, pan_set_val);
	oc_servo(SERVO2_OC, TILT_PIN, 	SERVO2_TIM, SERVO_PERIOD, SERVO_MIN, SERVO_MAX, tilt_set_val);

    InitUSB();                              // initialize the USB registers and serial interface engine
    while (USB_USWSTAT!=CONFIG_STATE) {     // while the peripheral is not configured...
        ServiceUSB();                       // ...service USB requests
		led_on(LED);
		//There's no point in driving the servos when there's no one connected yet.
    }
	
    while (1) {
        ServiceUSB();                       // service any pending USB requests
		
		//blink the LED
		if (timer_flag(LED_TIM)) {
            timer_lower(LED_TIM);
            led_toggle(LED);
        }
		
		//Update the servo control values.
        x_gout = gyro_read(OUT_X_L);
    }
}
コード例 #8
0
ファイル: haptic.c プロジェクト: kstegner/elec_mini4
//OTHER INITIAL CONDITIONS
void initChip(){
    init_clock();
    init_uart();
    init_timer();
    init_ui();
    init_pin();
    init_oc();

    pin_analogIn(CUR);
    pin_analogIn(EMF);
    pin_analogIn(FB);

    pin_digitalIn(SF);
    pin_digitalIn(ENC);

    pin_digitalOut(D1);
    pin_digitalOut(D2);
    pin_digitalOut(IN1);
    pin_digitalOut(IN2);
    pin_digitalOut(ENA);
    pin_digitalOut(SLEW);
    pin_digitalOut(INV);

    oc_pwm(&oc1, D2, PWM_TIMER, 250, 0); 
}
コード例 #9
0
/**
 * Function for application main entry.
 */
int main(void)
{	
    init_leds();
    init_clock();

    uint32_t err_code;

    // Button configuration structure.
    static app_button_cfg_t p_button[] = {  {BUTTON_1, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                            {BUTTON_2, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                            {BUTTON_3, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                            {BUTTON_4, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}};
        
    // Macro for initializing the application timer module.
    // It will handle dimensioning and allocation of the memory buffer required by the timer, making sure that the buffer is correctly aligned. It will also connect the timer module to the scheduler (if specified).
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL);

    // Macro for initializing the GPIOTE module.
    // It will handle dimensioning and allocation of the memory buffer required by the module, making sure that the buffer is correctly aligned.
    APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);

    // Initializing the buttons.
    err_code = app_button_init(p_button, sizeof(p_button) / sizeof(p_button[0]), BUTTON_DEBOUNCE_DELAY);
    APP_ERROR_CHECK(err_code);
                                            
    // Enabling the buttons.										
    err_code = app_button_enable();
    APP_ERROR_CHECK(err_code);

    while(true)
    {
        // Do nothing.
    }
}
コード例 #10
0
ファイル: main.c プロジェクト: mengpq/os
/*======================================================================*
                            kernel_main
 *======================================================================*/
PUBLIC int kernel_main()
{
	clear_screen();
	loadELF();
	TASK*		p_task		= task_table;
	PROCESS*	p_proc		= proc_table;
	char*		p_task_stack	= task_stack + STACK_SIZE_TOTAL;
	u16		selector_ldt	= SELECTOR_LDT_FIRST;
	int i,priority;

	proc_table[0].ticks = proc_table[0].pre_ticks=proc_table[0].priority =   20;  proc_table[0].status = RUNNING;
	init_task(proc_table,task_table,SELECTOR_LDT_FIRST,p_task_stack,20,RUNNING);
	for (i=1; i<NR_TASKS; i++){
		proc_table[i].pid=i+1;
		proc_table[i].status=STOPPED;
		task_table[i].stacksize=0x400;
	}
	control_ticks();

	k_reenter=0;
	ticks=0;

	p_proc_ready=proc_table;

	init_clock();
    init_keyboard();

	restart();

	while(1){}
}
コード例 #11
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_timer();
    init_i2c();
    InitUSB();
    init_oc();

    init_display(&i2c3, 0x70, 0x71);
    init_game(&timer1, &timer2, &A[0], &disp1, &disp2);
    init_gun(&D[13], &A[1], &A[2], &timer3);
    init_launcher(&D[5], &D[8], &D[3], &D[4]);
    init_shooter(&D[6], &D[9], &D[1], &D[2], &D[7], &D[0], &oc3, &oc4);
    init_baller(&D[10], &oc2, &timer4, &shooter, &launcher);
    init_pix(&D[11], &timer5, 30, 0.05);
    init_audio(&D[12]);

    uint8_t level = 0;
    uint8_t hit_flag = 0;
    while (1) {
        ServiceUSB(); // usb times out if not checked fast enough :/
        level = run_game(hit_flag);
        ServiceUSB();
        hit_flag = run_gun(level);
        ServiceUSB();
        run_baller(level);
    }
}
コード例 #12
0
ファイル: servo_test.c プロジェクト: RyanEggert/space-lander
int16_t main(void) {
    // printf("Starting Rocket Controller...\r\n");
    init_clock();
    init_ui();
    init_pin();
    init_timer();
    init_i2c();
    setup();
    init_servo_driver(&sd1, &i2c3, 16000., 0x0);
    init_servo(&servo4, &sd1, 0);
    InitUSB();
    U1IE = 0xFF; //setting up ISR for USB requests
    U1EIE = 0xFF;
    IFS5bits.USB1IF = 0; //flag
    IEC5bits.USB1IE = 1; //enable
    // uint32_t pid_command;
    servo_set(&servo4, 1500, 0);
    while (1) {
        if (timer_flag(&timer1)) {
            // Blink green light to show normal operation.
            timer_lower(&timer1);
            led_toggle(&led2);
            // servo_set(&servo4, 1500, 0);
        }
    }
}
コード例 #13
0
ファイル: sys_main.c プロジェクト: Lellansin/LibraryManager
static void init_system()
{
	cur_sale = make_new_sale(1);
	cursor_hide();
	init_clock();
	update_clock();
}
コード例 #14
0
ファイル: login.c プロジェクト: Lellansin/LibraryManager
/*
 * 2.输入获取
 * 3.处理输入
 */
void login()
{
	int Login_status;
	init_clock();	
	init_user();

	while (1) {

		/* 显示界面 */
		show_login_window();

		/* 获取用户名 */
		get_user_name();
		/* 获取密码 */
		get_pass_word();

		Login_status = check_login();

		/* 
		 * 验证用户名密码
		 */
		if ( Login_status == LOGIN_INFO_SUCCESS ) {
			/* 进入系统 */
			sys_main();
		}

		/* 错误提示 */
		print_err(Login_status);
		
	}
}
コード例 #15
0
ファイル: haptic_damper.c プロジェクト: gubbatuba/elecanisms
void setup(void) {
    // Initialize PIC24 modules.
    init_clock();
    init_ui();
    init_timer();
    init_pin();
    init_oc();
    init_spi();
    init_uart();

    // Configure single SPI comms. system
    pin_digitalOut(SPI_CS);
    pin_set(SPI_CS);
    spi_open(spi_inst, SPI_MISO, SPI_MOSI, SPI_SCK, spi_freq, spi_mode);

    // Configure & start timers used.
    timer_setPeriod(&timer1, 1);
    timer_setPeriod(&timer2, 1);  // Timer for LED operation/status blink
    timer_setPeriod(&timer3, LOOP_TIME); // Timer for main control loop
    timer_start(&timer1);
    timer_start(&timer2);
    timer_start(&timer3);

    // Configure dual PWM signals for bidirectional motor control
    oc_pwm(&oc1, PWM_I1, NULL, pwm_freq, pwm_duty);
    oc_pwm(&oc2, PWM_I2, NULL, pwm_freq, pwm_duty);

    InitUSB();                              // initialize the USB registers and
                                            // serial interface engine
    while (USB_USWSTAT != CONFIG_STATE) {   // while periph. is not configured,
        ServiceUSB();                       // service USB requests
    }
}
コード例 #16
0
ファイル: main.c プロジェクト: Finspire13/OSCourseDesign
/*======================================================================*
                            kernel_main
 *======================================================================*/
PUBLIC int kernel_main()
{
	disp_str("-----\"kernel_main\" begins-----\n");

	TASK*		p_task		= task_table;
	PROCESS*	p_proc		= proc_table;
	char*		p_task_stack	= task_stack + STACK_SIZE_TOTAL;
	u16		selector_ldt	= SELECTOR_LDT_FIRST;
	int i;
	for (i = 0; i < NR_TASKS; i++) {
		strcpy(p_proc->p_name, p_task->name);	// name of the process
		p_proc->pid = i;			// pid

		p_proc->ldt_sel = selector_ldt;

		memcpy(&p_proc->ldts[0], &gdt[SELECTOR_KERNEL_CS >> 3],
		       sizeof(DESCRIPTOR));
		p_proc->ldts[0].attr1 = DA_C | PRIVILEGE_TASK << 5;
		memcpy(&p_proc->ldts[1], &gdt[SELECTOR_KERNEL_DS >> 3],
		       sizeof(DESCRIPTOR));
		p_proc->ldts[1].attr1 = DA_DRW | PRIVILEGE_TASK << 5;
		p_proc->regs.cs	= ((8 * 0) & SA_RPL_MASK & SA_TI_MASK)
			| SA_TIL | RPL_TASK;
		p_proc->regs.ds	= ((8 * 1) & SA_RPL_MASK & SA_TI_MASK)
			| SA_TIL | RPL_TASK;
		p_proc->regs.es	= ((8 * 1) & SA_RPL_MASK & SA_TI_MASK)
			| SA_TIL | RPL_TASK;
		p_proc->regs.fs	= ((8 * 1) & SA_RPL_MASK & SA_TI_MASK)
			| SA_TIL | RPL_TASK;
		p_proc->regs.ss	= ((8 * 1) & SA_RPL_MASK & SA_TI_MASK)
			| SA_TIL | RPL_TASK;
		p_proc->regs.gs	= (SELECTOR_KERNEL_GS & SA_RPL_MASK)
			| RPL_TASK;

		p_proc->regs.eip = (u32)p_task->initial_eip;
		p_proc->regs.esp = (u32)p_task_stack;
		p_proc->regs.eflags = 0x1202; /* IF=1, IOPL=1 */

		p_task_stack -= p_task->stacksize;
		p_proc++;
		p_task++;
		selector_ldt += 1 << 3;
	}

	k_reenter = 0;
	ticks = 0;
        shot_num=-1;
        is_shot=1;
        game_target=0x01;
	p_proc_ready	= proc_table;

	init_clock();
        init_keyboard();

	restart();



	while(1){}
}
コード例 #17
0
ファイル: tls.c プロジェクト: momodupi/cc2530
//数据存入缓存数组
void transf_temper()
{
  init_clock();
  read_data();

  if(ana == 1)
  {
    datacache[0] = '+';
  }
  else
  {
    datacache[0] = '-';
  }
  if (temp/1000 == 0)
  {
    datacache[1] = ' ';
  }
  else
  {
    datacache[1] = temp/1000 + 0x30;
  }
  if ((temp/1000 == 0) && (temp/100 == 0))
  {
    datacache[2] = ' ';
  }
  else
  {
    datacache[2] = temp/100 + 0x30;
  }
  datacache[3] = (temp%100)/10 + 0x30;
  datacache[4] = '.';
  datacache[5] = temp%10 + 0x30;
  datacache[6] = 'C';
  datacache[7] = '\r';
}
コード例 #18
0
ファイル: main.c プロジェクト: aravind2/mwtp
int main(void)
{
  init_other_hw(); /* Must call this first */
  init_timer();
  init_audio();
  init_turnled();
  init_inputs();

  enable_task(TURNLED_TASK);
  enable_task(AUDIO_TASK);
  enable_task(INPUTS_TASK);
  enable_task(COUNTDOWN_TASK);
   
  /* initialize display, cursor off */
  lcd_init(LCD_DISP_ON);

  init_clock();

  /* Enable interrupts */
  sei();

  for (;;) {                           /* loop forever */
    poll_inputs();
    poll_clock();
    sleep_until_interrupt();
  } /* end loop forever */
}
コード例 #19
0
ファイル: encodertest.c プロジェクト: erin-pierce/elecanisms
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_spi();

    ENC_MISO = &D[1];
    ENC_MOSI = &D[0];
    ENC_SCK = &D[2];
    ENC_NCS = &D[3];

    pin_digitalOut(ENC_NCS);
    pin_set(ENC_NCS);

    spi_open(&spi1, ENC_MISO, ENC_MOSI, ENC_SCK, 2e8);


    InitUSB();                              // initialize the USB registers and serial interface engine
    while (USB_USWSTAT!=CONFIG_STATE) {     // while the peripheral is not configured...
        ServiceUSB();                       // ...service USB requests
    }
    while (1) {
        ServiceUSB();                       // service any pending USB requests
    }
}
コード例 #20
0
ファイル: main.c プロジェクト: nf-dj/cellpilot
int main() {
    init_clock();
    init_gpio();
    init_usart();
    init_pwm();
    while(1) {}
}
コード例 #21
0
ファイル: kernel.c プロジェクト: andylin211/andyos
int main(void)
{    
    init_global();

    init_gdt();

    init_idt();

    init_tss();

    init_virtual_memory_mapping();

    init_process();

    init_8259a();

    init_clock();

    init_keyboard();

    init_syscall();

    debug_helper();

    restart();
}
コード例 #22
0
ファイル: blink.c プロジェクト: CharlieMouton/elecanisms
int16_t main(void) {
    int led2_on;
    int led3_on;

    led2_on = 0;
    led3_on = 1;
    init_clock();
    init_ui();
    init_timer();

    led_on(&led1);
    timer_setPeriod(&timer2, 0.1);
    timer_start(&timer2);

    while (1) {
        if (timer_flag(&timer2)) {
            timer_lower(&timer2);
            led_toggle(&led1);
        }

        if(!sw_read(&sw2)){
            timer_setPeriod(&timer2, 0.5);
            timer_start(&timer2);
            led2_on = 1;
            led3_on = 0;
        } else if(!sw_read(&sw3)){
            timer_setPeriod(&timer2, 0.1);
            timer_start(&timer2);
            led2_on = 0;
            led3_on = 1;
        }
        led_write(&led2, led2_on);
        led_write(&led3, led3_on);
    }
}
コード例 #23
0
ファイル: mp2.c プロジェクト: jacobkingery/elecanisms_mp2
int16_t main(void) {
    init_clock();
    init_timer();
    init_ui();
    init_pin();
    init_spi();
    init_oc();
    init_md();

    // Current measurement pin
    pin_analogIn(&A[0]);

    // SPI pin setup
    ENC_MISO = &D[1];
    ENC_MOSI = &D[0];
    ENC_SCK = &D[2];
    ENC_NCS = &D[3];
    pin_digitalOut(ENC_NCS);
    pin_set(ENC_NCS);

    // Open SPI in mode 1
    spi_open(&spi1, ENC_MISO, ENC_MOSI, ENC_SCK, 2e6, 1);

    // Motor setup
    md_velocity(&md1, 0, 0);

    // Get initial angle offset
    uint8_t unset = 1;
    while (unset) {
        ANG_OFFSET = enc_readReg((WORD) REG_ANG_ADDR);
        unset = parity(ANG_OFFSET.w);
    }
    ANG_OFFSET.w &= ENC_MASK;

    // USB setup
    InitUSB();
    while (USB_USWSTAT!=CONFIG_STATE) {
        ServiceUSB();
    }

    // Timers
    timer_setFreq(&timer2, READ_FREQ);
    timer_setFreq(&timer3, CTRL_FREQ);
    timer_start(&timer2);
    timer_start(&timer3);

    // Main loop
    while (1) {
        ServiceUSB();
        if (timer_flag(&timer2)) {
            timer_lower(&timer2);
            get_readings();
        }
        if (timer_flag(&timer3)) {
            timer_lower(&timer3);
            set_velocity();
        }
    }
}
コード例 #24
0
ファイル: dmtimer0.c プロジェクト: AubrCool/barebox
/**
 * @brief Initialize the Clock
 *
 * Enable dmtimer0.
 *
 * @return result of @ref init_clock
 */
static int dmtimer0_init(void)
{
	dmtimer0_cs.mult = clocksource_hz2mult(CLK_RC32K, dmtimer0_cs.shift);
	/* Enable counter */
	writel(0x3, AM33XX_DMTIMER0_BASE + TCLR);

	return init_clock(&dmtimer0_cs);
}
コード例 #25
0
ファイル: main.c プロジェクト: VahidHeidari/NES_DEV
void SystemInit()
{
	FLASH->ACR = 0x00000012;
	init_clock();
	init_lcd();
	init_port();
	init_usart();
}
コード例 #26
0
ファイル: clock.c プロジェクト: vkleen/barebox-novena
static int clocksource_init (void)
{
    cs.mult = clocksource_hz2mult(1000 * 1000 * 1000, cs.shift);

    init_clock(&cs);

    return 0;
}
コード例 #27
0
ファイル: daughterboard.c プロジェクト: saulrh/pcimotor
/* main function */
int main(void)
{
    /* ============================== */
    /* initialization =============== */
    /* ============================== */
    
    WDT_EnableAndSetTimeout(WDT_PER_512CLK_gc);

    /* set up LED pins */
    init_leds();

    /* set up I2C as slave */
    init_twi();

    /* set up our clocks */
    init_clock();
    
    /* set up sensors */
    init_sensors();

    /* set up motors */
    init_motors();

    /* set up crude digital outputs */
    init_digout();

    /* Flash all the LEDs for two and a half seconds to make sure
     * they're hooked up */
    led_orders->behavior = LED_BEHAVIOR_TIMED;
    led_orders->time = 4000;
    led_error1->behavior = LED_BEHAVIOR_TIMED;
    led_error1->time = 6000;
    led_error2->behavior = LED_BEHAVIOR_TIMED;
    led_error2->time = 8000;
    led_mota->behavior = LED_BEHAVIOR_TIMED;
    led_mota->time = 10000;
    led_motb->behavior = LED_BEHAVIOR_TIMED;
    led_motb->time = 12000;

    /* motA.duty = 4000; */
    /* motA.direction = 1; */
    /* motB.duty = 16000; */
    /* motB.direction = 1; */

    /* enable interrupts - things start ticking now */
    sei();


    /* ============================== */
    /* main loop ==================== */
    /* ============================== */
    for(;;)
    {
        _delay_us(10);
        WDT_Reset();
    }
}
コード例 #28
0
ファイル: time.c プロジェクト: MinimumLaw/ravion-barebox
static int clocksource_init(void)
{
	/* reset time base */
	asm ("li 3,0 ; mttbu 3 ; mttbl 3 ;");

	cs.mult = clocksource_hz2mult(get_timebase_clock(), cs.shift);

	return init_clock(&cs);
}
コード例 #29
0
ファイル: spring.c プロジェクト: erin-pierce/elecanisms
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_spi();

    init_timer();
    init_oc();
    init_md();

    led_off(&led2);
    led_off(&led3);

    ENC_MISO = &D[1];
    ENC_MOSI = &D[0];
    ENC_SCK = &D[2];
    ENC_NCS = &D[3];


    read_angle.w=0x3FFF;
    Pscale.w=1;
    Iscale.w=0;
    direction.w=1;
    speed.w=0;
    angle_now.i=180;
    angle_prev.i=180;
    angle.w=10;
    uint8_t loop = 0;

    pin_digitalOut(ENC_NCS);
    pin_set(ENC_NCS);

    spi_open(&spi1, ENC_MISO, ENC_MOSI, ENC_SCK, 2e8,1);

    timer_setPeriod(&timer1, 0.05);
    timer_start(&timer1);

    InitUSB();  
                              // initialize the USB registers and serial interface engine
    while (USB_USWSTAT!=CONFIG_STATE) {     // while the peripheral is not configured...
        ServiceUSB();                       // ...service USB requests
    }  

   while(1){
    ServiceUSB();
        if (timer_flag(&timer1)) {
            timer_lower(&timer1);
            angle_prev=angle_now; 
            angle_prev_con=angle;                // service any pending USB requests
            angle_now = enc_readReg(read_angle);
            angle_now = mask_angle(angle_now);
            angle=convert_Angle(angle_prev,angle_now,&loop);

            spring_simple(angle);
        }
    }    
}
コード例 #30
0
ファイル: clock.c プロジェクト: caicry/mini2440-barebox
static int clocksource_init(void)
{
	mtspr(SPR_TTMR, SPR_TTMR_CR | 0xFFFFFF);
	cs.mult = clocksource_hz2mult(OPENRISC_TIMER_FREQ, cs.shift);

	init_clock(&cs);

	return 0;
}