Ejemplo n.º 1
0
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
void main(void) {

	int16 time1[SAMPLE_SIZE], time0[SAMPLE_SIZE];
	int8  i;

	initMSP430();				// Setup MSP to process IR and buttons


    while (1)  {

		while(IR_DECODER_PIN != 0);			// IR input is nominally logic 1

		for(i=0; i<SAMPLE_SIZE; i++) {

			TAR = 0;						// reset timer and
			while(IR_DECODER_PIN==0);		// wait while IR is logic 0
			time0[i] = TAR;					// and store timer A

			TAR = 0;						// reset timer and
			while(IR_DECODER_PIN != 0);		// wait while IR is logic 1
			time1[i] = TAR;					// and store timer A

		} // end for

		while (1);							// "run single"

    } // end while
} // end main
Ejemplo n.º 2
0
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
void main(void) {

	initMSP430();				// Setup MSP to process IR and buttons
	int32 bitstring=0x00000000;
	int32	i;
	int8	packetIndex2=0;
	stopRobot();
	_enable_interrupt();
	while(1)  {
		if (new_packet) {
			_disable_interrupt();
			packetIndex2=0;					//this part consolidates the incoming packet
			while (packetData[packetIndex2]!=2)
			{
				packetIndex2++;
			}
			packetIndex2++;
			while (packetIndex2<33)
			{
				bitstring+=packetData[packetIndex2];
				bitstring<<=1;
				packetIndex2++;
			}
			if (bitstring==BUTTON_FIVE)			//this part translates the packet
			{
				stopRobot();
			} else if (bitstring==BUTTON_TWO)
			{
				moveRobotForward();
			} else if (bitstring==BUTTON_FOUR)
			{
				moveRobotLeft();
			} else if (bitstring==BUTTON_SIX)
			{
				moveRobotRight();
			} else if (bitstring==BUTTON_EIGHT)
			{
				moveRobotBackwards();
			} else if (bitstring==BUTTON_ONE)
			{
				moveRobotLeftSlow();
			} else if (bitstring==BUTTON_THREE)
			{
				moveRobotRightSlow();
			} else
			{
				stopRobot();
			}
			for (i=0;i<0xFFFFF;i++);
			bitstring=0x00000000;
			packetIndex=0;
			_enable_interrupt();
			new_packet=0;
		} else
		{
			bitstring=0x00000000;
		}
	} // end infinite loop
} // end main
Ejemplo n.º 3
0
__interrupt void timerOverflow (void) {

	initMSP430();

	packetIndex = 0;

	TACTL &= ~TAIFG;		//clear flag

}
void main(void)
{
	sec = 0;									// Initialize sec to 0
	min = 0;									// Initialize min to 0
   	WriteToDisplay(0, DIGIT_1);					// Initialize digit 1
   	WriteToDisplay(0, DIGIT_2);					// Initialize digit 2
   	WriteToDisplay(0, DIGIT_3);					// Initialize digit 3
   	WriteToDisplay(':', L_GROUP);				// Display colon
	initMSP430();
	_BIS_SR(LPM0_bits + GIE);					// Enter LPM0 w/ interrupt
}
Ejemplo n.º 5
0
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
void main(void) {

	initMSP430();				// Setup MSP to process IR and buttons

	while(1)  {
		if (newIrPacket) {
			switch (irPacket) {
				case PLY:
					//turn on LED1
					P1OUT |= BIT0;
					break;
				case STP:
					//turn off LED1
					P1OUT &= ~BIT0;
					break;
				case PWR:
					//do stuff
					break;
				case FFW:
					//turn on LED2
					P1OUT |= BIT6;
					break;
				case RRW:
					//turn off LED2
					P1OUT &= ~BIT6;
					break;
				case ZER:
					//do stuff
					break;
				case ONE:
					//do stuff
					break;
				case TWO:
					//do stuff
					break;
				case THR:
					//do stuff
					break;
			}
			newIrPacket = FALSE;
			irPacket = 0;
		}
	} // end infinite loop
} // end main
Ejemplo n.º 6
0
/*
 * main.c
 * Initializes the robot
 * Waits for a new IR packet to be recieved, then handles the request
 */
void main(void) {
	
    initMSP430();				//initialize system
    initIR();

    P1DIR |= BIT0 | BIT6;				// Enable updates to the LED
   	P1OUT &= ~(BIT0 | BIT6);			// An turn the LED off

    GO_STOP;

    while(1){
    	if(packetIndex == 34){
    		handlePress();
    		_delay_cycles(LONG_T);
    		initIR();
    	}
    }

}
Ejemplo n.º 7
0
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
void main(void) {

	initMSP430();				// Setup MSP to process IR and buttons

	while(1)  {

		if (newIrPacket) {	//Got a new packet!
			_disable_interrupt();
			newIrPacket = FALSE;
			packetIndex = 0;

			if(packetBits == ONE){
				P1OUT ^= BIT0;		//Alternate the Red LED
			}
			else if(packetBits == TWO){
				P1OUT ^= BIT6;		//Alternate the Green LED
			}

			_enable_interrupt();

		} // end if new IR packet arrived
	} // end infinite loop
} // end main
Ejemplo n.º 8
0
void main(void) {

	WDTCTL = WDTPW + WDTHOLD; // disable WDT

	initMSP430();

	blip();

	_delay_cycles(160000); // wait

	initLCD();

	while (1) {

		_delay_cycles(1600000);
		blip();
		clearScreen(1);

		set_font(&font_5x7); // FONT_SM
		setColor(COLOR_16_RED);
		draw_string(5, 5, "Texas Instruments");

		set_font(&font_8x12); // FONT_MD
		setColor(COLOR_16_WHITE);
		draw_string(5, 20, "2.2\" 320x240 BoosterPack");
		setColor(COLOR_16_BLUE);
		draw_string(5, 40, "& MSP430F5529 LaunchPad");
		setColor(COLOR_16_ORANGE);
		draw_string(5, 60, "RobG's graphics library");
		setColor(COLOR_16_PURPLE);
		draw_string(5, 80, "Works with:");
		setColor(COLOR_16_YELLOW);
/*
		set_font(&font_11x16); // FONT_LG
		draw_string(5, 100, "F5172 F5510 F5529");
		setColor(COLOR_16_GREEN_YELLOW);
		draw_string(5, 120, "G2553 G2955 & more");
*/
		set_font(&font_Dyson_8x9);
		draw_string(5, 120, "DYSON FONT ABC...");

		blip();
		_delay_cycles(40000000);
		clearScreen(1);

		drawTILogo(56, 56, COLOR_16_RED);
		drawTILogo(55, 56, COLOR_16_RED);
		drawTILogo(56, 55, COLOR_16_RED);
		drawTILogo(55, 55, COLOR_16_RED);
		drawTILogo(50, 50, COLOR_16_WHITE);

		_delay_cycles(32000000);
		blip();

		shesGotColors(100);

		_delay_cycles(12000000);
		blip();

		clearScreen(1);

		drawLogicLines(8);

		_delay_cycles(16000000);
		blip();

/*!!sz:
		drawSpirograph(40, 20, 15);
		_delay_cycles(16000000);
!!*/
		setOrientation(++orientation & 0x03);
	}
}
Ejemplo n.º 9
0
void main(void) {
	// === Initialize system ================================================
	IFG1=0; /* clear interrupt flag1 */
    WDTCTL = WDTPW|WDTHOLD;                 // stop the watchdog timer
    initMSP430();

    P2DIR |= BIT2;							// P2.2 is associated with TA1CCR1
	P2SEL |= BIT2;							// P2.2 is associated with TA1CCTL1

	P2DIR |= BIT4;							// P2.2 is associated with TA1CCR2
	P2SEL |= BIT4;							// P2.2 is associated with TA1CCTL2



	TA1CTL = ID_3 | TASSEL_2 | MC_1;		// Use 1:8 presclar off MCLK
    TA1CCR0 = 100;							// set signal period

    TA1CCR1 = 20;
    TA1CCTL1 = OUTMOD_7;					// set TACCTL1 to Reset / Set mode

    TA1CCR2 = 80;
    TA1CCTL2 = OUTMOD_3;

    // P2.0 - Timer1_A, capture: CCI0A input, compare: Out0 output
    // P2.1 - Timer1_A, capture: CCI1A input, compare: Out1 output
    // P2.3 - Timer1_A, capture: CCI0B input, compare: Out0 output
    // P2.5 - Timer1_A, capture: CCI2B input, compare: Out2 output

    while(1)  {

    		if(flagged==1) {
    			_disable_interrupt();
    			packetCount = 0;
    			while(packetData[packetCount]==2) {
    				packetCount++;
    			}
    			while(packetCount<33) {

    				irPacket+=packetData[packetCount];
    				irPacket<<=1;
    				packetCount++;
    			}
    			irPacket+=packetData[packetCount];




    			if(irPacket == SEL) {
					stopMovingForward();
					stopMovingBackward();
					movement=0;
				}

    			if (movement == 0) {

					if(irPacket == CH_UP) {
						moveForward();
						movement = 1;
					}
					if(irPacket == CH_DW) {
						moveBackward();
						movement = 1;
					}
					if(irPacket == CH_L) {
						moveLeft();
					}
					if(irPacket == CH_R) {
						moveRight();
					}
    			}

    			unsigned int i;
    			for(i=0; i<0xFFFF;i++);
    			for(i=0; i<0xFFFF;i++);
    			for(i=0; i<0xFFFF;i++);
    			packetIndex=0;
    			irPacket=0x00000000;
    			flagged =0;
    			_enable_interrupt();
    		} else {
    			irPacket = 0x00000000;
    		}




    	} // end if new IR packet arrived
} //end forever loop
Ejemplo n.º 10
0
// -----------------------------------------------------------------------
//	Main: Initializes the MSP430 and checks input for a known code
// -----------------------------------------------------------------------
void main(void) {

	init();
	initNokia();
	initMSP430();				// Setup MSP to process IR and buttons
	clearDisplay();
	x=1;		y=1;
	color= BLACK;
	drawBlock(y,x);//, color);

	while(1)  {

		if (newIrPacket) {	//Got a new packet!
			_disable_interrupt();
			newIrPacket = FALSE;
			packetIndex = 0;

			if(IS_BUTTON_ONE){
				P1OUT ^= BIT0;		//Alternate the Red LED
			}

			else if(IS_BUTTON_TWO){
				P1OUT ^= BIT6;		//Alternate the Green LED
			}

			//Check if color is changed by middle button
			else if(packetBits == BIG_MIDDLE){
				color = (color+1)%2;
			}

			//Check if up button is pressed
			else if (packetBits == BIG_UP) {
				if (y>=1) y=y-1;
				drawBlock(y,x,color);
			}

			//Check if down button is pressed
			else if (packetBits == BIG_DOWN) {
				if (y<=6) y=y+1;
				drawBlock(y,x,color);
			}

			//Check if left button is pressed
			else if (packetBits == BIG_LEFT) {
				if (x>=1) x=x-1;
				drawBlock(y,x,color);
			}

			//Check if right button is pressed
			else if (packetBits == BIG_RIGHT) {
				if (x<=10) x=x+1;
				drawBlock(y,x,color);
			}



			initMSP430();
			_enable_interrupt();

		} // end if new IR packet arrived
	} // end infinite loop
} // end main
Ejemplo n.º 11
0
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    initMSP430();

    while (1) {
    	if (packetIndex > 40) {
    				_disable_interrupt();

    				while(packetData[i] != 2 && i < 80){
    					i++;
    				}

    				for(j = 0; j < 31; j++){
    					i++;
    					irPacket += packetData[i];
    					irPacket <<= 1;
    				}

    				if(irPacket == CH_UP){
    					initRobot();

    					moveForward(50);

    					newPacket = TRUE;
    				}

    				if(irPacket == CH_DW){
    					initRobot();

    					moveBackward(50);

    					newPacket = TRUE;
    				}

    				if(irPacket == VOL_UP){
    					initRobot();

    					turnRight(50);

    					newPacket = TRUE;
    				}

    				if(irPacket == VOL_DW){
    					initRobot();

    					turnLeft(50);

    					newPacket = TRUE;
    				}

    				if(irPacket == ONE){
    					newPacket = TRUE;
    				}

    				if(irPacket == TWO){
    					newPacket = TRUE;
    				}

    				if(irPacket == THR){
    					newPacket = TRUE;
    				}

    				if(irPacket == PWR){
    					newPacket = TRUE;
    					shutDown();
    				}

    				if(newPacket == TRUE){
    					initMSP430();
    					newPacket = FALSE;
    				}

    				i = 0;
    				packetIndex = 0;
    				_enable_interrupt();
    			} // end if new IR packet arrived
    		}
}
Ejemplo n.º 12
0
void main(void) {

	//This sets up the block position
	unsigned char x, y, c;

	IFG1=0; 					// clear interrupt flag1
	WDTCTL=WDTPW+WDTHOLD; 		// stop WD

	BCSCTL1 = CALBC1_8MHZ;		//set up clock
	DCOCTL = CALDCO_8MHZ;


	init();
	initNokia();
	initMSP430();
	clearDisplay();
	drawBlock(y,x,c);

	x = 6;
	y = 4;
	c=0xFF;

	initMSP430();




	while(1){										//		Determine value of IrPacket
		if(packetIndex == 34){						// if one full signal is recieved, then the loop will iterate
			_disable_interrupt();
			int32 IrPacket = 0;
			int32 setBit = 0xF0000000;

			char i;
			for(i = 2; i<34; i++){
				int16 current = packetData[i];		// This is the current element
				if(current/10 < 100){
					IrPacket &= ~setBit;
				} else {
					IrPacket |= setBit;
				}
					setBit >>= 1;
				}
			packetIndex++;							// This just makes sure that the loop is not entered into again.
			initNokia();

//		Handle the button presses

			if (IrPacket == ZERO) {					//This is the process in which we pick the "color" of the block
							if(c == 0xFF){
								c = 0;
							} else if (c == 0){
								c = 0xFF;
							}
						}

						if (IrPacket == VOL_UP) {			//These just check for button presses in a particular direction.
							if (y>=1) y=y-1;
						} else if (IrPacket == VOL_DW) {
							if (y<=6) y=y+1;
						} else if (IrPacket == ONE) {
							if (x>=1) x=x-1;
						} else if (IrPacket == TWO) {
							if (x<=10) x=x+1;
						}

			drawBlock(y, x, c);					//draws the block
			initMSP430();						//Now we look for another IR input.
		}
	}
Ejemplo n.º 13
0
void main(void) {

	initMSP430();

	moveForward();

	  P1DIR &= ~BIT3;
	  P1REN |= BIT3;

	    // Left
	    P2DIR |= BIT0;	// 1,2EN as OUT
	    P2DIR |= BIT1;  // Sets direction of left motor
	    P2DIR |= BIT2;							// P2.2 is associated with TA1CCR
	    P2SEL |= BIT2;							// P2.2 is associated with TA1CCTL1

		// Right
	   	P2DIR |= BIT5;  // 3,4EN as OUT
	   	P2DIR |= BIT3;  // direction of right motor
	   	P2DIR |= BIT4;							// P2.2 is associated with TA1CCR2
	   	P2SEL |= BIT4;							// P2.2 is associated with TA1CCTL2

	TA1CTL = ID_3 | TASSEL_2 | MC_1;			// Use 1:8 presclar off MCLK
	TA1CCR0 = 100;								// set signal period

	TA1CCR1 = 50;
	TA1CCTL1 = OUTMOD_7;						// set TACCTL1 to Reset / Set mode

	TA1CCR2 = 50;
	TA1CCTL2 = OUTMOD_3;						// set TACCTL2 to Set / Reset mode

	while(1)  {

		//This runs if we get a new packet from the remote and decodes it to control the code
		if(newIRPacket){

			_disable_interrupt();

			if(packet == VOL_UP){
				moveForward();
			}else if(packet == VOL_DW){
				moveBackward();
			}else if(packet == TWO ){
				rotateLeft();
				__delay_cycles(fullturn);
			}else if(packet == ONE){
				rotateRight();
				__delay_cycles(fullturn);
			}else{
				stopMoving();
			}

			//Now we reset the interrupt so we can run through this cycle again.
			_enable_interrupt();

			initMSP430();
			newIRPacket= FALSE;
		}


	}
}