Exemplo n.º 1
0
//各个外设的初始化
void Peripheral_Init(void)
{
	// 中断向量表配置
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	
	PS_Init();	
    KEY_Init();	
	STATU_Init();
	LED_Init();
	BEEP_Init();
    CAN1_Init();
	CAN2_Init();
    OLED_Init();
    ADC_Configuration();
}
Exemplo n.º 2
0
static void Init(void) {
	Frame.Data = rxbuffer; /* Set pointer to OutData buffer */

	// Inicializacion UART
	uartData.handle = AS1_Init(&uartData);
	uartData.isSent = FALSE;
	uartData.rxChar = '\0';
	uartData.rxPutFct = UART_RxBuff_Put;

	canData.handle = CAN1_Init(&canData);
	canData.isSent = FALSE;
	canData.rxChar = '\0';
	canData.rxPutFct = CAN_RxBuff_Put;

	/* set up to receive RX into input buffer */
	UART_RxBuff_Init(); /* initialize RX buffer */
	CAN_RxBuff_Init(); /* initialize RX buffer */

	/* Set up ReceiveBlock() with a single byte buffer. We will be called in OnBlockReceived() event. */
	while (AS1_ReceiveBlock(uartData.handle, (LDD_TData *) &uartData.rxChar,
			sizeof(uartData.rxChar)) != ERR_OK) {
	} /* initial kick off for receiving data */
}
Exemplo n.º 3
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();
		}

}
Exemplo n.º 4
0
void MAIN_vInit(void)
{
  // USER CODE BEGIN (Init,2)

  // USER CODE END

  //// -----------------------------------------------------------------------
  //// Begin of Important Settings for the Start-Up File
  //// -----------------------------------------------------------------------
  ///  All following settings must be set in the start-up file. You can use 
  ///  DAvE's project file (*.dpt) to include this register values into your 
  ///  compiler EDE.

    ///  ---------------------------------------------------------------------
    ///  Initialization of the SYSCON Register:
    ///  ---------------------------------------------------------------------
    ///  - 256 words system stack
    ///  - Internal ROM area mapped to segment 1
    ///  - the segmentation is enabled (CSP is saved/restored during 
    ///  interrupt entry/exit)
    ///  - Internal ROM disabled
    ///  - the pin #BHE is enabled
    ///  - the pins #WR and #BHE retain their normal functions
    ///  - system clock output CLKOUT is disabled
    ///  - latched #CS mode
    ///  - pin #RSTIN is pulled low during the internal reset sequence
    ///  - the on-chip X-Peripherals are enabled and can be accessed
    ///  - accesses to the XBUS peripherals are done internally

    //// this register must be set in the start-up file
    //// SYSCON  =  0x101C

    ///  ---------------------------------------------------------------------
    ///  Initialization of the SYSCON1 Register:
    ///  ---------------------------------------------------------------------

    //// this register must be set in the start-up file
    //// SYSCON1  =  0x0000

    ///  ---------------------------------------------------------------------
    ///  Initialization of the SYSCON2 Register:
    ///  ---------------------------------------------------------------------

    //// this register must be set in the start-up file
    //// SYSCON2  =  0x0000

    ///  ---------------------------------------------------------------------
    ///  Initialization of the SYSCON3 Register:
    ///  ---------------------------------------------------------------------

    //// this register must be set in the start-up file
    //// SYSCON3  =  0x0000

    ///  ---------------------------------------------------------------------
    ///  --- initialization of the BUSCON 0-4 and ADRRSEL Registers 1-4 ---
    ///  ---------------------------------------------------------------------


    ///  ---------------------------------------------------------------------
    ///  ---------- external bus 0 is enabled ----------
    ///  ---------------------------------------------------------------------
    ///  - 16-bit Multiplexed Bus
    ///  - memory cycle time control: 15 waitstates
    ///  - With read/write delay: activate command 1 TCL after falling edge 
    ///  of ALE
    ///  - chip select mode: address chip select
    ///  - memory tristate control: 1 waitstate
    ///  - ALE lengthening control: lengthened ALE signal
    ///  - Address windows are switched immediately
    ///  - Normal #WR signal

    //// this register must be set in the start-up file
    //// BUSCON0  =  0x06C0




  //// -----------------------------------------------------------------------
  //// End of Important Settings for the Start-Up File
  //// -----------------------------------------------------------------------




  //   -----------------------------------------------------------------------
  //   Initialization of the Peripherals:
  //   -----------------------------------------------------------------------

  //   initializes the Parallel Ports
  IO_Init();

  //   initializes the Asynchronous/Synchronous Serial Interface (ASC0)
  ASC0_Init();

  //   initializes the General Purpose Timer Unit (GPT1)
  GPT1_vInit();

  //   initializes the Watchdog Timer (WDT)
  WDT_Init();

  //   initializes the Real Timer Clock (RTC)
  RTC_Init();

  //   initializes the Analog / Digital Converter (ADC)
  ADC_vInit();

  //   initializes the Capture / Compare Unit 2 (CAPCOM2)
  CC2_Init();

  //   initializes the Capture / Compare Unit 6 (CAPCOM6)
  CC6_Init();

  //   initializes the On-Chip CAN Interface 1 (CAN1)
  CAN1_Init();

  // USER CODE BEGIN (Init,3)

  // USER CODE END

  //   globally enable interrupts
  PSW_IEN        =  1;          

} //  End of function MAIN_vInit