void init_devices (void)
{
 cli();         //Clears the global interrupts
 port_init();
 timer1_init();
 adc_init();
 uart0_init();
 sei();         //Enables the global interrupts
}
//function to initialize all devices
void init_devices()
	{
	cli(); //Clears the global interrupts
	
	timer1_init();
	port_init();  //Initializes all the ports
	uart0_init(); //Initailize UART1 for serial communication
	//adc_init();
	sei();   //Enables the global interrupts
	}
/*
* Function For Devices Initialisation
*/
void init_devices (void)
{
 	cli(); ///< Clears the global interrupts
	port_init(); ///< initialise the ports
	adc_init();
	uart0_init();
	timer5_init();
	timer1_init();
	sei();   //Enables the global interrupts
}
Exemplo n.º 4
0
void ADS7843::init()
{
	port_init(); 		//端口初始化
	interrupt_init();  	//中断初始化
	CS_HIGH;					//片选拉高
	SCK_LOW;					//时钟为低
	CS_LOW;             		//片选拉低
	
	isInitialized = true;
}
void init_devices (void)
{
	cli();          //Clears the global interrupts
	port_init();
	adc_init();
	lcd_init();
	timer5_init();
	TIMSK5 = 0x01; //timer5 overflow interrupt enable.
	sei();         //Enables the global interrupts
}
Exemplo n.º 6
0
void init()
{
	cli();   //Clears the global interrupts
	port_init();   //Initializes all the ports
	uart0_init();   //Initialize UART0 for serial communication
	left_encoder_interrupt_init();   //Initialize interrupts for left encoder
	right_encoder_interrupt_init();  //Initialize interrupts for right encoder
	timer5_init();   //Initialize TIMER5 for PWM
	sei();   //Enables the global interrupts
}
void init_devices (void)
{
 cli(); //Clears the global interrupts
 
 //for motion
 port_init();
 
 //for LCD
 port_init();
 adc_init();
 
 //for Xbee
 uart0_init(); //Initailize UART0 for serial communiaction
 uart2_init(); //Initailize UART1 for serial communiaction
 
 sei(); //Enables the global interrupts
 

}
void init_devices (void)
{
    cli(); //Clears the global interrupts
    port_init();
    uart0_init(); //Initailize UART1 for serial communiaction
    adc_init();
    timer5_init();
    timer1_init();
    sei();   //Enables the global interrupts
}
Exemplo n.º 9
0
void main() {
  sysclk_init(); // Initialize oscillator
  wait_ms(1000);
  port_init(); // Initialize crossbar and GPIO

  gpib_init();

  timer_init();
  
  EA = 1; // Global Interrupt enable

  usb0_init();

  while (1) {
    gpib_polling();
    usb_polling();

    if(sys_state & SYS_PERIODIC_ACTIVE){
      sys_state &= ~SYS_PERIODIC_ACTIVE;
      led_toggle(1);
    }

    if(sys_state & SYS_GPIB_CONTROLLER){
      led_on(2);
    }else{
      led_off(2);
    }

    { // check talked
      static __xdata u8 persistent = 0;
      if(sys_state & SYS_GPIB_TALKED){
        led_on(3);
        persistent = 0x40;
      }else if(persistent > 0){
        led_toggle(3);
        persistent--;
      }else{
        led_off(3);
      }
    }

    { // check listened
      static __xdata u8 persistent = 0;
      if(sys_state & SYS_GPIB_LISTENED){
        led_on(4);
        persistent = 0x40;
      }else if(persistent > 0){
        led_toggle(4);
        persistent--;
      }else{
        led_off(4);
      }
    }
  }
}
Exemplo n.º 10
0
void init_devices (void)
{
 cli(); //Clears the global interrupts
 timer1_init();
 port_init();
 adc_init();
 timer5_init();
 left_position_encoder_interrupt_init();
 right_position_encoder_interrupt_init();
 sei(); //Enables the global interrupts
}
//Function to initialize all the peripherals
void init_devices(void)
{
	cli(); //disable all interrupts
	port_init();
	timer1_init();
	adc_init();
	uart0_init(); 
//	left_position_encoder_interrupt_init();
// 	right_position_encoder_interrupt_init();
	sei(); //re-enable interrupts 
}
Exemplo n.º 12
0
/*!
 *  @brief      鹰眼ov7725采集图像(采集到的数据存储在 初始化时配置的地址上)
 *  @since      v5.0
 */
void ov7725_eagle_get_img()
{
    ov7725_eagle_img_flag = IMG_START;                   //开始采集图像
    port_init(PTD14, ALT1 | IRQ_FALLING | PULLUP );          //初始化 PTD7 管脚,复用功能为GPIO ,下降沿触发中断,上拉电阻
    PORTD_ISFR  |= 0x4000;
    enable_irq(PORTD_IRQn);                         //允许PTA的中断
    while(ov7725_eagle_img_flag != IMG_FINISH)           //等待图像采集完毕
    {
        if(ov7725_eagle_img_flag == IMG_FAIL)            //假如图像采集错误,则重新开始采集
        {
            ov7725_eagle_img_flag = IMG_START;           //开始采集图像
            PORTA_ISFR = ~0;                //写1清中断标志位(必须的,不然回导致一开中断就马上触发中断)
            //enable_irq(PORTD_IRQn);                 //允许PTA的中断
        }
    }
    port_init(PTD13, ALT1 | PULLUP );         //PCLK

    port_init(PTD14, ALT1 | PULLDOWN );     //场中断,上拉,上降沿触发中断,带滤波

}
Exemplo n.º 13
0
// порт
cli_result_t parse4port ( void *Port, int argc, char **argv )
{
    const char *PortCfg[ 5 ];
    #define File ( PortCfg[ 0 ] )
    #define Parity ( PortCfg[ 1 ] )
    #define Speed ( PortCfg[ 2 ] )
    #define DBits ( PortCfg[ 3 ] )
    #define SBits ( PortCfg[ 4 ] )
    
    // настроить порт
    cli_arg_t JournalArgs[] = 
    {
        { "port_file", 0, CLI_OPTIONAL_ARG, CLI_REQUIRED_VAL, __parse4port_strp, &File },
        { "port_parity", 0, CLI_OPTIONAL_ARG, CLI_REQUIRED_VAL, __parse4port_strp, &Parity },
        { "port_speed", 0, CLI_OPTIONAL_ARG, CLI_REQUIRED_VAL, __parse4port_strp, &Speed },
        { "port_sbits", 0, CLI_OPTIONAL_ARG, CLI_REQUIRED_VAL, __parse4port_strp, &DBits },
        { "port_dbits", 0, CLI_OPTIONAL_ARG, CLI_REQUIRED_VAL, __parse4port_strp, &SBits },
        CLI_LAST_ARG
    };
    
    cli_result_t Result = cli_parse ( JournalArgs, argc, argv );
    if ( Result != CLI_SUCCESS )
    {
        return Result;
    }
    
    if ( rs232_init ( ( *( askue_port_t** ) Port )->RS232, &( ( *( askue_port_t** ) Port )->Termios ) ) )
    {
        return CLI_ERROR_HANDLER;
    }
    
    rs232_set_speed ( &( ( *( askue_port_t** ) Port )->Termios ), Speed );
    rs232_set_databits ( &( ( *( askue_port_t** ) Port )->Termios ), DBits );
    rs232_set_stopbits ( &( ( *( askue_port_t** ) Port )->Termios ), SBits );
    rs232_set_parity ( &( ( *( askue_port_t** ) Port )->Termios ), Parity );
    
    if ( rs232_apply ( ( *( askue_port_t** ) Port )->RS232, &( ( *( askue_port_t** ) Port )->Termios ) ) )
    {
        return CLI_ERROR_HANDLER;
    }
    
    if ( port_init ( *( askue_port_t** ) Port, File, Speed, DBits, SBits, Parity ) == -1 )
    {
        return CLI_ERROR_HANDLER;
    }

    return Result;
    
    #undef File
    #undef Parity
    #undef Speed
    #undef DBits
    #undef SBits
}
Exemplo n.º 14
0
static void memport_init( muse_env *env, void *ptr, muse_cell args )
{
	memport_t *p = (memport_t*)ptr;

	p->base.mode |= MUSE_PORT_READ_WRITE;

	port_init( env, (muse_port_base_t*)p );
	
	p->first = p->last = NULL;
	p->read_offset = 0;
}
Exemplo n.º 15
0
void init_devices (void)
{
 cli(); //Clears the global interrupts
 port_init();
 adc_init(); 
 lcd_init();
 lcd_set_4bit();
 
// timer1_init();
 sei(); //Enables the global interrupts
}
Exemplo n.º 16
0
void init_devices1 (void)
{
	cli(); //Clears the global interrupts
	
	lcd_port_config();  // configure the LCD port
	lcd_set_4bit();
	lcd_init();
	port_init();
	timer5_init();
	sei(); //Enables the global interrupts
}
Exemplo n.º 17
0
gboolean serial_open_port (struct port *p, enum PortUsers user)
{
	/* Open the given serial port */
	
	gchar c[2];
	
	/* 'open' can block in newer linux kernels if the serial device does not
	 * indicate it is ready (e.g. with data carrier detect) and some of the 
	 * devices that we connect to may not do that, so we have to open 
	 * non-blocking here.  We revert to blocking behaviour when the port is 
	 * initialised - see port_init.
	 */
	  
	//if ((p->f = open (p->name, O_RDWR | O_NOCTTY)) == -1)
	if ((p->f = open (p->name, O_RDWR | O_NOCTTY | O_NONBLOCK)) == -1)
		return FALSE;
	p->ref_count++;
	p->user |= user;
	
	/* Save current port settings */
	
	tcgetattr (p->f, &p->old_tio);
	
	/* Initialise the serial port for testing */
	
	port_init (p, PS_TEST);
	
	/* Check to see if port is already in use */
	
	if (read (p->f, c, 1)) {
		c[1] = '\0';
		L_print ("{o}Comms port %s appears to be in use - read '%s' "
													 "from port\n", p->name, c);
	}
	
	/* Initialise the serial port for communications */
	
	port_init (p, PS_READY);
	
	return TRUE;	
}
Exemplo n.º 18
0
void init_devices(void)
{
 CLI(); //disable all interrupts
 port_init();
 //init_uart();
 init_uart2();

 MCUCR = 0x00;
 GICR  = 0x00;
 TIMSK = 0x00; //timer interrupt sources
 SEI(); //re-enable interrupts
}
Exemplo n.º 19
0
Arquivo: SD_main.c Projeto: nandra/AVR
//call this routine to initialize all peripherals
void init_devices(void)
{
 cli();
 port_init();
 spi_init();
 uart_init();

 MCUCR = 0x00;
 GICR  = 0x00;
 TIMSK = 0x00; //timer interrupt sources
 //all peripherals are now initialized
}
Exemplo n.º 20
0
int main(void)
{

watchdog_init();
clock_init();
port_init();
timer_init();
adc_init();	
__bis_SR_register(LPM0_bits + GIE);

return 0;
}
Exemplo n.º 21
0
Arquivo: gpio.c Projeto: pepe1791/KL25
void led_init(void)
{
	port_init();
	
	gpio_set_pin_mode(RED_LED_PORT,   RED_LED_PIN,   OUTPUT);
	gpio_set_pin_mode(GREEN_LED_PORT, GREEN_LED_PIN, OUTPUT);
	gpio_set_pin_mode(BLUE_LED_PORT,  BLUE_LED_PIN,  OUTPUT);

	GPIO_PIN_WRITE(RED_LED_PORT,   RED_LED_PIN,   HIGH);
	GPIO_PIN_WRITE(GREEN_LED_PORT, GREEN_LED_PIN, HIGH);
	GPIO_PIN_WRITE(BLUE_LED_PORT,  BLUE_LED_PIN,  HIGH);
}
Exemplo n.º 22
0
//Function to initialize all the devices
void init_devices()
{
 cli(); //Clears the global interrupt
 port_init();  //Initializes all the ports
 timer5_init();
 timer3_init();
 timer1_init();
 left_position_encoder_interrupt_init();
 right_position_encoder_interrupt_init();
 ext_position_encoder_interrupt_init ();
 sei();   // Enables the global interrupt 
}
Exemplo n.º 23
0
//Function to initialize all the devices
void init_devices()
{
	cli(); //Clears the global interrupt
	port_init();  //Initializes all the ports
	left_position_encoder_interrupt_init();
	right_position_encoder_interrupt_init();

        timer5_init();
        uart0_init(); //Initailize UART1 for serial communiaction

	sei();   // Enables the global interrupt
}
Exemplo n.º 24
0
void init_devices (void)
{
 cli(); //Clears the global interrupt
 port_init();  //Initializes all the ports
 uart0_init();
 lcd_set_4bit();
 lcd_init(); 
 servo_init();
 left_position_encoder_interrupt_init();
 right_position_encoder_interrupt_init();
 sei();   // Enables the global interrupt 
}
Exemplo n.º 25
0
void main(){
	vdp_init();
	port_init();
	psg_init();
	scene_type = SCENE_DEMO;
	while(373){
		stage = 0;	/* リセットしないとデモでぷんぷん丸が滑り続ける */
		current_player = 0;
		while(373){
			scene_type = SCENE_DEMO;
			title_init();
			title_main();
			if(scene_type == SCENE_LOAD) break;
			if(scene_type == SCENE_SOUND_TEST){
				sound_test_init();
				sound_test_main();
				scene_type = SCENE_DEMO;
			}else{
				intro_main();
			}
		}
		intro_main();
		score_init();
		level = 0;
		/* cheat */
		if(ports[0].button & BUTTON_UP) stage = 1;
		if(ports[0].button & BUTTON_LEFT) stage = 2;
		if(ports[0].button & BUTTON_RIGHT) stage = 3;
		if(ports[0].button & BUTTON_DOWN){
			scene_type = SCENE_ALL_CLEAR;
		}else{
			while(373){
				game_init();
				map_show();
				game_set_bgm();
				game_main();
				game_swap_players();
				psg_init();
				/* game over when there is no players */
				if((players_continue[0] == 0) && (players_continue[1] == 0)){
					break;
				}
			}
		}
		if(scene_type == SCENE_ALL_CLEAR){
			stage = 0;		/* リセットしないとデモでぷんぷん丸が滑り続ける */
			current_player = 0;
			intro_ending_main();	/* intro loop */
			ending_main();		/* ending loop */
		}
		gameover_main("- GAME OVER -");
	}
}
Exemplo n.º 26
0
/**
 * @brief   ChibiOS/RT initialization.
 * @details After executing this function the current instructions stream
 *          becomes the main thread.
 * @pre     Interrupts must disabled before invoking this function.
 * @post    The main thread is created with priority @p NORMALPRIO and
 *          interrupts are enabled.
 *
 * @special
 */
void chSysInit(void) {
#if CH_DBG_ENABLE_STACK_CHECK == TRUE
  extern stkalign_t __main_thread_stack_base__;
#endif

  port_init();
  _scheduler_init();
  _vt_init();
#if CH_CFG_USE_TM == TRUE
  _tm_init();
#endif
#if CH_CFG_USE_MEMCORE == TRUE
  _core_init();
#endif
#if CH_CFG_USE_HEAP == TRUE
  _heap_init();
#endif
#if CH_DBG_STATISTICS == TRUE
  _stats_init();
#endif
#if CH_DBG_ENABLE_TRACE == TRUE
  _dbg_trace_init();
#endif

#if CH_CFG_NO_IDLE_THREAD == FALSE
  /* Now this instructions flow becomes the main thread.*/
  setcurrp(_thread_init(&ch.mainthread, NORMALPRIO));
#else
  /* Now this instructions flow becomes the idle thread.*/
  setcurrp(_thread_init(&ch.mainthread, IDLEPRIO));
#endif

  currp->p_state = CH_STATE_CURRENT;
#if CH_DBG_ENABLE_STACK_CHECK == TRUE
  /* This is a special case because the main thread thread_t structure is not
     adjacent to its stack area.*/
  currp->p_stklimit = &__main_thread_stack_base__;
#endif
  chSysEnable();

  /* Note, &ch_debug points to the string "main" if the registry is
     active, else the parameter is ignored.*/
  chRegSetThreadName((const char *)&ch_debug);

#if CH_CFG_NO_IDLE_THREAD == FALSE
  /* This thread has the lowest priority in the system, its role is just to
     serve interrupts in its context while keeping the lowest energy saving
     mode compatible with the system status.*/
  (void) chThdCreateStatic(ch.idle_thread_wa, sizeof(ch.idle_thread_wa),
                           IDLEPRIO, (tfunc_t)_idle_thread, NULL);
#endif
}
    /*!
	 initialize all devices. call all other initialization function
    */
void init_devices (void)
{
	cli(); //Clears the global interrupts
	port_init();
	adc_init();
	uart3_init();
	timer5_init();
	timer4_init();
	TCCR4B = 0x00;
	TIMSK4 = 0x01; //timer4 overflow interrupt enable
	TIMSK3 = 0x01;
	sei();   //Enables the global interrupts
}
void init_devices (void)
{
 	cli(); //Clears the global interrupts
	port_init();
	adc_init();
	timer5_init();
	left_position_encoder_interrupt_init();
	right_position_encoder_interrupt_init();
	sei();   //Enables the global interrupts

	// To initialize the direction of the bot to north
	init_location();
}
Exemplo n.º 29
0
void setup()
{
  //Initialize serial and wait for port to open:
  int rate = 9600;
  Serial.begin(rate); 
  while (!Serial)
  {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  //prints title with ending line break 
  //Serial.println("serial initialize succfull !"); 
  port_init();
  delay(500);
}
Exemplo n.º 30
0
int main(void) {
	
	uint8_t count=0,x=15;
	uint8_t readbyte;
	
	
	unsigned char s[15]="\r\npassword:\0";
	uart_init(MYUBRR);
	port_init();
	eeprom_write_byte ((uint8_t*) USERPW_ADDRESS, DEFPW);
	readbyte = eeprom_read_byte((uint8_t*)USERPW_ADDRESS);

	while(1){
		
		
		while( s[count] != '\0' ){
			
			send_to_debug(s[count]);
			_delay_ms(25);
			count++;
		}
		count=0;
		
		while(is_rx_done != true);
		
		
		is_rx_done = false;
		
		
		
		if(rx_byte == readbyte){
			
			authorised(x);
		}
		else
			access_denied(x);
		
// 		switch(rx_byte){
// 		
// 			case readbyte: 
// 				authorised(x);
// 				break;
// 			
// 			default:
// 				access_denied(x);
// 				break;
// 		 
// 			}
	}
}