示例#1
0
文件: main.c 项目: j-a-r-i/stm32
//------------------------------------------------------------------------------
void TaskComm(void* pvParameters)
{		
	char ch = 'a';
	(void) pvParameters;                    // Just to stop compiler warnings.
	
#ifdef USE_SERIAL
	usart_str("Hello\r\n");
#endif
	for (;;) {
		//vTaskDelay(500);
		if (xQueueReceive(commQueue1, &ch, (TickType_t)1000)) {
#ifdef USE_SERIAL
			//out_time(usart_put, &timeRtc);
			usart_put('M');
			out_byte(usart_put, measCounter);
			usart_put(' ');
			out_byte(usart_put, temp);
			usart_put(' ');
			out_byte(usart_put, 0);
			usart_put(' ');
			out_byte(usart_put, 0);
			usart_put('\r');
			usart_put('\n');
#endif
		}
	}
}
示例#2
0
文件: main.c 项目: j-a-r-i/stm32
//------------------------------------------------------------------------------
void RTC_IRQHandler(void)
{
	if(RTC_GetITStatus(RTC_IT_ALRA) != RESET) {
		//USART_SendData(USART1, 'a');
#ifdef USE_SERIAL
		usart_str("rtc irq\n");
#endif
		RTC_ClearITPendingBit(RTC_IT_ALRA);
	}
}
示例#3
0
文件: main.c 项目: j-a-r-i/stm32
//------------------------------------------------------------------------------
void rtc_init(void)
{
	RTC_InitTypeDef initRtc;
	RTC_AlarmTypeDef alarmRtc;

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

	PWR_BackupAccessCmd(ENABLE);

	//RCC_BackupResetCmd(ENABLE);
    //RCC_BackupResetCmd(DISABLE);

	RCC_LSICmd(ENABLE);

	while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);

	RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);

	RCC_RTCCLKCmd(ENABLE);

	if (RTC_WaitForSynchro() == ERROR) {
#ifdef USE_SERIAL
		usart_str("E RTC 0\r\n");
#endif
	}

	initRtc.RTC_AsynchPrediv = 99;  // LSI is 40kHz
	initRtc.RTC_SynchPrediv  = 399;
	initRtc.RTC_HourFormat  = RTC_HourFormat_24;
	if (RTC_Init(&initRtc) == ERROR) {
#ifdef USE_SERIAL
		usart_str("E RTC 1\r\n");
#endif
	}

	// Sets time
	//
	timeRtc.RTC_H12  = RTC_H12_AM;
	timeRtc.RTC_Hours = 12;
	timeRtc.RTC_Minutes = 00;
	timeRtc.RTC_Seconds = 00;
	if (RTC_SetTime(RTC_Format_BIN, &timeRtc)) {
#ifdef USE_SERIAL
		usart_str("E RTC 2\r\n");
#endif
	}

	// Configure alarm
	//
	RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
	
	alarmRtc.RTC_AlarmTime.RTC_H12 = RTC_H12_AM;
	alarmRtc.RTC_AlarmTime.RTC_Hours = 12;
	alarmRtc.RTC_AlarmTime.RTC_Minutes = 00;
	alarmRtc.RTC_AlarmTime.RTC_Seconds = 20;
	alarmRtc.RTC_AlarmDateWeekDay = 0x31;
	alarmRtc.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
	alarmRtc.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay;
	RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &alarmRtc);

	RTC_ITConfig(RTC_IT_ALRA, ENABLE);

	RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
}
示例#4
0
int main(void)
{
  Board tmp;
  for(uint8_t i = 0; i < 3; ++i)
  {
    tmp = Board(T1[i]);
    tmp.print();
  }
  return 0;
	SudokuBoard::Difficulty difficulty = SudokuBoard::INTERMEDIATE;

  // Initialize the random number generator
  int timeSeed = 0;
  srand(timeSeed);

  // Create a new puzzle board
  // and set the options
  SudokuBoard* ss = new SudokuBoard();
	/*SudokuBoard sss;
	SudokuBoard* ss = &sss;*/
  // Solve puzzle or generate puzzles
  // until end of input for solving, or
  // until we have generated the specified number.
	int number_to_benchmark=1000;
  bool done = false;
  while (!done){

      // Record whether the puzzle was possible or not,
      // so that we don't try to solve impossible givens.
      bool havePuzzle = false;
      // Generate a puzzle
      havePuzzle = ss->generatePuzzle();
      if (!havePuzzle){
          //cout << "Could not generate puzzle.";
          //cout << endl;
				usart_str("Could not generate puzzle.");
				usart_str("\r\n");
      }

      if (havePuzzle){

          // Count the solutions if requested.
          // (Must be done before solving, as it would
          // mess up the stats.)

          // Solve the puzzle
          ss->solve();

          // Bail out if it didn't meet the difficulty standards for generation
          if (difficulty!=SudokuBoard::UNKNOWN && difficulty!=ss->getDifficulty()){
              havePuzzle = false;
          } else {
              // Set loop to terminate if enough have been generated.
							if(!(--number_to_benchmark)) done = true;
							srand(number_to_benchmark);
							//char bufor[5];
							//sprintf(bufor,"%d",1000-number_to_benchmark);
							//usart_str(bufor);
						  //usart_str("\r\n");
          }
      }

      if (havePuzzle){
          //table
          // Print the puzzle itself.
          //ss->printPuzzle();

          //ss->printSolution();
          Board tmp(ss->puzzle,ss->solution);
          tmp.print();
          printf(",\n");
      }
  }
	
}
示例#5
0
int main(void)
{
	SysTick_Config(SystemCoreClock / 1000000);
	
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);//port A dla RS232

  /* GPIO - konfiguracja */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3;//PA2 - TxD, PA3 - RxD
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
	/* funkcje alternatywne - usart2 */
	GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2);
	GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2);
	
	/* zegarek dla usart2 */
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
	
	/*USART_ClockInitStruct.USART_Clock=USART_Clock_Enable;
	USART_ClockInitStruct.USART_CPOL=USART_CPOL_High;
	USART_ClockInitStruct.USART_CPHA=USART_CPHA_2Edge;
	USART_ClockInitStruct.USART_LastBit=USART_LastBit_Disable;
	USART_ClockInit(USART2, &USART_ClockInitStruct);*/
	
	/*konfiguracja*/
	USART_InitStruct.USART_BaudRate=9600;//prędkość
	USART_InitStruct.USART_WordLength=USART_WordLength_8b;//8 bit danych
	USART_InitStruct.USART_StopBits=USART_StopBits_1;//1 stop bit
	USART_InitStruct.USART_Parity=USART_Parity_No;//parity = none
	USART_InitStruct.USART_Mode=USART_Mode_Rx|USART_Mode_Tx;//włącz Rx i Tx
	USART_InitStruct.USART_HardwareFlowControl=USART_HardwareFlowControl_None;//brak kontroli przepływu
	USART_Init(USART2, &USART_InitStruct);
	//włączamy usart
	USART_Cmd(USART2, ENABLE);
	
	//USART2->BRR=4375;
	RCC_GetClocksFreq(&RCC_Clocks);
	usart_str("Witaj\r\n");
	/*while(1){
		while(USART_GetFlagStatus(USART2, USART_FLAG_RXNE)==RESET);
			USART_ClearFlag(USART2, USART_FLAG_RXNE);
			dane=USART_ReceiveData(USART2);
			USART_SendData(USART2, dane);
			while(USART_GetFlagStatus(USART2, USART_FLAG_TXE)!=SET);
	}*/
	
	SudokuBoard::Difficulty difficulty = SudokuBoard::EASY;

        // Initialize the random number generator
        int timeSeed = 0;
        srand(timeSeed);

        // Create a new puzzle board
        // and set the options
        SudokuBoard* ss = new SudokuBoard();
				/*SudokuBoard sss;
				SudokuBoard* ss = &sss;*/
        // Solve puzzle or generate puzzles
        // until end of input for solving, or
        // until we have generated the specified number.
				int number_to_benchmark=1000;
        bool done = false;
        while (!done){

            // Record whether the puzzle was possible or not,
            // so that we don't try to solve impossible givens.
            bool havePuzzle = false;
            // Generate a puzzle
            havePuzzle = ss->generatePuzzle();
            if (!havePuzzle){
                //cout << "Could not generate puzzle.";
                //cout << endl;
							usart_str("Could not generate puzzle.");
							usart_str("\r\n");
            }

            if (havePuzzle){

                // Count the solutions if requested.
                // (Must be done before solving, as it would
                // mess up the stats.)

                // Solve the puzzle
                ss->solve();

                // Bail out if it didn't meet the difficulty standards for generation
                if (difficulty!=SudokuBoard::UNKNOWN && difficulty!=ss->getDifficulty()){
                    havePuzzle = false;
                } else {
                    // Set loop to terminate if enough have been generated.
										if(!(--number_to_benchmark)) done = true;
										srand(number_to_benchmark);
										char bufor[5];
										sprintf(bufor,"%d",1000-number_to_benchmark);
										usart_str(bufor);
									  usart_str("\r\n");
                }
            }

            if (havePuzzle){

                // Print the puzzle itself.
                ss->printPuzzle();

                ss->printSolution();
            }
        }

        //delete ss;
				
				while(1);
	
}