Пример #1
0
/**
  * @brief  Reset Chrono to zero.
  * @param  None.
  * @retval None.
  */
void Time_ResetMenu(void)
{
  LCD_SetCursorPos(LCD_LINE1, 0);
  LCD_Print(" Reset Chrono ? ");
  LCD_SetCursorPos(LCD_LINE2, 0);
  LCD_Print("<No        Yes>");

  /* Endless loop */
  while (1)
  {
    /* Check which key is pressed */
    Key = ReadJoystick();

    /* If "RIGHT" pushbutton is pressed */
    if (Key == JOY_RIGHT)
    {
      Time_Reset();

      Time_Pause();

      Restore_LastDisplay() ;
      /* Exit */
      return ;
    }

    /* If "LEFT" pushbutton is pressed */
    if (Key == JOY_LEFT)
    {
      Restore_LastDisplay() ;
      /* Exit */
      return ;
    }

  }
}
Пример #2
0
int main(void)
{
    char strClearLine[15] = "ID:            ";
    /* Init System, IP clock and multi-function I/O */
    SYS_Init();     

    /* Init UART0 for printf */
    UART0_Init();   

    printf("CPU @ %dHz\n", SystemCoreClock);

    /* Init SPI0 and LCD */
    LCD_Init();
    LCD_EnableBackLight();
    LCD_ClearScreen();


    LCD_Print(0, "SPI Sample Code ");
    LCD_Print(1, "For Flash Test");
    LCD_Print(2, "Press INT button");

    /* Init P3.2 */
    GPIO_Init();

    SPIFLASH_Init();
    sprintf(g_strBuf, "ID:%x         ", SPIFLASH_ReadId()&0xFFFFUL);
    LCD_Print(3, strClearLine);
    LCD_Print(3, g_strBuf);

    while (!g_isPress);

    SpiTest();

    return 1;
}
Пример #3
0
/**
  * @brief  Record Time in memory.
  * @param  None
  * @retval None
  */
void Time_Record(void)
{
  if (SaveId < MAXSAVETIME)
  {
    STM_EVAL_LEDOn(LED3);
    LCD_SetCursorPos(LCD_LINE1, 0);
    LCD_Print(" Record Done  ");
    Time_SaveCurrentTime(SaveId);
    SavedTime_Show(LCD_LINE2, SaveId);
    SaveId++;
    Delay(0x3FFF) ;
    STM_EVAL_LEDOff(LED3);

  }
  else
  {
    LCD_SetCursorPos(LCD_LINE1, 0);
    LCD_Print("   Recordable   ");
    LCD_SetCursorPos(LCD_LINE2, 0);
    LCD_Print("  Mem is Full  ");
    Delay(0x17FFF) ;

  }

  Restore_LastDisplay() ;
}
Пример #4
0
/**
  * @brief  Pause Chronometer
  * @param  None.
  * @retval None.
  */
void Time_Pause(void)
{
  Time_Show(LCD_LINE2);
  LCD_SetCursorPos(LCD_LINE1, 0);

  if (PauseStatus == RESET)
  {
    STM_EVAL_LEDOn(LED2);
    LCD_Print(RESETDISPLAY);
    LastDisplay = 'P';
    CLK_RTCClockConfig(CLK_RTCCLKSource_Off, CLK_RTCCLKDiv_1);
    STM_EVAL_LEDOff(LED1);
  }
  else
  {
    STM_EVAL_LEDOn(LED1);
    LCD_Print(DEFAULTDISPLAY);
    LastDisplay = 'D';
    CLK_RTCClockConfig(CLK_RTCCLKSource_LSE, CLK_RTCCLKDiv_1);
    STM_EVAL_LEDOff(LED2);
  }

  /* Invert Pause Status */
  PauseStatus = (BitStatus)(~PauseStatus);
}
Пример #5
0
void DoAutoZero(void){
		
	LCD_FullDisp(	" Ready for Auto-Zero",
					"(Keep Pitob Ass. Out",
					"& Sampling Pump Off)",
					"  Press Enter Key   ");		
	
	//w8 for user to press ENTER key
	WaitFor(EnterKey);
	//Enter key pressed, go to AUTOZERO of Pitot_DP, Orifice_DP and Orifice_GAS_DP.

	//User is expected to remove any input to system, hence read values are offsets
	LCD_FullDisp(	"  Doing Auto-Zero   ",
					"(Keep Pitob Ass. Out",
					"& Sampling Pump Off)",
					"                    ");	
	delay_sec(1);
	
	OrifPart_DP.Zero= ExtAnalogRead(Ch_Orifice_DP);
	LCD_Setcursor(4,2);
	LCD_Print("------");	//Graphic loading Effect ;)
	delay_sec(1);
	Pitot_DP.Zero=	ExtAnalogRead(Ch_Pitot_DP);
	LCD_Print("------");
	delay_sec(1);
	OrifGas_DP.Zero= ExtAnalogRead(Ch_Orifice_Gas_DP);
	LCD_Print("------");
	LCD_FullDisp(	"                    ",	
					"   Auto-Zero done   ",
					"  Press Enter Key   ",				
					"                    ");
	WaitFor(EnterKey);
}
Пример #6
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
void main(void)
{
  uint8_t i = 0;
  
  /* Select fCPU = 16MHz */
  CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1);
  
  /* Init the Eval board LCD */
  STM8S_EVAL_LCD_Init();

  /* Clear LCD */
  LCD_Clear();

  LCD_SetCursorPos(LCD_LINE1, 0);
  LCD_Print("SPI-LCD example");		
  
  /* Display "moving" ST logo */
  for (i = 1; i < 8; i++)
  {
    PrintLogo();
    Delay(0xFFFF);
  }
  
  LCD_SetCursorPos(LCD_LINE2, 0);
  LCD_Print("               ");

  LCD_DisplayLogo(0x93);
  Delay(600);
  while(1)
  {}

}
Пример #7
0
/**
  * @brief  Restore Last Display
  * @param  None.
  * @retval None.
  */
void Restore_LastDisplay(void)
{
  LCD_SetCursorPos(LCD_LINE1, 0);
  if (LastDisplay == 'D')      LCD_Print(DEFAULTDISPLAY);
  else if (LastDisplay == 'P') LCD_Print(RESETDISPLAY);

}
Пример #8
0
void main(void)
{
	uint8_t error_flag;

	LED3=0;
	UART_Init();
	LCD_Init();
	SPI_master_init(400000); // Set clock rate to that speed in Hz
	error_flag = SDcard_init();
	

	while(1)
	{
		LED1 = 0;
		LED4 = 0;
		if(error_flag != NO_ERRORS)
		{
			LED4 = 0;
		}
		else
		{
			LED4 = 1;
		}
		delay_ms(1000);
		LED1 = 1;
		LED4 = 1;
		LCD_Write(COMMAND, LINE1);
		LCD_Print(16, "Coltons and Matt");
		LCD_Write(COMMAND, LINE2);
		LCD_Print(15, "hews LCD Works!");
		delay_ms(3000);
		LCD_Clear();
	}

}
Пример #9
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
void main(void)
{
   /* CLK configuration -------------------------------------------*/
  CLK_Config(); 

  /* Init TIM2 to generate 1 ms time base update interrupt */
  TimingDelay_Init();

  /* Enable Interrupts */
  enableInterrupts();

  /* Initialize LEDs mounted on STM8L152X-EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);

  /* Turn on LED1 and LED3 */
  STM_EVAL_LEDOn(LED1);
  STM_EVAL_LEDOn(LED3);

  /* Initialize push-buttons mounted on STM8L152X-EVAL board */
  STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_LEFT, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_EXTI);

  /* Init the Eval board LCD */
  STM8_EVAL_LCD_Init();

  /* Clear LCD */
  LCD_Clear();

  /* Enable general interrupts */
  enableInterrupts();

  LCD_SetCursorPos(LCD_LINE1, 0);
  LCD_Print("  System Clock  ");
  LCD_SetCursorPos(LCD_LINE2, 0);
  LCD_Print("  Source:  HSE  ");

  while (1)
  {
    /* Toggle LED2 and LED4 */
    STM_EVAL_LEDToggle(LED2);
    STM_EVAL_LEDToggle(LED4);

    /* Insert a delay */
    Delay(10);

    /* Toggle LED1 and LED3 */
    STM_EVAL_LEDToggle(LED1);
    STM_EVAL_LEDToggle(LED3);

    /* Insert a delay */
    Delay(10);
  }
}
Пример #10
0
/**
  * @brief  Eval Board IO Configuration.
  * @param  None
  * @retval None
  */
void EvalBoard_Init(void)
{
  /* Init the Eval board LCD */
  STM8_EVAL_LCD_Init();
  LCD_Clear();

  LCD_SetCursorPos(LCD_LINE1, 0);
  LCD_Print("  Chronometer  ");
  LCD_SetCursorPos(LCD_LINE2, 0);
  LCD_Print("   using RTC   ");

  /* Initialize push-buttons mounted on STM8L1528-EVAL board */
  STM_EVAL_PBInit(BUTTON_LEFT, BUTTON_MODE_GPIO);   /* For Saved Time parsing */
  STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_GPIO);  /* For Saved Time parsing */
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI);    /* For recording Time     */
  STM_EVAL_PBInit(BUTTON_SEL, BUTTON_MODE_EXTI);    /* For Time Pause/Resume  */
  STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_EXTI);   /* To enter to Saved Times*/
  STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_GPIO);     /* To exit from Saved Times*/
  STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_GPIO); /* To Reset Chrono after 2s */

  /* Initialize LEDs mounted on STM8L1528-EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);

  STM_EVAL_LEDOn(LED1);

  /* wait 1 second */
  Delay_Seconds(1);

  STM_EVAL_LEDOn(LED2);

  /* wait 1 second */
  Delay_Seconds(1);

  STM_EVAL_LEDOn(LED3);

  /* wait 1 second */
  Delay_Seconds(1);

  STM_EVAL_LEDOn(LED4);

  /* wait 1 second */
  Delay_Seconds(1);

  STM_EVAL_LEDOff(LED1);
  STM_EVAL_LEDOff(LED2);
  STM_EVAL_LEDOff(LED3);
  STM_EVAL_LEDOff(LED4);

  LCD_SetCursorPos(LCD_LINE1, 0);
  LCD_Print(DEFAULTDISPLAY);
}
Пример #11
0
/**
  * @brief Example  main entry point.
  * @param  None
  * @retval None
  */
void main(void)
{
    uint8_t state = 0x00;

    /* GPIO Configuration  -----------------------------------------------------*/
    GPIO_Config();

    /* Configure LCD mounted on STM8-128 EVAL board ----------------------------*/
    LCD_Config();

    /* Clock configuration -----------------------------------------------------*/
    CLK_Config();

    enableInterrupts();

    while (1)
    {
        while(state == OscillatorStatus)
        {}
        state = OscillatorStatus; /* Update the selected master clock oscillator */

        /* joystick right */
        if(OscillatorStatus == 0x00)
        {
            CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);

            /* Print on LCD line2*/
            LCD_SetCursorPos(LCD_LINE2, 0);
            LCD_Print("   CLK = HSI    ");
        }

        /* joystick up */
        if(OscillatorStatus == 0x01)
        {
            CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSE, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);

            /* Print on LCD line2*/
            LCD_SetCursorPos(LCD_LINE2, 0);
            LCD_Print("   CLK = HSE    ");
        }

        /* joystick down */
        if(OscillatorStatus == 0x02)
        {
            CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_LSI, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);

            /* Print on LCD line2*/
            LCD_SetCursorPos(LCD_LINE2, 0);
            LCD_Print("   CLK = LSI    ");
        }
    }
}
Пример #12
0
/**
  * @brief  Reports the name of the source file and the source line number
  *   where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
    LCD_SetCursorPos(LCD_LINE1, 0);
    LCD_Print("      ERR       ");
    LCD_SetCursorPos(LCD_LINE2, 0);
    LCD_Print("     ASSERT     ");
  }
}
Пример #13
0
/**
  * @brief  Configure the LCD available on the evaluation board
  * @param  None
  * @retval None
  */
void LCD_Config(void)
{
    /* Init the Eval board LCD */
    STM8S_EVAL_LCD_Init();

    /* Clear LCD */
    LCD_Clear();

    /* Display the welcome text on LCD */
    LCD_SetCursorPos(LCD_LINE1, 0);
    LCD_Print("   STM8S CAN    ");
    /* Print "Press Key" on LCD line2*/
    LCD_SetCursorPos(LCD_LINE2, 0);
    LCD_Print("   Press Key    ");
}
Пример #14
0
/**
  * @brief  Configure the LCD available on the evaluation board
  * @param  None
  * @retval None
  */
static void LCD_Config(void)
{
    /* Init the Eval board LCD */
    STM8S_EVAL_LCD_Init();

    /* Clear LCD */
    LCD_Clear();

    /* Print on LCD line1*/
    LCD_SetCursorPos(LCD_LINE1, 0);
    LCD_Print("Clock Selection");
    /* Print on LCD line2*/
    LCD_SetCursorPos(LCD_LINE2, 0);
    LCD_Print("  Use joystick  ");
}
Пример #15
0
/**
  * @brief  Display the current RV voltage on the LCD.
  * @param  voltage: specifies the voltage to display.
  * @retval None
  */
void ShowVoltage(uint16_t Voltage)
{
    uint8_t voltage1000 = 0;
    uint8_t voltage100 = 0;
    uint8_t voltage10 = 0;


    /* Thousands voltage value*/
    voltage1000 = (uint8_t)(Voltage / 1000);
    /* Hundreds voltage value */
    voltage100 = (uint8_t)((Voltage % 1000) / 100);
    /* Tens voltage value */
    voltage10 = (uint8_t)((Voltage % 100 ) / 10);


    /* Fill the LCDString fields with the current Voltage */
    LCDString[3] = (uint8_t)((uint8_t)(voltage1000) + ASCII_NUM_0);
    LCDString[5] = (uint8_t)((uint8_t)(voltage100) + ASCII_NUM_0);
    LCDString[6] = (uint8_t)((uint8_t)(voltage10) + ASCII_NUM_0);

    /* Print the RV Voltage  on the LCD line2 */
    /* Print "RV ADC Voltage" on LCD line1*/
    LCD_SetCursorPos(LCD_LINE2, 0);
    LCD_Print(LCDString);

}
Пример #16
0
void main(void) {         
	Sys_Init();	//All init function
	putchar(' ');
	XBR0_Init();
	ADC_Init();    
	Port_Init();     
	PCA_Init();     
	SMB_Init();	//end the init function
	     
	lcd_clear();	
	lcd_print("initializing\r\n");
		

	PCA0CP2 = 0xFFFF - MOTOR_NEUT;
	PCA0CPL0 = 0xFFFF - PW_CENTER;
   	PCA0CPH0 = (0xFFFF - PW_CENTER) >> 8;
	while (n_Counts < 50);	//pause for a second?

	start_run();
	while (1) { 
		while(SS){            // if the slideswitch is off          
			slide_switch_off();
		}///end slide switch off
		while(!SS)	//while the slideswitch is on
		{
			Heading();
			Ranger();
			LCD_Print();	//print all values on the lcd
			printf("\n\r Range:%d  Compass:%d  PW:%d", range, heading, PW);	//print these on the secure crt for data aquisition
		}
	}	//end of the infinite while loop
}//end of the main function
Пример #17
0
void SavedTime_Show(uint8_t Line, uint8_t SavedTimeId)
{
  mstime = 1000 - ((uint32_t)((uint32_t)SaveSubsecond[SavedTimeId] * 1000) / (uint32_t)RTC_InitStr.RTC_SynchPrediv);
  ms100 = (uint8_t)(mstime / 100);
  ms10  = (uint8_t)((mstime % 100 ) / 10);
  ms1  =  (uint8_t)(mstime % 10);

  LCDStringTime[0] = (uint8_t)((uint8_t)( SavedTimeId + 1 + ASCII_NUM_0));
  LCDStringTime[1] = '-';

  /* Fill the LCDString fields with the current Time*/
  LCDStringTime[SHOW_POINT] = (uint8_t)(((uint8_t)(RTC_SaveTimeStr[SavedTimeId].RTC_Hours & 0xF0) >> 4) + ASCII_NUM_0);
  LCDStringTime[SHOW_POINT+1] = (uint8_t)(((uint8_t)(RTC_SaveTimeStr[SavedTimeId].RTC_Hours & 0x0F)) + ASCII_NUM_0);

  LCDStringTime[SHOW_POINT+3] = (uint8_t)(((uint8_t)(RTC_SaveTimeStr[SavedTimeId].RTC_Minutes & 0xF0) >> 4) + ASCII_NUM_0);
  LCDStringTime[SHOW_POINT+4] = (uint8_t)(((uint8_t)(RTC_SaveTimeStr[SavedTimeId].RTC_Minutes & 0x0F)) + (uint8_t)ASCII_NUM_0);

  LCDStringTime[SHOW_POINT+6] = (uint8_t)(((uint8_t)(RTC_SaveTimeStr[SavedTimeId].RTC_Seconds & 0xF0) >> 4) + ASCII_NUM_0);
  LCDStringTime[SHOW_POINT+7] = (uint8_t)(((uint8_t)(RTC_SaveTimeStr[SavedTimeId].RTC_Seconds & 0x0F)) + ASCII_NUM_0);

  LCDStringTime[SHOW_POINT+9] = (uint8_t)((uint8_t)(ms100 + ASCII_NUM_0));
  LCDStringTime[SHOW_POINT+10] = (uint8_t)((uint8_t)(ms10 + ASCII_NUM_0));
  LCDStringTime[SHOW_POINT+11] = (uint8_t)((uint8_t)(ms1 + ASCII_NUM_0));

  /* Print the Time Calendar on the LCD*/
  LCD_SetCursorPos(Line, 0);
  LCD_Print((uint8_t *)LCDStringTime);

  /* Restore String */
  LCDStringTime[0] = ' ';
  LCDStringTime[1] = ' ';
}
Пример #18
0
/**
  * @brief  Display the current voltage on the LCD.
  * @param  voltage: specifies the voltage to display.
  * @retval None
  */
void ShowVoltages(uint32_t PotVoltage, uint32_t BNCVoltage )
{
  uint8_t voltage1000 = 0;
  uint8_t voltage100 = 0;
  uint8_t voltage10 = 0;

  /* Thousands voltage value*/
  voltage1000 = (uint8_t)(PotVoltage / 1000);
  /* Hundreds voltage value */
  voltage100 = (uint8_t)((PotVoltage % 1000) / 100);
  /* Tens voltage value */
  voltage10 = (uint8_t)((PotVoltage % 100 ) / 10);


  /* Fill the LCDString fields with the current Voltage */
  LCDString[1]  = (uint8_t)((uint8_t)(voltage1000) + ASCII_NUM_0);
  LCDString[3] = (uint8_t)((uint8_t)(voltage100) + ASCII_NUM_0);
  LCDString[4] = (uint8_t)((uint8_t)(voltage10) + ASCII_NUM_0);

  /* Thousands voltage value*/
  voltage1000 = (uint8_t)(BNCVoltage / 1000);
  /* Hundreds voltage value */
  voltage100 = (uint8_t)((BNCVoltage % 1000) / 100);
  /* Tens voltage value */
  voltage10 = (uint8_t)((BNCVoltage % 100 ) / 10);

  LCDString[9]  = (uint8_t)((uint8_t)(voltage1000) + ASCII_NUM_0);
  LCDString[11] = (uint8_t)((uint8_t)(voltage100) + ASCII_NUM_0);
  LCDString[12] = (uint8_t)((uint8_t)(voltage10) + ASCII_NUM_0);

  /* Print the Voltage on the LCD*/
  LCD_SetCursorPos(LCD_LINE2, 0);
  LCD_Print(LCDString);
}
Пример #19
0
void Time_Show(uint8_t Line, uint8_t pos)
{
  /* Wait until the calendar is synchronized */
  while (RTC_WaitForSynchro() != SUCCESS);

  /* Get the current subsecond Time*/
  Subsecondvalue = RTC_GetSubSecond();

  /* Wait until the calendar is synchronized */
  while (RTC_WaitForSynchro() != SUCCESS);
  /* Get the current Time*/
  RTC_GetTime(RTC_Format_BCD, &RTC_TimeStr);

  Mstime = 999 - ((uint32_t)((uint32_t)Subsecondvalue * 1000) / (uint32_t)RTC_InitStr.RTC_SynchPrediv);

  Ms100 = (uint8_t)(Mstime / 100);
  Ms10  = (uint8_t)((Mstime % 100 ) / 10);
  Ms1  =  (uint8_t)(Mstime % 10);


  /* Fill the LCDString fields with the current Time : second and milliseconds*/

  LCDStringTime[pos] = (uint8_t)(((uint8_t)(RTC_TimeStr.RTC_Seconds & 0xF0) >> 4) + ASCII_NUM_0);
  LCDStringTime[pos+1] = (uint8_t)(((uint8_t)(RTC_TimeStr.RTC_Seconds & 0x0F)) + ASCII_NUM_0);

  LCDStringTime[pos+3] = (uint8_t)((uint8_t)(Ms100 + ASCII_NUM_0));
  LCDStringTime[pos+4] = (uint8_t)((uint8_t)(Ms10 + ASCII_NUM_0));
  LCDStringTime[pos+5] = (uint8_t)((uint8_t)(Ms1 + ASCII_NUM_0));

  /* Print the Time Calendar on the LCD*/
  LCD_SetCursorPos(Line, 0);
  LCD_Print((uint8_t*)LCDStringTime);
}
void main(void) {         
	Sys_Init();	//All init function
	putchar(' ');
	XBR0_Init();
	ADC_Init();    
	Port_Init();     
	PCA_Init();     
	SMB_Init();	//end the init function
	     
	lcd_clear();	
	lcd_print("initializing\r\n");
	printf("\n\n\n\rinitalizing");

	PCA0CP2 = 0xFFFF - MOTOR_NEUT;//set all to neutural
	PCA0CPL0 = 0xFFFF - PW_CENTER;
   	PCA0CPH0 = (0xFFFF - PW_CENTER) >> 8;

	pause();	//pause for a second?
	start_run();

	while (1) { 
		while(SS){            // if the slideswitch is off          
			slide_switch_off();
		}///end slide switch off
		while(!SS){	//while the slideswitch is on
			Heading();
			Ranger();
			LCD_Print();	//print all values on the lcd
			printf("\n\rRange:%d Compass:%d dh: %d, mPW: %d, sPW %d, batt:%d, obst: %d", range, heading, desired_heading, MOTOR_PW_AND_STEER_PW, STEER_PW, battery, near_obstical);	//print these on the secure crt for data aquisition
			//printf("\n\r Range:%d Compass:%d dh: %d, mPW: %d, sPW %d, obst: %d", range, heading, desired_heading, MOTOR_PW_AND_STEER_PW, STEER_PW, near_obstical);	//print these on the secure crt for data aquisition
		}//end slide switch on
	}	//end of the infinite while loop
}//end of the main function
Пример #21
0
/**
  * @brief  Main routine. 
  * @param  None.
  * @return None.
  */
int32_t main(void)                 
{
    SYS_UnlockReg();
    SYS->P5_MFP = (SYS->P5_MFP & 0x00FFFCFC) | 0x03;  /* P5.1 -> XTAL2, P5.0 -> XTAL1 */
    CLK->PWRCON = CLK_PWRCON_XTL12M | 4 | 8 ;

    SYS_Init();
  
    /* SPI test */   
    LCD_Init();   
    LCD_EnableBackLight();
    LCD_ClearScreen();
    LCD_Print(0, "Welcome! Nuvoton");
    LCD_Print(1, "This is LB board");
    LCD_Print(2, "Mini51");
    LCD_Print(3, "TEST"); 
  
    // backlight control pin P5.4
    GPIO_SetMode(P5,1<<4,GPIO_PMD_OUTPUT);
  
    /* INT button triggers P3.2 */
    GPIO_SetMode(P3,(1<<2),GPIO_PMD_OPEN_DRAIN);  
    GPIO_EnableInt(P3, 2, GPIO_INT_FALLING);
    NVIC_EnableIRQ(EINT0_IRQn);
  
    /* Enable interrupt de-bounce function and select de-bounce sampling cycle time */
    GPIO_SET_DEBOUNCE_TIME(GPIO_DBNCECON_DBCLKSRC_HCLK,GPIO_DBNCECON_DBCLKSEL_16);  
    GPIO_ENABLE_DEBOUNCE(P3,1<<2);  

    /* Reset and stop TIMER0, TIMER1 counting first */
    TIMER1->TCSR = TIMER_TCSR_CRST_Msk;
  
    /* Enable TIMER0, TIMER1, NVIC */
    NVIC_EnableIRQ(TMR1_IRQn);
    
    /* To Configure TCMPR values based on Timer clock source and pre-scale value */
    TIMER_SET_PRESCALE_VALUE(TIMER1,0);
  
    
    /* Start TIMER1 counting and setting*/
    TIMER_Open(TIMER1,TIMER_PERIODIC_MODE,SystemCoreClock/1000); 
    
    TIMER_EnableInt(TIMER1);

    while(1) ;    // loop forever
    
}
Пример #22
0
void Disp_IntroLcdMsgs(void){
	LCD_PowerOff();
	LCD_Frame1();			//make good looking frame around LCD
	LCD_Setcursor(1,9);
	LCD_Print("   ");
	LCD_Setcursor(1,10);
	LCD_DataWrite(1);		//prints polltech logo that is stored at location 1
	LCD_Setcursor(2,2);
	LCD_Print("     Polltech     ");
	LCD_Setcursor(3,2);
	LCD_Print("    Instruments   ");
	LCD_PowerOn();
	delay_sec(1);
	LCD_Setcursor(2,2);
	LCD_Print("StackMonitoringKit");
	LCD_Setcursor(3,2);
	LCD_Print(" Model PEM-SMK 20 ");
	
	delay_sec(1);
}
Пример #23
0
/*---------------------------------------------------------------------------------------------------------*/
int32_t main(void)
{

    /* Init system, IP clock and multi-function I/O */
    SYS_Init();

    /* Init UART0 for printf */
    UART0_Init();

    /* Init GPIO P2.0 (output) and P3.2 (EINT0) */
    GPIO_Init();

    /* Init SPI0 and LCD */
    LCD_Init();
    LCD_EnableBackLight();
    LCD_ClearScreen();

    LCD_Print(0, "Boot from LDROM");
    LCD_Print(1, "Press SW_INT   ");

    while (1)
    {
        if (g_u8IsPress)
        {
            g_u8IsPress = FALSE;
            
            /* Switch to boot from APROM */
            SYS_UnlockReg();
            FMC->ISPCON = FMC_ISPCON_BS_APROM;
            _SYS_RESET_CPU();
            while (1);
        }
        else
        {
            /* LED blanking for 1000ms */
            P2->DOUT ^= 1;
            SYS_SysTickDelay(300000);
            SYS_SysTickDelay(200000);
        }
    }
}
Пример #24
0
void EINT0_IRQHandler(void)
{
    P3->ISRC = 1 << 2;

    g_isPress = 1;

    /* Toggle LED */
    P20 = P20 ^ 1;

    printf("EINT0 Interrupt!\n");

    LCD_Print(3, "EINT0 Interrupt!");
}
Пример #25
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
void main(void)
{

   /* CLK configuration -------------------------------------------*/
  CLK_Config(); 

  /* Init the Eval board LCD */
  STM8_EVAL_LCD_Init();

  /* Clear  LCD */
  LCD_Clear();

  /* Print the Voltage on the LCD*/
  LCD_SetCursorPos(LCD_LINE1, 0);
  LCD_Print("  POT      BNC  ");

   /* ADC configuration -------------------------------------------*/
  ADC_Config();

   /* DMA configuration -------------------------------------------*/
  DMA_Config();
    
  /* Enable ADC1 DMA requests*/
  ADC_DMACmd(ADC1, ENABLE);

  /* Start ADC1 Conversion using TIM1 TRGO*/
  ADC_ExternalTrigConfig(ADC1, ADC_ExtEventSelection_Trigger2,
                         ADC_ExtTRGSensitivity_Rising);

  /* Master Mode selection: Update event */
  TIM1_SelectOutputTrigger(TIM1_TRGOSource_Update);

  /* Enable TIM1 */
  TIM1_Cmd(ENABLE);

  /* Enable Interrupts */
  enableInterrupts();

  /* Infinite loop*/
  while (1)
  {
    if (DisplayStatus != DISABLE)
    {
      /* Display Potentiometer RV and BNC voltage values on LCD*/
      ShowVoltages(PotVoltage, BNCVoltage);
      /* Disable displaying voltages on LCD until next DMA Channel0 Transfer complete occurs */
      DisplayStatus = DISABLE;
    }
  }
}
Пример #26
0
/**
  * @brief  Parse Saved Times.
  * @param  None
  * @retval None
  */
void SavedTime_Erase(void)
{
  if ( SaveId != 0)
  {


    LCD_SetCursorPos(LCD_LINE1, 0);
    LCD_Print("Erase Records ?");
    LCD_SetCursorPos(LCD_LINE2, 0);
    LCD_Print("<No        Yes>");

    /* Endless loop */
    while (1)
    {
      /* Check which key is pressed */
      Key = ReadJoystick();

      /* If "RIGHT" pushbutton is pressed */
      if (Key == JOY_RIGHT)
      {
        SaveId = 0;
        Restore_LastDisplay() ;
        /* Exit */
        return ;
      }

      /* If "LEFT" pushbutton is pressed */
      if (Key == JOY_LEFT)
      {
        Restore_LastDisplay() ;
        /* Exit */
        return ;
      }

    }
  }
}
Пример #27
0
/**
  * @brief Display led status and communication direction on the LCD
  * @param Ledstatus the led status
  * @retval None
  */
void LCD_Display(uint8_t Ledstatus)
{
    LCD_SetCursorPos(LCD_LINE2, 0);

    switch((uint8_t)Ledstatus)
    {
    case(0):
        LCD_Print("Sender   LD4 ON ");
        break;

    case(1):
        LCD_Print("Sender   LD3 ON ");
        break;

    case(2):
        LCD_Print("Sender   LD2 ON ");
        break;

    case(3):
        LCD_Print("Sender   LD1 ON ");
        break;

    case(4):
        LCD_Print("Receiver LD4 ON ");
        break;

    case(5):
        LCD_Print("Receiver LD3 ON ");
        break;

    case(6):
        LCD_Print("Receiver LD2 ON ");
        break;

    case(7):
        LCD_Print("Receiver LD1 ON ");
        break;
    }
}
Пример #28
0
/**
  * @brief  Print ST logo on the LCD
  * @param  None
  * @retval None
  */
void PrintLogo(void)
{
  static uint8_t logo_pos = 0x90;
  static int8_t logo_pos_index = 1;

  LCD_SetCursorPos(LCD_LINE2, 0);
  LCD_Print("               ");

  LCD_DisplayLogo(logo_pos);
  logo_pos += logo_pos_index;
  if (logo_pos > 0x95)
  {
    logo_pos -= 2;
    logo_pos_index = -1;
  }
  if (logo_pos < 0x90)
  {
    logo_pos += 2;
    logo_pos_index = 1;
  }
}
Пример #29
0
void lcdprint(void *p)
{
while(1)
{  
   sen_dat[1]=MEGA8_ADCRead(9);		   //IR 3
   sen_dat[0]=MEGA8_ADCRead(6);	  	   //IR 1	
   sen_dat[2]=MEGA8_ADCRead(15);	   //IR	5
   sen_dat[4]=MEGA8_ADCRead(5);	   	   //IR	6
   sen_dat[3]=MEGA8_ADCRead(4);		   //IR 7 
   sen_dat[5]=MEGA8_ADCRead(0);	       //IR	8
   ADC_Data[0] = AD0_Conversion(6);	   //IR 2
   ADC_Data[2] = AD0_Conversion(7);    //IR 4
   LCD_Print(1,5,ADC_Data[2],3);    //IR 4
   LCD_Print(1,9,sen_dat[1],3);     //IR 3
   LCD_Print(1,13,ADC_Data[0],3);   //IR 2 
   LCD_Print(2,1,sen_dat[2],3);	    //IR 5
   LCD_Print(2,5,sen_dat[4],3);		//IR 6
   LCD_Print(2,9,sen_dat[3],3);	    //IR 7
   LCD_Print(2,13,sen_dat[5],3);	//IR 8
   LCD_Print(1,1,sen_dat[0],3);    	//IR 1
  
 }
}
Пример #30
0
void Time_Show(uint8_t Line)
{
  /* Wait until the calendar is synchronized */
  while (RTC_WaitForSynchro() != SUCCESS);

  /* Get the current subsecond Time*/
  subsecondvalue = RTC_GetSubSecond();

  /* Wait until the calendar is synchronized */
  while (RTC_WaitForSynchro() != SUCCESS);

  /* Get the current Time*/
  RTC_GetTime(RTC_Format_BCD, &RTC_TimeStr);

  mstime = 1000 - ((uint32_t)((uint32_t)subsecondvalue * 1000) / (uint32_t)RTC_InitStr.RTC_SynchPrediv);


  ms100 = (uint8_t)(mstime / 100);
  ms10  = (uint8_t)((mstime % 100 ) / 10);
  ms1  =  (uint8_t)(mstime % 10);


  /* Fill the LCDString fields with the current Time*/
  LCDStringTime[SHOW_POINT] = (uint8_t)(((uint8_t)(RTC_TimeStr.RTC_Hours & 0xF0) >> 4) + ASCII_NUM_0);
  LCDStringTime[SHOW_POINT+1] = (uint8_t)(((uint8_t)(RTC_TimeStr.RTC_Hours & 0x0F)) + ASCII_NUM_0);

  LCDStringTime[SHOW_POINT+3] = (uint8_t)(((uint8_t)(RTC_TimeStr.RTC_Minutes & 0xF0) >> 4) + ASCII_NUM_0);
  LCDStringTime[SHOW_POINT+4] = (uint8_t)(((uint8_t)(RTC_TimeStr.RTC_Minutes & 0x0F)) + (uint8_t)ASCII_NUM_0);

  LCDStringTime[SHOW_POINT+6] = (uint8_t)(((uint8_t)(RTC_TimeStr.RTC_Seconds & 0xF0) >> 4) + ASCII_NUM_0);
  LCDStringTime[SHOW_POINT+7] = (uint8_t)(((uint8_t)(RTC_TimeStr.RTC_Seconds & 0x0F)) + ASCII_NUM_0);

  LCDStringTime[SHOW_POINT+9] = (uint8_t)((uint8_t)(ms100 + ASCII_NUM_0));
  LCDStringTime[SHOW_POINT+10] = (uint8_t)((uint8_t)(ms10 + ASCII_NUM_0));
  LCDStringTime[SHOW_POINT+11] = (uint8_t)((uint8_t)(ms1 + ASCII_NUM_0));

  /* Print the Time Calendar on the LCD*/
  LCD_SetCursorPos(Line, 0);
  LCD_Print((uint8_t *)LCDStringTime);
}