Ejemplo n.º 1
0
Archivo: main.c Proyecto: lab11/ving
int main (void)
{
	sysclk_init();
	wdt_disable(WDT);
	initLeds();
//	rumblecationInit();
	uartInit();

	
	volatile int i;
	
	while(1) {
		//uart_write(UART0, 's');
		//i++;
		/*if(transmitBufRead != transmitBufWrite) {
			uart_write(UART0, transmitBuf[transmitBufRead]);
			transmitBufRead++;
		}*/
		if(uart_is_rx_ready(UART0)) {
			uint8_t in;
			uart_read(UART0, &in);
			uart_write(UART0, in);
		}
	}

}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: z80/avrusb
void __attribute__((noreturn)) main( void )
{
    cli();
    initLeds();

    wdt_enable( WDTO_1S );

    // USB initialization.
    usbInit();
    usbDeviceDisconnect();  // enforce re-enumeration, do this while interrupts are disabled!
    unsigned char b = 150;
    while ( b-- )
    {
        _delay_ms( 1 );
        wdt_reset();
    }
    cpuIoInit();

    usbDeviceConnect();
    sei();

    for ( ;; )
    {
        // main event loop
        usbPoll();
        wdt_reset();
        cpuIoPoll();
        //_delay_ms( 10 );
    }
}
Ejemplo n.º 3
0
/* entry points ======================================================== */
int main(void)
{
	int i;

	initLeds();

	while(1)
	{
		ledOn(LED_D1_GPIO_PORT,LED_D1_GPIO_PIN);
		ledOn(LED_D2_GPIO_PORT,LED_D2_GPIO_PIN);
		ledOn(LED_D3_GPIO_PORT,LED_D3_GPIO_PIN);
		ledOn(LED_D4_GPIO_PORT,LED_D4_GPIO_PIN);

		for(i=0;i<0x500000;i++);

		ledOff(LED_D1_GPIO_PORT,LED_D1_GPIO_PIN);
		ledOff(LED_D2_GPIO_PORT,LED_D2_GPIO_PIN);
		ledOff(LED_D3_GPIO_PORT,LED_D3_GPIO_PIN);
		ledOff(LED_D4_GPIO_PORT,LED_D4_GPIO_PIN);

		for(i=0;i<0x500000;i++);

	}

}
Ejemplo n.º 4
0
Archivo: main.c Proyecto: inevs/mybot
void setup() {
	initLeds();
    initLcd();
    initSensors();
    enableDigitalSensors();
    enableAnalogSensors();
}
Ejemplo n.º 5
0
void spinX(void){
    initLeds();
    lineX5();
    lineX1();
    _delay_ms(100);
    lineX5();
    lineX2();
    _delay_ms(100);
    lineX5();
    lineX3();
    _delay_ms(100);
    lineX5();
    lineX6();
    _delay_ms(100);
    lineX5();
    lineX9();
    _delay_ms(100);
    lineX5();
    lineX8();
    _delay_ms(100);
    lineX5();
    lineX7();
    _delay_ms(100);
    lineX5();
    lineX4();
    _delay_ms(100);
}
int main(void)
{
   /* perform the needed initialization here */
			initLeds();
			initTeclas();


			while (TRUE)
				{
				if (scanTeclas() == TRUE)
					{
					if (leeTecla(TEC_1,FALSE,TRUE) == TRUE){Led = WHITE;};
					if (leeTecla(TEC_2,FALSE,TRUE) == TRUE){Led = LED_1;};
					if (leeTecla(TEC_3,FALSE,TRUE) == TRUE){Led = LED_2;};
					if (leeTecla(TEC_4,FALSE,TRUE) == TRUE){Led = LED_3;};
					}
				else
					{
					delay(DELAY);
					prendeLed(Led);
					delay(DELAY);
					apagaLed(Led);
					};
				};
			return 0;
}
Ejemplo n.º 7
0
int main(void) {
    // Setup the system clock to run at 40 Mhz from PLL with crystal reference (only need to call once)
    SYSCTL_RCC_R = 0x02C00540;

    // Call function initleds to initialize the leds (only need to call once)
    initLeds();

    //fpointer, stacksize, priority
    addTaskToList(toggleRed		, 128, 1, 1000);
    addTaskToList(toggleGreen	, 128, 2, 800);
    addTaskToList(toggleBlue	, 128, 3, 500);
    addTaskToList(wait			, 128, 4, 1	);

    //Configure Systick (heartbeat for the system to work on) (only need to call once)
    NVIC_ST_RELOAD_R 	= F_TICK-1;		//a systick every ms
    NVIC_ST_CTRL_R 		= 0x7;			//enable systick timer, interrupt, main clock source

    //Interupt enable (only need to call once)
    NVIC_EN0_R 			|= (1<<15);		//systick is vector 15 in the interrupt table, enable it

    while(1)
    {
        //this could be used as an idle function
        //sleep();
    }
}
Ejemplo n.º 8
0
void init(void) {
    initLeds();
    initTimer();
    initPWM();
    initSpi();
    LIS302DL_Init();
}
Ejemplo n.º 9
0
void main(void)
{
	initSysClock();

	initUartDebug();

	initLeds();

	initLaunchpadSW1();

	initSysTick();

	initBluetooth();

	initUSB();

	initRfModule(false);

	setRfTxAddress(RF_DESTINATION_ADDR);

	Network_setSelfAddress(RF_CONTOLBOARD_ADDR);

	while (true)
	{
		if ((g_bConnected == false) || (g_bSuspended == true))
		{
			GPIOPinWrite(LED_PORT_BASE, LED_ALL, LED_RED);
			continue;
		}

		GPIOPinWrite(LED_PORT_BASE, LED_ALL, LED_GREEN);

		if (g_USBRxState == USB_RX_DATA_AVAILABLE)
		{
			GPIOPinWrite(LED_PORT_BASE, LED_ALL, LED_BLUE);

			switch (usbBufferHostToDevice[0])
			{
			//-----------------Bootloader Handle-------------------

			case BOOTLOADER_BROADCAST_PACKET:
				broadcastBslData();
				break;

			case BOOTLOADER_SCAN_JAMMING:
				scanJammingSignal();
				break;

			default:
				normalPacketHandle();
				break;
			}

			g_USBRxState = USB_RX_IDLE;

			turnOffLED(LED_BLUE);
		}
	}
}
/** \brief Main function
 *
 * This is the main entry point of the software.
 *
 * \returns 0
 *
 * \remarks This function never returns. Return value is only to avoid compiler
 *          warnings or errors.
 */
int main(void)
{
   /* perform the needed initialization here */
	initLeds();
   while(1) {
      /* add your code here */
   }
   return 0;
}
Ejemplo n.º 11
0
/**
 * Arduino's setup function, called once at startup, after init
 */
void
setup()
{
  initLeds();
  initDebugSerial();
  initUserSwitch();
  marioThemePlayer.playMarioTheme();
  initSD();
  initGpsSerial();
}
Ejemplo n.º 12
0
/* internal public functions =========================================== */
int main(void)
{
	initLeds();

	exti2Init();
	exti3Init();
	exti4Init();
	exti5Init();

    while(1)
    {
    }
}
Ejemplo n.º 13
0
void door(void) {
    initLeds();
    col1();
    col4();
    col7();
    _delay_ms(200);
    col1();
    col5();
    col9();
    _delay_ms(200);
    col1();
    col2();
    col3();
    _delay_ms(200);
}
Ejemplo n.º 14
0
int main() {
	SystemInit();

	initSystick();
	initAccelerometer();
	initLeds();

	AccelerometerDataStruct dat;

	uint32_t lastTime = 0;

	while(1) {
		if (millisecondCounter > lastTime + 100) {
			readAxes(&dat);	// read sensor and store into `dat'
			setbuf(stdout, NULL);
			printf("X: %d Y: %d Z: %d\n", dat.X, dat.Y, dat.Z);	// the member variables for each direction
			lastTime = millisecondCounter;


			// Add extra logic here to light LEDs based on orientation of the board
			if(dat.X<-500){
			GPIOD->BSRRL|=(1<<12);
			GPIOD->BSRRH|=(1<<13);
			GPIOD->BSRRH|=(1<<14);
			GPIOD->BSRRH|=(1<<15);			
			}
			if(dat.Y<-500){
			GPIOD->BSRRL|=(1<<15);
			GPIOD->BSRRH|=(1<<12);
			GPIOD->BSRRH|=(1<<13);
			GPIOD->BSRRH|=(1<<14);
			}
			if(dat.Y>500){
			GPIOD->BSRRL|=(1<<13);
			GPIOD->BSRRH|=(1<<12);
			GPIOD->BSRRH|=(1<<14);
			GPIOD->BSRRH|=(1<<15);
			}
			if(dat.X>500){
			GPIOD->BSRRL|=(1<<14);
			GPIOD->BSRRH|=(1<<12);
			GPIOD->BSRRH|=(1<<13);
			GPIOD->BSRRH|=(1<<15);
			}

		}
	}
}
int main(void)
{
   /* perform the needed initialization here */
			initLeds();

			while (1){
				prendeLed(YELLOW);
				apagaLed(GREEN);
				for (var=DELAY; var > 0; var--){
					asm("nop");
				};
				toggleLed_RGB(BLUE);
				prendeLed(GREEN);
				for (var=DELAY; var > 0; var--){
					asm("nop");
				};
				prendeLed(RED);
				toggleLed_RGB(BLUE);
				toggleLed_RGB(GREEN);
				for (var=DELAY; var > 0; var--){
					asm("nop");
				};
				apagaLed(YELLOW);
				toggleLed_RGB(BLUE);
				toggleLed_RGB(GREEN);
				toggleLed_RGB(RED);
				for (var=DELAY; var > 0; var--){
					asm("nop");
				};
				apagaLed(GREEN);
				toggleLed_RGB(BLUE);
				toggleLed_RGB(GREEN);
				toggleLed_RGB(RED);
				for (var=DELAY; var > 0; var--){
					asm("nop");
				};
				apagaLed(RED);
				toggleLed_RGB(BLUE);
				toggleLed_RGB(RED);
				for (var=DELAY; var > 0; var--){
					asm("nop");
				};
                apagaLed_RGB(WHITE);
                toggleLed_RGB(WHITE);

			}
			return 0;
}
Ejemplo n.º 16
0
void setup(void)
{

    // Set button pins (14-17) as inputs. Bits(0-3)
    DDRC &= 0xF0;

    // Set reset pin as output
    pinMode(ESP_CHIP_RESET, OUTPUT);
    // Keep reset pin held high for regular operation
    digitalWrite(ESP_CHIP_RESET, HIGH);

    initLeds();

    Serial.begin(19200);
    debugSerial.begin(19200);

    esp.wifiCb.attach(&wifiCb);

    debugSerial.println("ARDUINO: Initial Setup Complete");
}
Ejemplo n.º 17
0
int main (void)
{
	initTimer();
	initLeds();


	loggerInit();
	loggerWriteToMarker((LogMesT)"\r\nFFT sample program\r\n*", '*');
	loggerWriteToMarker((LogMesT)"\r\n>*", '*');			/* Prompt */
	for(;;) {
		
		capture_wave(capture, FFT_N);
				
		fft_input(capture, bfly_buff);
		fft_execute(bfly_buff);
		fft_output(bfly_buff, spektrum);
		
		_delay_ms(50);
	}
}
Ejemplo n.º 18
0
int __attribute__((noreturn)) main(void) {
    uint8_t i;

    initLeds();

    wdt_enable(WDTO_1S);

    // reenumerate USB on startup by disconnecting for >250ms
    usbInit();
    usbDeviceDisconnect();
    i = 0;
    while (--i) {
        wdt_reset();
        _delay_ms(1);
    }
    usbDeviceConnect();
    wdt_reset();

    // setup ports for RESET and PROG contolling
    DDRD |= 3;

    sei();

    for (;;) {
        // blink led in idle mode
        if (!progMode) {
            ++redLedBlinkCount;
            if (redLedBlinkCount == 0) {
                turnRedLedOn();
            } else if (redLedBlinkCount == 0xAFFF) {
                turnRedLedOff();
            }
        }

        wdt_reset();
        usbPoll();
    }
}
Ejemplo n.º 19
0
void init() {
    initLeds();
    initButton();
}
Ejemplo n.º 20
0
void main(void)
{
	PORTA=0x00;
	DDRA=0x00;

	PORTB=0x00;
	DDRB=0x00;

	PORTC=0x00;
	DDRC=0x00;

	PORTD=0x00;
	DDRD=0x00;

	PORTE=0x00;
	DDRE=0x00;

	PORTF=0x00;
	DDRF=0x00;

	PORTG=0x00;
	DDRG=0x00;

	initTimer0();
    initTimer1();
    initTimer2();
    initTimer3();

	enableTimers();

	// External Interrupt(s) initialization
	// INT0-INT7: Off
	EICRA=0x00;
	EICRB=0x00;
	EIMSK=0x00;

	// Analog Comparator initialization
	// Analog Comparator: Off
	// Analog Comparator Input Capture by Timer/Counter 1: Off
	ACSR=0x80;
	SFIOR=0x00;

	// ====================== TRUE INITIALIZATION =============================

    initLeds();
	//initJumpers();

	InitFans();
	// configure Fans
    FanSetPower(&fan1, 5);
	FanSetPower(&fan2, 0);
	FanSetPower(&fan3, 0);
	FanSetPower(&fan4, 0); // max is 27

	FanEnable(&fan2);
	FanEnable(&fan3);
	FanEnable(&fan4);




	InitRailControl();

	InitPsuControl();

	InitPullDownControl();

	//InitTemperature(); // no temperature-based control yet // depend on jumper J1

	InitSignalControl();

	InitADC();
	InitBatChargeControl();

	initPPC_State();

    initUSART();


	#asm("sei")

	while(1)
	{
		// read jumpers
		// read inputs
		// update fans
		// update outputs
		// enter sleep

		/*
		// test fan speed debug
		if (getTicksDelta(lastFanStepTickCount) > FAN_STEP_INTERVAL)
		{
			lastFanStepTickCount = getTickCount();
			debug_fan_power_step++;
			if (debug_fan_power_step > PWR_FAN_MAX)
				debug_fan_power_step = PWR_FAN_MIN;
            FanSetPower(&fan1, debug_fan_power_step);
		};
		*/

        BatChargeUpdate();
		//batChargeState.all_batteries_charged = 1; // !!!
		SignalsIndicateCharged(batChargeState.all_batteries_charged);

		#if 1
        SignalReadUpdate();


		switch (ppcState.mode)
		{
		case(PPC_MODE_WAITING):
		{
			if (InputsTransientHigh(SIGNAL_INDEX_SPINT_POWER))
			{
				setPPC_Mode(PPC_MODE_STARTING);
			};
			break;
		}; // waiting mode state

		case(PPC_MODE_STARTING):
		{
            FanEnable(&fan1);
            switch(ppcState.stage)
			{
			case(0):
                PsuSet(0,0,1,0);
				PsuUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(200);

				break;

			case(1):
                PsuSet(1,0,1,0);
				PsuUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(200);

				break;

			case(2):
                PsuSet(1,0,1,1);
				PsuUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(200);

				break;

			case(3):
                RailSet(1,0);
				RailUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(200);

				break;

			case(4):
                RailSet(1,1);
				RailUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(1000);

				break;

			case(5):
                PullDownSet(1,0,0);
				PullDownUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(100);

				break;

			case(6):
                PullDownSet(0,0,0);
				PullDownUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(100);

				break;

			default:
				setPPC_Mode(PPC_MODE_ACTIVE);
				break;

			};
			ppcState.stage++;
			break;
		}; // starting mode state

		case(PPC_MODE_ACTIVE):
		{
			FanEnable(&fan1);

			if (signalState.current_signal_state[SIGNAL_INDEX_SPINT_POWER] == 0)
			{
				setPPC_Mode(PPC_MODE_PARKING);
			};

			//if (InputsTransientLow(SIGNAL_INDEX_SPINT_POWER))

			break;
		}; // acitve mode state

		case(PPC_MODE_PARKING):
		{
			FanDisable(&fan1);
			switch(ppcState.stage)
			{
			case(0): // turn off PSU power
                PsuSet(0,0,0,0);
				PsuUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(200);

				break;
			case(1): // park computer (pull-in)
                PullDownSet(1,0,0);
				PullDownUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(100);

				break;
			case(2): // park computer (pull-out)
                PullDownSet(0,0,0);
				PullDownUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(1000); // wait before clamping power rail

				break;

			case(3): // turn-off rails
                RailSet(0,0);
				RailUpdateOutput();
				PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;
				delay_ms(200);

				break;
			default:
				setPPC_Mode(PPC_MODE_WAITING);
				break;
			};

			ppcState.stage++;
			break;
		}; // Parking mode state

		}; // MODE Switch




		// This function locks for 0.2 second minimum
		// This must be read in the end of control loop
		/*
		TemperatureReadUpdate();
		if (temperatureState.temperature1 != 0)
		{
			if (temperatureState.temperature1 <= 30)
			{
				FanDisable(&fan1);
			}
			else
			{
				FanEnable(&fan1);
				FanSetPower(&fan1,(unsigned char)(PWR_FAN_MIN + ((signed int)(PWR_FAN_MAX - PWR_FAN_MIN))*temperatureState.temperature1/60));
			};
		}
		else
		{
			FanDisable(&fan1);
		};
		*/


		RailUpdateOutput();
		PsuUpdateOutput();
		PullDownUpdateOutput();

		networkUpdate();

		PORTA = railState.port_value | psuState.port_value | pullDownState.portA_value;

        #endif


		/*
		if (ppcState.mode == PPC_MODE_WAITING)
		{
			#asm("sleep")
		}
		*/
	}



} // main
Ejemplo n.º 21
0
void testleddown(){
	initLeds();
	GPIOD->BSRRH |= (1<<12|1<<13|1<<14|1<<15);
}
Ejemplo n.º 22
0
/**
 * this function provide the test function to light up LEDs
 */
void testledup(){
	initLeds();
	GPIOD->BSRRL |= (1<<12|1<<13|1<<14|1<<15);
}
Ejemplo n.º 23
0
// Initializes the hardware
void initHardware (void) {
    initIntc();
    initLeds();
    initButtons();
    initAudio();
}
Ejemplo n.º 24
0
int main( int argc, const char * argv[] )
{
    //g_ledThread = new 

    if ( argc<2 ) {
        printf("usage: cr3 <filename>\n");
        return 1;
    }

    signal(SIGINT,QuitSignalCount);
    signal(SIGTERM,QuitSignalCount);

#ifdef ENABLE_LEDS
    initLeds();
#endif
    //signal(SIGCHLD,WaitSignalChildExit);

    {
#ifdef ENABLE_LEDS
        postLeds( true );
#endif
        int res = InitDoc( (char *)argv[1] );

        if ( !res ) {
            printf("Failed to show file %s\n", argv[1]);
            closeLeds();
            return 2;
        }
#ifdef ENABLE_LEDS
        postLeds( false );
#endif
    }

   if(g_QuitSignalCounter)
   {
      g_QuitSignalCounter=0;
      GrClose();
      printf("INT signal \n");
#ifdef ENABLE_LEDS
      closeLeds();
#endif
      return 0;
   }

   signal(SIGINT,ExceptionExit);
   signal(SIGTERM,ExceptionExit);

    CRLog::info("Entering event loop");
    CRJinkeWindowManager::instance->runEventLoop();
    CRLog::info("Exiting event loop");

#ifdef ENABLE_LEDS
    closeLeds();
#endif

    HyphMan::uninit();
    ldomDocCache::close();
    ShutdownCREngine();

    return 0;
}
Ejemplo n.º 25
0
/**************************************************************************//**
\brief Open LEDs module

\return
    operation status
******************************************************************************/
result_t BSP_OpenLeds(void)
{
  initLeds();
  return BC_SUCCESS;
}
Ejemplo n.º 26
0
int
main()
{


	motor_running=0;
	updateCtr=0;
	dir=1;

	FLASH_Unlock();
	getConfig();
	FLASH_Lock();
	initUSART(s.usart_baud);
	printConfiguration();

	initPWM();
	initADC();
	if( s.commutationMethod == commutationMethod_HALL)
	{
		initHALL();
	}

	if(s.inputMethod == inputMethod_stepDir)
	{
		initStepDirInput();
	}
	else if (s.inputMethod == inputMethod_pwmVelocity)
	{
		initPWMInput();
	}
	if(s.inputMethod == inputMethod_stepDir || s.commutationMethod == commutationMethod_Encoder)
	{
		initEncoder();
	}

	if(s.inputMethod == inputMethod_stepDir)
	{
		initPid();
	}
	initLeds();
//	errorInCommutation=1;
	uint8_t ena;
	//check if ENA is on already at start. If it is, start motor.
#if ENA_POLARITY == 1
		ena = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_5);
#else
		ena = (~(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_5)))&1;
#endif
	if(ena)
	{
		pwm_motorStart();
		ENABLE_LED_ON;
	}
	//two different types of main loops depending on commutation method
	if(s.commutationMethod == commutationMethod_Encoder)
	{
		while (1)
		{


			  getEncoderCount();
			  if(encoder_commutation_pos != encoder_commutation_table[encoder_shaft_pos])
			  {
				  //usart_sendStr("commutation to ");
				  //usart_sendChar(encoder_commutation_table[encoder_shaft_pos]+48);
				  encoder_commutation_pos = encoder_commutation_table[encoder_shaft_pos];
				  pwm_Commute(encoder_commutation_pos);
				//  usart_sendStr("\n\r");
			  }
		}

    }
	else
	{
		while(1)
		{

		}
	}

}