Beispiel #1
0
//=============================================================================
int main(void)
{
  LIGHT_init();
  LCD_init();
  LIGHT_on();
  LCD_clear();
  BEEP_init();
  RTC_init();
  RTOS_init();
  RC5_Init();
  RC5_Reset();
  ENC_init();
  KBD_init();
  bmp180Init();
  dht22Init();
  rda5807Init();
  rda5807PowerOn();
  rda5807SetMute(1);
  ds18x20SearchDevices();
  LCD_goto(0, 0);
  LCD_puts("POGODNAY STATION");
  LCD_goto(0, 1);
  LCD_puts("  VERSION 1.0   ");
  _delay_ms(1000);
  LCD_clear();
  LCD_load_bignum();
  ds18x20Process();
  if (bmp180HaveSensor()) bmp180Convert();
  dht22Read();
#if (DEBUG == 1)
  if ((BUT_1_PINX & (1<<(BUT_1_PIN))) == 0) {
    _delay_ms(100);
    if ((BUT_1_PINX & (1<<(BUT_1_PIN))) == 0) {
      RTOS_setTask(EVENT_SET_STATE_OPTION, 0, 0);
      BEEP_beep();
	  while (((BUT_1_PINX & (1<<(BUT_1_PIN))) == 0)) { }
      BEEP_beep();
    }
  }
#else
  RTOS_setTask(EVENT_SET_STATE_OPTION, 0, 0);
  BEEP_beep();
#endif
  RTOS_setTaskFunc(set_blink, 0, 1000);      // моргание
  RTOS_setTaskFunc(KBD_scan, 0, 5);          // запускаем опрос кнопок
  RTOS_setTaskFunc(ENC_poll, 0, 1);          // запускаем опрос енкодера
  RTOS_setTaskFunc(RC5_scan, 0, 5);          // запускаем опрос RC5
  RTOS_setTask(EVENT_SET_SHOW, 0, 0);		 // запуск шоу
  sei(); 				        			 // Разрешили прерывания
  while(1) {
    RTOS_dispatchTask();    			     // Вызываем диспетчер в цикле.    
  }
}
Beispiel #2
0
/**
  * @brief  RCR receiver demo exec.
  * @param  None
  * @retval None
  */
void Menu_RC5Decode_Func(void)
{
  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
  TIM_OCInitTypeDef  TIM_OCInitStructure;
  
  /* Disable the TIM15, LED Toggling  */
  TIM_Cmd(TIM15, DISABLE);
  
  /* Disable the JoyStick interrupt */
  Demo_IntExtOnOffCmd(DISABLE);
  
  while (Menu_ReadKey() != NOKEY)
  {}
  /* Clear the LCD */ 
  LCD_Clear(LCD_COLOR_WHITE);   
  
  /* Display Image */
  LCD_SetDisplayWindow(120, 192, 64, 64);
  Storage_OpenReadFile(120, 192, "STFILES/TV.BMP");  
  LCD_WindowModeDisable();
  
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(LCD_COLOR_BLUE);
  /* Set the LCD Text Color */
  LCD_SetTextColor(LCD_COLOR_WHITE);
  LCD_DisplayStringLine(LCD_LINE_9, "  To exit press UP  ");
  
  /* Initialize the InfraRed application: RC5 */
  RFDemoStatus = RC5DEMO; 
  RC5_Init();
  
  while(Menu_ReadKey() != UP)
  {   
    /* Decode the RC5 frame */
    RC5_Decode(&RC5_FRAME);
  }
  
  LCD_Clear(LCD_COLOR_WHITE);
  
  TIM_DeInit(TIM2);
  /* Time Base configuration 100ms*/
  TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
  TIM_TimeBaseStructure.TIM_Prescaler = 1000;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseStructure.TIM_Period = 0x0C80;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
  TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
  
  /* Channel 1, 2, 3 and 4 Configuration in Timing mode */
  TIM_OCStructInit(&TIM_OCInitStructure);
  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Timing;
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 0x0;  
  TIM_OC1Init(TIM2, &TIM_OCInitStructure);
 
  Demo_LedShow(ENABLE);
  
  /* Exit the RF5 demo */
  RFDemoStatus = 0;
  
  /* Enable the JoyStick interrupt */
  Demo_IntExtOnOffCmd(ENABLE);
  
  /* Display menu */
  Menu_DisplayMenu();
}
Beispiel #3
0
/*************************************************************************
	main
	====
**************************************************************************/
int main(void)
{
	// USB: Init
	// CAS -> Initialization of KbdInputReport to initial values (0,0,0,0,..)
	HIDDKbdInputReport_Initialize (&KbdInputReport);

	// CAS -> Variable used to simulate the pressing of Letter A (0x04)
	int i;

	DBG("Initialising USB stack\n");
	
	// CAS -> Variable used to simulate the pressing of Letter A (0x04)
	// 	USBInit()
	//		USBHwInit()										HW Init
	//			-> Set Pins for USB, AHBClock, ACK generate interrupts
	//		USBHwRegisterDevIntHandler(HandleUsbReset)
	//			-> Define un handler (HandleUsbReset).
	//
	// initialize stack
	USBInit();
	
	// register device descriptors
	USBRegisterDescriptors(abDescriptors);

	// register HID standard request handler
	USBRegisterCustomReqHandler(HIDHandleStdReq);

	// register class request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

	// register endpoint (2?). Interrupt In Endpoint
	USBHwRegisterEPIntHandler(INTR_IN_EP, NULL);

	// register frame handler
	USBHwRegisterFrameHandler(HandleFrame);
	
	DBG("Starting USB communication\n");


	// connect to bus
	USBHwConnect(TRUE);

	//RC5: Init
	GPIO_SetDir(0,1<<4,1);
	GPIO_SetDir(0,1<<5,1);

	GPIO_SetValue(0,1<<5);
	GPIO_SetValue(0,1<<4);


	RC5_Init();

	// main() Loop:


	// call USB interrupt handler continuously
	
	// CodeRed - either read mouse, or provide "fake mouse readings"
	while (1)
	{

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


			// RC5
		    if (RC5_flag)                      // wait for RC5 code
		    	    {

		      if((RC5_System==0)&&(RC5_Command==1)){
		      GPIO_ClearValue(0,1<<4);
		      for(i=0;i<1000000;i++);
		      GPIO_SetValue(0,1<<4);
		      for(i=0;i<1000000;i++);
		      }

		      if((RC5_System==0)&&(RC5_Command==5)){
		      GPIO_ClearValue(0,1<<5);
		      for(i=0;i<1000000;i++);
		      GPIO_SetValue(0,1<<5);
		      for(i=0;i<1000000;i++);
		      }

		      RC5_flag = 0;
		      printf( "RC5 =  %d   %d\n", RC5_System, RC5_Command);
		    }
		    // RC5

		  USBHwISR();
		  if (i < 5) {
			  KbdInputReport.Key_1 = 0x04;
		  }
		  else {
			  KbdInputReport.Key_1 = 0x00;
		  }
		}
		
	}
	
	return 0;
}