Esempio n. 1
0
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;
		}*/
	}
}
void init_devices (void) //use this function to initialize all devices
{
 cli(); //disable all interrupts
 init_ports();
 timer5_init();
 sei(); //re-enable interrupts
}
Esempio n. 3
0
int main(void) {
    uint16_t ctimer;

    init_ports();
    init_timers();

    /* clear flags and enable interrupts */
    TIFR = _BV(OCF0A); /* timer 0 output compare A */
    GIFR = _BV(PCIF);  /* pin-change interrupt */
    sei(); /* enable interrupts */

    for (;;) {
        ATOMIC_BLOCK(ATOMIC_FORCEON) {
            ctimer = commtimer;
        }
        if (ctimer > COM_PERIOD_MAX)
            stalled = 1;

        if (stalled) {
            spinup();
            stalled = 0;
        }
        wdt_reset();
    }
}
Esempio n. 4
0
int main(void)
{
    init_ports();
    init_osc();
    startup(); // setup sequence
    TMR0_init(); // will use for 15 min timer

    int i;
    while(1)// main loop
    {
        while(!detect);// main loop, program spends majority here, detect active low

        for(i=5; i !=0; i--) // to separate beginning of trigger sequence
        {
            delayUs(50000);
        }
        trigger(); // take picture
        for(i=10; i !=0; i--) // delay after picture
        {
            delayUs(50000);
        }
    }

    return (EXIT_SUCCESS);
}
Esempio n. 5
0
int main(void)
{
	CLKPR = 0x80;
	CLKPR = 0x00;

	init_ports();
	init_timer1();
	init_timer2();
	init_analog();

	TWAR = 1 << 1;
	TWCR = 0x45;
	TWCR = (1 << TWEN) | (1 << TWIE) | (1 << TWEA);

	sei();
	state = WAIT_ZCROSS;
	//state = TEST;
	while (1)
	{
     		_delay_ms(10000);
     	}
	clr_led();
	cli();

	boot_main();
}
/****************************************BEGIN OF MAIN**************************************/
main(){
    long timeOut = 0;
	//safety precaution, the motor won't spin forever
	long setTimeOut = 1000000; //default 1000000
	int *currentCommand;
	char currentSetting = 'c'; //shades always start closed.
    int k = 0;
	int i = 0;

    init_ports();


	while(1){
		       //this is a command coming from the arduino
		if((PORTB & 0b01110000) == (dataPin + parityPin)){ //initialization bracket
			currentCommand = getCommand();

			//for debug
			/* for(i=0; i<8; i){
				PORTC = 0xff;
				delay_ms(40);
				PORTC = 0x00;
				if(*(currentCommand+i) == dataPin){
					PORTA = 0b0000010;
				}
				else
					PORTA = 0b00000100;
				delay_ms(2000);
				PORTA = 0x00;
			} */

			if (*currentCommand == dataPin){   //if its 0b00000001
				openShades(setTimeOut); //Pin RA0 trips "open" relay
				currentSetting = 'o';
			}
			else if(*(currentCommand +1) == 0x00){ //0b00000000
				closeShades(setTimeOut); //Pin RA1 trips "close" relay
				currentSetting = 'c';
			}
			while(PORTB & 0b01110000);  // wait until port B is clean before continuing
		}

		else if(PORTC & 0b00000001){  //the button on the console
			delay_ms(1); //debounce
			if(PORTC & 0b00000001){  // OPEN THE SHADES
				if(currentSetting == 'c'){
					openShades(setTimeOut);
					sendStatus('o');
					currentSetting = 'o';
				}
				else if(currentSetting =='o'){
					closeShades(setTimeOut);
					sendStatus('c');
					currentSetting = 'c';
				}
			}
		}
	}
}
Esempio n. 7
0
/** \brief      Initialize the MSP430 CPU.
 *
 *  This function initializes :
 *  <ol>
 *      <li>WatchDog</li>
 *      <li>Ports</li>
 *  </ol>
 */
void
msp430_cpu_init(void)
{
  dint();
  watchdog_init();
  init_ports();
  eint();
}
Esempio n. 8
0
void run_test(void)
{
	test_reset();
	init_ports();
	pd_set_dual_role(PD_DRP_TOGGLE_ON);

	RUN_TEST(test_request);
	RUN_TEST(test_sink);

	test_print_result();
}
Esempio n. 9
0
File: board.c Progetto: RELJEF/dapp
void board_init( void )
{
    _BIC_SR( GIE ); /* Disable interrupts during initialization. */

    WDTCTL = WDTPW | WDTHOLD; /* Stop WDT */

    init_ports( );
    init_button_led( );
    init_rf( );

    _BIS_SR( GIE ); /* Enable interrupts after initialization. */
}
Esempio n. 10
0
int main(void)
{
	init_ports();
	init_timer();
	restore_settings();	/** restore source and volume settings, must be done after port initialisation	*/


	sei();	/** global enabling of interrupts	*/
    while(1)
    {
        //TODO:: Please write your application code
    }
}
Esempio n. 11
0
int main(void) {

	MCUSR &= ~(0x08);
    WDTCR = 0;
    init_ports();
    init_timer();

    sei();

    for(;;) {

    }
}
Esempio n. 12
0
int main(void)
{
	init_ports();
	init_timer();
	init_pin_interrupt();
	sei(); // Enable global interrupts
 
	while (1)
    {
		start_sleep();
	}
	return 0;
}
Esempio n. 13
0
int main(int argc, char* argv[])
{
  // code to set things to run xenomai
  init_xenomai();
  init_ports();

  //startup code
  startup();

  printf("pause\n");
  pause();

  exit_ports();
}
Esempio n. 14
0
/************************************************************************
   main programm
***************************************************************************/
int main(void){
   init_ports();    
   tlcd_init4bit();  

   _delay_ms(1000);  
   tlcd_setPosition(1,0);
   tlcd_putString("Hallo Welt!"); 
   _delay_ms(1000);  
   tlcd_setPosition(2,0);
   tlcd_putString("doch nicht :)"); 

  while(1){
  }//while(1)
}//end main() 
void main() {
    int counter = 0;
    int lastDivision = 0;
    int smallOffset = 0;
    int totalOffset = 0;
    int charCount = 0;
    int charBegin = 0;
    int charEnd = 0;
    int sevensCounter = 0;
     
    int numChars1 = 34;  //this should be like arraysize(streamChars); it should return the number of actual characters used in array
    int numChars2 = 34;
    int numChars3 = 34;
    int numChars4 = 40;
    init_ports();

    index = 1099;  //DEBUG... reset before entering loop

    while(1){  //the infinite loop
        if(PORTC & 0b10000000){
            //send response

            //get info, put into arrays
        }


        //display(ascii character, start location )

       
         //number of characters times # of columns for each(6 columns + space) 
        //controls how far to go negative before restarting scroll.

        //854 = 1100-120.  
        
        if(index > 500){  //number of characters times # of columns for each(6 columns + space) 
            for(int i = 0; i < 30; i++){  //this is always running 17 times to populate the screen
                display(streamChars1[i],(index + smallOffset));
                //for(int i = 0; i< 10; i++){;}  //delay
                charCount++;  //increments the characters placed... this will increase by 17 each time
                smallOffset += 7;
            }
             smallOffset = 0;
             index --;
        }
        else{
            counter = 0;
            index = 1099;
        }
    }
}
int main(void)
{
	init_timers();
	init_ports();
	set_up_pwm();

   	UC0IE |= UCA0RXIE; // Enable USCI_A0 RX interrupt - Enable UART Recieve Commands

   	__bis_SR_register(GIE);


   	while (1){
   	}
}
Esempio n. 17
0
void main() {
   unsigned char idx = 0;
   unsigned char idx1 = 0;
   unsigned char idx2 = 0;
   unsigned char idx3 = 0;
   
   unsigned char nextval;
   unsigned int accu;
   init_ports(); 
   // Setup Timer
   T0CS = 0; // T0 clock select, in OPTION_REG, 0 means INTERNAL (CLKOUT)
   PSA = 0; // Prescaler assigned to Timer0 module
   PS0=0; PS1=1; PS2=0; // Prescaler 1:8
   TMR0=100;
   T0IF = 0; // clear Timer 0 interrupt flag
   
   nextval=map[sine[0]>>1];
   while(1) {
	  // wait for timer flag
	  while(!T0IF){} // wait for timer to roll-over

	  // set timer count, clear flag
      TMR0=250;
      T0IF = 0; // clear T0 interrupt flag
	  
	  // put pre-computed value
	  GPIO = nextval;
	  
	  // compute next value
	  accu = 0;
	  accu += sine[idx];
#if MULTIPLE == 1
      accu += sine[idx1];
      accu += sine[idx2];
      accu += sine[idx3];
      nextval = map[accu >> (1+2)]; 
#else
      nextval = map[accu >> (1)]; 
#endif
      //nextval = map[sine[idx]>>1]; 
      idx = (idx+1) & (sizeof(sine)-1);

#if MULTIPLE == 1
      idx1 = (idx1 + 2) & (sizeof(sine)-1);
      idx2 = (idx2 + 3) & (sizeof(sine)-1);
      idx3 = (idx3 + 6) & (sizeof(sine)-1);
#endif
  }
}
Esempio n. 18
0
int main(void)
{
    init_ports();
    init_osc();

    while(1)// main loop
    {
            modulate = 1;
            NOP4; NOP4; NOP2;
            modulate = 0;
            NOP4; NOP4; NOP2;
    }

    return (EXIT_SUCCESS);
}
Esempio n. 19
0
static void ping_port()
{   
    int size = 0;
    ports_num = &size;

    port = init_ports(ports_num);
    print_menu_items();
    add_designer_label();
    print_port_items();
    monit_keys();
    clear();
    print_frame();
    add_menu_label();
    print_menu_items();
    add_designer_label();
}
Esempio n. 20
0
//////////////////////////////////////////////////////////////////////
// Start here
void main() {
	int i;
   init_ports();

   while(1) { // infinite loop

      GPIO = 0x3F;//(1<<4);
      for(i=0; i<=25000; i++)
      {}

      GPIO = 0;
      for(i=0; i<=25000; i++)
      {}

  }
}
Esempio n. 21
0
void main(void)
//-----------------------------------------------------------------------------------------------------
//  Purpose:	The MCU will come here after reset. 
//  
//
//  Rev:    1.5a     TEMPLATE RELEASE
//  
//  Notes:          None    
//-----------------------------------------------------------------------------------------------------
{
	
	//Initialization function calls 
	init_ports();
	motors_init();
	system_clock_init();
	InitDisplay("FHBTEST    "); //Start-up splash changed to unity ID
	InitUART();
	ADInit();	
	ENABLE_SWITCHES;	
	/* LED initialization - macro defined in qsk_bsp.h */
 	ENABLE_LEDS	


	//Polling for switch presses 
	while(TRUE) 
	{
		if(S1 == PRESSED)
		{
			BNSPrintf(LCD,"\tTEST          \n        ");
			project2ADemo(); 		
		}
		else if (S2 == PRESSED)
		{
			BNSPrintf(LCD,"\tOff            \n        ");
		}
		else if (S3 == PRESSED)
		{
			BNSPrintf(LCD,"\tFigure 8              \n        ");
			DoFigureEight();
		}
		else
		{
       		BNSPrintf(LCD,"\tTeam 2                 \n        ");
        }
		
	}
}
Esempio n. 22
0
int fpga_build_model(struct fpga_model* model, int fpga_rows,
	const char* columns, const char* left_wiring, const char* right_wiring)
{
	int rc;

	memset(model, 0, sizeof(*model));
	model->cfg_rows = fpga_rows;
	strncpy(model->cfg_columns, columns, sizeof(model->cfg_columns)-1);
	strncpy(model->cfg_left_wiring, left_wiring,
		sizeof(model->cfg_left_wiring)-1);
	strncpy(model->cfg_right_wiring, right_wiring,
		sizeof(model->cfg_right_wiring)-1);
	strarray_init(&model->str, STRIDX_64K);
	rc = get_xc6_routing_bitpos(&model->sw_bitpos, &model->num_bitpos);
	if (rc) FAIL(rc);

	// The order of tiles, then devices, then ports, then
	// connections and finally switches is important so
	// that the codes can build upon each other.

	rc = init_tiles(model);
	if (rc) FAIL(rc);

	rc = init_devices(model);
	if (rc) FAIL(rc);

	if (s_high_speed_replicate) {
		rc = replicate_routing_switches(model);
		if (rc) FAIL(rc);
	}

	// todo: compare.ports only works if other switches and conns
	//       are disabled, as long as not all connections are supported
	rc = init_ports(model, /*dup_warn*/ !s_high_speed_replicate);
	if (rc) FAIL(rc);

	rc = init_conns(model);
	if (rc) FAIL(rc);

	rc = init_switches(model, /*routing_sw*/ !s_high_speed_replicate);
	if (rc) FAIL(rc);
	return 0;
fail:
	return rc;
}
Esempio n. 23
0
/**
* Initializes the network.
*
* Gives the initial values to the simulation depending on the topology.
*/
void init_network(void) {
    long i;
    dim j;
    way k;	// for mesh-like topologies
    long n,p;	// router and port.
    long nr, np;	// neighbor router and port.

    if (topo < DIRECT) {
        for (i=0; i<NUMNODES; i++) {
            for (j=0; j<ninj; j++) // Init injection queues
                inj_init_queue(&network[i].qi[j]);
            init_ports(i); // Init transit and injection ports
            for (j=0; j<ndim; j++) {
                for (k=0; k<nways; k++) {
                    network[i].nbor[dir(j,k)] = neighbor(i, j, k);
                    network[i].nborp[dir(j,k)] = dir(j,k);
                    network[i].op_i[dir(j,k)] = ESCAPE;
                }
            }
        }
    }
    else if (topo==FATTREE)
        create_fattree();
    else if (topo==THINTREE)
        create_thintree();
    else if (topo==SLIMTREE)
        create_slimtree();
    else if (topo==ICUBE)
        create_icube();

    for(i=0; i<faults; i++) {
        do {
            n=rand()%NUMNODES;
            p=rand()%radix;
        } while (network[n].p[p].faulty!=0);
        nr=network[n].nbor[p];
        if (p%2)
            np=p-1;
        else
            np=p+1;
        printf("breaking link %d.%d->%d.%d\n",n,p,nr,np);
        network[n].p[p].faulty=1;
        //network[nr].p[np].faulty=1; // Broken link means two direction malfunction.
    }
}
Esempio n. 24
0
/**
 * initialize - Performs all initialization procedures
 *
 * Returns a CHARLIE_STAT_* constant that indicates the succes or
 * failure of the initialization.
 */
static uint8_t initialize(void)
{
    charlie.shutdown = FALSE;
    
    init_atmega();
    init_ports();
    debug_init_ports();
    
    rs232_init();
    spi_init_master();
    i2c_init();
    
    if (rtc_init()) {
        return CHARLIE_STAT_RTC_ERROR;
    }
    time_init();
    time_sync_to_realtime();
    
    sched_init();
    
    if (card_init()) {
        return CHARLIE_STAT_CARD_ERROR;
    }
    if (fsys_init()) {
        return CHARLIE_STAT_FSYS_ERROR;
    }
    if (fsys_check_read_only()) {
        return CHARLIE_STAT_FSYS_READONLY;
    }
    
    cfg_load();
    if (enc28j60_init(&cfg.mac_addr)) {
        return CHARLIE_STAT_NET_ERROR;
    }
    net_init();
    
    adc_init();
    sensors_init();
    pump_init();
    plants_init();
    
    sei();

    return CHARLIE_STAT_OK;
}
Esempio n. 25
0
// == Program Code
int main(int argc, char* argv[]) {
  // Initialisations
  programState = PROG_STATE_INIT;

  init_LCD();
  init_ports();
  init_EXTI();
  init_NVIC();
  init_ADC();
  init_TIM14();

  display(DISP_WELCOME, 0);
  programState = PROG_STATE_WAIT_FOR_SW0;

  // Infinite loop
  while (1) {
    __asm("nop");
  }
}
Esempio n. 26
0
static void init_uc ( )
{
	// config ports
	init_ports ( );

	// conifg timer
	timer_init ( );

	// config the ADC
	adc_init ( );

	// configure external interrupt request (keypress)
	init_ext_irq ( );

	events_init ( );

	dia_cntrl_init ( );

	return;
}
Esempio n. 27
0
static void
init_second_stage( void *user_data, size_t n_entries, const topology_port_status *s ) {
  assert( user_data != NULL );

  broadcast_helper *broadcast_helper = user_data;

  // Initialize ports
  init_ports( &broadcast_helper->switches, n_entries, s );

  // Set asynchronous event handlers

  // (1) Set port status update callback
  add_callback_port_status_updated( port_status_updated, broadcast_helper );

  // (2) Set packet-in handler
  set_packet_in_handler( handle_packet_in, broadcast_helper );

  // (3) Get all link status
  get_all_link_status( init_last_stage, broadcast_helper );
}
Esempio n. 28
0
EFFECT_LV2::EFFECT_LV2 (Lilv::Plugin pdesc) throw(ECA_ERROR&) :plugin_desc(pdesc) 
{
  bool inplacebroken=plugin_desc.has_feature(ECA_LV2_WORLD::InPlaceBrokenNode());
  if (inplacebroken) {
    throw(ECA_ERROR("AUDIOFX_LV2", "Inplace-broken plugins not supported."));
  }
  /* FIXME: strip linefeeds and other forbidden characters; write down to
   *        to ECA_OBJECT docs what chars are allowed and what are not... */
  Lilv::Node name(plugin_desc.get_name());
  name_rep = string(name.as_string());
  unique_rep = string(plugin_desc.get_uri().as_string());
  Lilv::Node author(plugin_desc.get_author_name());
  if(author) {
    maker_rep = string(author.as_string());
  } else {
    maker_rep = string();
  }
  buffer_repp = 0;
  init_ports();
}
Esempio n. 29
0
int main(void) {

	// Halt the watchdog timer - According to the datasheet the watchdog timer
	// starts automatically after powerup. It must be configured or halted at
	// the beginning of code execution to avoid a system reset. Furthermore,
	// the watchdog timer register (WDTCTL) is password protected, and requires
	// the upper byte during write operations to be 0x5A, which is the value
	// associated with WDTPW.
	WDTCTL = WDTPW + WDTHOLD;

	init_ports();
	
	// Finally, enable global interrupts
	__bis_SR_register(GIE);

	while(1) {
		// Check state and bleep the speaker if needed
	}

}
/***** Function To Initialize All The Devices *****/	
void init_devices()
{
 asm("cli");

 init_ports();  //Initializes all the ports
 //XDIV=0x00;
 XMCRA=0x00;
 XMCRB=0x00;
 uart0_init(); //Initailize UART1 for serial communiaction
 EIMSK  = 0x00;
 TIMSK0 = 0x00; //timer0 interrupt sources
 TIMSK1 = 0x00; //timer1 interrupt sources
 TIMSK2 = 0x00; //timer2 interrupt sources
 TIMSK3 = 0x00; //timer3 interrupt sources
 TIMSK4 = 0x00; //timer4 interrupt sources
 TIMSK5 = 0x00; //timer5 interrupt sources
 

 asm("sei");   // Enables the global interrupt 
}