Ejemplo n.º 1
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */ 
  
  /* LCD Display init  */
  Display_Init();
  
  /* Initialize LED4 */
  STM_EVAL_LEDInit(LED4);
  
  /* Configure ADC channel 11 */
  ADC_Config();
  
  /* Infinite loop */
  while (1)
  {   
    /* Get ADC1 converted data */
    ADC1ConvertedValue =ADC_GetConversionValue(ADC1);
    
    /* Compute the voltage */
    ADC1ConvertedVoltage = (ADC1ConvertedValue *3300)/0xFFF;
    
    
    /* Display converted data on the LCD */
    Display();
  }
}
Ejemplo n.º 2
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40xx.s/startup_stm32f427x.s) before to branch to 
       application main. 
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */
  
#ifdef USE_LCD
  /* LCD Display init  */
  Display_Init();
#endif /* USE_LCD */

  /* ADC1 Channel Vbat configuration */
  ADC_Config();
 
  /* Start ADC1 Software Conversion */ 
  ADC_SoftwareStartConv(ADC1);

  while (1)
  {
#ifdef USE_LCD
  /* Display ADC converted value on LCD */
    Display();
#endif /* USE_LCD */
  }
}
Ejemplo n.º 3
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
  this is done through SystemInit() function which is called from startup
  file (startup_stm32f429_439xx.s) before to branch to application main.
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32f4xx.c file
  */
#ifdef USE_LCD 
  /* LCD Display init  */
  Display_Init();
#endif /* USE_LCD */
  
  /* ADC3 configuration *******************************************************/
  /*  - Enable peripheral clocks                                              */
  /*  - DMA2_Stream0 channel2 configuration                                   */
  /*  - Configure ADC Channel13 pin as analog input                           */
  /*  - Configure ADC3 Channel13                                              */
  ADC3_CH13_DMA_Config();
  
  /* Start ADC3 Software Conversion */ 
  ADC_SoftwareStartConv(ADC3);
  
  while (1)
  {
    /* convert the ADC value (from 0 to 0xFFF) to a voltage value (from 0V to 3.0V)*/
    uwADC3ConvertedVoltage = uhADC3ConvertedValue *3000/0xFFF;
    /* Display ADCs converted values on LCD */
#ifdef USE_LCD 
    Display();
#endif /* USE_LCD */
  }
}
Ejemplo n.º 4
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */ 

  /* LCD Display init  */
  Display_Init();
   
  /* ADC1 and DMA configuration */
  ADC1_DMA_Config();

  /* Infinite loop */
  while (1)
  {
    /* Test DMA1 TC flag */
    while((DMA_GetFlagStatus(DMA1_FLAG_TC1)) == RESET ); 
    
    /* Clear DMA TC flag */
    DMA_ClearFlag(DMA1_FLAG_TC1);
    
    /* Display converted data on the LCD */
    Display();
  }
}
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */ 

  /* ADC Configuration */
  ADC_Config();
  /* LCD Display init  */
  Display_Init();
    
  /* Infinite loop */
  while (1)
  {
    /* Test EOC flag */
    while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
    
    /* Get ADC1 converted data */
    ADC1ConvertedValue =ADC_GetConversionValue(ADC1);
    
    /* Compute the voltage */
    ADC1ConvertedVoltage = (ADC1ConvertedValue *3300)/0xFFF;
    
    /* Display converted data on the LCD */
    Display();
  }
}
Ejemplo n.º 6
0
char *JadEdit_Init(int val, void *data)
{
    int editpos;

    Display_Init(&MazeInpCamera);

    MazeFile_LoadInitialData();		/* Load the initial graphics data  */

    Animated_Init();			/* Now init the animation stuff */
    
    /* Get the mazemap */
    Maze_SetMap(MazeMap.left, MazeMap.top, 32, 32, MazeMap.map);
    /* Set up the display */
    Maze_SetDisplayList(Display_TileList,&MazeMap.posx, &MazeMap.posy);

    /* And at last the Edit-Cursor */
    editpos = (MazeMap.posy * VIEWMESHSIZE) + MazeMap.posx;
    Display_TileList[editpos].flags  |= TILE_ISEDIT;
    Display_TileList[editpos].direction = MazeMap.side;	/* Which Side to put */

    /* Set the textclock */
    secondclock = JadEdit_ClockFunction(0, 1000, JAD_CLOCKNEW);

    return JADINPUT_CAPTION;
}
Ejemplo n.º 7
0
/**
 * Initializes the system.
 * System control registers must be unlocked.
 */
void SYS_Init() {
	// TODO: why is SYS_UnlockReg() needed? Should be already unlocked.
	SYS_UnlockReg();

	// HIRC clock (internal RC 22.1184MHz)
	CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);
	CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);
	
	// HCLK clock source: HIRC, HCLK source divider: 1
	CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKDIV0_HCLK(1));
	
	// HXT clock (external XTAL 12MHz)
	CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk);
	CLK_WaitClockReady(CLK_STATUS_HXTSTB_Msk);
	
	// Enable 72MHz optimization
	FMC_EnableFreqOptimizeMode(FMC_FTCTL_OPTIMIZE_72MHZ);
	
	// Core clock: PLL
	CLK_SetCoreClock(PLL_CLOCK);
	CLK_WaitClockReady(CLK_STATUS_PLLSTB_Msk);
	
	// SPI0 clock: PCLK0
	CLK_SetModuleClock(SPI0_MODULE, CLK_CLKSEL2_SPI0SEL_PCLK0, 0);
	CLK_EnableModuleClock(SPI0_MODULE);
	
	// TMR0 clock: HXT
	CLK_SetModuleClock(TMR0_MODULE, CLK_CLKSEL1_TMR0SEL_HXT, 0);
	CLK_EnableModuleClock(TMR0_MODULE);

	// USBD clock
	CLK_SetModuleClock(USBD_MODULE, 0, CLK_CLKDIV0_USB(3));
	CLK_EnableModuleClock(USBD_MODULE);
	
	// Enable USB 3.3V LDO
	SYS->USBPHY = SYS_USBPHY_LDO33EN_Msk;

	// EADC clock: 72Mhz / 8
	CLK_SetModuleClock(EADC_MODULE, 0, CLK_CLKDIV0_EADC(8));
	CLK_EnableModuleClock(EADC_MODULE);
	
	// Enable BOD (reset, 2.2V)
	SYS_EnableBOD(SYS_BODCTL_BOD_RST_EN, SYS_BODCTL_BODVL_2_2V);
	
	// Update system core clock
	SystemCoreClockUpdate();

	// Initialize dataflash
	Dataflash_Init();

	// Initialize I/O
	Display_SetupSPI();
	Button_Init();
	ADC_Init();

	// Initialize display
	Display_Init();
}
Ejemplo n.º 8
0
/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART2_UART_Init();
  MX_I2C1_Init();
  MX_TIM2_Init();
  /* USER CODE BEGIN 2 */

  Display_Init();
  CircularBuff_Init();
  DisplayUpdater_Init();

  HAL_TIM_Base_Start_IT(&htim2);      //start timer2 in interrupt mode.

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */

	__WFI(); // CPU sleep
  }
  /* USER CODE END 3 */
}
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */

	//Initialize the touchscreen
	TSC_Init();

#ifdef PRINT_ON_LCD
  /* LCD Display init  */
  Display_Init();
#endif

  /* ADC3 configuration *******************************************************/
  /*  - Enable peripheral clocks                                              */
  /*  - DMA2_Stream0 channel2 configuration                                   */
  /*  - Configure ADC Channel3 pin as analog input                            */
  /*  - Configure ADC3 Channel3                                               */
  ADC3_CH3_DMA_Config();

  /* Start ADC3 Software Conversion */ 
  ADC_SoftwareStartConv(ADC3);

  while (1)
  {
  	int x, y;
	char szTemp[64];

	if (TSC_TouchDet()) {           /* Show touch screen activity         */
		TP_GetAdXY(&x, &y);
	}
	else {
	  x = 0;
	  y = 0;
	}
	sprintf(szTemp, "X:%04d Y:%04d       ", x, y);
	LCD_DisplayStringLine(LINE(5), (uint8_t *)szTemp);

    ADC3ConvertedVoltage = ADC3ConvertedValue *3300/0xFFF;
#ifdef PRINT_ON_LCD
  /* Display ADC3 converted value on LCD */
    Display();
#endif
  }
}
Ejemplo n.º 10
0
void HAL_LCD_initDisplay(void)
{
	GPIO_Init();
	usleep(100000);
	HAL_LCD_enableDisplay();
	usleep(100000);
	SPI_Init();
	usleep(100000);
	PWM_Init();
	usleep(100000);

	PWM_Run();

	Display_Init();
}
Ejemplo n.º 11
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
 uint32_t random32bit = 0;
 uint32_t counter = 0;

  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)
       before to branch to application main. 
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */

  /* Display init (LCD or/and USART)*/
  Display_Init();
  
  /* Key Button configuration */
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO);
  
  /* RNG configuration */
  RNG_Config();

  while (1)
  {
    /* Wait until Key button is pressed */
    while(STM_EVAL_PBGetState(BUTTON_KEY) != RESET)
    {
    }
    /* Loop while Key button is maintained pressed */
    while(STM_EVAL_PBGetState(BUTTON_KEY) == RESET)
    {
    }

    for(counter = 0; counter < 8; counter++)
    {
      /* Wait until one RNG number is ready */
      while(RNG_GetFlagStatus(RNG_FLAG_DRDY)== RESET)
      {
      }

      /* Get a 32bit Random number */       
      random32bit = RNG_GetRandomNumber();

      /* Display the Random number value on the LCD or/and USART */
      Display(random32bit, counter+1);
    }
  }
}
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */ 

  /* LCD Display init  */
  Display_Init();
  
  /* Key button and Tamper button configuration */
#ifdef USE_STM320518_EVAL
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO);
#else
  STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_GPIO);
#endif /* USE_STM320518_EVAL */  

  /*  Configures LED1 GPIO */
  STM_EVAL_LEDInit(LED1);
  
  /* Configure ADC1  */
  ADC_Config();

  /* Configure TIM3  */
  TIM_Config();  

  /* Infinite loop */
  while (1)
  {
    /* Press Key button for STM320518_EVAL and Tamper button for STM32072B_EVAL  to get the converted data */
#ifdef USE_STM320518_EVAL
    while(STM_EVAL_PBGetState(BUTTON_KEY) != RESET);
#else
    while(STM_EVAL_PBGetState(BUTTON_TAMPER) != RESET);
#endif /* USE_STM320518_EVAL */ 
    
    /* Get ADC1 converted data */
    ADC1ConvertedValue =ADC_GetConversionValue(ADC1);
    
    /* Compute the voltage */
    ADC1ConvertedVoltage = (ADC1ConvertedValue *3300)/0xFFF;
    
    /* Display converted data on the LCD */
    Display();
  }
}
Ejemplo n.º 13
0
/*
配置系统的顺序
CPU 内部、底层硬件
外部接口
外部硬件(按键、显示)
读取外部配置数据
传感器系统(RTC 时钟)
操作系统
任务
驻留任务(如:传感器读取、恒温箱温控、掉电时间记录)
采样任务
监控任务
*/
__task	int32_t	main( void )
{

	BIOS_Init();
	beep();
	RTOS_Init();		//	尽早执行

	ConfigureLoad();	//	先确定仪器型号
	CalibrateLoad();	//	读传感器前执行,	远程存储器中的参数,应等通讯初始化后再读。
	SampleSetLoad();	//	恢复采样前执行

	Display_Init();
	DisplaySetGrayVolt( Configure.DisplayGray * 0.022f );
	DisplaySetLight( Configure.DisplayLight );
	DisplaySetTimeout( Configure.TimeoutLight );
	Keyboard_Init();	//	配置完背光超时时间后再初始化

	RTC_Init();			//	为避免启动过程中时钟失败造成的假死现象,放在显示初始化之后
	SD_Init();				//	SD卡读写初始化,放在开关机存取之前
	PowerLog_Init();	//	开关机存取,时间初始化之后

	SENSOR_Local_Init();
	delay( 1000u );		//配合下位机初始化	<注意!要进行下位机测试来确定参数!>300
	
	Animation();		//	开机动画
	delay( 1600u );

	ShowEdition();	//	确定型号之后,显示初始化之后
	delay( 1400u );

	SENSOR_Remote_Init();		//	modbus通信初始化
	delay( 100u );

	HCBox_Init();
	delay( 100u );
	
	Sampler_BootResume();	//	时间配置完成之后,设置参数读入之后。
	delay( 100u );
	
	SamplerTypeSelect();
	delay( 100u );

	for(;;)
	{
		menu_Main();	//	转主菜单
	}
}
Ejemplo n.º 14
0
int main(void){
	
  PLL_Init(Bus80MHz);                   // 80 MHz
	DisableInterrupts();
  //ADC0_InitSWTriggerSeq3_Ch9();         // allow time to finish activating
  Timer0A_Init100HzInt();               // set up Timer0A for 100 Hz interrupts
	Timer1_Init();
	Display_Init();						//initialize display
	Timer2_Init1Hz();		
	PortF_Init(); //initialize portf with onboard switches
	PortE_Init(); // initialize port e as breadboard switches.
	
  EnableInterrupts();

  while(1){

	}
}
Ejemplo n.º 15
0
void main() {
  Display_Init();
  MCU_Init();
  #ifdef INIT_BLE
  BLE_Init();
  delay_ms(2000);
  #else
  RN_WAKE = 1;
  wait_response("CMD");
  #endif
  DrawFrame();
  InitTimer2();
  while(1)
  {
    if(data_ready)
    {
      //If characteristic is configured as write
      //received messages come here
      Display_Message();
      reset_buff();
    }
    else
    {
       //Test: every 5sec increase baterry level (0 to 100%)
       //and send value via Bluetooth Low Energy
       if (tmr_flg)
       {
          batt_level++;
          if(batt_level > 100)
          {
            batt_level = 0;
          }
          Display_BatteryLevel();
          if(RN_CONN)
          { //send battery level value if BLE connected
            shorttohex(batt_level, batt_level_txt);
            ltrim(batt_level_txt);
            ble2_write_server_characteristic_value_via_UUID("2A19",batt_level_txt);
          }
          tmr_flg = 0;
       }
    }
  }
}
Ejemplo n.º 16
0
/*
配置系统的顺序
CPU 内部、底层硬件
外部接口
外部硬件(按键、显示)
读取外部配置数据
传感器系统(RTC 时钟)
操作系统
任务
驻留任务(如:传感器读取、恒温箱温控、掉电时间记录)
采样任务
监控任务
*/
__task	int32_t	main( void )
{

	BIOS_Init();
	beep();
	RTOS_Init();		  //	尽早执行
		
	EditionSelsct();
	ConfigureLoad();	//	先确定仪器型号
	CalibrateLoad();	//	读传感器前执行,	远程存储器中的参数,应等通讯初始化后再读。
	SampleSetLoad();	//	恢复采样前执行
	
	Display_Init();
	DisplaySetGrayVolt( Configure.DisplayGray * 0.01f );
	DisplaySetLight( Configure.DisplayLight );
	DisplaySetTimeout( Configure.TimeoutLight );
	Keyboard_Init();	//	配置完背光超时时间后再初始化。

	ShowEdition();		//	版本显示 确定型号之后,显示初始化之后	
	SENSOR_Local_Init();	//	本地传感器读取以及液晶灰度调节
	
	RTC_Init();			  //	为避免启动过程中时钟失败造成的假死现象,放在显示初始化之后
	
	SD_Init();				//	SD卡读写初始化,放在开关机存取之前
	delay( 500u );
	PowerLog_Init();	//	开关机存取,时间和SD卡初始化之后
	
	delay( 2000u );		//  配合下位机初始化
	SENSOR_Remote_Init();		//	modbus通信初始化

	HCBox_Init();
	delay( 500u );
	
	Sampler_BootResume();	  //	时间配置完成之后,设置参数读入之后。
	delay( 1500u );
	
	SamplerSelect = Q_ALL;	//	初始化当前采样器为不合理的值,进行一次切换,切换到第一个合理的值。
	SamplerTypeSwitch();
	for(;;)
	{
		menu_Main();	        //	转主菜单
	}
}
Ejemplo n.º 17
0
void main (void){
  timer= newObj(Timer,(ulong)500); 
  
 /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
 /*** End of Processor Expert internal initialization.                    ***/
  
  Teclas_Init();
  Display_Init(); // Inicializacion del display
  Grabacion_Init();
  
  newAllocObj(&mainThread,ThreadAdjuntable);
  cap=GET_INSTANCE();
  #ifdef _ENTRADA_SIMULADA
  CapturadorSimulado_setMicroSegundos(cap,100000000);
  CapturadorSimulado_setPulsos(cap,2);
  #endif
  {
    void * adjuntador= ThreadAdjuntable_getAdjuntador(&mainThread);
    newAllocObj(&sensorRpm,SensorRpm,adjuntador,1000,cap,&config,"SEn rPM");
    deleteObj(&adjuntador);
  }
 	
 	  														 
  for(;;){
    WDog1_Clear();
    
    
    
    if(Timer_isfinish(timer)){
      Timer_Restart(timer);
      _GetterPrint(&sensorRpm,1);
    //  Pasar_Numero(Capturador_getMicroSegundos(cap)/1000,0,0);
    //  Pasar_Numero(Capturador_getPulsos(cap),1,0);
     // CapturadorSimulado_setPulsos(cap,CapturadorSimulado_getPulsos(cap)+1);
    }

    //Eventos
    MethodContainer_Execute(&mainThread);
  }
}
Ejemplo n.º 18
0
void main (void){
  struct Timer * t1=newObj(Timer,(ulong)1000); 
  struct Timer *t2=newObj(Timer,(ulong)4000);
  struct Timer *t3=newObj(Timer,(ulong)6000);
  struct Timer *t4=newObj(Timer,(ulong)8000);
  struct Timer *t5=newObj(Timer,(ulong)10000);
  struct Timer *t6=newObj(Timer,(ulong)12000);
  struct Timer *t7=newObj(Timer,(ulong)18000); 
  int a = 1;
 /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
 /*** End of Processor Expert internal initialization.                    ***/
  Display_Init(); // Inicializacion del display
  PutValLed(1,0);  
  
  
 //lrReg8Bits(TIE, 1);
  /*ComunLeds_SetVal();
  
  for(;;){
    WDog1_Clear();
    Display2_PutVal(a);
   
    if(Timer_isfinish(t1)){
      a<<=1;
      Timer_Restart(t1);
      if(a==0)
        a=1;
    }
  //  clrReg8Bits(DDRA, DDRA_BIT0_MASK);
    setReg8Bits(PORTA,0);
    bits5ULN_PutVal(0);
  }
  
    */
    
  for(;;){
    WDog1_Clear();
    if(t1 && Timer_isfinish(t1)){
      PasarASCII("Ok88",0); //texto fijo
      deleteObj(&t1);
    }
    if(t2 &&Timer_isfinish(t2)){
      deleteObj(&t2);
      PasarASCII("P.8o.8",1);  //texto fijo con punto
    }
    if(t3 &&Timer_isfinish(t3)){
      deleteObj(&t3);
      Pasar_Numero(2568,1,0);   //paso numero de 4 cifras
    }
    if(t4 &&Timer_isfinish(t4)){
      deleteObj(&t4);
      Pasar_Numero(25681,0,1);   //paso numero de 5 cifras
    }
    if(t5 &&Timer_isfinish(t5)){
      deleteObj(&t5);
       PasarASCII("P.dhAcEL",0);  //texto scroll con punto
    }
    if(t6 &&Timer_isfinish(t6)){
      deleteObj(&t6);
       PasarASCII("V 000.7",1);  //texto scroll con punto
    }
    if(t7 &&Timer_isfinish(t7)){
      deleteObj(&t7);
       PasarASCII("JoniM",1);  //texto scroll con punto
    }  
      
  }
  
}
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */ 

  RTC_TimeTypeDef  RTC_TimeStruct;   
  RTC_TimeTypeDef  RTC_TimeStructureInit;
  RTC_TimeTypeDef  RTC_StampTimeStruct;
  
  /* Configure the external interrupt "RIGHT" and "LEFT" buttons */
  STM_EVAL_PBInit(BUTTON_RIGHT,BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_LEFT,BUTTON_MODE_EXTI);
  
  /* Configure the RTC peripheral by selecting the clock source.*/
  RTC_Config();
  
  /* LCD Display init  */
  Display_Init();
  
  /* Configure the RTC tamper register : To Clear all the Backup data register */
  RTC_TamperConfig();

  /* Initialize time Stucture */
  RTC_TimeStructInit(&RTC_TimeStruct); 

  /* Infinite loop */
  while (1)
  {
    /* Set the LCD Back Color and text size */
    LCD_SetFont(&Font16x24);
    LCD_SetBackColor(White);
    
    /* Check on the event 'start' */
    if(StartEvent != 0x0)
    {  
      /* Get the RTC sub second fraction */
      SecondFraction = (((256 - (uint32_t)RTC_GetSubSecond()) * 1000) / 256);
      
      /* Get the Curent time */
      RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
      
      /* Refresh : Display the curent time and the sub second on the LCD  */
      RTC_Time_Display(37, Black , RTC_Get_Time(SecondFraction , &RTC_TimeStruct));
    }
    else
    {
      /* Re-initialize the Display time on the LCD */
      RTC_Time_InitDisplay();
    }  
    
    /* Left button is pressed */
      if (Button_State == LEFT_ON)
      {
        /* Enable Tamper interrupt */
      RTC_ITConfig(RTC_IT_TAMP, ENABLE);
      /* Enabale the tamper 1 */
      RTC_TamperCmd(RTC_Tamper_1 , ENABLE);
      
      /* Set the LCD Back Color */
      LCD_SetBackColor(White);
      
      /* Clear the LCD line 5 */
      LCD_ClearLine(Line5);
      
      /* Get the current time */
      RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructureInit);
      CurrentTimeSec = (RTC_TimeStructureInit.RTC_Hours * 3600) + (RTC_TimeStructureInit.RTC_Minutes * 60) +
        RTC_TimeStructureInit.RTC_Seconds;     
      
      /* start count */
      StartEvent = 0x1;
      /* Reinitialize Button_State variable */
      Button_State = 0; 
      }
    /* Right button is pressed */
      else if (Button_State == RIGHT_ON)
      {
        uint16_t Colorx;
      
      if (BackupIndex < 5)
      {
        if((uint8_t)(BackupIndex% 2) != 0x0)
        { 
          /* Set LCD backcolor*/
          LCD_SetBackColor(Blue2);
          Colorx = White;
        }
        else
        {
          /* Set LCD backcolor*/
          LCD_SetBackColor(Cyan);
          Colorx = Black;
        }
        SubSecFrac = 0;
        /* Get the Current sub second and time */
        SubSecFrac = (((256 - (uint32_t)RTC_GetSubSecond()) * 1000) / 256);
        
        RTC_GetTime(RTC_Format_BIN, &RTC_StampTimeStruct);
        
        LCD_SetFont(&Font16x24);
        /* Display result on the LCD */
        RTC_Time_Display( LINE(3 + BackupIndex), Colorx, RTC_Get_Time(SubSecFrac , &RTC_StampTimeStruct) ); 
        
        if (BackupIndex < 2)
        {
          /* Save time register  to Backup register ( the first 5 register is reserved for time) */
          RTC_WriteBackupRegister(BKPDataReg[BackupIndex],(uint32_t)RTC->TR);
        
          /* Save sub second time stamp register ( the latest 6 register is reserved for time) */
          RTC_WriteBackupRegister(BKPDataReg[BackupIndex + 2], SubSecFrac);
        }
        
      }
      else
      {
        /* the backup register is full with 10trials */
        /* Set the LCD Back Color */
        LCD_SetBackColor(White);
        LCD_SetFont(&Font12x12);
        /* Set the LCD Text Color */
        LCD_SetTextColor(Red); 
        LCD_DisplayStringLine(LINE(16), (uint8_t *)MESSAGE4);
        LCD_DisplayStringLine(LINE(17), (uint8_t *)MESSAGE5);
        
      }  
      BackupIndex++;
      /* Set the LCD Back Color */
      LCD_SetBackColor(White);  
      /* Reinitialize Button_State variable */
      Button_State = 0; 
      }
   
   /* TAMPER button is pressed */
   else if (Button_RTC == RTC_TAMP)
   {
     /* Set the LCD Back Color */
    LCD_SetBackColor(White);
    LCD_SetFont(&Font16x24);
    /* Clear LCD line 5 to 9 */
    for (i=0; i < 5; i++)
    {  
      /* Clear all the LCD lignes from 3 to 7 */
      LCD_ClearLine(LINE(3+i));
    }
    
    /* reset Counter */
    BackupIndex = 0 ;
    
    /* Enetr to idle */
    StartEvent =0x0;
    
    LCD_SetFont(&Font12x12);
    RTC_Time_InitDisplay();
    
    LCD_SetFont(&Font12x12);
    LCD_ClearLine(LINE(16));
    LCD_ClearLine(LINE(17));
    
    /* Enable Tamper interrupt */
    RTC_ITConfig(RTC_IT_TAMP, DISABLE);
    /* Enabale the tamper 1 */
    RTC_TamperCmd(RTC_Tamper_1 , DISABLE);
    /* Reinitialize Button_RTC variable */
    Button_RTC = 0; 
   }
  }
}
Ejemplo n.º 20
0
void main (void){
  int teclas=0;
  char tecla;
  struct Timer * timer=newObj(Timer,(ulong)30); 
 /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
 /*** End of Processor Expert internal initialization.                    ***/
  Teclas_Init();
  Display_Init(); // Inicializacion del display
  
    
  for(;;){
    WDog1_Clear();
    tecla=get_key();

    if(tecla=='u'){
      PasarASCII(" uP ",0); //texto fijo
      teclas++;
    }

    if(tecla=='d'){
      PasarASCII("down",0); //texto fijo
      teclas++;
    }

    if(tecla=='r'){
      PasarASCII("enter",0);
      teclas++;
    }

    if(tecla=='k'){
      PasarASCII("eSc ",0); //texto fijo
      teclas++;
    }

    if(tecla=='f'){
      PasarASCII("MAntEnidA",0); //texto fijo
      teclas++;      
    }

    if(tecla=='s'){
      PasarASCII("StoP",0); //texto fijo
      teclas++;      
    }
    
    
    if(Teclas_TimePass() && Timer_isfinish(timer)){
      PasarASCII("tiEMPo",0); //texto fijo     
      teclas=0; 
      Timer_Restart(timer);
    }
    

    
    if(Timer_isfinish(timer)){
      
      Pasar_Numero(teclas,1,0);
      Timer_Restart(timer);
    }

      
  }
}
Ejemplo n.º 21
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f30x.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f30x.c file
     */
  
  /* Configure the ADC clock */
  RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div2);
  
  /* Enable ADC1 clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12, ENABLE);
  
  /* LCD Display init  */
  Display_Init();
      
  /* Setup SysTick Timer for 1 µsec interrupts  */
  if (SysTick_Config(SystemCoreClock / 1000000))
  { 
    /* Capture error */ 
    while (1)
    {}
  }
  
  /* ADC Channel configuration */
   /* GPIOC Periph clock enable */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);

  /* Configure ADC Channel7 as analog input */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  
  ADC_StructInit(&ADC_InitStructure);

  /* Calibration procedure */
  ADC_VoltageRegulatorCmd(ADC1, ENABLE);
  
  /* Insert delay equal to 10 µs */
  Delay(10);
  
  ADC_SelectCalibrationMode(ADC1, ADC_CalibrationMode_Differential);
  ADC_StartCalibration(ADC1);
  
  while(ADC_GetCalibrationStatus(ADC1) != RESET );
  calibration_value = ADC_GetCalibrationValue(ADC1);
     
  ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;                                                                    
  ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode;                    
  ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;             
  ADC_CommonInitStructure.ADC_DMAMode = ADC_DMAMode_OneShot;                  
  ADC_CommonInitStructure.ADC_TwoSamplingDelay = 0;          
  
  ADC_CommonInit(ADC1, &ADC_CommonInitStructure);
  
  ADC_InitStructure.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Enable;
  ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; 
  ADC_InitStructure.ADC_ExternalTrigConvEvent = ADC_ExternalTrigConvEvent_0;         
  ADC_InitStructure.ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_None;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_OverrunMode = ADC_OverrunMode_Disable;   
  ADC_InitStructure.ADC_AutoInjMode = ADC_AutoInjec_Disable;  
  ADC_InitStructure.ADC_NbrOfRegChannel = 1;
  ADC_Init(ADC1, &ADC_InitStructure);
  
  /* ADC1 regular channel7 and channel8 configuration */ 
  ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 1, ADC_SampleTime_7Cycles5);
  ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 2, ADC_SampleTime_7Cycles5);
  
  /* Select the differetiel mode for Channel 7 */
  ADC_SelectDifferentialMode(ADC1, ADC_Channel_7, ENABLE);
   
  /* Enable ADC1 */
  ADC_Cmd(ADC1, ENABLE);
  
  /* wait for ADRDY */
  while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_RDY));
  
  /* Start ADC1 Software Conversion */ 
  ADC_StartConversion(ADC1);   
  
  /* Infinite loop */
  while (1)
  {
    /* Test EOC flag */
    while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
    
    /* Get ADC1 converted data */
    ADC1ConvertedValue =ADC_GetConversionValue(ADC1);
    
    /* Compute the voltage */
	ADC1ConvertedVoltage = (ADC1ConvertedValue *6600)/0xFFF;
    
    /* Display converted data on the LCD */
    Display();
  }
}
Ejemplo n.º 22
0
// === CODE ===
int main(int argc, char *argv[], const char **envp)
{
    AxWin3_Connect(NULL);

    // --- Build up window
    gMainWindow = AxWin3_RichText_CreateWindow(NULL, AXWIN3_RICHTEXT_READONLY);
    AxWin3_SetWindowTitle(gMainWindow, "Terminal");	// TODO: Update title with other info

    gMenuWindow = AxWin3_Menu_Create(gMainWindow);
    AxWin3_Menu_AddItem(gMenuWindow, "Copy\tWin+C", NULL, NULL, 0, NULL);
    AxWin3_Menu_AddItem(gMenuWindow, "Paste\tWin+V", NULL, NULL, 0, NULL);
    // TODO: Populate menu


    // TODO: Tabs?

    AxWin3_RichText_SetKeyHandler	(gMainWindow, Term_KeyHandler);
    AxWin3_RichText_SetMouseHandler	(gMainWindow, Term_MouseHandler);
    AxWin3_RichText_SetDefaultColour(gMainWindow, 0xFFFFFF);
    AxWin3_RichText_SetBackground   (gMainWindow, 0x000000);
    AxWin3_RichText_SetFont		(gMainWindow, "#monospace", 10);
    AxWin3_RichText_SetCursorPos	(gMainWindow, 0, 0);
    AxWin3_RichText_SetCursorType	(gMainWindow, AXWIN3_RICHTEXT_CURSOR_INV);
    AxWin3_RichText_SetCursorBlink	(gMainWindow, 1);

    tTerminal *term = Display_Init(80, 25, 100);
    AxWin3_ResizeWindow(gMainWindow, 80*8, 25*16);
    AxWin3_MoveWindow(gMainWindow, 20, 50);
    AxWin3_ShowWindow(gMainWindow, 1);
    AxWin3_FocusWindow(gMainWindow);

    // Create PTY
    giPTYHandle = _SysOpen("/Devices/pts/ptmx", OPENFLAG_READ|OPENFLAG_WRITE);
    if( giPTYHandle < 0 ) {
        perror("Unable to create/open PTY");
        _SysDebug("Unable to create/open PTY: %s", strerror(errno));
        return -1;
    }
    // - Initialise
    {
        _SysIOCtl(giPTYHandle, PTY_IOCTL_SETID, "gui0");
        struct ptymode	mode = {.InputMode = PTYIMODE_CANON|PTYIMODE_ECHO, .OutputMode=0};
        struct ptydims	dims = {.W = 80, .H = 25};
        _SysIOCtl(giPTYHandle, PTY_IOCTL_SETMODE, &mode);
        _SysIOCtl(giPTYHandle, PTY_IOCTL_SETDIMS, &dims);
    }

    // Spawn shell
    {
        int	fd = _SysOpen("/Devices/pts/gui0", OPENFLAG_READ|OPENFLAG_WRITE);
        int	fds[] = {fd, fd, fd};
        const char	*argv[] = {"CLIShell", NULL};
        int pid = _SysSpawn("/Acess/Bin/CLIShell", argv, envp, 3, fds, NULL);
        if( pid < 0 )
            _SysDebug("ERROR: Shell spawn failed: %s", strerror(errno));
        _SysIOCtl(fd, PTY_IOCTL_SETPGRP, &pid);
        _SysClose(fd);
    }

    // Main loop
    for( ;; )
    {
        fd_set	fds;

        FD_ZERO(&fds);
        FD_SET(giPTYHandle, &fds);
        AxWin3_MessageSelect(giPTYHandle + 1, &fds);

        if( FD_ISSET(giPTYHandle, &fds) )
        {
            _SysDebug("Activity on child stdout");
            // Read and update screen
            char	buf[512];
            int len = _SysRead(giPTYHandle, buf, sizeof(buf));
            if( len <= 0 )	break;

            Term_HandleOutput(term, len, buf);
        }
    }

    return 0;
}

int Term_KeyHandler(tHWND Window, int bPress, uint32_t KeySym, uint32_t Translated)
{
    static int	ctrl_state = 0;

    // Handle modifiers
#define _bitset(var,bit,set) do{if(set)var|=1<<(bit);else var&=~(1<<(bit));}while(0)
    switch(KeySym)
    {
    case KEYSYM_LEFTCTRL:
        _bitset(ctrl_state, 0, bPress!=0);
        return 0;
    case KEYSYM_RIGHTCTRL:
        _bitset(ctrl_state, 1, bPress!=0);
        return 0;
    }
#undef _bitset

    // Handle shortcuts
    // - Ctrl-A -- Ctrl-Z
    if( ctrl_state && KeySym >= KEYSYM_a && KeySym <= KEYSYM_z )
    {
        Translated = KeySym - KEYSYM_a + 1;
        _SysDebug("Ctrl-%c: KS %x => Trans %x", 'A'+(KeySym-KEYSYM_a), KeySym, Translated);
    }

    // == 2 :: FIRE
    if( bPress == 2 )
    {
        if( Translated )
        {
            char	buf[6];
            int	len;

            // Encode and send
            len = WriteUTF8(buf, Translated);

            _SysDebug("Keystroke %x:%x translated to '%.*s'", KeySym, Translated, len, buf);
            _SysWrite(giPTYHandle, buf, len);

            return 0;
        }

        // No translation, look for escape sequences to send
        const char *str = NULL;
        switch(KeySym)
        {
        case KEYSYM_LEFTARROW:
            str = "\x1b[D";
            break;
        case KEYSYM_RIGHTARROW:
            str = "\x1b[C";
            break;
        case KEYSYM_UPARROW:
            str = "\x1b[A";
            break;
        case KEYSYM_DOWNARROW:
            str = "\x1b[B";
            break;
        }
        if( str )
        {
            _SysWrite(giPTYHandle, str, strlen(str));
        }
    }
    return 0;
}

int Term_MouseHandler(tHWND Window, int bPress, int Button, int Row, int Col)
{
    return 0;
}

void Term_HandleOutput(tTerminal *Term, int Len, const char *Buf)
{
    // TODO: Handle graphical / accelerated modes

    //_SysDebug("Term_HandleOutput: %i \"%.*s\"", Len, Len, Buf);

    int	ofs = 0;
    int	esc_len = 0;

    while( ofs < Len )
    {
        esc_len = Term_HandleVT100(Term, Len - ofs, Buf + ofs);
        if( esc_len < 0 ) {
            Display_AddText(Term, -esc_len, Buf + ofs);
            esc_len = -esc_len;
        }
        ofs += esc_len;
        //_SysDebug("Len = %i, ofs = %i", Len, ofs);
    }

    Display_Flush(Term);
}
Ejemplo n.º 23
0
void main (void){
  char tecla;
   
  
 /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
 /*** End of Processor Expert internal initialization.                    ***/
  newAlloced(&plataforma,&PlataformaEmbedded);
  Teclas_Init();
  Display_Init(); // Inicializacion del display
  com_initialization(&arrayNodosComunicacion);
  
  add1msListener(_new(&Method,on1ms,0));
  add40msListener(_new(&Method,on40ms,0));
  
  newAlloced(&mainThread,&ThreadAdjuntable);
  cap=GET_INSTANCE();
  #ifdef _ENTRADA_SIMULADA
  CapturadorSimulado_setMicroSegundos(cap,100000000);
  CapturadorSimulado_setPulsos(cap,2);
  #endif
  {
    void * adjuntador= ThreadAdjuntable_getAdjuntador(&mainThread);
    newAlloced(&sensorRpm,&SensorRpm,adjuntador,1000,cap,&config,"SEn rPM");
    _delete(adjuntador);
  }
  newAlloced(&pwm,&PWMTimer,&pwm_config,0);
  newAlloced(&pid,ControlPID,&pid_config,&sensorRpm,&pwm);
  newAlloced(&msj[0],MessageOut); 
  
  #ifndef HD90
  PID_AddOnTSalChange(&pid,OnTSalChange,NULL);
  #endif
  
  /*
  DN_Init(&CBox_Pri);
  Sets_Init();
  PWM_Hmi_Add(&pwm,0);
  SenRpmHmi_Add(&sensorRpm,0);
  PidHmi_AddBoxes(&pid,0);

//  PidHmi_AddBoxes(&pid,2);
//  PidHmi_AddBoxes(&pid,3);
  Sets_AddBoxes();   */
  
  DN_staticInit(&OpList,&AccessList);
  
  setConectada(&pwm,TRUE);
  LedsSalida_init(&ledsSalida);
 	
 	  														 
  for(;;){
    WDog1_Clear();
    tecla=get_key();  
    
    //Eventos
    MethodContainer_execute(&mainThread);
    mainLoop(&plataforma);
   
    
    DN_Proc(tecla);
  }
}
Ejemplo n.º 24
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
 /* This sample code shows how to convert an analog input and read the converted
    data using polling mode. */
   
  /* STM32F0xx HAL library initialization:
       - Configure the Flash prefetch
       - Systick timer is configured by default as source of time base, but user 
         can eventually implement his proper time base source (a general purpose 
         timer for example or other time source), keeping in mind that Time base 
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
         handled in milliseconds basis.
       - Low Level Initialization
     */
  HAL_Init();

  /* Configure the system clock to 48 MHz */
  SystemClock_Config();

  /* Initialize LEDs on board */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);

  
  /* Configure Tamper push-button in non-interrupt mode */
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);

  /* LCD Display init  */
  Display_Init();
  
  /* Configure the ADC peripheral */
  ADC_Config();

  /* Run the ADC calibration */  
  if (HAL_ADCEx_Calibration_Start(&AdcHandle) != HAL_OK)
  {
    /* Calibration Error */
    Error_Handler();
  }

  /* Configure the TIM peripheral */
  TIM_Config();  

  /*## Enable peripherals ####################################################*/

  /* Timer counter enable */
  if (HAL_TIM_Base_Start(&TimHandle) != HAL_OK)
  {
    /* Counter Enable Error */
    Error_Handler();
  }
  
  /* For this example purpose, enable ADC overrun interruption. */
  /* In this ADC LowPower example, ADC overrun is not considered as an error, */
  /* but as a way to watch the ADC low power modes effectiveness.             */
  /* Note: Enabling overrun has no usefulness except for this example purpose:*/
  /*       ADC overrun cannot occur with ADC low power mode "auto-wait"       */
  /*       Usually, in normal application, overrun is enabled automatically   */
  /*       by HAL ADC driver with functions "HAL_ADC_Start_IT()" or           */
  /*       "HAL_ADC_Start_DMA()", but this is not compliant with low power    */
  /*       modes. Refer to comments of parameter "LowPowerAutoWait" in HAL    */
  /*       ADC driver definition file.                                        */
  __HAL_ADC_ENABLE_IT(&AdcHandle, (ADC_IT_OVR));

  /* Start ADC conversion */
  HAL_ADC_Start(&AdcHandle);
  
  /* Wait for the first ADC conversion to be completed (timeout unit: ms) */
  HAL_ADC_PollForConversion(&AdcHandle, (1000/TIMER_FREQUENCY_HZ));
  
  /* Infinite loop */
  while (1)
  {
    /* Wait for at least 2 ADC conversions elapsed time, to let time for      */
    /* potential overrun event to occur (unit: ms)                            */
    HAL_Delay(2* (1000/TIMER_FREQUENCY_HZ));
  
    /* Manage LED1 status in function of ADC overrun event */
    if (ubADC_overrun_status != RESET)
    {
      /* Turn on LED1 to indicate ADC overrun event */
      BSP_LED_On(LED1);
      
      /* Reset overrun status variable for next iteration loop */ 
      ubADC_overrun_status = RESET;
    }
    else
    {
      /* Turn off LED1 to indicate no ADC overrun event */
      BSP_LED_Off(LED1);
    }
  
    /* Press Tamper push-button on STM32091C-EVAL to get the converted data */
    while(BSP_PB_GetState(BUTTON_TAMPER) != GPIO_PIN_RESET);
    while(BSP_PB_GetState(BUTTON_TAMPER) != GPIO_PIN_SET);
    
    /* Get ADC1 converted data */
    /* If ADC low power mode auto-wait is enabled, this release the ADC */
    /* from idle mode: a new conversion will start at the next trigger  */
    /* event.                                                           */
    uhADCxConvertedValue = HAL_ADC_GetValue(&AdcHandle);
    
    /* Compute the voltage */
    uhADCxConvertedVoltage = COMPUTATION_DIGITAL_12BITS_TO_VOLTAGE(uhADCxConvertedValue);
    
    /* Display converted data on the LCD */
    Display();
  }
}
Ejemplo n.º 25
0
int main(int argc, char **argv)
{
	printf("-------------------------------------------------------\n");
	printf("Welcome to SHARP Memory Display demo using Intel Edison\n");
	printf("-------------------------------------------------------\n");
	sleep(1);
	
	signal(SIGINT, &sig_handler);
	
	GPIO_Init();
	sleep(1);
	SPI_Init();
	sleep(1);
	PWM_Init();
	sleep(1);
	
	PWM_Run(); 
	
	Display_Init();
	printf("SHARP Display initialized\n");
	
	while(isrunning)
	{
		//Loop Forever
                Display_Init();
		printf("UNI FREIBURG\n");
		Display_Image("Uni_Freiburg");
		sleep(5);

                Display_Init();
                printf("INTEL ATOM\n");
		Display_Image("Intel_Atom");
		sleep(5);

                Display_Init();
                printf("NIKOLA TESLA\n");
		Display_Image("Nikola_Tesla");
		sleep(5);

                Display_Init();
                printf("ALBERT EINSTEIN\n");
		Display_Image("Albert_Einstein");
		sleep(5);

                Display_Init();
                printf("WHITE TIGER\n");
		Display_Image("White_Tiger");
		sleep(5);
		
                Display_Init();
                printf("WALL-E\n");
		Display_Image("Wall_E");
		sleep(5);
	}
	
	//reset all GPIOs to '0'
	mraa_gpio_write(SCS, 0);
	
	//close all GPIOs
	mraa_gpio_close(SCS);
	
	//close all Peripherals
	mraa_spi_stop(spi);
	mraa_pwm_close(pwm);
	
	fprintf(stdout, "\nSHARP Display exited\n");
	
	return MRAA_SUCCESS;
}