void main (void)
{
	
	BSP_Init( );
	
	SET_MAIN_CLOCK_SOURCE(CRYSTAL);  
	initUART();
	printf( "Start iwsn system...\n" );
	
	InitRFIO(); /* set io as normal io, not uart */
	
	//P0DIR &= ~0x03; /* Set button as input */
	EnableRecv();
	SMPL_Init( NULL );
	
	/* turn on the radio so we are always able to receive data asynchronously */
	SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, NULL );
	
	/* turn on LED. */
	BSP_TURN_ON_LED1( );
	BSP_TURN_ON_LED2( );
	
  /* never coming back... */
  framework_entry();

  /* but in case we do... */
  while (1) ;
}
Beispiel #2
0
int main(void)
{
	
	ConfigPins();
	initUART();
	initSysTick();	
	RValue = initAccel();	
	printInteger(RValue);
	if (RValue == 0) {
		printString("Boldly going :)\r\n");
	} else {
		printString("Inertia sensors offline :(\r\n");
	}
	while (1) { 		
		Temperature = getTemperature();		
		printShort(Temperature);		
		printString(" ");					
		getMotion(&m);
		printShort(m.x_a);		
		printString(" ");
		printShort(m.y_a);		
		printString(" ");
		printShort(m.z_a);		
		printString(" ");		
		printString("\r\n");				
		GPIO0DATA ^= BIT2;				
		delay(10000);
	}

	return 0;
}
int main(void){

    DDRC |= _BV(PC0);
    DDRC |= _BV(PC1);
    DDRC |= _BV(PC4);
    DDRC |= _BV(PC5);
    DDRC |= _BV(PC6);
    DDRC |= _BV(PC7);

    DDRB |= 0xFF;

    DDRD |= _BV(PD0);
    DDRD |= _BV(PD1);
    DDRD |= _BV(PD2);
    DDRD |= _BV(PD3);
    DDRD |= _BV(PD4);
    DDRD |= _BV(PD5);
    DDRD |= _BV(PD6);
    DDRD |= _BV(PD7);

	initCAN(NODE_HOME);
    initUART();
    char output[size];

    while(1){
        ssDisplay(velocity);
     }
}
Beispiel #4
0
int main (void)
{
	uint8_t no = 0;
//	wait(10);
	setMU2PutFunc(uart0Put);
	setMU2GetFunc(uart0Get);
	initUART(
		UART0,
		StopBitIs1Bit|NonParity,
		ReceiverEnable|TransmiterEnable|ReceiveCompleteInteruptEnable,
		UARTBAUD(19200)
	);
	initLED();
	initSwitch();
	
	initRCRx();
	
	no = Switch() & 0x03;
	
	mu2Command("EI",EI[no]);
	mu2Command("DI",DI[no]);
	mu2Command("GI",GI[no]);
	mu2Command("CH",CH[no]);

	sei();
	userMain();
	
	return 0;
}
Beispiel #5
0
int main(void)
{
	WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

	initPorts();
	initUART();
	char g_x[15];
	volatile int i = 0;
	__bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, interrupts enabled
//	__bis_SR_register(GIE);
	while(1) {
		test_func();
		if (flg_rx) {

			if (UCA1RXBUF == '*') {
				analyze_cmd(g_x);
//		    	UART_sendChar(g_x);
		    	memset(g_x, 0, i);
		    	i = 0;
		    }
			else if (UCA1RXBUF == 13) {		// compare to ascii {CR} d'13, 0x0D
				analyze_cmd(g_x);
				memset(g_x, 0, i);
				i = 0;
			}
		    else {
		    	g_x[i] = UCA1RXBUF;
		    	i++;
		    }
			flg_rx = 0;
		}
		if (flg_rx == 0)
			__bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, interrupts enabled
	}
}
Beispiel #6
0
void main(void) {

    SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

    INTEnableSystemMultiVectoredInt();

    ANSELA = 0x00000000;
    ANSELB = 0x00000000;

    initUART();
    I2CModule * i2c = initI2C();
    //testUART();
    SID * sid = createSid();
    SIDPlayer * sidPlayer = createSIDPlayer(sid);
    initSIDNet(sidPlayer,getI2CReceiveBuffer(i2c),getI2CTransmitBuffer(i2c));

    writeStringUART(HELLO_MSG,strlen(HELLO_MSG));
    while(1) {
        if(FIFOCount(getI2CReceiveBuffer(i2c)) >0) {
          //  writeFIFO(getI2CTransmitBuffer(i2c),readFIFO(getI2CReceiveBuffer(i2c)) & 0xFF);
            processSidNetCommand();
       
        }
        //play();
    }
}
Beispiel #7
0
// MAIN FUNCTION ----------------------------------- /
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
	initPorts();							// initialize ports
	initUART();								// initialize uart
	char rxBuffer[15];						// Serial RX buffer
	__bis_SR_register(LPM0_bits + GIE);		// Enter LPM0
	volatile unsigned int i = 0;
	while(1) {
		if (g_rxFlag) {
			if (UCA1RXBUF == '*') {			// * signifies end of cmd, do analysis
				rxBuffer[i] = UCA1RXBUF;
				analyze_cmd(rxBuffer);
		    	memset(rxBuffer, 0, i);
		    	i = 0;
		    }
			else if (UCA1RXBUF == 13) {		// compare to ascii {CR} d'13, 0x0D
				analyze_cmd(rxBuffer);
				memset(rxBuffer, 0, i);
				i = 0;
			}
		    else {
		    	rxBuffer[i] = UCA1RXBUF;
		    	i++;
		    }
			g_rxFlag = 0;						// reset Rx Flag
		}
		__bis_SR_register(LPM0_bits + GIE);    	// Enter LPM0, interrupts enabled
	}
}
Beispiel #8
0
int main()
{
	initUART();
	UART_enable();
	UART_puts("\r\nSTARTING...\r\n");
	PSX_init();
	_delay_ms(1000);
	UART_puts("\r\nENTERING MAIN...\r\n");
	while(1)
	{
		_delay_ms(50);
		PSX_get_button_state();
		UART_puth(PSX_get_button_pressure(BUTTON_PRESSURE_R2));	
		UART_puts(" ");	
		if(PSX_button_pressed(BUTTON_SQUARE))
		{
			PSX_set_pressure_mode(CMD_PRESSURE_OFF);
		}
		if(PSX_button_pressed(BUTTON_TRIANGLE))
		{
			PSX_set_pressure_mode(CMD_PRESSURE_ON);
		}
		if(PSX_button_pressed(BUTTON_R1))
			PSX_set_input_mode(CMD_SET_ANALOG, CMD_LOCK_OFF);
		if(PSX_button_pressed(BUTTON_L1))
			PSX_set_input_mode(CMD_SET_DIGITAL, CMD_LOCK_OFF);
	}
	return 0;
}
Beispiel #9
0
void main(void)
{
    initUART();
    *pSIC_IAR1 = 0x43322221;
    register_handler(ik_ivg10,RX_IRQ);
    register_handler(ik_ivg11, DMA_IRQ);
    *pSIC_IMASK= 0xC000;
}
Beispiel #10
0
int main()
{
  initADC();
  initUART();
  DDRC|=(1<<PC5);
  while(1)
  {
  
  }
}
Beispiel #11
0
void wcycle_init ()
{
	initPins ();
	initClocks ();
	initFlash ();
	initUART ();
	initPWM ();
	initDHT ();

	wcycle_pwm_ctl (readFlash());
}
Beispiel #12
0
	int main(void)
	{
		initUART();
		while(1)
		{
			writeString(readString());
			putByte('\r');
			putByte('\n');
		}
		return 0;
	}
Beispiel #13
0
int main() {
	/*
	IOCON_PIO1_5 = 0x000000d0;
	GPIO1DIR |= 1 << 5;
	GPIO1MASKED[1 << 5] = 0;
	for (int i = 0;; i++) {
		GPIO1MASKED[1 << 5] = i;
	}
	*/
	matrixled_init();
	ux_init();
	
#if ENEBLE_WDT == 1
	slowClock();
#endif
	
#if SYSTICK_WAIT == 1
#if ENEBLE_WDT == 1
	InitSysTick(120000);
#else
	InitSysTick(12000);	// 12,000,000Hz 12,000 -> 10 = 1ms
#endif
#endif
	
#if ENEBLE_WDT == 0
	initUART();
#endif
	
	/*
	for (;;) {
		playMML("C");
		println("TEST\n");
		toggleSounder();
		wait(10000);
	}
//	uart();
	*/
	
//	bitman();
	//	bitman2();
	for (;;) {
		if (!ux_state()) {
			break;
		}
		WAIT(10);
	}
	for (;;) {
		animate(DATA_ANIM, LEN_DATA_ANIM);
		app_mikuji();
//		app_keytest();
		app_renda();
	}
	return 0;
}
int main(void)
{
	
	
	init32MHzClock();
	initUART();
	spi_set_up();
	intiLoopTimer();
	sendUM6_Data();	
    while(1) {}
}
Beispiel #15
0
int main(void)
{	
	char ch;	  	 
	LockoutProtection();
	InitializeMCU();
	initUART();																							    
	MoveStraight();
/*	while(1) {	
		UARTprintf("\nROBZ DEMO\n");
		UARTprintf("  0=UART Demo\n  1=Motor Demo\n");
		UARTprintf("  2=Servo Demo\n  3=Line Sensor\n");
		UARTprintf("  4=IR Sensor Demo\n  5=Encoders Demo\n");
		UARTprintf("  6=MoveStraight\n");
		
		UARTprintf(">> ");
		ch = getc();
		putc(ch);
		UARTprintf("\n");

		if (ch == '0') {
			UARTprintf("\nUART Demo\n");
			uartDemo();	 
		}
		else if (ch == '1') {
			UARTprintf("\nMotor Demo\n");
			initMotors();
			motorDemo(); 
		}
		else if (ch == '2') {
			UARTprintf("\nServo Demo\n");
			initServo();
			servoDemo();   
		}
		else if (ch == '3') {			   
			UARTprintf("\nLine Sensor Demo\n");
			initLineSensor();		  
			lineSensorDemo();
		}
		else if (ch == '4') {	   
			UARTprintf("\nIR Sensor Demo\n");
			initIRSensor();
			IRSensorDemo();	 
		}
		else if (ch == '5') {
			UARTprintf("\nEncoders Demo\n");
			initEncoders();
			encoderDemo();
		}
		else if (ch == '6') {
			UARTprintf("\nMove Straight\n");
			MoveStraight();
		}
	}	*/ 
}
Beispiel #16
0
int main(void)
{
  initUART();
  while(1)
  {
    writeString("Surya Na Mass");
    putByte('\r');
    putByte('\n');
  }
  return 0;
}
Beispiel #17
0
//-----------------------------------------------------------------------------
// main
void main(void)
{
	initPorts();
	initTimer1();
	initUART();

	while(1)
	{
		
		updateDigits();
		updateDisplay();


		if(beepCounter<115) beepCounter++;		// beeper off count
		else
		{
			beepCounter = 0;
			BEEP_BEEP_OFF;
		}


		if(secondCounter<1000) secondCounter++;		// 1 second tasks
		else
		{
			if(LATBbits.LATB0 == 0) COLON_ON;	// blink colon once per second
			else COLON_OFF;
			secondCounter = 0;
		}
		

		if(lnetTimeoutCounter<14580) lnetTimeoutCounter++;		// (lnet timeout 14.58 sec)
		else													// no overlap with 1 sec
		{
			LNET_OFF;
			lnetConnected = FALSE;
			PM_OFF;
			lnetHours = 88;
			lnetMinutes = 88;
		}

		// tasks that execute once per second are located in secTasks()
		
		while(TMR1H < 0x09);
		while(TMR1L < 0xC4);  // wait for 1 ms to elapse

		TMR1H = 0;
		TMR1L = 0; // reset tmr1 registers
	}
	
	return;
}
Beispiel #18
0
int main (int argc, char *argv[]) {
	
	if (argc != 3) {
		printf ("Usage: graph <serial port device (ex /dev/ttyUSB0)> <csv filename>\n");
		exit(-1);
	} 

	uartfd = initUART(argv[1]);
	file = fopen(argv[2], "w");
		
	fprintf (file, "roll, ");
	fprintf (file, "pitch, ");
	fprintf (file, "yaw, ");
	fprintf (file, "x accel, ");
	fprintf (file, "y accel, ");
	fprintf (file, "z accel\n");
	
	//Set up termination signal routine (when user hits Ctrl-c or SIGINT is sent to this process)
	signal(SIGINT, terminate);
		
	unsigned char rxBuffer[RX_BUFFER_LENGTH];
	int counter = 0;
	while (1) {
	
		int bytesRead = read (uartfd, rxBuffer, RX_BUFFER_LENGTH-1);
		int i;
		for (i=0; i<bytesRead; i++) {
			if (rxBuffer[i] == 0xAA) {
				int j=0;
				while (i<bytesRead) { // if 0xAA was found at index in rxBuffer other than 0, shift everything over so that 0xAA is at 0
					rxBuffer[j] = rxBuffer[i];
					j++;
					i++;
				}
				while (j<18) {
					int dataBytesRead = read (uartfd, rxBuffer+j, RX_BUFFER_LENGTH-j-1);
					j += dataBytesRead;
					usleep(100);
				}
				fprintf (file, "%d, ", ((struct imu_rx_pkt_t*)rxBuffer)->roll);
				fprintf (file, "%d, ", ((struct imu_rx_pkt_t*)rxBuffer)->pitch);
				fprintf (file, "%d, ", ((struct imu_rx_pkt_t*)rxBuffer)->yaw);
				fprintf (file, "%d, ", ((struct imu_rx_pkt_t*)rxBuffer)->x_accel);
				fprintf (file, "%d, ", ((struct imu_rx_pkt_t*)rxBuffer)->y_accel);
				fprintf (file, "%d\n", ((struct imu_rx_pkt_t*)rxBuffer)->z_accel);
				break;
			}
		}
	}
}
Beispiel #19
0
static void prvQueueReceiveTask( void *pvParameters )
{
	static const TickType_t xShortBlock = pdMS_TO_TICKS( 50 );

	/* Check the task parameter is as expected. */
	configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER );

	initUART();
	initI2CModule();

	for( ;; )
	{
		uint8_t msg[sizeof(TransportMessages)];
		MsgBaseType& code = reinterpret_cast<MsgBaseType&>(msg);

		/* Wait until something arrives in the queue - this task will block
		indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
		FreeRTOSConfig.h. */
		xQueueReceive( xQueue, &msg, portMAX_DELAY );

		/*  To get here something must have been received from the queue, but
		is it the expected value?  If it is, toggle the LED. */
		switch (static_cast<TransportCodes>(code.msgCode)) {
		case TransportCodes::BLINK:
			/* Blip the LED for a short while so as not to use too much
			power. */
			configTOGGLE_LED();
			vTaskDelay( xShortBlock );
			configTOGGLE_LED();
			break;
		case TransportCodes::RXMSG:
		{
			RxMsgBase& rxmsg = static_cast<RxMsgBase&>(code);

			tLayer.handleMsg(rxmsg);
			break;
		}
		case TransportCodes::TXMSG:
		{
			TxMsgBase& txmsg = static_cast<TxMsgBase&>(code);

			tLayer.msgWasSent(txmsg);
			break;
		}
		default:
			break;
		}
	}
}
Beispiel #20
0
int main(void)
{	
	char ch;	  	 
	LockoutProtection();
	InitializeMCU();
	initUART();																							    
	
	while(1) {	
		UARTprintf("\nRAS Demo for Robotathon 2012\n");
		UARTprintf("  0=UART Demo\n  1=Motor Demo\n");
		UARTprintf("  2=Servo Demo\n  3=Line Sensor\n");
		UARTprintf("  4=IR Sensor Demo\n  5=Encoders Demo\n");
		
		UARTprintf(">> ");
		ch = getc();
		putc(ch);
		UARTprintf("\n");

		if (ch == '0') {
			UARTprintf("\nUART Demo\n");
			uartDemo();	 
		}
		else if (ch == '1') {
			UARTprintf("\nMotor Demo\n");
			initMotors();
			motorDemo(); 
		}
		else if (ch == '2') {
			UARTprintf("\nServo Demo\n");
			initServo();
			servoDemo();   
		}
		else if (ch == '3') {			   
			UARTprintf("\nLine Sensor Demo\n");
			initLineSensor();		  
			lineSensorDemo();
		}
		else if (ch == '4') {	   
			UARTprintf("\nIR Sensor Demo\n");
			initIRSensor();
			IRSensorDemo();	 
		}
		else if (ch == '5') {
			UARTprintf("\nEncoders Demo\n");
			initEncoders();
			encoderDemo();
		}
	}
}
Beispiel #21
0
bool MainWindow::startCommunication()
{
    if (initUART((char*)mSerialPort->currentText().toLocal8Bit().constData(),mBaudrate->currentText().toInt())!=UART_OK)
    {
        QMessageBox::critical(this, tr("Open failed"),tr("Failed, an error occured during opening serial port..."));
        return false;
    }

    connect( mSerialThread, SIGNAL(controlState(bool,bool,bool,bool,bool,bool)), this, SLOT(receiveControlState(bool,bool,bool,bool,bool,bool)));
    connect( mSerialThread, SIGNAL(charReceived(int,int)),this, SLOT(eventDataReceived(int,int)));

    mSerialThread->start();

    return true;
}
Beispiel #22
0
void main()
{
	BSP_Init( );	
	SET_MAIN_CLOCK_SOURCE(CRYSTAL); 	
	initUART();
	
	initOuterRF();	
 	enableOuterRF();
	enableOuterRFData();

	/* turn on LED. */
	BSP_TURN_ON_LED1( );
	BSP_TURN_ON_LED2( );
	
	running();
	return;
}
Beispiel #23
0
int main(void)
{
    initIO();
    initTimer0();
    initA2D();
    initUART();
    initLCD();

    sei();

    while(1)
    {
        handleEvents();
    }

    return 0;
}
Beispiel #24
0
int main(void)
{
	DisableInterrupts(); // Permet de ne pas avoir d'interruption durant l'initialisation
	LCD_Init();
	initGPIO();	//Appel des fonctions d'initialisation 
	initSysTick();
	initUART();
	initADC0();	
	EnableInterrupts(); // Active les interruptions pour la suite de l'exécution du programme

	__asm
	{
		WFI
	}

	while(1){} // Boucle vide
}
Beispiel #25
0
int main(){

	sampleBufferStruct sampleBuffer;

	initUART();
	printf("Start up\n\r");
	initSampling(&sampleBuffer);

	DDRA = 0x01;
	PORTA = 0x01;

	startSampling();

	while(1){
		printf("%d;\n\r",popSample(&sampleBuffer));
	}
	return 0;
}
Beispiel #26
0
int main(void)
 {
        //Init Motor
     /*
        BYTE_SET(DDRD,0xFE);
        PORTB = 0xFF;
        PORTB = 0xC0;
        DDRA  = 0x10;
        PORTA = 0x00;
       */ 
		
		initAdc();
		initUART();
		initTimer();
	//	DDRC=0xFF;
		

		//Enable interrupt after all init else Infinite loop
        sei();
        
       	calibration(); 

        //Enable_watchdog(WDTO_500MS);

	for (;;) 
	{  /* loop forever */
//		lireTelecommande();
/*		if(timerOvf == 1)
		{

		*/
	Vitesse_D = getUartVitesse();
	Angle_D = getUartAngle();
	Vg = getAvgSpeedMoteurGauche();
	Vd = getAvgSpeedMoteurDroit();

	CalculPWM(Vitesse_D,Angle_D,Vg,Vd,&Duty_G,&Duty_D);

		/*	timerOvf = 0;
		}
  */  
	}
}
Beispiel #27
0
int main()
{
	LED1_ENABLE();
	LED1_ON();

/*
	LED1_ON();
	delay(800000);
	LED1_OFF();
*/

	unsigned char ch = '\0';
	init_baudrate();
	clock_init();

	initUART();
	
	serial_putc('c'); 
	serial_putc('o'); 
	serial_putc('d'); 
	serial_putc('e'); 
	serial_putc('\n'); 
	serial_putc('\n'); 

	ch = '\n';
	serial_putc(ch/10+'0'); 
	serial_putc(ch%10+'0'); 
	serial_putc(' '); 

	//printf1("pclk scale is %d\n", get_PCLK());
	
	while(1)
	{
		ch = serial_getc();

		//if (ch <= '9' && ch >= '0')
		if (ch == '\r')
			ch = '\n';
		serial_putc(ch);
	};

	return 0;
};
Beispiel #28
0
int main () {

  #ifdef DELAY
    DDRB |= (1 << DDB1); // PB1 as OUTPUT
    PORTB |= (1 << PB1);
    _delay_ms(4800);
    PORTB &= ~(1 << PB1);
  #endif


  #ifdef SERIAL
    // UART
    initUART();
    writeString("Shadow Initialized \n");
  #endif

  setup_outputs();

  DDRB |= (1 << DDB4);


  #ifdef ADC_SHADOW
    setup_adc();
  #endif
  #ifdef COLLISION_DETECTION
    setup_collision();
  #endif

  // Loop
  while(1) {
    // check_collision();
    // PORTB |= (1 << PB1);
    // PORTB &= ~(1 << PB1);
    // _delay_ms(1);

    // char str[15];
    // sprintf(str, "%d", val);
    // writeString(str);
    // writeString("\n");
  }

}
/****************************************************************
* Main
****************************************************************/
int main(){	
	// Set the signal callback for Ctrl-C
	signal(SIGINT, signal_handler);

	initUART();
	setSerial();
	while(keepgoing){
		cwrotate(800);
		ccwrotate(800);
		burstout(1000);
		burstin(1000);
		starburstout(600);
		starburstin(600);
		spiralin(400);
		spiralout(400);
		flashon_off(800);
		snake(200);
	}
	return 0;
}
Beispiel #30
0
void main(void) {
  WDTCTL = WDTPW | WDTHOLD;   // Stop watchdog timer

  initUART();

  P1OUT = 0;                  // Preload LEDs off (active high!)
  P1DIR |= LED1|LED2;         // Set pin with LED1 to output
  P1REN |= B1;                // Enable pull up/down resistor for B1 (P1.3)
  P1OUT |= B1;                // set as pull up resistor for B1 (P1.3)
  P1IE |= B1;                 // Enable interrupts on edge
  P1IES |= B1;                // Sensitive to negative edge (H->L)

  do {
    P1IFG = 0;                // Clear any pending interrupts ...
  } while (P1IFG != 0);       // ... until none remain

  for (;;) {                  // Loop forever (should not need)
    __low_power_mode_0 ();    // LPM0 with int'pts
  }
}