Ejemplo n.º 1
0
void	BSP_Init()
{
	NVIC_Configuration();

#if	USING_SRAM_AS_HEAP > 0
	FSMC_SRAM_Init();
#endif

#if	WATCHDOG_ENABLE > 0
	WATCHDOG_setTimeOut(15);	//如果15秒仍未启动完成,那么就复位
	WATCHDOG_enable();			//调试时要屏蔽
#endif

	_init_alloc(HEAP_BASE, HEAP_TOP);

	USART1_Init();
	USART2_Init();
	USART3_Init();

#ifdef STM32F10X_CL
	UART4_Init();
	UART5_Init();
#endif //STM32F10X_CL

	Delay_ms(10);
}
int main(void)
{
	unsigned int nCount;
	unsigned char vEncoder[20]="--------------------";
	int i;
  RCC_Configuration();
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
	NVIC_Configuration();
		EXTI_Configuration();
  USART1_Init();
	USART2_Init();															
	USART3_Init();
	UART4_Init();
	UART5_Init();
	SPI2_Init();
	SysTick_Init();
	//init_NRF24L01();
	RX_Mode();
	//nRF24L01_ISR();
	
  while(1)
{

	//Serial_PutString("While ");


}
}	 
int main(void){

PLL_Init();
SysTick_Init();
	
UART4_Init();
	Edge_Detect_Init();

	Timer_Capture_Init();
	UART_OutUDec(1,4);
while(1)
{
	 SysTick_Wait10ms(100);

	if(((1<<TIMER0_RIS_R)&(0x1)))
	{
		TIMER0_ICR_R|=(1<<1);
		UART_OutUDec(TIMER0_TAR_R,4);
		New_Line(4);
		
	}
	
}
}
Ejemplo n.º 4
0
void Peripherals_Init(void)
{
#ifdef NVIC_AUTOINIT
  NVIC_Init();
#endif /* NVIC_AUTOINIT */
#ifdef SIM_AUTOINIT
  SIM_Init();
#endif /* SIM_AUTOINIT */

#ifdef MCM_AUTOINIT
  MCM_Init();
#endif /* MCM_AUTOINIT */
#ifdef PMC_AUTOINIT
  PMC_Init();
#endif /* PMC_AUTOINIT */
#ifdef PORTA_AUTOINIT
  PORTA_Init();
#endif /* PORTA_AUTOINIT */
#ifdef PORTB_AUTOINIT
  PORTB_Init();
#endif /* PORTB_AUTOINIT */
#ifdef PORTC_AUTOINIT
  PORTC_Init();
#endif /* PORTC_AUTOINIT */
#ifdef PORTD_AUTOINIT
  PORTD_Init();
#endif /* PORTD_AUTOINIT */
#ifdef PORTE_AUTOINIT
  PORTE_Init();
#endif /* PORTE_AUTOINIT */

#ifdef ADC0_AUTOINIT
  ADC0_Init();
#endif /* ADC0_AUTOINIT */
#ifdef ADC1_AUTOINIT
  ADC1_Init();
#endif /* ADC1_AUTOINIT */
#ifdef AIPS0_AUTOINIT
  AIPS0_Init();
#endif /* AIPS0_AUTOINIT */
#ifdef AIPS1_AUTOINIT
  AIPS1_Init();
#endif /* AIPS1_AUTOINIT */
#ifdef AXBS_AUTOINIT
  AXBS_Init();
#endif /* AXBS_AUTOINIT */
#ifdef CAN0_AUTOINIT
  CAN0_Init();
#endif /* CAN0_AUTOINIT */
#ifdef CMP0_AUTOINIT
  CMP0_Init();
#endif /* CMP0_AUTOINIT */
#ifdef CMP1_AUTOINIT
  CMP1_Init();
#endif /* CMP1_AUTOINIT */
#ifdef CMP2_AUTOINIT
  CMP2_Init();
#endif /* CMP2_AUTOINIT */
#ifdef CMT_AUTOINIT
  CMT_Init();
#endif /* CMT_AUTOINIT */
#ifdef CRC_AUTOINIT
  CRC_Init();
#endif /* CRC_AUTOINIT */
#ifdef DAC0_AUTOINIT
  DAC0_Init();
#endif /* DAC0_AUTOINIT */
#ifdef DMAMUX_AUTOINIT
  DMAMUX_Init();
#endif /* DMAMUX_AUTOINIT */
#ifdef DMA_AUTOINIT
  DMA_Init();
#endif /* DMA_AUTOINIT */
#ifdef ENET_AUTOINIT
  ENET_Init();
#endif /* ENET_AUTOINIT */
#ifdef EWM_AUTOINIT
  EWM_Init();
#endif /* EWM_AUTOINIT */
#ifdef FB_AUTOINIT
  FB_Init();
#endif /* FB_AUTOINIT */
#ifdef FMC_AUTOINIT
  FMC_Init();
#endif /* FMC_AUTOINIT */
#ifdef FTFE_AUTOINIT
  FTFE_Init();
#endif /* FTFE_AUTOINIT */
#ifdef FTM0_AUTOINIT
  FTM0_Init();
#endif /* FTM0_AUTOINIT */
#ifdef FTM1_AUTOINIT
  FTM1_Init();
#endif /* FTM1_AUTOINIT */
#ifdef FTM2_AUTOINIT
  FTM2_Init();
#endif /* FTM2_AUTOINIT */
#ifdef FTM3_AUTOINIT
  FTM3_Init();
#endif /* FTM3_AUTOINIT */
#ifdef I2C0_AUTOINIT
  I2C0_Init();
#endif /* I2C0_AUTOINIT */
#ifdef I2C1_AUTOINIT
  I2C1_Init();
#endif /* I2C1_AUTOINIT */
#ifdef I2C2_AUTOINIT
  I2C2_Init();
#endif /* I2C2_AUTOINIT */
#ifdef I2S0_AUTOINIT
  I2S0_Init();
#endif /* I2S0_AUTOINIT */
#ifdef LLWU_AUTOINIT
  LLWU_Init();
#endif /* LLWU_AUTOINIT */
#ifdef LPTMR0_AUTOINIT
  LPTMR0_Init();
#endif /* LPTMR0_AUTOINIT */
#ifdef MPU_AUTOINIT
  MPU_Init();
#endif /* MPU_AUTOINIT */
#ifdef PDB0_AUTOINIT
  PDB0_Init();
#endif /* PDB0_AUTOINIT */
#ifdef PIT_AUTOINIT
  PIT_Init();
#endif /* PIT_AUTOINIT */
#ifdef PTA_AUTOINIT
  PTA_Init();
#endif /* PTA_AUTOINIT */
#ifdef PTB_AUTOINIT
  PTB_Init();
#endif /* PTB_AUTOINIT */
#ifdef PTC_AUTOINIT
  PTC_Init();
#endif /* PTC_AUTOINIT */
#ifdef PTD_AUTOINIT
  PTD_Init();
#endif /* PTD_AUTOINIT */
#ifdef PTE_AUTOINIT
  PTE_Init();
#endif /* PTE_AUTOINIT */
#ifdef RCM_AUTOINIT
  RCM_Init();
#endif /* RCM_AUTOINIT */
#ifdef RNG_AUTOINIT
  RNG_Init();
#endif /* RNG_AUTOINIT */
#ifdef RTC_AUTOINIT
  RTC_Init();
#endif /* RTC_AUTOINIT */
#ifdef SDHC_AUTOINIT
  SDHC_Init();
#endif /* SDHC_AUTOINIT */
#ifdef SMC_AUTOINIT
  SMC_Init();
#endif /* SMC_AUTOINIT */
#ifdef SPI0_AUTOINIT
  SPI0_Init();
#endif /* SPI0_AUTOINIT */
#ifdef SPI1_AUTOINIT
  SPI1_Init();
#endif /* SPI1_AUTOINIT */
#ifdef SPI2_AUTOINIT
  SPI2_Init();
#endif /* SPI2_AUTOINIT */
#ifdef SystemControl_AUTOINIT
  SystemControl_Init();
#endif /* SystemControl_AUTOINIT */
#ifdef SysTick_AUTOINIT
  SysTick_Init();
#endif /* SysTick_AUTOINIT */
#ifdef UART0_AUTOINIT
  UART0_Init();
#endif /* UART0_AUTOINIT */
#ifdef UART1_AUTOINIT
  UART1_Init();
#endif /* UART1_AUTOINIT */
#ifdef UART2_AUTOINIT
  UART2_Init();
#endif /* UART2_AUTOINIT */
#ifdef UART3_AUTOINIT
  UART3_Init();
#endif /* UART3_AUTOINIT */
#ifdef UART4_AUTOINIT
  UART4_Init();
#endif /* UART4_AUTOINIT */
#ifdef UART5_AUTOINIT
  UART5_Init();
#endif /* UART5_AUTOINIT */
#ifdef USB0_AUTOINIT
  USB0_Init();
#endif /* USB0_AUTOINIT */
#ifdef USBDCD_AUTOINIT
  USBDCD_Init();
#endif /* USBDCD_AUTOINIT */
#ifdef VREF_AUTOINIT
  VREF_Init();
#endif /* VREF_AUTOINIT */
#ifdef WDOG_AUTOINIT
  WDOG_Init();
#endif /* WDOG_AUTOINIT */
}
Ejemplo n.º 5
0
int main(void)
{
//	u8 a[] = {0xAA, 0xAA, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,0x99,0xa0,0x04,0x10,0x08,0x01,0x08,0x99};
    u8 a[] = {0x11, 0x22, 0x33,0x44, 0x55, 0x66, 0x77};
	RobotRate rate;
	WheelSpeed wheelspeed;

  	SystemInit();
	
	USART1_Init(115200);
	USART2_Init(115200);
	USART3_Init(38400);
	UART4_Init(115200);

	CAN1_Init();
	LED_Init();
//	TIM2_Init();
	TIM3_Init();
	SysTick_Init();
	Motor_init();	  
	amp_init();
	mag_sensor_init();
	flash_init();

    DelayMs(1000);	   //Time for Motor Driver Board to init

	//set_all_speedctl();
	t3 = micros();
	//*************************initial sensor***************************************************************//
	while(t < 0x15)
	{
		if(UART4RecvPtrR != UART4RecvPtrW) 
		{
			op = AHRSCheckDataFrame();
			if(op == ACC_METER || op == GYRO || op == ANGLE_OUTPUT || op == MAG_METER ) 
			{
				SensorInitial(op);
				t++;
			} 
		}
		
		t4 = micros();
		time_taken = t4 - t3;
		if(time_taken > 3000000)
		{
			//break;	
		}
	
	}
	sch_init();
	sch_add_task(sensors, 6, 20);
	sch_add_task(AHRS_compute, 1, 50);
//	sch_add_task(led_task, 4, 100);
	sch_add_task(UART2Proc, 10, 20);
//  sch_add_task(UART3Proc, 3, 20);
//	sch_add_task(UART3Proc, 4, 20);
//	sch_add_task(FRIDCheck, 2, 20);
	sch_start();

		while (1)
		{
			sch_dispatch_tasks();	
			//Welcome();
		}

}