示例#1
0
文件: gps.c 项目: agyoungs/m16cgps
/*******************************************************************************
* Purpose: Initializes the GPS Module.
* Passed: No arguments passed.
* Locals: int index - GPS Buffer Index
* Returned: No values returned.
* Author: Will Flores [email protected]
*******************************************************************************/
void gps_init() {
    int index; // GPS Buffer Index

    /* 1. Turn GPS OFF before turning it on */
    GPS_PWR = OFF;
    clearScreen();
    BNSPrintf(LCD, "\tTurning\nGPS on...");
    DisplayDelay(DISPLAY_DELAY1);

    /* 2. Turn GPS ON */
    GPS_PWR = ON; // transistion from low to high
    timerDelay(2*ONE_SECOND);
    while(timerA1_started); // wait 2 seconds

    /* 3. Turn GPS_RESET ON for 250 ms */
    //clearScreen();
    //BNSPrintf(LCD, "\tGPS\nRESET");
    //DisplayDelay(DISPLAY_DELAY);
    GPS_RESET = ON; // transistion from low to high
    timerDelay(TWO_FIFTY_MS);
    while(timerA1_started); // wait 250 ms to transistion this signal

    /* 4. Pull GPS_PWRCTRL LOW for 2 seconds */
    //clearScreen();
    //BNSPrintf(LCD,"\tGPSPWRCTRL\nLOW");
    GPS_PWRCTRL = OFF; // GPS PWRCNTRL LOW
    timerDelay(2*ONE_SECOND);
    while(timerA1_started); // wait 2 seconds
    //BNSPrintf(LCD, "\tGPSPWRCTRL\nHIGH");
    //DisplayDelay(DISPLAY_DELAY);

    /* 5. Transition GPS_PWRCTRL */
    GPS_PWRCTRL = ON;

    /* 6. Wait until GPS_PWRCHK turns ON */
    //clearScreen();
    //BNSPrintf(LCD, "\tChecking\nPWRCHK");
    //DisplayDelay(DISPLAY_DELAY);
    while(!GPS_PWRCHK); // GPS PWRCHK

    /* 7. Release GPS_PWRCTRL */
    //clearScreen();
    //BNSPrintf(LCD, "\tPWRCTRL\nLOW");
    //DisplayDelay(DISPLAY_DELAY);
    GPS_PWRCTRL = OFF; // Drive PWRCNTRL back to low

    /* 8. We're done! */
    clearScreen();
    BNSPrintf(LCD, "\tGPS on!");
    DisplayDelay(DISPLAY_DELAY);

    /* Clear the longitude and latitude buffers */
    for (index = 0; index < 13; ++index) {
        lonGet[index] = latGet[index] = CLEAR_INDEX;
    }
}
示例#2
0
void set_port3_pin2(void)
{
    if (p3_2 == PIN_LOW)
    {
        BNSPrintf(LCD,"\tR-ON    \n        ");
        p3_2 = PIN_HIGH;
    }
    else if (p3_2 == PIN_HIGH)
    {
        BNSPrintf(LCD,"\tR-OFF    \n        ");
        p3_2 = PIN_LOW;
    }
}
示例#3
0
void set_port3_pin0(void)
{
    if (p3_0 == PIN_LOW)
    {
        BNSPrintf(LCD,"\tL-ON    \n        ");
        p3_0 = PIN_HIGH;
    }
    else if (p3_0 == PIN_HIGH)
    {
        BNSPrintf(LCD,"\tL-OFF    \n        ");
        p3_0 = PIN_LOW;
    }
}
示例#4
0
void main(void)
//-----------------------------------------------------------------------------------------------------
//  Purpose:	The MCU will come here after reset. 
//  
//
//  Rev:    1.5a     TEMPLATE RELEASE
//  
//  Notes:          None    
//-----------------------------------------------------------------------------------------------------
{
	
	//Initialization function calls 
	init_ports();
	motors_init();
	system_clock_init();
	InitDisplay("FHBTEST    "); //Start-up splash changed to unity ID
	InitUART();
	ADInit();	
	ENABLE_SWITCHES;	
	/* LED initialization - macro defined in qsk_bsp.h */
 	ENABLE_LEDS	


	//Polling for switch presses 
	while(TRUE) 
	{
		if(S1 == PRESSED)
		{
			BNSPrintf(LCD,"\tTEST          \n        ");
			project2ADemo(); 		
		}
		else if (S2 == PRESSED)
		{
			BNSPrintf(LCD,"\tOff            \n        ");
		}
		else if (S3 == PRESSED)
		{
			BNSPrintf(LCD,"\tFigure 8              \n        ");
			DoFigureEight();
		}
		else
		{
       		BNSPrintf(LCD,"\tTeam 2                 \n        ");
        }
		
	}
}
示例#5
0
文件: LCD.c 项目: audiocircuit/ECE306
void InitDisplay(char far StartupString1[] )
//-----------------------------------------------------------------------------------------------------
//  Purpose: This will initialize the LCD and then display the define LOGO one line ine
//				and the passed parameter StartupString1 on line 2.
//
//  Rev:    1.0     Initial Release
//  
//  Notes:          None    
//-----------------------------------------------------------------------------------------------------
{
	int i;

	// initial port directions
	prc2=1;							// unprotect as Port 9 is used
	PORT_DDR = PORT_DDR_VALUE; 

	EN_PIN = HIGH;
	EN_PIN_DDR = HIGH;				// set port that controls EN as output
	RS_PIN = HIGH;
	RS_PIN_DDR = HIGH;				// set port that controls RS as output

	EN_PIN = LOW;

	LCD_write(CTRL_WR,0x33);
	DisplayDelay(20);
	LCD_write(CTRL_WR,0x32);
	DisplayDelay(20);
	LCD_write(CTRL_WR,FUNCTION_SET);	/* reset sequence */
	LCD_write(CTRL_WR,FUNCTION_SET);
	LCD_write(CTRL_WR,LCD_CURSOR_OFF);
	LCD_write(CTRL_WR,LCD_CLEAR);
	LCD_write(CTRL_WR,LCD_HOME_L1);

	DisplayString(LCD_LINE1, LOGO);
	
	BNSPrintf(LCD_FILE_NUM, "\t%8s\n%8s",LOGO, StartupString1);	
	DisplayDelay(6000);	
}
示例#6
0
文件: gps.c 项目: agyoungs/m16cgps
/*******************************************************************************
* Purpose: Displays the GPS information for user to view
* Passed: char * TopStr - Top string to be viewed.
*         char * BottomStr - Bottom string to be viewed.
* Locals: int displayIndex - where in the buffer are they going to see.
*         int topStrSize - Top display string size
*         int bottomStrSize - Bottom display string size
*         int thumbval - Thumbwheel ADC value;
*         int topShowem - The bounds of what we're going to show at top.
*         int botShowem - The bounds of what we're going to show at bottom.
*
* Returned: No values returned.
* Author: Will Flores [email protected]
*******************************************************************************/
void displayScroller(char * TopStr, char * BottomStr) {
    int displayIndex = CLEAR_INDEX;
    int topStrSize = CLEAR_INDEX;
    int bottomStrSize = CLEAR_INDEX;
    int thumbval = CLEAR_INDEX;
    int topShowem = CLEAR_INDEX;
    int botShowem = CLEAR_INDEX;
    /* Determine input String Size */
    topStrSize = strlength(TopStr);
    bottomStrSize = strlength(BottomStr);

    /* Get thumb wheel value */
    thumbval = (T_WHEEL & T_WHEELMASK) >> ADC_MSbyte_SHIFT;
    /* We're tweaking the range without tweaking the above bit shift */
    if (thumbval == DISPLAY_3_CHAR) thumbval = DISPLAY_2_CHAR;
    /* The thumbwheel should be able to handle showing all of the below stuff */
    displayIndex = thumbval*GPS_DISPLAY_LIMIT;

    /* Measure how much they want to show us */
    topShowem = topStrSize - displayIndex;
    botShowem = bottomStrSize - displayIndex;

    clearScreen();
    /* Determine what you want to display */
    if (topShowem >= GPS_DISPLAY_LIMIT) { /* Check to see if we can display everything */
        BNSPrintf(LCD, "\tLAT%c%c%c%c%c", TopStr[displayIndex], TopStr[displayIndex+DISPLAY_1_CHAR],
                  TopStr[displayIndex+DISPLAY_2_CHAR], TopStr[displayIndex+DISPLAY_3_CHAR], TopStr[displayIndex+DISPLAY_4_CHAR]);
    }
    else {
        switch (topShowem) { /* The special cases for our display */
        case DISPLAY_4_CHAR:
            BNSPrintf(LCD, "\tLAT%c%c%c%c", TopStr[displayIndex], TopStr[displayIndex+DISPLAY_1_CHAR],
                      TopStr[displayIndex+DISPLAY_2_CHAR], TopStr[displayIndex+DISPLAY_3_CHAR]);
            break;
        case DISPLAY_3_CHAR:
            BNSPrintf(LCD, "\tLAT%c%c%c", TopStr[displayIndex], TopStr[displayIndex+DISPLAY_1_CHAR],
                      TopStr[displayIndex+DISPLAY_2_CHAR]);
            break;
        case DISPLAY_2_CHAR:
            BNSPrintf(LCD, "\tLAT%c%c", TopStr[displayIndex], TopStr[displayIndex+DISPLAY_1_CHAR]);
            break;
        case DISPLAY_1_CHAR:
            BNSPrintf(LCD, "\tLAT%c", TopStr[displayIndex]);
            break;
        default:
            BNSPrintf(LCD, "\tLAT ");
            break;
        }
    }
    /* Determine what part of the bottom do they want to show */
    if (botShowem >= GPS_DISPLAY_LIMIT) {
        BNSPrintf(LCD, "\t\nLON%c%c%c%c%c", BottomStr[displayIndex], BottomStr[displayIndex+DISPLAY_1_CHAR],
                  BottomStr[displayIndex+DISPLAY_2_CHAR], BottomStr[displayIndex+DISPLAY_3_CHAR], BottomStr[displayIndex+DISPLAY_4_CHAR]);
    }
    else {
        switch (botShowem) {
        case DISPLAY_4_CHAR:
            BNSPrintf(LCD, "\t\nLON%c%c%c%c", BottomStr[displayIndex], BottomStr[displayIndex+DISPLAY_1_CHAR],
                      BottomStr[displayIndex+DISPLAY_2_CHAR], BottomStr[displayIndex+DISPLAY_3_CHAR]);
            break;
        case DISPLAY_3_CHAR:
            BNSPrintf(LCD, "\t\nLON%c%c%c", BottomStr[displayIndex], BottomStr[displayIndex+DISPLAY_1_CHAR],
                      BottomStr[displayIndex+DISPLAY_2_CHAR]);
            break;
        case DISPLAY_2_CHAR:
            BNSPrintf(LCD, "\t\nLON%c%c", BottomStr[displayIndex], BottomStr[displayIndex+DISPLAY_1_CHAR]);
            break;
        case DISPLAY_1_CHAR:
            BNSPrintf(LCD, "\t\nLON%c", BottomStr[displayIndex]);
            break;
        default:
            BNSPrintf(LCD, "\t\nLON ");
            break;
        }
    }
    // Stabilize for 250 ms
    timerDelay(TWO_FIFTY_MS);
    while(timerA1_started);
}
示例#7
0
void clear_port3_pin0_and_pin2(void)
{
    BNSPrintf(LCD,"\tALL OFF  \n        ");
    p3_0 = PIN_LOW;
    p3_2 = PIN_LOW;
}