예제 #1
0
void set_up(){
     // Stop WDT
     WDT_A_hold(WDT_A_BASE);

     // Basic GPIO initialization
     Board_init();
     Clock_init();

     // Set up LCD
     lcd_init();

     print_string(22,30,"*WELCOME*");
     Delay();

     //Buttons S1 S2
	 switch_init();

	 //PORTD=0xFF;
	 //adc 6.6 pin
	 adc_init();
	 //DDRC=0XFF;

	 eeprom_address=0x0000;
	 AdcThreshold=eeprom_read_byte(eeprom_address);
	 eeprom_address++;
	 dcval=eeprom_read_byte(eeprom_address);
	 eeprom_address++;
	 fourier_offset=eeprom_read_byte(eeprom_address);
	 eeprom_address=0x10;
	 FThreshold=eeprom_read_byte(eeprom_address);

	 //usart_init();
	 //pwm_init();

}
예제 #2
0
ClockGuard::ClockGuard()
{
    WDT_A_hold(WDT_A_BASE);
    MasterClock::instance();
    SubsystemClock::instance().driveOut();
    AuxiliaryClock::instance().driveOut();
}
예제 #3
0
파일: main.c 프로젝트: HclX/freertos
int _system_pre_init( void )
{
    /* Stop Watchdog timer. */
    WDT_A_hold( __MSP430_BASEADDRESS_WDT_A__ );

    /* Return 1 for segments to be initialised. */
    return 1;
}
예제 #4
0
void boardInitialisation(void)
{
	WDT_A_hold( WDT_A_BASE );																//MSP's WDT is turned on by default. If you don't stop it, at some point, your system'll restart
	unusedPinsConfiguration();																//To minimise power consumption, all pins needs to be initialised. Floating pins waste a lot of power
	pinConfiguration();																		//This function will configure all the pins used in this project
	clockConfiguration();																	//Will configure MCLK = SMCLK = 8MHz and ACLK to 32768 Hz
	ADCConfiguration();																		//Will configure ADC and memory location to which it'll write to
	timerConfiguration();																	//Will configure timer to tick once every 8 seconds
}
예제 #5
0
파일: main.c 프로젝트: ctag/cpe495
/*
 * ======== main ========
 */
void main(void)
{
    WDT_A_hold(WDT_A_BASE); //Stop watchdog timer

    // Minimum Vcore setting required for the USB API is PMM_CORE_LEVEL_2
    PMM_setVCore(PMM_CORE_LEVEL_2);
    USBHAL_initPorts();           // Config GPIOS for low-power (output low)
    USBHAL_initClocks(8000000);   // Config clocks. MCLK=SMCLK=FLL=8MHz; ACLK=REFO=32kHz
    USB_setup(TRUE,TRUE);  // Init USB & events; if a host is present, connect
    initRTC();             // Start the real-time clock

    __enable_interrupt();  // Enable interrupts globally

    int prevLeft = getLeft();
    int prevRight = getRight();
    int left;
    int right;

    while (1)
    {
        // Enter LPM0, which keeps the DCO/FLL active but shuts off the
        // CPU.  For USB, you can't go below LPM0!
        __bis_SR_register(LPM0_bits + GIE);

        // If USB is present, sent the time to the host.  Flag is set every sec

        left = getLeft();
        right = getRight();
        timeStr[0] = '[';
        itoa(left, &timeStr[1], 10);
        itoa(right, &timeStr[2], 10);
        timeStr[3] = ']';
        timeStr[4] = '\n';
        timeStr[5] = '\0';
//
//        if (bSendTimeToHost)
//        {
//            bSendTimeToHost = FALSE;
//            convertTimeBinToASCII(timeStr);

            // This function begins the USB send operation, and immediately
            // returns, while the sending happens in the background.
            // Send timeStr, 9 bytes, to intf #0 (which is enumerated as a
            // COM port).  1000 retries.  (Retries will be attempted if the
            // previous send hasn't completed yet).  If the bus isn't present,
            // it simply returns and does nothing.
            if (USBCDC_sendDataInBackground(timeStr, 6, CDC0_INTFNUM, 1000))
            {
              _NOP();  // If it fails, it'll end up here.  Could happen if
                       // the cable was detached after the connectionState()
            }           // check, or if somehow the retries failed
//        }
    }  //while(1)
}  //main()
예제 #6
0
//-----------------------------------------------------------------------------
int _system_pre_init(void)
{
    // Stop Watchdog timer
    WDT_A_hold(__MSP430_BASEADDRESS_WDT_A__);     // Stop WDT

    /*==================================*/
    /* Choose if segment initialization */
    /* should be done or not. */
    /* Return: 0 to omit initialization */
    /* 1 to run initialization */
    /*==================================*/
    return 1;
}
/*
 *  ======== WDT_A_graceInit ========
 *  Initialize Config for the MSP430 WDT_A
 */
void WDT_A_graceInit(void)
{
    /* USER CODE START (section: WDT_A_graceInit_prologue) */
    /* User initialization code */
    /* USER CODE END (section: WDT_A_graceInit_prologue) */

    /* Hold the Watchdog Timer */
    WDT_A_hold(WDT_A_BASE);

    /* USER CODE START (section: WDT_A_graceInit_epilogue) */
    /* User code */
    /* USER CODE END (section: WDT_A_graceInit_epilogue) */
}
예제 #8
0
파일: hal.c 프로젝트: jfdawson20/ti-leaf
//TI Leaf Board Specific init
void TILEAF_BoardInit(uint32_t clockFreq)
{
    //set clock frequency variable '
    CLOCKFREQ = clockFreq;

    WDT_A_hold(WDT_A_BASE); // Stop watchdog timer
    // Minimum Vcore setting required for the USB API is PMM_CORE_LEVEL_2 .
    PMM_setVCore(PMM_CORE_LEVEL_2);
    USBHAL_initPorts();           // Config GPIOS for low-power (output low)
    USBHAL_initClocks(clockFreq);   // Config clocks. MCLK=SMCLK=FLL=8MHz; ACLK=REFO=32kHz
    USB_setup(TRUE, TRUE); // Init USB & events; if a host is present, connect

    __enable_interrupt();  // Enable interrupts globally
}
예제 #9
0
파일: main.c 프로젝트: HclX/freertos
static void prvSetupHardware( void )
{
    /* Stop Watchdog timer. */
    WDT_A_hold( __MSP430_BASEADDRESS_WDT_A__ );

	/* Set all GPIO pins to output and low. */
	GPIO_setOutputLowOnPin( GPIO_PORT_P1, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 );
	GPIO_setOutputLowOnPin( GPIO_PORT_P2, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 );
	GPIO_setOutputLowOnPin( GPIO_PORT_P3, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 );
	GPIO_setOutputLowOnPin( GPIO_PORT_P4, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 );
	GPIO_setOutputLowOnPin( GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 | GPIO_PIN8 | GPIO_PIN9 | GPIO_PIN10 | GPIO_PIN11 | GPIO_PIN12 | GPIO_PIN13 | GPIO_PIN14 | GPIO_PIN15 );
	GPIO_setAsOutputPin( GPIO_PORT_P1, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 );
	GPIO_setAsOutputPin( GPIO_PORT_P2, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 );
	GPIO_setAsOutputPin( GPIO_PORT_P3, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 );
	GPIO_setAsOutputPin( GPIO_PORT_P4, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 );
	GPIO_setAsOutputPin( GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 | GPIO_PIN8 | GPIO_PIN9 | GPIO_PIN10 | GPIO_PIN11 | GPIO_PIN12 | GPIO_PIN13 | GPIO_PIN14 | GPIO_PIN15 );

	/* Configure P2.0 - UCA0TXD and P2.1 - UCA0RXD. */
	GPIO_setOutputLowOnPin( GPIO_PORT_P2, GPIO_PIN0 );
	GPIO_setAsOutputPin( GPIO_PORT_P2, GPIO_PIN0 );
	GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_P2, GPIO_PIN1, GPIO_SECONDARY_MODULE_FUNCTION );
	GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_P2, GPIO_PIN0, GPIO_SECONDARY_MODULE_FUNCTION );

	/* Set PJ.4 and PJ.5 for LFXT. */
	GPIO_setAsPeripheralModuleFunctionInputPin(  GPIO_PORT_PJ, GPIO_PIN4 + GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION  );

	/* Set DCO frequency to 8 MHz. */
	CS_setDCOFreq( CS_DCORSEL_0, CS_DCOFSEL_6 );

	/* Set external clock frequency to 32.768 KHz. */
	CS_setExternalClockSource( 32768, 0 );

	/* Set ACLK = LFXT. */
	CS_initClockSignal( CS_ACLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1 );

	/* Set SMCLK = DCO with frequency divider of 1. */
	CS_initClockSignal( CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );

	/* Set MCLK = DCO with frequency divider of 1. */
	CS_initClockSignal( CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );

	/* Start XT1 with no time out. */
	CS_turnOnLFXT( CS_LFXT_DRIVE_0 );

	/* Disable the GPIO power-on default high-impedance mode. */
	PMM_unlockLPM5();
}
void main(void)
{
    //Stop watchdog timer
    WDT_A_hold(WDT_A_BASE);

    //Set P1.0 to output direction
    GPIO_setAsOutputPin(
        GPIO_PORT_P1,
        GPIO_PIN0
        );

    //Enable P1.4 internal resistance as pull-Up resistance
    GPIO_setAsInputPinWithPullUpResistor(
        GPIO_PORT_P1,
        GPIO_PIN4
        );

    //P1.4 interrupt enabled
    GPIO_enableInterrupt(
        GPIO_PORT_P1,
        GPIO_PIN4
        );

    //P1.4 Hi/Lo edge
    GPIO_selectInterruptEdge(
        GPIO_PORT_P1,
        GPIO_PIN4,
        GPIO_HIGH_TO_LOW_TRANSITION
        );

    //P1.4 IFG cleared
    GPIO_clearInterrupt(
        GPIO_PORT_P1,
        GPIO_PIN4
        );

    //Enter LPM4 w/interrupt
    __bis_SR_register(LPM4_bits + GIE);

    //For debugger
    __no_operation();
}
예제 #11
0
//*****************************************************************************
// Main
//*****************************************************************************
void main (void)
{
    // Stop watchdog timer
    WDT_A_hold( WDT_A_BASE );

    // Initialize GPIO
    initGPIO();

    // Initialize clocks
    initClocks();

    // Initialize timers
    initTimers();

    __bis_SR_register( GIE );         // Enable interrupts globally

    while(1) {
        __no_operation();             // Placeholder for while loop (not required)
    }
}
예제 #12
0
void main(void)
{


    // Stop WDT
    WDT_A_hold(WDT_A_BASE);

    // Basic GPIO initialization
    Board_init();
    Clock_init();

    // Set up LCD
    Dogs102x64_UC1701Init();
    GrContextInit(&g_sContext, &g_sDogs102x64_UC1701);
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
    GrContextFontSet(&g_sContext, &g_sFontFixed6x8);
    GrClearDisplay(&g_sContext);

    int toggle=0;
    while(1){
    	//GrClearDisplay(&g_sContext);
		print_string(0,0,"===Team Members===");
	    print_string(0,8,"Anson Bastos");
	    print_string(0,16,"Dhiraj Patil");
	    print_string(0,24,"Abhinendra Singh");
	    print_string(0,32,"Melroy Tellis");
	    print_string(0,40,"Abhishek Suryawanshi");
        toggle=(toggle>4)?(0):(toggle);
    	switch(toggle){
    	case 0:
    	    highlight_and_print_string(0,8,"Anson Bastos");

    	    Delay();
    	    toggle++;
    	    break;
    	case 1:
    	    highlight_and_print_string(0,16,"Dhiraj Patil");

    	    Delay();
    	    toggle++;
    	    break;
    	case 2:
    	    highlight_and_print_string(0,24,"Abhinendra Singh");

    	    Delay();
    	    toggle++;
    	    break;
    	case 3:
    	    highlight_and_print_string(0,32,"Melroy Tellis");

    	    Delay();
    	    toggle++;
    	    break;
    	case 4:
    	    highlight_and_print_string(0,40,"Abhishek Suryawanshi");

    	    Delay();
    	    toggle++;
    	    break;
    	}



    }


}
예제 #13
0
파일: main.c 프로젝트: Greeeg/gpsLogger
/*  
 * ======== main ========
 */
int main (void)
{
    WDT_A_hold(WDT_A_BASE); // Stop watchdog timer

    // Minumum Vcore setting required for the USB API is PMM_CORE_LEVEL_2 .
    PMM_setVCore(PMM_CORE_LEVEL_2);
    USBHAL_initPorts();                // Config GPIOS for low-power (output low)
    USBHAL_initClocks(MCLK_FREQUENCY); // Config clocks. MCLK=SMCLK=FLL=MCLK_FREQUENCY; ACLK=REFO=32kHz
    hal_sd_pwr_on();
    initTimer();
    USB_setup(FALSE, TRUE);      // Init USB & events; if a host is present, connect

    __enable_interrupt();       // Enable interrupts globally

   // GPS_init();

    // state machine
    while (1)
    {
    	switch( state )
    	{
    	case sIDLE:

    		hal_led_a(0);
    		hal_led_b(0);
    		hal_gps_pwr_off();
    		hal_sd_pwr_off();
    		UCS_turnOffXT2();



    			/* USB connected */
    			if(USB_getConnectionInformation() & USB_VBUS_PRESENT)
    			{
    				hal_led_a(CYAN);



    				//PMM_setVCore(PMM_CORE_LEVEL_2);
    				hal_sd_pwr_on();
    				shortDelay();
    				USBMSC_initMSC();                  // Initialize MSC API, and report media to the host
    				if (USB_enable() == USB_SUCCEED){
    					state = sUSB;
    					hal_led_a(GREEN);
    					//hal_sd_pwr_on();
    					//detectCard();

    					USB_reset();
    				    USB_connect();  //generate rising edge on DP -> the host enumerates our device as full speed device
    				}
    				break; // don't enter sleep
    			}

    			/* start GPS */
    			if(hal_button_event())
    			{

    				/* delay for starting */
    				hal_led_a(RED);
    				uint8_t timeout = 16;
    				while( hal_button_status() == 1 && --timeout )
    				{
    					shortDelay();
    				}
    				hal_led_a(0);
    				if( hal_button_status() == 0 )
    					break;

    				state = sGPS;
    				hal_led_a(CYAN);

    				hal_sd_pwr_on();

    				timeout = 8;
    				while( --timeout )
					{
						shortDelay();
					}

    				detectCard();
    			    Timer_A_startCounter(TIMER_A0_BASE, TIMER_A_UP_MODE);

    			    gps_start();
    				hal_button_event();
    				break; // don't enter sleep
    			}


    			USB_disable(); //Disable
    			hal_gps_rtc_on(); // saves around 7uA
    			Timer_A_stop(TIMER_A0_BASE);
    			//UCS_turnOffSMCLK();
    			//PMM_setVCore(PMM_CORE_LEVEL_0);
    			__bis_SR_register(LPM4_bits + GIE);
    			_NOP();
    			//UCS_turnOnSMCLK();
    			//PMM_setVCore(PMM_CORE_LEVEL_2);

    		break;

    	case sGPS:


				/* stop GPS */
				if((USB_getConnectionInformation() & USB_VBUS_PRESENT))
				{
					state = sIDLE;
					gps_stop();
					break;
				}

				if(hal_button_event())
				{
					/* delay for stopping */
					uint8_t timeout = 16;

					while( hal_button_status() == 1 && --timeout )
					{
						hal_led_a(RED);
						shortDelay();
						hal_led_a(RED);
					}
					hal_led_a(0);
					if( hal_button_status() == 0 )
						break;

					state = sIDLE;
					gps_stop();
					break;


				}



    			if (bDetectCard){
					USBMSC_checkMSCInsertionRemoval();

					// Clear the flag, until the next timer ISR
					bDetectCard = 0x00;
				}
    			while( gps_check() )
    			{
    				gps_do();
    			}
    			__bis_SR_register(LPM0_bits + GIE);
    			_NOP();


    		break;

    	case sUSB:

    			if(!(USB_getConnectionInformation() & USB_VBUS_PRESENT))
				{
    				state = sIDLE;
    				break;
				}
    					/* check state of chareger? */
    			if( hal_charge_status())
    				hal_led_b(RED);
    			else
    				hal_led_b(GREEN);

    			hal_button_event(); // clear button event
    					switch (USB_getConnectionState())
    					{
    						case ST_ENUM_ACTIVE:



    							USBMSC_processMSCBuffer(); // Handle READ/WRITE cmds from the host

    							// Every second, the Timer_A ISR sets this flag.  The
    							// checking can't be done from within the timer ISR, because it
    							// enables interrupts, and this is not a recommended
    							// practice due to the risk of nested interrupts.
    							if (bDetectCard){
    								USBMSC_checkMSCInsertionRemoval();

    								// Clear the flag, until the next timer ISR
    								bDetectCard = 0x00;
    							}

    							break;

    						// These cases are executed while your device is disconnected from
    						// the host (meaning, not enumerated); enumerated but suspended
    						// by the host, or connected to a powered hub without a USB host
    						// present.
    						case ST_PHYS_DISCONNECTED:
    						case ST_ENUM_SUSPENDED:
    						case ST_PHYS_CONNECTED_NOENUM_SUSP:
    							hal_led_a(BLUE);
    							//state = sIDLE;
    							break;

    						// The default is executed for the momentary state
    						// ST_ENUM_IN_PROGRESS.  Usually, this state only last a few
    						// seconds.  Be sure not to enter LPM3 in this state; USB
    						// communication is taking place here, and therefore the mode must
    						// be LPM0 or active-CPU.
    						case ST_ENUM_IN_PROGRESS:
    						default:;
    					}
    		break;
    	}
    }

}
예제 #14
0
//***** Main Function *********************************************************
void main (void)
{
	uint16_t i = 0;
	uint16_t val = 0;
	uint16_t loc = 0;
	uint16_t status = 0;

    // Stop watchdog timer
    WDT_A_hold( WDT_A_BASE );

    // Initialize GPIO
    initGPIO();

    if ( erase != 0 )                                  // This lets you easily erase the flash by changing the value
    	erase_infoB();                                 // of the "erase" variable before reaching this point in the code

    if ( fill != 0 )                                   // This lets you easily fill the flash by changing the value
    	fill_infoB();                                  // of the "fill" variable before reaching this point in the code

    if (count[ 0 ] == 0xffff )
    {
    	val = 1;
    	loc = 0;
    }
    else if ( count[ NUMBER_OF_WORDS-1 ] != 0xFFFF )
    {
    	val = count[ NUMBER_OF_WORDS-1 ];
    	erase_infoB();
    	loc = 0;
    }
    else
    {
    	for ( i = 1; i < NUMBER_OF_WORDS-2; i++ )
    	{
    		if ( count[ i ] == 0xffff )
    		{
    			val = count[ i - 1 ];
    			val++;
    			loc = i;
    			break;
    		}
    	}
    }

	status = write_infoB_location( val, loc );
	if ( status == 0 )
		while( 1 );

    // Inform the programmer how many times the board has been power-on reset
    //   which isn't possible without some form of non-volaile memory
printf( "This program has been power cycled %d times\n", val );

    // Flash the LED 'count' number of times ... this way you can 'see' how many
    //   times a power-on reset has occured, even if you can't read the printf()
    for ( i = 0; i < val; i++ )
    {
        // Turn on LED
        GPIO_setOutputHighOnPin( GPIO_PORT_P1, GPIO_PIN0 );

        // Wait about a second
        __delay_cycles( ONE_SECOND );

        // Turn off LED
        GPIO_setOutputLowOnPin( GPIO_PORT_P1, GPIO_PIN0 );

        // Wait another second
        __delay_cycles( HALF_SECOND );
    }

    // Trap program here
    while(1);
}
예제 #15
0
파일: main.c 프로젝트: NHLBI-MR/PRiME
void main(void)
{
	WDT_A_hold(WDT_A_BASE);
	memset(psaData,0,8);

	while (1) {
		switch (nextState) {
		case InituProc:
			curState=InituProc;

			uProcConfig();
			PSAConfig();
			CSaAFConfig();

			nextState=InitHW;
			break;
		case InitHW:
			curState=InitHW;

			simType=SimNone;
			PSAInit();
			CSaAFInit();
			PSASetMode(PSANormal);
			PSAEnableTransfer(true);
			//IRQ handler will set this to true
			goodTransfer=false;
			totalTestLEDLoops=SIMNONE_LEDTEST_LOOPS;
			totalTXLEDLoops=SIMNONE_LEDTX_LOOPS;

			nextState=Ready;
			break;
		case Ready:
			curState=Ready;

			if (startLEDcycle) {
				if (simType==SimNone) {
					SetLED(TEST_LED_PORT, TEST_LED_PIN,false);
					SetLED(TRANSFER_LED_PORT,TRANSFER_LED_PIN,true);
				} else {
					SetLED(TEST_LED_PORT, TEST_LED_PIN,true);
				}
				curTestLEDLoops=0;
				curTXLEDLoops=0;
				ledTestToggle=false;
				startLEDcycle=false;
			}
			if (ledTXToggle) {
				ToggleLED(TRANSFER_LED_PORT, TRANSFER_LED_PIN);
				ledTXToggle=false;
			}


			if (ledTestToggle) {
				ToggleLED(TEST_LED_PORT, TEST_LED_PIN);
				ledTestToggle=false;
			}

			if (!goodTransfer && simType==SimNone) {
				nextState=UpdateBadTXData;
				readyForBadTXData=true;

			} else if (resetBtn) {
				nextState=InitHW;
				resetBtn=false;
			} else if (testBtn) {
				if (simType==SimNone) {
					//next sim type is ADS1198 test signal
					nextState=InitPSATest;
				} else if (simType==SimHW) {
					//next sim type is Launchpad generated signal
					nextState=StartSimIRQ;
				} else {
					nextState=InitHW;
				}
				testBtn=false;
			} else if (readyForSimUpdate) {
				nextState=UpdateSimData;
				readyForSimUpdate=false;
			} else if (readyForPSAData) {
				nextState=ReadFromPSA;
				readyForPSAData=false;
			} else if (readyForBadTXData) {
				nextState=UpdateBadTXData;
				readyForBadTXData=false;
			}

			break;
		case ReadFromPSA:
			curState=ReadFromPSA;

			PSARead(psaData);

			nextState=WriteToCSaAF;
			break;
		case WriteToCSaAF:
			curState=WriteToCSaAF;

			CSaAFWrite(psaData);

			nextState=Ready;
			break;
		case StartSimIRQ:
			curState=StartSimIRQ;

			//1ms "master" clock is resused for simulation
			PSAEnableTransfer(false);
			totalTestLEDLoops=SIMSW_LEDTEST_LOOPS;
			goodTransfer=false;
			simType=SimSW;
			nextState=Ready;
			break;
		case UpdateSimData:
			curState=UpdateSimData;

			static uint32_t last_val_change=0;
			if (timer_ms-last_val_change>=SIM_HALFPERIOD) {
				GenPulseData(SIM_AMP);
				last_val_change=timer_ms;
			}

			nextState=WriteToCSaAF;
			break;
		case UpdateBadTXData:
			curState=UpdateBadTXData;
			static uint32_t last_pulse_change=0;
			static uint32_t last_txval_change=0;
			static bool STAGE_PULSE=true;


			if (timer_ms-last_txval_change>=BADTX_HALFPERIOD) {
				if (STAGE_PULSE) {
					GenPulseData(BADTX_AMP);
				} else{
					//memset only copies uint8
					memset(psaData,0,16);
				}

				last_txval_change=timer_ms;
			}
			if (timer_ms-last_pulse_change>=BADTX_HALFPERIOD*BADTX_PULSES*2) {
				STAGE_PULSE=!STAGE_PULSE;
				last_pulse_change=timer_ms;
			}

			nextState=WriteToCSaAF;
			break;
		case InitPSATest:
			curState=InitPSATest;

			PSASetMode(PSATest);
			PSAEnableTransfer(true);
			simType=SimHW;
			totalTestLEDLoops=SIMHW_LEDTEST_LOOPS;

			nextState=Ready;
			break;
		default:
			break;
		}
	}
}
예제 #16
0
int main(void) {
	WDT_A_hold(WDT_A_BASE);

	return 0;
}
void main(void)
{
    //Stop Watchdog Timer
    WDT_A_hold(WDT_A_BASE);

       PowerLevel_3();
   Clk_MCLK_24M_SMCLK_3M_ACLK_32768Hz();
    //Enable A/D channel inputs
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6,
                                               GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 +
                                               GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5 +
                                               GPIO_PIN6 + GPIO_PIN7
                                               );

    //Initialize the ADC12_A Module
    /*
     * Base address of ADC12_A Module
     * Use internal ADC12_A bit as sample/hold signal to start conversion
     * USE MODOSC 5MHZ Digital Oscillator as clock source
     * Use default clock divider of 1
     */
    ADC12_A_init(ADC12_A_BASE,
                 ADC12_A_SAMPLEHOLDSOURCE_SC,
                 ADC12_A_CLOCKSOURCE_ADC12OSC,
                 ADC12_A_CLOCKDIVIDER_1
                 );

    ADC12_A_enable(ADC12_A_BASE);

    /*
     * Base address of ADC12_A Module
     * For memory buffers 0-7 sample/hold for 256 clock cycles
     * For memory buffers 8-15 sample/hold for 4 clock cycles (default)
     * Enable Multiple Sampling
     */
    ADC12_A_setupSamplingTimer(ADC12_A_BASE,
                               ADC12_A_CYCLEHOLD_256_CYCLES,
                               ADC12_A_CYCLEHOLD_4_CYCLES,
                               ADC12_A_MULTIPLESAMPLESENABLE);

    //Configure Memory Buffers
    /*
     * Base address of the ADC12_A Module
     * Configure memory buffer 0
     * Map input A0 to memory buffer 0
     * Vref+ = AVcc
     * Vref- = AVss
     * Memory buffer 0 is not the end of a sequence
     */
    ADC12_A_configureMemoryParam param0 = {0};
    param0.memoryBufferControlIndex = ADC12_A_MEMORY_0;
    param0.inputSourceSelect = ADC12_A_INPUT_A0;
    param0.positiveRefVoltageSourceSelect = ADC12_A_VREFPOS_AVCC;
    param0.negativeRefVoltageSourceSelect = ADC12_A_VREFNEG_AVSS;
    param0.endOfSequence = ADC12_A_NOTENDOFSEQUENCE;
    ADC12_A_configureMemory(ADC12_A_BASE,&param0);

    /*
     * Base address of the ADC12_A Module
     * Configure memory buffer 1
     * Map input A1 to memory buffer 1
     * Vref+ = AVcc
     * Vref- = AVss
     * Memory buffer 1 is not the end of a sequence
     *
     */
    ADC12_A_configureMemoryParam param1 = {0};
    param1.memoryBufferControlIndex = ADC12_A_MEMORY_1;
    param1.inputSourceSelect = ADC12_A_INPUT_A1;
    param1.positiveRefVoltageSourceSelect = ADC12_A_VREFPOS_AVCC;
    param1.negativeRefVoltageSourceSelect = ADC12_A_VREFNEG_AVSS;
    param1.endOfSequence = ADC12_A_NOTENDOFSEQUENCE;
    ADC12_A_configureMemory(ADC12_A_BASE,&param1);
    /*
     * Base address of the ADC12_A Module
     * Configure memory buffer 2
     * Map input A2 to memory buffer 2
     * Vref+ = AVcc
     * Vref- = AVss
     * Memory buffer 2 is not the end of a sequence
     */
    ADC12_A_configureMemoryParam param2 = {0};
    param2.memoryBufferControlIndex = ADC12_A_MEMORY_2;
    param2.inputSourceSelect = ADC12_A_INPUT_A2;
    param2.positiveRefVoltageSourceSelect = ADC12_A_VREFPOS_AVCC;
    param2.negativeRefVoltageSourceSelect = ADC12_A_VREFNEG_AVSS;
    param2.endOfSequence = ADC12_A_NOTENDOFSEQUENCE;
    ADC12_A_configureMemory(ADC12_A_BASE,&param2);
    /*
     * Base address of the ADC12_A Module
     * Configure memory buffer 3
     * Map input A3 to memory buffer 3
     * Vr+ = AVcc
     * Vr- = AVss
     * Memory buffer 3 IS the end of a sequence
     */
    ADC12_A_configureMemoryParam param3 = {0};
    param3.memoryBufferControlIndex = ADC12_A_MEMORY_3;
    param3.inputSourceSelect = ADC12_A_INPUT_A3;
    param3.positiveRefVoltageSourceSelect = ADC12_A_VREFPOS_AVCC;
    param3.negativeRefVoltageSourceSelect = ADC12_A_VREFNEG_AVSS;
    param3.endOfSequence = ADC12_A_ENDOFSEQUENCE;
    ADC12_A_configureMemory(ADC12_A_BASE,&param3);

    //Enable memory buffer 3 interrupt
    ADC12_A_clearInterrupt(ADC12_A_BASE,
                           ADC12IFG3);
    ADC12_A_enableInterrupt(ADC12_A_BASE,
                            ADC12IE3);

    //Enable/Start first sampling and conversion cycle
    /*
     * Base address of ADC12_A Module
     * Start the conversion into memory buffer 0
     * Use the repeated sequence of channels
     */
    ADC12_A_startConversion(ADC12_A_BASE,
                            ADC12_A_MEMORY_0,
                            ADC12_A_REPEATED_SEQOFCHANNELS);

    //Enter LPM0, Enable interrupts
    __bis_SR_register(LPM0_bits + GIE);
    //For debugger
    __no_operation();
}
예제 #18
0
void main(void)
{
	tRectangle myRectangle1 = { 5, 10, 60, 50};
	tRectangle myRectangle2 = { 30, 20, 100, 60};
	tRectangle myRectangle3 = { 0, 0, 101, 63};

    // Stop WDT
    WDT_A_hold(WDT_A_BASE);

    // Basic GPIO initialization
    Board_init();
    Clock_init();

    // Set up LCD
    Dogs102x64_UC1701Init();
    GrContextInit(&g_sContext, &g_sDogs102x64_UC1701);
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
    GrContextFontSet(&g_sContext, &g_sFontFixed6x8);
    GrClearDisplay(&g_sContext);

    // Intro Screen
    GrStringDrawCentered(&g_sContext,
    		"How to use MSP430",
    		AUTO_STRING_LENGTH,
    		51,
    		16,
    		TRANSPARENT_TEXT);
    GrStringDrawCentered(&g_sContext,
    		"Graphics Library",
    		AUTO_STRING_LENGTH,
    		51,
    		32,
    		TRANSPARENT_TEXT);
    GrStringDrawCentered(&g_sContext,
    		"Primitives",
    		AUTO_STRING_LENGTH,
    		51,
    		48,
    		TRANSPARENT_TEXT);
    Delay();
    GrClearDisplay(&g_sContext);


    // Draw pixels and lines on the display
    GrStringDraw(&g_sContext,
    		"Draw Pixels",
    		AUTO_STRING_LENGTH,
    		20,
    		0,
    		TRANSPARENT_TEXT);
    GrStringDraw(&g_sContext,
    		"& Lines",
    		AUTO_STRING_LENGTH,
    		30,
    		10,
    		TRANSPARENT_TEXT);
    GrPixelDraw(&g_sContext, 10, 10);
    GrPixelDraw(&g_sContext, 10, 12);
    GrPixelDraw(&g_sContext, 12, 12);
    GrPixelDraw(&g_sContext, 12, 10);
    GrLineDraw(&g_sContext, 15, 15, 60, 60);
    GrLineDraw(&g_sContext, 10, 50, 90, 10);
    GrLineDraw(&g_sContext,
    		0,
    		GrContextDpyHeightGet(&g_sContext) - 1,
    		GrContextDpyWidthGet(&g_sContext) - 1,
    		GrContextDpyHeightGet(&g_sContext) - 1);
    Delay();
    GrClearDisplay(&g_sContext);

    // Draw circles on the display
    GrStringDrawCentered(&g_sContext,
    		"Draw Circles",
    		AUTO_STRING_LENGTH,
    		51,
    		5,
    		TRANSPARENT_TEXT);
    GrCircleDraw(&g_sContext, 30, 50, 10);
    GrCircleFill(&g_sContext, 65, 37, 23);
    Delay();



    GrClearDisplay(&g_sContext);

    // Draw rectangles on the display
    GrStringDrawCentered(&g_sContext,
    		"Draw Rectangles",
    		AUTO_STRING_LENGTH,
    		51,
    		5,
    		TRANSPARENT_TEXT);
    GrRectDraw(&g_sContext, &myRectangle1);
    GrRectFill(&g_sContext, &myRectangle2);
    // Text won't be visible on screen due to transparency
    GrStringDrawCentered(&g_sContext,
    		"Normal Text",
    		AUTO_STRING_LENGTH,
    		65,
    		30,
    		TRANSPARENT_TEXT);
    // Text draws foreground and background for opacity
    GrStringDrawCentered(&g_sContext,
    		"Opaque Text",
    		AUTO_STRING_LENGTH,
    		65,
    		40,
    		OPAQUE_TEXT);
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrContextBackgroundSet(&g_sContext, ClrBlack);
    // Text draws with inverted color to become visible
    GrStringDrawCentered(&g_sContext,
    		"Invert Text",
    		AUTO_STRING_LENGTH,
    		65,
    		50,
    		TRANSPARENT_TEXT);
    Delay();
    GrClearDisplay(&g_sContext);

    // Invert the foreground and background colors
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
	GrRectFill(&g_sContext, &myRectangle3);
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrContextBackgroundSet(&g_sContext, ClrBlack);
	GrStringDrawCentered(&g_sContext,
			"Invert Colors",
			AUTO_STRING_LENGTH,
			51,
			5,
			TRANSPARENT_TEXT);
	GrRectDraw(&g_sContext, &myRectangle1);
	GrRectFill(&g_sContext, &myRectangle2);
	// Text won't be visible on screen due to transparency
    GrStringDrawCentered(&g_sContext,
    		"Normal Text",
    		AUTO_STRING_LENGTH,
    		65,
    		30,
    		TRANSPARENT_TEXT);
    // Text draws foreground and background for opacity
    GrStringDrawCentered(&g_sContext,
    		"Opaque Text",
    		AUTO_STRING_LENGTH,
    		65,
    		40,
    		OPAQUE_TEXT);
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
    // Text draws with inverted color to become visible
    GrStringDrawCentered(&g_sContext,
    		"Invert Text",
    		AUTO_STRING_LENGTH,
    		65,
    		50,
    		TRANSPARENT_TEXT);
	Delay();
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrContextBackgroundSet(&g_sContext, ClrWhite);
	GrClearDisplay(&g_sContext);

    // Draw Images on the display
    GrImageDraw(&g_sContext, &LPRocket_96x37_1BPP_UNCOMP, 3, 13);
    Delay();
    GrClearDisplay(&g_sContext);
    GrImageDraw(&g_sContext, &TI_Logo_69x64_1BPP_UNCOMP, 16, 0);

    while(1)
    {
    }

}
예제 #19
0
void main(void){

    WDT_A_hold(WDT_A_BASE); // Stop WDT

    boardInit(); // Basic GPIO initialization

    clockInit(8000000); // Config clocks. MCLK=SMCLK=FLL=8MHz; ACLK=REFO=32kHz

    Sharp96x96_LCDInit(); // Set up the LCD


    GrContextInit(&g_sContext, &g_sharp96x96LCD);
  	GrContextForegroundSet(&g_sContext, ClrBlack);
  	GrContextBackgroundSet(&g_sContext, ClrWhite);
  	GrContextFontSet(&g_sContext, &g_sFontFixed6x8);
  	GrClearDisplay(&g_sContext);
  	GrFlush(&g_sContext);

	while(1){
		// Intro Screen
		GrClearDisplay(&g_sContext);
		GrStringDrawCentered(&g_sContext,
							 "How to use",
							 AUTO_STRING_LENGTH,
							 48,
							 15,
							 TRANSPARENT_TEXT);
		GrStringDrawCentered(&g_sContext,
							 "the MSP430",
							 AUTO_STRING_LENGTH,
							 48,
							 35,
							 TRANSPARENT_TEXT);
		GrStringDraw(&g_sContext,
					 "Graphics Library",
					 AUTO_STRING_LENGTH,
					 1,
					 51,
					 TRANSPARENT_TEXT);
		GrStringDrawCentered(&g_sContext,
							 "Primitives",
							 AUTO_STRING_LENGTH,
							 48,
							 75,
							 TRANSPARENT_TEXT);

		GrFlush(&g_sContext);
		Delay();
		GrClearDisplay(&g_sContext);

		// Draw pixels and lines on the display
		GrStringDrawCentered(&g_sContext,
							 "Draw Pixels",
							 AUTO_STRING_LENGTH,
							 48,
							 5,
							 TRANSPARENT_TEXT);
		GrStringDrawCentered(&g_sContext,
							 "& Lines",
							 AUTO_STRING_LENGTH,
							 48,
							 15,
							 TRANSPARENT_TEXT);
		GrPixelDraw(&g_sContext, 30, 30);
		GrPixelDraw(&g_sContext, 30, 32);
		GrPixelDraw(&g_sContext, 32, 32);
		GrPixelDraw(&g_sContext, 32, 30);
		GrLineDraw(&g_sContext, 35, 35, 90, 90);
		GrLineDraw(&g_sContext, 5, 80, 80, 20);
		GrLineDraw(&g_sContext,
				   0,
				   GrContextDpyHeightGet(&g_sContext) - 1,
				   GrContextDpyWidthGet(&g_sContext) - 1,
				   GrContextDpyHeightGet(&g_sContext) - 1);
		GrFlush(&g_sContext);
		Delay();
		GrClearDisplay(&g_sContext);

		// Draw circles on the display
		GrStringDraw(&g_sContext,
					 "Draw Circles",
					 AUTO_STRING_LENGTH,
					 10,
					 5,
					 TRANSPARENT_TEXT);
		GrCircleDraw(&g_sContext,
					 30,
					 70,
					 20);
		GrCircleFill(&g_sContext,
					 60,
					 50,
					 30);
		GrFlush(&g_sContext);
		Delay();
		GrClearDisplay(&g_sContext);

		// Draw rectangles on the display
		GrStringDrawCentered(&g_sContext,
							 "Draw Rectangles",
							 AUTO_STRING_LENGTH,
							 48,
							 5,
							 TRANSPARENT_TEXT);
		GrRectDraw(&g_sContext, &myRectangle1);
		GrRectFill(&g_sContext, &myRectangle2);
		// Text below won't be visible on screen due to transparency
		// (foreground colors match)
		GrStringDrawCentered(&g_sContext,
							 "Normal Text",
							 AUTO_STRING_LENGTH,
							 50,
							 50,
							 TRANSPARENT_TEXT);
		// Text below draws foreground and background for opacity
		GrStringDrawCentered(&g_sContext,
							 "Opaque Text",
							 AUTO_STRING_LENGTH,
							 50,
							 65,
							 OPAQUE_TEXT);
		GrContextForegroundSet(&g_sContext, ClrWhite);
		GrContextBackgroundSet(&g_sContext, ClrBlack);
		GrStringDrawCentered(&g_sContext,
							 "Invert Text",
							 AUTO_STRING_LENGTH,
							 50,
							 80,
							 TRANSPARENT_TEXT);
		GrFlush(&g_sContext);
		Delay();

		// Invert the foreground and background colors
		GrContextForegroundSet(&g_sContext, ClrBlack);
		GrContextBackgroundSet(&g_sContext, ClrWhite);
		GrRectFill(&g_sContext, &myRectangle3);
		GrContextForegroundSet(&g_sContext, ClrWhite);
		GrContextBackgroundSet(&g_sContext, ClrBlack);
		GrStringDrawCentered(&g_sContext,
							 "Invert Colors",
							 AUTO_STRING_LENGTH,
							 48,
							 5,
							 TRANSPARENT_TEXT);
		GrRectDraw(&g_sContext, &myRectangle1);
		GrRectFill(&g_sContext, &myRectangle2);
		// Text below won't be visible on screen due to
		// transparency (foreground colors match)
		GrStringDrawCentered(&g_sContext,
							 "Normal Text",
							 AUTO_STRING_LENGTH,
							 50,
							 50,
							 TRANSPARENT_TEXT);
		// Text below draws foreground and background for opacity
		GrStringDrawCentered(&g_sContext,
							 "Opaque Text",
							 AUTO_STRING_LENGTH,
							 50,
							 65,
							 OPAQUE_TEXT);
		// Text below draws with inverted foreground color to become visible
		GrContextForegroundSet(&g_sContext, ClrBlack);
		GrContextBackgroundSet(&g_sContext, ClrWhite);
		GrStringDrawCentered(&g_sContext,
							 "Invert Text",
							 AUTO_STRING_LENGTH,
							 50,
							 80,
							 TRANSPARENT_TEXT);
		GrFlush(&g_sContext);
		Delay();
		GrContextForegroundSet(&g_sContext, ClrBlack);
		GrContextBackgroundSet(&g_sContext, ClrWhite);
		GrClearDisplay(&g_sContext);

		// Draw Images on the display
		GrImageDraw(&g_sContext, &LPRocket_96x37_1BPP_UNCOMP, 3, 28);
		GrFlush(&g_sContext);
		Delay();
		GrClearDisplay(&g_sContext);
		GrImageDraw(&g_sContext, &TI_Logo_69x64_1BPP_UNCOMP, 15, 15);
		GrFlush(&g_sContext);
		Delay();
		// __bis_SR_register(LPM0_bits+GIE); //enter low power mode 0 with interrupts
	}
}
__interrupt void watchDogIsr(void)
{
	WDT_A_resetTimer(WDT_A_BASE);
	WDT_A_hold(WDT_A_BASE);
	__low_power_mode_off_on_exit();
}