Esempio n. 1
0
int main(void) {
	
	init_port();
	init_interrupt();

	sei();

	while(1) {
		
		if( i+j==38 ) {
			
			PORTB = 0x80;
			_delay_ms(300);
			PORTB = 0x00;

			i=0;
			j=0;

		}
	
	}

	return 0;

}
Esempio n. 2
0
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;
}
Esempio n. 3
0
int kmain(int argc, char* argv[], uint32_t table) {
	int exit_num = 0;
	unsigned *old_instr1 = 0, *old_instr2 = 0;
	unsigned *old_instr_irq_1 = 0, *old_instr_irq_2 = 0;

	app_startup(); /* bss is valid after this point */
	global_data = table;

	//install the swi custom handler
	install_handler((unsigned int*)0x8, (int)swi_handler, old_instr1, old_instr2);
	//install the irq custom handler
	install_handler((unsigned int*)0x18, (int)irq_handler, old_instr_irq_1, old_instr_irq_2);

	//initiate the interrupt and timer 0
	init_interrupt();
	init_timer0();
	
	//load user program	
	exit_num = load_user(argc, argv);

	//restore the swi system handler
	restore_handler((unsigned int*)0x8, old_instr1, old_instr2);
	//restore the irq system handler
	restore_handler((unsigned int*)0x18, old_instr_irq_1, old_instr_irq_2);

	return exit_num;

}
Esempio n. 4
0
File: main.c Progetto: monaka/B-Free
/* init_itron --- ITRON の初期化を行う。
 *
 */
static ER
init_itron ()
{
  init_interrupt ();
  simple_init_console ();	/* コンソールに文字を出力できるようにする */
  pmem_init ();			/* 物理メモリ管理機能の初期化		*/
  banner ();			/* 立ち上げメッセージ出力		*/
  printf ("init_itron: start\n");
  init_kalloc ();		/* バイト単位のメモリ管理機能の初期化	*/
  init_semaphore ();		/* セマフォの管理機能の初期化		*/
  init_msgbuf ();		/* メッセージ管理機能の初期化		*/
  init_eventflag ();		/* イベントフラグ管理機能の初期化	*/
#ifdef notdef
  init_mpl ();			/* メモリプール管理機能の初期化		*/
  simple_init_console ();	/* コンソールに文字を出力できるようにする */
#endif
  init_task ();			/* タスク管理機能の初期化 */

  /* 1番目のタスクを初期化する。そしてそのタスクを以後の処
   * 理で使用する。
   */
  init_task1 ();

  printf ("call init_timer\n"); 
  init_timer ();	/* インターバルタイマ機能の初期化 */
  start_interval ();	/* インターバルタイマの起動	  */
  init_io ();
  return (E_OK);
}
static int __init shuttle_gpio_init(void)
{

	init_shuttle_proc() ;
	init_input_dev() ;
	init_gpio_status() ;
	init_shuttle_gpio_key() ;
    init_shuttle_timer() ;

    init_interrupt() ;
	printk(KERN_INFO MOD_NAME "Module Init: Shuttle module\n");
	return 0;
}
Esempio n. 6
0
void main (void) {
init_mcu ();

init_interrupt ();


_BIS_SR(LPM3_bits + GIE);


while (1);
//_BIS_SR(LPM3_bits + GIE);


}
Esempio n. 7
0
File: subp.c Progetto: flavioc/XSB
void cancel_proc(int sig)
{
#ifdef MULTI_THREAD
  th_context *th = find_context(xsb_thread_self());

  if (th->cond_var_ptr != NULL)
	pthread_cond_broadcast( th->cond_var_ptr ) ;
#endif
#ifndef LINUX
  init_interrupt();  /* reset interrupt, if using signal */
#endif
  //    asynint_val |= THREADINT_MARK;
    asynint_code = 0;
}
Esempio n. 8
0
int main(void)
{
	init_port();
	init_interrupt();
	lcd_init();
	DDRA=0xff;
    while(1)
    {
		received=PINC;

		switch(PINC)
		{
			case decVolume:
			{
				vButton--;
				volume
				break;
			}
			case incVolume:
			{
				vButton++;
				break;
			}
			case decSpeed:
			{
				sButton--;				
				speed(vButton);
				break;
			}
			case incSpeed:
			{
				sButton++;
				speed(vButton);				
				break;
			}
			case bass:
			{
				
			}
			case treble:
			{
				
			}
			
			default:{}
			
		}
        
    } //while ends.
}
static void nmi_int_handler(void)
{
   /* Non Maskable Interrupt -- remove interrupt event from queue */
   remove_interrupt_event();
   /* setup r4300 Status flags: reset TS and SR, set BEV, ERL, and SR */
   g_cp0_regs[CP0_STATUS_REG] = (g_cp0_regs[CP0_STATUS_REG] & ~(CP0_STATUS_SR | CP0_STATUS_TS | UINT32_C(0x00080000))) | (CP0_STATUS_ERL | CP0_STATUS_BEV | CP0_STATUS_SR);
   g_cp0_regs[CP0_CAUSE_REG]  = 0x00000000;
   /* simulate the soft reset code which would run from the PIF ROM */
   pifbootrom_hle_execute(&g_dev);
   /* clear all interrupts, reset interrupt counters back to 0 */
   g_cp0_regs[CP0_COUNT_REG] = 0;
   g_gs_vi_counter = 0;
   init_interrupt();

   g_dev.vi.delay = g_dev.vi.next_vi = 5000;
   add_interrupt_event_count(VI_INT, g_dev.vi.next_vi);

   /* clear the audio status register so that subsequent write_ai() calls will work properly */
   g_dev.ai.regs[AI_STATUS_REG] = 0;
   /* set ErrorEPC with the last instruction address */
   g_cp0_regs[CP0_ERROREPC_REG] = PC->addr;
   /* reset the r4300 internal state */
   if (r4300emu != CORE_PURE_INTERPRETER)
   {
      /* clear all the compiled instruction blocks and re-initialize */
      free_blocks();
      init_blocks();
   }
   /* adjust ErrorEPC if we were in a delay slot, and clear the delay_slot and dyna_interp flags */
   if(g_dev.r4300.delay_slot==1 || g_dev.r4300.delay_slot==3)
   {
      g_cp0_regs[CP0_ERROREPC_REG]-=4;
   }
   g_dev.r4300.delay_slot = 0;
   dyna_interp = 0;
   /* set next instruction address to reset vector */
   last_addr = UINT32_C(0xa4000040);
   generic_jump_to(UINT32_C(0xa4000040));

#ifdef NEW_DYNAREC
   if (r4300emu == CORE_DYNAREC)
   {
      g_cp0_regs[CP0_ERROREPC_REG]=(pcaddr&~3)-(pcaddr&1)*4;
      pcaddr = 0xa4000040;
      pending_exception = 1;
      invalidate_all_pages();
   }
#endif
}
Esempio n. 10
0
//***************************************************************************************
// MAIN function starts here             
//***************************************************************************************
int main() {
  
    //Initialize Interrupts
    init_interrupt();
  
    // Initialization sequence
    if (enumerated != 0xDEADBEEF){
		initialization();
    }
    
    while(1);
    
    // Should not reach here
    mbus_sleep_all();
    while(1);
}
Esempio n. 11
0
File: subp.c Progetto: flavioc/XSB
/* TLS: 2/02 removed "inline static" modifiers so that this function
   can be called from interprolog_callback.c */
void keyint_proc(int sig)
{
#ifdef MULTI_THREAD
  th_context *th = find_context(xsb_thread_self());

  if (th->cond_var_ptr != NULL)
	pthread_cond_broadcast( th->cond_var_ptr ) ;
#endif
#ifndef LINUX
  init_interrupt();  /* reset interrupt, if using signal */
#endif
  if (asynint_val & KEYINT_MARK) {
    xsb_abort("unhandled keyboard interrupt");
  } else {
    asynint_val |= KEYINT_MARK;
    asynint_code = 0;
  }
}
Esempio n. 12
0
void reset_hard(void)
{
   poweron_device(&g_dev);

   pifbootrom_hle_execute(&g_dev);
   last_addr = UINT32_C(0xa4000040);
   next_interrupt = 624999;
   init_interrupt();

   g_dev.vi.delay = g_dev.vi.next_vi = 5000;
   add_interrupt_event_count(VI_INT, g_dev.vi.next_vi);

   if(r4300emu != CORE_PURE_INTERPRETER)
   {
      free_blocks();
      init_blocks();
   }
   generic_jump_to(last_addr);
}
Esempio n. 13
0
File: init.c Progetto: hirakuni45/RX
void init(void)
{
	init_interrupt();

	// C++ constractor
	rx_run_preinit_array();
	rx_run_init_array();

	set_intr_level(15);

	// main の起動
	static int argc = 0;
	static char **argv = 0;
	int ret = main(argc, argv);

	rx_run_fini_array();

	// メイン関数の「return」
	while(1) ;
}
Esempio n. 14
0
/**
 * Expects to be called back through os_dev_create().
 *
 * @param The device object associated with this accelerometer
 * @param Argument passed to OS device init, unused
 *
 * @return 0 on success, non-zero error on failure.
 */
int
lis2dw12_init(struct os_dev *dev, void *arg)
{
    struct lis2dw12 *lis2dw12;
    struct sensor *sensor;
    int rc;

    if (!arg || !dev) {
        rc = SYS_ENODEV;
        goto err;
    }

    lis2dw12 = (struct lis2dw12 *) dev;

    lis2dw12->cfg.mask = SENSOR_TYPE_ALL;

    log_register(dev->od_name, &_log, &log_console_handler, NULL, LOG_SYSLEVEL);

    sensor = &lis2dw12->sensor;

    /* Initialise the stats entry */
    rc = stats_init(
        STATS_HDR(g_lis2dw12stats),
        STATS_SIZE_INIT_PARMS(g_lis2dw12stats, STATS_SIZE_32),
        STATS_NAME_INIT_PARMS(lis2dw12_stat_section));
    SYSINIT_PANIC_ASSERT(rc == 0);
    /* Register the entry with the stats registry */
    rc = stats_register(dev->od_name, STATS_HDR(g_lis2dw12stats));
    SYSINIT_PANIC_ASSERT(rc == 0);

    rc = sensor_init(sensor, dev);
    if (rc) {
        goto err;
    }

    /* Add the light driver */
    rc = sensor_set_driver(sensor, SENSOR_TYPE_ACCELEROMETER,
            (struct sensor_driver *) &g_lis2dw12_sensor_driver);
    if (rc) {
        goto err;
    }

    /* Set the interface */
    rc = sensor_set_interface(sensor, arg);
    if (rc) {
        goto err;
    }

    rc = sensor_mgr_register(sensor);
    if (rc) {
        goto err;
    }

    if (sensor->s_itf.si_type == SENSOR_ITF_SPI) {

        rc = hal_spi_disable(sensor->s_itf.si_num);
        if (rc) {
            goto err;
        }

        rc = hal_spi_config(sensor->s_itf.si_num, &spi_lis2dw12_settings);
        if (rc == EINVAL) {
            /* If spi is already enabled, for nrf52, it returns -1, We should not
             * fail if the spi is already enabled
             */
            goto err;
        }

        rc = hal_spi_enable(sensor->s_itf.si_num);
        if (rc) {
            goto err;
        }

        rc = hal_gpio_init_out(sensor->s_itf.si_cs_pin, 1);
        if (rc) {
            goto err;
        }
    }


    init_interrupt(&lis2dw12->intr, lis2dw12->sensor.s_itf.si_ints);
    
    lis2dw12->pdd.notify_ctx.snec_sensor = sensor;
    lis2dw12->pdd.registered_mask = 0;
    lis2dw12->pdd.interrupt = NULL;

    rc = init_intpin(lis2dw12, lis2dw12_int_irq_handler, sensor);
    if (rc) {
        return rc;
    }

    return 0;
err:
    return rc;

}
Esempio n. 15
0
static void execute(int run)
{
        XTime time;
        u32 frame, init_frame, frame_before_start, generations;
        unsigned int seed;

        init_interrupt();

        XTime_GetTime(&time);
        seed = time;
        srand(seed);

        frame_before_start = read_frame_number();

        XTime_SetTime(0);

        while (!OCM_CPU0_RUNNING);

        OCM_CPU1_RUNNING = 1;

        /* If the program will run without PL reset then the first frame will
         * not be 0. */
        init_frame = init_popul();
        update_development(get_elit(), init_frame, time);

        for (generations = 1; OCM_CPU0_RUNNING; ++generations) {
                frame = new_popul();
                update_development(get_elit(), frame, generations);
        }

        XTime_GetTime(&time);

        if (init_frame > 0 && init_frame == frame_before_start) {
                /* The first frames should be removed because those belong to
                 * the previous run. The size of the FIFO implies that only
                 * one frame remain in the FIFO but it will influence one
                 * run (furthermore, these frames might be several times
                 * in the development list). */
                int removed_developments = remove_first_frames();
                const int removed_frames = 1;

                /* Consequently, the frames are renumbered and should start
                 * with number 0 */
                postproc_development(init_frame + removed_frames);

#if 0
                xil_printf("Frame before start: 0x%X. First frame: 0x%X. "
                                "I removed %d development items "
                                "(%d frames).\n\r",
                                frame_before_start, init_frame,
                                removed_developments, removed_frames);
                (void) run;
#else
                (void) removed_developments;
#endif
        }

        xil_printf("Run %d is finished.\n\r", run);

        next_development_run(seed, time, OCM_FRAME_COUNTER, generations);

        OCM_CPU1_RUNNING = 0;
}
Esempio n. 16
0
/**
 * Main function of server applcation that creates the tunnel interface, starts threads and configures the connections
 */
int main(int argc, char **argv)
{
    //initializing system io components
    init_sysio();
    const char* __progname__ = argv[0];

    /*Setting up the interrupt and binding it to a handler*/
    init_interrupt(&exit_signal, SIGINT, BOOL_FALSE);
    set_interrupt_sh(&exit_signal, _exit_handler);

    /*The program uses argtable2 implementation for parsing arguments
     * More information and examples for argtable2:
     *
     * http://argtable.sourceforge.net/example/index.html
     *
     * */
    struct arg_lit  *help = arg_lit0("h","help","show help");
    struct arg_int  *time = arg_int0("t", "time", "<n>", "time interval");
    struct arg_end  *end  = arg_end(20);
    void* argtable[] = {help, time, end};
    int nerrors;
    int exitcode=EXIT_SUCCESS;


    /* verify the argtable[] entries were allocated sucessfully */
    if (arg_nullcheck(argtable) != 0)
    {
      /* NULL entries were detected, some allocations must have failed */
      ERRORPRINT("%s: insufficient memory\n",__progname__);
      exitcode=1;
      goto exit;
    }

    /* Parse the command line as defined by argtable[] */
    nerrors = arg_parse(argc,argv,argtable);

    /* special case: '--help' takes precedence over error reporting */
    if (help->count > 0)
    {
      INFOPRINT("Usage: %s", __progname__);
      arg_print_syntax(stdout,argtable,"\n");
      arg_print_glossary(stdout,argtable,"  %-20s %s\n");
      exitcode=0;
      goto exit;
    }

    /* If the parser returned any errors then display them and exit */
    if (nerrors > 0)
    {
      /* Display the error details contained in the arg_end struct.*/
      arg_print_errors(stdout,end,__progname__);
      INFOPRINT("Try '%s --help' for more information.\n",__progname__);
      exitcode=1;
      goto exit;
    }

    INFOPRINT("Service build by using devclego version %s.\n\n", DEVCLEGO_VERSION);

    /*devclego starts here
     * Build the abstract finite state machine by ceating it
     * and then running the program.
     * After the program proc finished, fsm is doomed.*/
    fsm_ctor();
    program(time);
    fsm_dtor();
exit:
	return exitcode;
}