int YARPMEIDeviceDriver::open(void *d)
{
	// temporarily removed
	int16 rc = 0;

	MEIOpenParameters *p = (MEIOpenParameters *)d;

	_njoints = p->nj;

	rc = dsp_init(p->meiPortAddr);	// init
	rc = dsp_reset();				// reset

	_ref_speeds = new double [_njoints];
	ACE_ASSERT (_ref_speeds != NULL);
	_ref_accs = new double [_njoints];
	ACE_ASSERT (_ref_accs != NULL);
	_ref_positions = new double [_njoints];
	ACE_ASSERT (_ref_positions != NULL);
	_all_axes = new int16[_njoints];
	ACE_ASSERT (_all_axes != NULL);

	int i;
	for(i = 0; i < _njoints; i++)
		_all_axes[i] = i;

	_filter_coeffs = new int16* [_njoints];
	ACE_ASSERT (_filter_coeffs != NULL);
	for(i = 0; i < _njoints; i++)
	{
		_filter_coeffs[i] = new int16 [COEFFICIENTS];
		ACE_ASSERT (_filter_coeffs[i] != NULL);
	}

	_dsp_rate = dsp_sample_rate();
	
	_winding = new int16[_njoints];
	ACE_ASSERT (_winding != NULL);
	memset (_winding, 0, sizeof(int16) * _njoints);

	_16bit_oldpos = new double[_njoints];
	ACE_ASSERT (_16bit_oldpos != NULL);
	memset (_16bit_oldpos, 0, sizeof(double) * _njoints);

	_position_zero = new double[_njoints];
	ACE_ASSERT (_position_zero != NULL);
	memset (_position_zero, 0, sizeof(double) * _njoints);

	int mask = p->ioPorts;
	for (i = 0; i < MAX_PORTS; i++)
	{
		if (mask & 0x1)
			init_io (i, IO_OUTPUT);
		else
			init_io (i, IO_INPUT);

		mask >>= 1;
	}

	return rc;
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
    init_io(&in, stdin, "r", argc > 1 ? argv[1] : "");
    init_io(&out, stdout, "w", argc > 2 ? argv[2] : "");

    runLexer();
    
    return 0;
}
Exemplo n.º 3
0
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);

    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            init_cxx_funcs();
            init_lockit();
            init_exception(hinstDLL);
            init_locale(hinstDLL);
            init_io(hinstDLL);
            init_misc(hinstDLL);
            break;
        case DLL_PROCESS_DETACH:
            if (lpvReserved) break;
            free_io();
            free_locale();
            free_lockit();
            free_misc();
            break;
    }

    return TRUE;
}
Exemplo n.º 4
0
/*
 * Register a filedesc for readable events
 * Set up its input buffer
 */
int 	new_open (int des)
{
	if (des < 0)
		return des;		/* Invalid */

	if (!io_rec)
		init_io();

	if (!FD_ISSET(des, &readables))
		FD_SET(des, &readables);
	if (FD_ISSET(des, &writables))
		FD_CLR(des, &writables);
	if (FD_ISSET(des, &held_readables))
		FD_CLR(des, &held_readables);
	if (FD_ISSET(des, &held_writables))
		FD_CLR(des, &held_writables);

	/*
	 * Keep track of the highest fd in use.
	 */
	if (des > global_max_fd)
		global_max_fd = des;

	return des;
}
Exemplo n.º 5
0
Arquivo: main.c Projeto: 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);
}
Exemplo n.º 6
0
void preprocess(FILE *infile, char *infilename)
{
   char *cp;

   init_io(infile, infilename);

   cp = strrchr(infilename, CPP_FILESEPCHAR_1);
   if (!cp) {
      cp = strrchr(infilename, CPP_FILESEPCHAR_2);
   }
   if (cp)
   {
      char save = *cp;
      *cp = '\0';
      init_incldir(infilename);
      *cp = save;
   }
   else
   {
      init_incldir(".");
   }

   autodef_file(infilename);
   autodef_line(1);
   out_at(1, infilename);
}
Exemplo n.º 7
0
void setup() {

// Generated by Acceleo !! Penser � cr�er les configurations de votre programme ! 

// Ceci n'est pas generee par acceleo 
	pinMode(MOTOR, OUTPUT);
	pinMode(OUT3, OUTPUT);

	CONSOLE.begin(9600);
	CONSOLE.println(F("setup 0"));

	getRam(NULL, false);

	keyboard.begin(KBD_DATA, KBD_CLOCK, MyKeymap_French);
	
	pinMode(CHP, OUTPUT);
	pinMode(RST, OUTPUT);
//pinMode(LED, OUTPUT);

	//ESP.begin(ESP_BAUDS);
	/*
	 */
	CONSOLE.println(F("setup 1"));
	getRam(NULL, false);

	init_io();
	StateMachine_setup();
}
Exemplo n.º 8
0
void soc_family_init(void)
{
  init_sysclk();
  init_exception_prio();

  /* Enable peripheral clocks. */
  init_peripheral_clocks();

  /* Set up IO pin direction and mode registers. */
  init_io();

#ifdef SYSTEM_SOC_CORTEXM3_STM32_GPIO_USED
  /* Set up GPIO. */
  init_GPIO();
#endif

#ifdef SYSTEM_SOC_CORTEXM3_STM32_USART_USED
  /* Set up USART. */
  init_USART();
#endif

#ifdef SYSTEM_SOC_CORTEXM3_STM32_SPI_USED
  /* Set up SPI. */
  init_SPI();
#endif
}
Exemplo n.º 9
0
/*********************************************************************************************************
** Function name:           drawLine
** Descriptions:            drawLine
*********************************************************************************************************/
void ePaper::drawLine(int x0, int y0, int x1, int y1)
{

    init_io();
    
    int x = x1-x0;
    int y = y1-y0;
    int dx = abs(x), sx = x0<x1 ? 1 : -1;
    int dy = -abs(y), sy = y0<y1 ? 1 : -1;
    int err = dx+dy, e2;                                              
    for (;;)
    {                                                          
        drawPixel(x0,y0,1);
        e2 = 2*err;
        if (e2 >= dy) 
        {                                                
            if (x0 == x1) break;
            err += dy; x0 += sx;
        }
        if (e2 <= dx) 
        {                                                
            if (y0 == y1) break;
            err += dx; y0 += sy;
        }
    }
}
Exemplo n.º 10
0
int tmlib_init (void)
{
#ifdef SFS_WANTED
	clock_t  init_ticks = times (NULL);

	init_scheduler ();

	create_parent_task (init_ticks);

	create_idle_task ();

	init_soft_irq ();

	init_io ();
#endif
	mem_init ();

	msg_Q_init ();

	init_timer_mgr ();

#ifdef SFS_WANTED
	setup_interrupt ();
#endif

	return 0;
}
Exemplo n.º 11
0
Arquivo: io_uring.c Projeto: arh/fio
static int prep_more_ios(struct submitter *s, int max_ios)
{
	struct io_sq_ring *ring = &s->sq_ring;
	unsigned index, tail, next_tail, prepped = 0;

	next_tail = tail = *ring->tail;
	do {
		next_tail++;
		read_barrier();
		if (next_tail == *ring->head)
			break;

		index = tail & sq_ring_mask;
		init_io(s, index);
		ring->array[index] = index;
		prepped++;
		tail = next_tail;
	} while (prepped < max_ios);

	if (*ring->tail != tail) {
		/* order tail store with writes to sqes above */
		write_barrier();
		*ring->tail = tail;
		write_barrier();
	}
	return prepped;
}
Exemplo n.º 12
0
int main(void)
{
    char msg[]="A nice long message for you to read !!!!"
               "A second very long message to read :) !!";

    /* set up systick */
    if(SysTick_Config(SystemCoreClock/1000))
    {
        while(1);
    }

    /* set the pins up */
    init_io();
    /* start the lcd */
    hd44780_init();

    hd44780_write_string(msg);

    while(1)
    {
        delayms(300);
        hd44780_shift(0,1);
    }

    return 0;
}
Exemplo n.º 13
0
void main() {
    int8_t i = 0;
    char c = 'A';
    char custom_chars[] = {
        0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x00,
        
        0x00, 0x00, 0x0e, 0x0a,
        0x0e, 0x00, 0x00, 0x00,
        
        0x00, 0x1f, 0x11, 0x11,
        0x11, 0x1f, 0x00, 0x00
    };
    _asm bcf _WDTCON, 0 _endasm;
    init_io();
    
    lcd_init();
    
    lcd_custom_char_create(custom_chars, 0, 3);
    delay_ms(500);
    lcd_command(LCD_CMD_DISPLAY_CONTROL | LCD_CMD_DISPLAY_CONTROL_ON);
    //lcd_test_do();
    while(1) {
        lcd_position(0, 0);
        lcd_write(i++ % 3, LCD_RS_DATA, 2);
        delay_ms(150);
        PORTEbits.RE1 ^= 1;
    }
}
Exemplo n.º 14
0
int main(void)
{
    int i = 0;

    /* Initiate IO ports and peripheral devices. */
    init_io();
	
    /* Indicate that the device has just booted. */
    boot_msg();

    /* Set the layer to start drawing at */
    current_layer = 0x00;
	
    /* 
     * Enable interrupts to start drawing the cube buffer. When interrupts
     * are enabled, ISR(TIMER2_COMP_vect) will run on timed intervals. 
     */
    sei();

    /* Main program loop. */
    while (1) {
	for (i = 0; i < NUM_ANIMATIONS + 1; ++i) {
	    launch_effect(i);
	}
	/* Comment the loop above and uncomment the line below
	 * if you want the effects in random order (produced some bugs.) */
	/* launch_effect(rand() % 13); */
    }

}
int main(void) {
    unsigned char ret;

    init_io();

    cli();
    check_wdt();
    setup_wdt();
    sei();                                      // Enables interrupts

    // Enable Sleep Mode for Power Down
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);    // Set Sleep Mode: Power Down
    sleep_enable();                     // Enable Sleep Mode

    for(;;) {                                               // Event Loop
        if(tick_flag) {
            tick_flag = 0;
            sleep_disable();

            set_sleep_mode(SLEEP_MODE_PWR_DOWN);
            sleep_enable();
            sleep_mode();
        }
    }
}
Exemplo n.º 16
0
/*********************************************************************************************************
* \brief According to EPD size and temperature to get stage_time
* \note Refer to COG document Section 5.3 for more details
*
* \param EPD_type_index The defined EPD size
**********************************************************************************************************/
void ePaper::begin(EPD_size sz)
{
    size = sz;
    direction = DIRNORMAL;
    
    switch(size)
    {
        case EPD_1_44:              // 128*96
        SIZE_LEN    = 128;
        SIZE_WIDTH  = 96;
        break;
        
        case EPD_2_0:               // 200*96
        SIZE_LEN    = 200;
        SIZE_WIDTH  = 96;
        break;
        
        case EPD_2_7:               // 264*176
        SIZE_LEN    = 264;
        SIZE_WIDTH  = 176;
        break;
        
        default:
        println_ep("wrong size");
        while(1);                   // die here
    }
    
    DISP_LEN    = SIZE_LEN;
    DISP_WIDTH  = SIZE_WIDTH;
    
    EPD.begin(size);
    init_io();
}
Exemplo n.º 17
0
int YARPMEIDeviceDriver::initPortAsOutput(void *p)
{
	int16 rc = 0;
	int *port = (int *) p;
	rc = init_io(*port, IO_OUTPUT);
	return rc;
}
Exemplo n.º 18
0
void main()
{
	unsigned char testdisplay[8]={'1','1','1','1','1','1','1','1'};
	uchar i; //自己加的
//	uchar datedisplay[7];
	init_io();
	P0=0x00;//屏蔽数码管
	 delay(10);                 //延时
//    wela=0;
//	dula=0; 
//	inte();
 lcd_init2();	
	lcd12864(testdisplay);
	/******************自己加的**************************/
	while(NRF_Check());	

	RX_Mode();//	
	interface();
	while(NRF24L01_RxPacket(RxBuf)!=0);
	while(1)
	{
		if(NRF24L01_RxPacket(RxBuf)==0)		
		{
			for(i=0;i<8;i++)
			datedisplay[i]=RxBuf[i];	
		}

	checkbutton();
	lcd12864(datedisplay);

	}		
}
Exemplo n.º 19
0
int main(void) {
	init_timer();
  init_io();

  USART_Init();

  sei();

  fill_cube(0xFF);

  _delay_us(1500000);

  int mode = (PIND & (1<<PD3));  

  if (mode) {

    while (1) {

      random_filler(1);
      random_filler(0);
      loadbar();
      rain(100);

      send_voxels_rand_z(200);

      set_edges();
      _delay_us(5000000);
    }

  } else {

    int escape = 0;
    int counter = 0;

    while (1) {

      uint8_t byte;
      byte = USART_Receive();

      if (!escape) {
        if (byte == 0xAB) { // escape character
          escape = 1;
        } else if (counter < 64) {
          tab[counter/8][counter%8] = byte;
          counter++;
        }
      } else {
        if (byte == 0xCD) { // start character
          counter = 0;
        } else if (byte == 0xAB && counter < 64) {
          tab[counter/8][counter%8] = byte;
          counter++;
        }
        escape = 0;
      }
    }

  }
  return 0;
}
Exemplo n.º 20
0
static void
erl_init(int ncpu)
{
    init_benchmarking();

#ifdef ERTS_SMP
    erts_system_block_init();
#endif

    erts_init_monitors();
    erts_init_gc();
    erts_init_time();
    erts_init_sys_common_misc();
    erts_init_process(ncpu);
    erts_init_scheduling(use_multi_run_queue,
			 no_schedulers,
			 no_schedulers_online);
    erts_init_cpu_topology(); /* Must be after init_scheduling */
    H_MIN_SIZE      = erts_next_heap_size(H_MIN_SIZE, 0);
    BIN_VH_MIN_SIZE = erts_next_heap_size(BIN_VH_MIN_SIZE, 0);

    erts_init_trace();
    erts_init_binary();
    erts_init_bits();
    erts_init_fun_table();
    init_atom_table();
    init_export_table();
    init_module_table();
    init_register_table();
    init_message();
    erts_bif_info_init();
    erts_ddll_init();
    init_emulator();
    erts_bp_init();
    init_db(); /* Must be after init_emulator */
    erts_bif_timer_init();
    erts_init_node_tables();
    init_dist();
    erl_drv_thr_init();
    init_io();
    init_copy();
    init_load();
    erts_init_bif();
    erts_init_bif_chksum();
    erts_init_bif_binary();
    erts_init_bif_re();
    erts_init_unicode(); /* after RE to get access to PCRE unicode */
    erts_delay_trap = erts_export_put(am_erlang, am_delay_trap, 2);
    erts_late_init_process();
#if HAVE_ERTS_MSEG
    erts_mseg_late_init(); /* Must be after timer (erts_init_time()) and thread
			      initializations */
#endif
#ifdef HIPE
    hipe_mode_switch_init(); /* Must be after init_load/beam_catches/init */
#endif
    packet_parser_init();
    erl_nif_init();
}
void init_all()
{
    init_io();
    init_periph();
    USART_init(UBBR_VALUE);
    init_timer1();
    set_sleep_mode(SLEEP_MODE_IDLE);
}
Exemplo n.º 22
0
void		init_socket(t_socket *socket, char *addr, int port)
{
  if (socket)
  {
    init_io((void*)socket, addr);
    init_socket_methods(socket);
    init_socket_values(socket, port);
  }
}
Exemplo n.º 23
0
Arquivo: o3.c Projeto: niklasmh/ntnu
int main() {

	init();

	init_io();
	update_time_display();

	while (true);
	return 0;
}
Exemplo n.º 24
0
int main(void)
{
    init_io();
    init_rtc();

    set_sleep_mode(SLEEP_MODE_IDLE);
    while(1)
    {
        sleep_mode();	//will wake up from time overflow interrupt
        display();
    }
}
Exemplo n.º 25
0
static void init () {
  /* Add System initialisation code here */

  init_io ();
  init_display ();
  init_TcpNet ();

  /* Setup and enable the SysTick timer for 10ms. */
  SystemCoreClockUpdate();
  SysTick->LOAD = (SystemCoreClock / 100) - 1;
  SysTick->CTRL = 0x05;
}
Exemplo n.º 26
0
int main(void) {
    /* Init Clock */
    PLLFBD = 126;
    CLKDIVbits.PLLPOST = 0;
    CLKDIVbits.PLLPRE = 1;

    __builtin_write_OSCCONH(0x03);
    __builtin_write_OSCCONL(OSCCON | 0x01);

    while (OSCCONbits.COSC != 3) ;
    while (OSCCONbits.LOCK != 1) ;

    tx_fifo.head=0;
    tx_fifo.tail=0;
    rx_fifo.head=0;
    rx_fifo.tail=0;

    /* Init PORT I/O */
    init_io();
    init_pps();
    init_uart();
    init_can();

    while (true) {

	counter++;
	counter_can++;
	fifo_putchar(&tx_fifo);
	if (can_test_receive())
	    print_rom_fifo("received CAN packet\r\n", &tx_fifo);
	if (counter_can == 30000) {
	    can_test_send();
	    counter_can = 0;
	}
	if (counter == 50000) {
	    print_rom_fifo("Hello dsPIC33 !\r\n", &tx_fifo);
	    //print_debug_fifo(&tx_fifo);
	    // ClrWdt();
	    counter = 0;
	}
	__delay_us(10);

	__builtin_btg((unsigned int *)&LATA, 0);
	__builtin_btg((unsigned int *)&LATA, 0);
	__builtin_btg((unsigned int *)&LATA, 0);
	__builtin_btg((unsigned int *)&LATA, 0);
	__builtin_btg((unsigned int *)&LATA, 0);
	__builtin_btg((unsigned int *)&LATA, 0);
	__builtin_btg((unsigned int *)&LATA, 0);
	__builtin_btg((unsigned int *)&LATA, 0);
    }
}
Exemplo n.º 27
0
void main(void)
{
	init_io();
	setup_counter();

	usb_init();
	ep0_init();

	while (1) {
		read_counter();
		usb_poll();
	}
}
Exemplo n.º 28
0
/*********************************************************************************************************
** Function name:           clear_sd
** Descriptions:            clear sd card
*********************************************************************************************************/
void ePaper::clear_sd()
{
    
    init_io();
    
    for(int i=0; i<DISP_WIDTH; i++)
    {
        for(int j=0; j<DISP_LEN; j++)
        {
            drawPixel(j, i, 0);
            
        }
    }
}
Exemplo n.º 29
0
__task void init (void) {
  /* Add System initialisation code here */ 

  init_io ();
  init_display ();
  init_TcpNet ();

  /* Initialize Tasks */
  os_tsk_prio_self (100);
  os_tsk_create (blink_led, 20);
  os_tsk_create (timer_task, 30);
  os_tsk_create_user (tcp_task, 0, &tcp_stack, sizeof(tcp_stack));
  os_tsk_delete_self();
}
Exemplo n.º 30
0
    ///
    /// Constructor
    ///
    writer_backend( const Device&                      io_dev
                  , const image_write_info< png_tag >& info
                  )
    : png_struct_info_wrapper( false )
    , _io_dev( io_dev )
    , _info( info )
    {
        // Create and initialize the png_struct with the desired error handler
        // functions.  If you want to use the default stderr and longjump method,
        // you can supply NULL for the last three parameters.  We also check that
        // the library version is compatible with the one used at compile time,
        // in case we are using dynamically linked libraries.  REQUIRED.
        get()->_struct = png_create_write_struct( PNG_LIBPNG_VER_STRING
                                                , nullptr  // user_error_ptr
                                                , nullptr  // user_error_fn
                                                , nullptr  // user_warning_fn
                                                );

        io_error_if( get_struct() == nullptr
                   , "png_writer: fail to call png_create_write_struct()"
                   );

        // Allocate/initialize the image information data.  REQUIRED
        get()->_info = png_create_info_struct( get_struct() );

        if( get_info() == nullptr )
        {
            png_destroy_write_struct( &get()->_struct
                                    , nullptr
                                    );

            io_error( "png_writer: fail to call png_create_info_struct()" );
        }

        // Set error handling.  REQUIRED if you aren't supplying your own
        // error handling functions in the png_create_write_struct() call.
        if( setjmp( png_jmpbuf( get_struct() )))
        {
            //free all of the memory associated with the png_ptr and info_ptr
            png_destroy_write_struct( &get()->_struct
                                    , &get()->_info
                                    );

            io_error( "png_writer: fail to call setjmp()" );
        }

        init_io( get_struct() );
    }