Пример #1
0
/*********************************************************************************************************//**
  * @brief  Period_Reload program,the example main funtion.
  * @retval None
  ***********************************************************************************************************/
void Period_Reload(void)
{

  NVIC_Configuration();               /* NVIC configuration                                                 */
  CKCU_Configuration();               /* System Related configuration                                       */
  USART_Configuration();              /* USART Related configuration                                        */
  SYSTICK_Configuration();            /* SYSTICK Related configuration                                      */
  LED_Configuration();

  /* WatchDog configuration */
  WDT_IntConfig(ENABLE);              /* Enable WDT Interrupt */
  WDT_SetPrescaler(WDT_PRESCALER_8);  /* Set Prescaler Value as 2 */
  WDT_SetReloadValue(0xEFF);          /* Set Reload Value as 0xEFF  */
  WDT_Restart();                      /* Reload Counter as WDTV Value */
  WDT_SetDeltaValue(0xA00);           /* Set Delta Value as 0xA00 */
  WDT_ProtectCmd(ENABLE);             /* Enable Protection  */

  //printf("\n\rWDT Period Reload Starts...\n\r");
  //printf("The Program Is Still Working If LED3 Keep Flashing\n\r");

  /* Enable the SYSTICK Counter */
  SYSTICK_CounterCmd(SYSTICK_COUNTER_ENABLE);

  while(1);
}
Пример #2
0
int main(void)
{
	//设置NVIC中断分组2位抢占优先级,2位响应优先级
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2) ;

	Ticker_Configuration();

	LED_Configuration();

	USART2_Configuration();

	delay_init();

	//Do_Loop_LED_Test();
	//Do_Loop_Motor_Test();
	//DISABLE_FOLLOWING_CODE(1);

	//主控通信控制器初始化
	Maincontrol_Configuration();

	Encoder_Configuration();
	Encoder_Start();

	//速度采样控制器初始化
	TIM2_Configuration(5);
	TIM2_Start();

	//电流检测
	ADC_Configuration();

	//电机初始化
	Motor_Init();

	while (1)
	{
		delay_ms(200);

		LED_RED_TOGGLE();
		LED_GREEN_TOGGLE();
	}
}
Пример #3
0
int main(void) {
	int brightness = 0;
	init_HSI_24MHz();

	LED_Configuration();
	PWM_TIM3_Configuration();



	while(1) {
		for (brightness = 0; brightness < 120; brightness++) {
			setTim3PWM1(brightness);
			soft_delay();
		}
		for (brightness = 119; brightness >= 0; brightness--) {
			setTim3PWM1(brightness);
			soft_delay();
		}

	}
}
Пример #4
0
void  BSP_Init (void)
{
	// Clock Config: HSE 72 MHz
#if __RTC_ENABLE == ON
	RTC_Configuration();
#else
	RCC_Configuration();
#endif


#if __USART1_ENABLE == ON
	// USART1 Config ==> FTDI
	USART1_Configuration();
#endif

#if __USART3_ENABLE == ON
	// USART3 Config ==> Trypano support card
	USART3_Configuration();
#endif


#if __SRAM_ENABLE == OFF && __LED_ENABLE == ON
	// LED Config
		LED_Configuration();
#endif

#if __SWITCH_ENABLE == ON
	// SWITCH Config
	SWITCH_Configuration();
#endif

	// I2C Config
#if __I2C_ENABLE == ON
		I2C_Configuration();
#endif

#if __POT_ENABLE == ON
	// Pot / ADC Config
	ADC_POT_Configuration();
#endif

#if __USB_ENABLE == ON
	//USB Config
	USB_Configuration();
#endif

#if __DAC1_ENABLE == ON
	//DAC Config and start
	DAC1_Configuration();
#endif


#if __SRAM_ENABLE == ON
	// RAM Config
	SRAM_Configuration();
#endif

#if __SDCARD_ENABLE == ON
	// SDCard Config
	SDCARD_Configuration();
#endif

#if __DAC2_ENABLE == ON
	DAC2_Configuration();
#endif

#if __ADCe1_ENABLE == ON
	ADCe1_Configuration();
#endif

}
Пример #5
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_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */ 
	LED_Configuration();
	SysTick_Configuration();
	USART_Configuration();
	Buzzer_Configuration();
	LED_Interrupt();//¿ªÆô¶¨Ê±Æ÷ÖжÏ
	PWM_Configuration();

	LED_Set(0x00);
  /* Infinite loop */
  while (1)										 
  {
// 	Set_Speed(1,50,0);
//	Set_Speed(2,50,0);
//	Buzzer_ON();
//	delay_ms(1000);
//	Set_Speed(1,50,1);
//	Set_Speed(2,50,1);
//	Buzzer_ON();
//	delay_ms(1000);
	switch(instruction)
	{
		case 'a': 
			Set_Speed(1,50,1);
			Set_Speed(2,50,1);
			break;
		case 'b': 
			Set_Speed(1,50,1);
			Set_Speed(2,50,0);
			break;	
		case 'c': 
			Set_Speed(1,50,0);
			Set_Speed(2,50,1);
			break;
		case 'd': 
			Set_Speed(1,50,0);
			Set_Speed(2,50,0);
			break;
		case 's': 
			Set_Speed(1,0,0);
			Set_Speed(2,0,0);
			break;
		case 'z':
				Buzzer_ON();
				break;
		case 'y':
				Buzzer_OFF();
				break;
		 default: break;
										
	}


  }
}
Пример #6
0
int main(void) 
{
	int i;
	Systick_Configuration();
	LED_Configuration();
	button_Configuration();
	usart1_Configuration(9600);
	SPI_Configuration();
  TIM4_PWM_Init();
	Encoder_Configration();
	buzzer_Configuration();
	ADC_Config();
	
	//curSpeedX = 0;
	//curSpeedW = 0;
	//shortBeep(2000, 8000);
	
	while(1) {
		readSensor();
		readGyro();
		readVolMeter();
		printf("LF %d RF %d DL %d DR %d aSpeed %d angle %d voltage %d lenc %d renc %d\r\n", LFSensor, RFSensor, DLSensor, DRSensor, aSpeed, angle, voltage, getLeftEncCount(), getRightEncCount());
		displayMatrix("UCLA");
		
		setLeftPwm(100);
		setRightPwm(100);
		delay_ms(1000);
	}
	//forwardDistance(4000,0,0,true);
	//displayMatrix("Sped");
	//targetSpeedX = 100;
	//delay_ms(2000);
	
	//
	//targetSpeedX = 100;
	//delay_ms(2000);
	//printf("==============================================\n\r=======================================================\r\n");
	
	//delay_ms(1000); 
	//displayMatrix("Wat");
	//delay_ms(1000);
	//displayMatrix("STOP");
	//displayMatrix("GO");
	
	turnRightAngle(LEFT);
	
	targetSpeedW = 0;
	delay_ms(1000);
	turnRightAngle(RIGHT);
	targetSpeedW = 0;
	delay_ms(1000);
	
	displayMatrix("STOP");
	delay_ms(3000); 
	targetSpeedX = 0;
	//
	targetSpeedW = 10;
	delay_ms(1000);
	targetSpeedX = 0;
	targetSpeedW = 0;
	return 0;
}
Пример #7
0
/*********************************************************************************************************
  * @brief  Calendar program.
  * @retval None
  ********************************************************************************************************/
void Calendar(void)
{
    CKCU_APBPerip1ClockConfig(CKCU_APBEN1_RTC, ENABLE);
    if(PWRCU_CheckReadyAccessed() != PWRCU_OK)
    {
        while(1);
    }

    /* Init LED3 and USART */
    LED_Configuration();
    USART_Configuration();

    /* Enable NVIC RTC interrupt */
    NVIC_EnableIRQ(RTC_IRQn);

    /* Check if the Power On Reset flag is set */
    if(PWRCU_GetFlagStatus() == PWRCU_FLAG_BAKPOR)
    {
        printf("\r\n\n Power On Reset occurred....");
    }

    if(PWRCU_ReadBackupRegister(PWRCU_BAKREG_0) != 0x5A5A)
    {
        u32 wInitTime = 0;
        /* Backup data register value is not correct or not yet programmed (when
           the first time the program is executed) */

        printf("\r\n\n RTC not yet configured....");

        /* RTC Configuration */
        RTC_Configuration();

        printf("\r\n RTC configured....");

        /* Adjust time by values entred by the user on the hyperterminal,
           Then store the init time to PWRCU_BAKREG_1. */
        wInitTime = Time_Regulate() ;
        PWRCU_WriteBackupRegister(PWRCU_BAKREG_1, wInitTime);

        /* Reset RTC Counter when Time is 23:59:59 */
        RTC_SetCompare(86400 - wInitTime) ;

        PWRCU_WriteBackupRegister(PWRCU_BAKREG_0, 0x5A5A);
        /* Enable RTC */
        RTC_Cmd(ENABLE) ;
    }
    else
    {
        printf("\r\n No need to configure RTC....");
    }

    /* Display current time in infinite loop */
    printf("\n\r");

    while (1)
    {
        /* If 1s has paased */
        if(gwTimeDisplay == 1)
        {
            /* Display current time.
               Current time is sum of the RTC counter value and the init time(stored in PWRCU_BAKREG_1 register).
               The init time (PWRCU_BAKREG_1 register) will be clear if the RTC Match flag(CMFLAG) is set.
               Refer to RTC_IRQHandler. */
            Time_Display(RTC_GetCounter() + PWRCU_ReadBackupRegister(PWRCU_BAKREG_1));
            gwTimeDisplay = 0;
        }
    }
}
Пример #8
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
    /* Periph clock enable */
    RCC_Configuration();

    /* Config the LED GPIO */
    LED_Configuration();

    /* Config the USART1 */
    USART1_Configuration();

    printf("NOR Flash Init!\n\r");

    /* EXMC nor flash init */
    EXMC_NorFlash_Init();

    /* Read Nor Flash ID and printf */
    NOR_ReadID(&NOR_ID);
    printf("\n\rNor Flash ID:0x%X 0x%X 0x%X 0x%X\n\r",NOR_ID.Manufacturer_Code,NOR_ID.Device_Code,
                                                      NOR_ID.Block_Protection_Indicator,NOR_ID.Block_Protection_Status);

    NOR_ReturnToReadMode();

    /* Erase the nor flash block to be written data */
    Status = NOR_EraseBlock(WRITE_READ_ADDR);
    if(NOR_SUCCESS == Status)
    {
        printf("\n\rErase nor flash block successfully!\n\r");
    }
    else
    {
        printf("\n\rErase nor flash block failure!\n\r");
    }

    /* Whether address cross-border */
    if((WRITE_READ_ADDR + BUFFER_SIZE ) > NOR_MAX_ADDRESS)
    {
        printf("\n\rAddress cross-border\n\r");
        GPIO_SetBits(LED_GPIO, LED4_PIN | LED5_PIN);
        while(1)
        {

        }
    }

    /* Fill WriteBuffer with the specified value */
    Fill_Buffer(WriteBuffer, BUFFER_SIZE, 0x1234);

    /* Write data to nor flash, WRITE_READ_ADDR: the starting address of the write data */
    Status = NOR_WriteBuffer(WriteBuffer, WRITE_READ_ADDR, BUFFER_SIZE);
    if(NOR_SUCCESS == Status)
    {
        printf("\n\rWrite data to nor flash block successfully!\n\r");
    }
    else
    {
        printf("\n\rWrite data to nor flash block failure!\n\r");
    }

    /* Read data from nor flash, WRITE_READ_ADDR: the starting address of the read data*/
    NOR_ReadBuffer(ReadBuffer, WRITE_READ_ADDR, BUFFER_SIZE);

    /* Read and write data comparison for equality */
    WriteReadStatus = 0;
    for (Index = 0x00; Index < BUFFER_SIZE; Index++)
    {
        if (ReadBuffer[Index] != WriteBuffer[Index])
        {
            WriteReadStatus++;
            break;
        }
    }

    printf("\n\rThe result to access the nor flash:\n\r");
    if (WriteReadStatus == 0)
    {
         printf("\n\rAccess nor flash successfully!\n\r");
         GPIO_SetBits(LED_GPIO, LED2_PIN | LED3_PIN | LED4_PIN | LED5_PIN);
    }
    else
    { 
         printf("\n\rAccess nor flash failure!\n\r"); 
         GPIO_SetBits(LED_GPIO, LED2_PIN | LED3_PIN);
    }

    printf("\n\rPrintf data to be read: \n\r");
    printf("\n\r");
    for(Index = 0; Index < BUFFER_SIZE; Index++)
    {
        printf("%X ",ReadBuffer[Index]);
    }

    while(1)
    {

    }
}
int main(void)
{
	while (1);
	/* Configuration */
  SystemInit();
	LED_Configuration();
	BUZZ_Configuration();
	//ADC_Configuration();
	CAN_Configuration();
/****************************µ×Å̳õʼ»¯******************************/
	Elmo_Init(elmo, 3);
//	PositionPID_Init();
	PositionIPD_Init();
	MoveLock();
	Delay_ms(100);
	BLUETOOTH_Configuration();
	Delay_ms(100);
	Encoder_Clear();
	Delay_ms(1000);
  MPU6500_init();
	TIM1_Configuration();
	TIM2_Configuration();
	TIM3_Configuration();
	TIM4_Configuration();

	if (SysTick_Config(SystemCoreClock / 1000))    /* Setup SysTick Timer for 1 msec interrupts  */
	{
		while(1){LED_ON(LED2);}/* Capture error */
	}
//	IpdAxisX.setpoint = 200;
//	IpdAngle.setpoint = 90;
//	PidAxisX.setpoint = 200;
//	CMDVelocity.X = 10; 
//	CMDVelocity.Y = 0;
//	CMDVelocity.A = 0;//Degree/Second
//  Elmo_Write(&elmo[0],0x01,0x01,50);	
  while (1)
  {	
		if(MPU_FLAG == 1)
		{
			MPU_FLAG = 0;
		}
		if(MAPAN_FLAG == 1)
		{
			MAPAN_FLAG = 0;
//			LED_TOGGLE(LED1);	
			MapanTask();//ÂëÅÌ	
	  }
		if(PID_PFLAG ==1)
		{
			PID_PFLAG = 0;
//			PositionPIDCal();
			PositionIPDCal();
			VelocityTransform();				
//			LED_TOGGLE(LED2);
		}
		if (LED_FLAG == 1)
		{
			LED_FLAG = 0;	
//			SquareTracking();
//			CircleTracking();
//			GoBack();
//			LED_TOGGLE(LED3);
//			SignalTracking();
//			angle_print();
//			PositionVelocity_print();
		}
  }
}