Beispiel #1
0
int main(void)
{
	uint8_t  pressed=0,new_button_state,last_button_state;

  	init_SPI();

	init_LED();
	
	init_PB();

 

#ifdef MASTER
    	STM_EVAL_LEDOn(LED5);
	xTaskCreate(pb_task,
	            (signed portCHAR *) "Push Button Task",
	            512 /* stack size */, NULL, tskIDLE_PRIORITY + 2, NULL);
#else	
	xTaskCreate(spi_recv_msg_task,
	            (signed portCHAR *) "SPI Recv Task",
	            512 /* stack size */, NULL, tskIDLE_PRIORITY + 2, NULL);
#endif

	/* Start running the tasks. */
	vTaskStartScheduler();
	
	STM_EVAL_LEDOff(LED5);
	return 0;
}
void main(void)
{
	WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
	init_LED();
	init_button();
	init_servo();
	TA0CTL=TASSEL_2 | ID_0 | MC_1;
	_BIS_SR(LPM0_bits | GIE);
}
Beispiel #3
0
Datei: main.c Projekt: ninux/mc
/**
 * main program
 */  
void main(void) 
{
    init_LED();
    init_timer();
    EnableInterrupts;

    while (1)
    {   
    	/* let the interrupt service routine do the job */
    }
    
  /* please make sure that you never leave main */
}
Beispiel #4
0
int main (int argc, char** argv)
{
	int i;

	wiringPiSetup () ;

	init_LED(LED1_PIN);
	init_LED(LED2_PIN);
	init_LED(LED3_PIN);
	init_LED(LED4_PIN);
	init_LED(LED5_PIN);
	init_LED(LED6_PIN);

	init_button(BUTTON_PIN);

	init_beep(BEEP_PIN);

	if(strcmp(argv[1], "LED")==0)
	{
		int led = atoi(argv[2]);
		int on = atoi(argv[3]);
		int off= atoi(argv[4]);

		switch(led)
		{
			case 1:
				LED_blink(LED1_PIN, on, off);
				break;
			case 2:
				LED_blink(LED2_PIN, on, off);
                                break;
			case 3:
                                LED_blink(LED3_PIN, on, off);
                                break;
                        case 4:
                                LED_blink(LED4_PIN, on, off);
                                break;
			case 5:
                                LED_blink(LED5_PIN, on, off);
                                break;
                        case 6:
                                LED_blink(LED6_PIN, on, off);
                                break;
		}
	}
	else if(strcmp(argv[1], "BEEP")==0)
	{
		int freq = atoi(argv[2]);
		Beep_Tone(BEEP_PIN, freq);
	}


	return 0 ;
}
Beispiel #5
0
int main(int argc, char *argv[])
{
	struct addrinfo	*ailist, *aip;
	struct addrinfo	hint;
	int				sockfd, err, n;
	char			*host;

	if (argc != 1)
		err_quit("usage: ./%s",argv[0]);
#ifdef _SC_HOST_NAME_MAX
	n = sysconf(_SC_HOST_NAME_MAX);
	if (n < 0)	/* best guess */
#endif
		n = HOST_NAME_MAX;
	host = malloc(n);
	if (host == NULL)
		err_sys("malloc error");
	if (gethostname(host, n) < 0)
		err_sys("gethostname error");
	init_LED();
	printf("hostname=%s\n",host);

	daemonize("Zynq@Server");
	hint.ai_flags = AI_PASSIVE;
	hint.ai_family = 0;
	hint.ai_socktype = SOCK_STREAM;
	hint.ai_protocol = 0;
	hint.ai_addrlen = 0;
	hint.ai_canonname = NULL;
	hint.ai_addr = NULL;
	hint.ai_next = NULL;
	if ((err = getaddrinfo(host, "2001", &hint, &ailist)) != 0) {
		syslog(LOG_ERR, "Zynq@Server: getaddrinfo error: %s",
		  gai_strerror(err));
		exit(1);
	}
	for (aip = ailist; aip != NULL; aip = aip->ai_next) {
		if ((sockfd = initserver(SOCK_STREAM, aip->ai_addr,
		  aip->ai_addrlen, QLEN)) >= 0) {
			serve(sockfd);
			exit(0);
		}
	}
	exit(1);
}
Beispiel #6
0
/*****************************************************
 * 	Function: main
 *	Description: Runs initialization of all modules
 *				and main state loop
 *	Input: NONE
 *	Output: NONE
 *****************************************************/
int main(void)
{
	init_Clock();				// Initialize clock
    init_LED();					// Initialize LEDs
    init_Zones();				// Initialize zones
    init_genTimer1();			// Initialize general timer 1
    init_BtnHandler();			// Initialize button interrupt handler
    init_Hibernation();			// Initialize hibernation module
    UART_SetupUART0();			// Initialize UART0
    I2C_SetupI2C3();			// Initialize I2C3
    init_IntTempSensor();		// Initialize internal temperature sensor
    AMS_InitSensor();			// Initialize analog moisture sensor

	// Enable master interrupts
	IntMasterEnable();

    //
    // Main loop
    //

	while(true)
	{
		switch(mode)
		{
			case RUN:
				statusLed = LED_GREEN_PIN;
				dateTime = DS1307_GetTime();			// Get the current time
				//HIH6130_UpdateData();					// Get HIH6130 Data
				checkZoneStatus();						// Check if status of each zone
				break;
			case OVERRIDE:
				statusLed = LED_RED_PIN;
				if(oneSecondCounter >= SECONDS_IN_24_HOURS)
				{
					// If 24 hours have passed, switch back to run mode
					clearAllZoneOverrides();
					oneSecondCounter = 0;
					mode = RUN;
				}
				else
				{
					setAllZoneOverrides();
				}
				break;
			case SYSTEM_SHUTDOWN:
				GPIOPinWrite(LED_REG, LED_RED_PIN, LED_ALL_OFF);				// Turn off all other leds
				GPIOPinWrite(LED_REG, LED_RED_PIN, LED_RED_PIN);				// Turn on red led to signal temperature shutdown
				int zoneNumber;
				for(zoneNumber=0; zoneNumber<NUMBER_OF_ZONES; zoneNumber++)		// Shutoff each zone
				{
					Zone* currentZone = Zones[zoneNumber];
					GPIOPinWrite(currentZone->Port, currentZone->Pin, currentZone->Pin);
				}
				IntMasterDisable();												// Disable all interrupts
				TimerEnable(BTN_OVERRIDE_TIM_BASE, TIMER_A);					// Turn off timer for button press
				TimerEnable(TIMER1_BASE, TIMER_A);								// Turn off general timer
				HibernateRequest();												// Go into hibernation until wake button is pressed
				break;
			default:

				break;
		}

		processZones();							// Process any changes to zones

	}


}