Beispiel #1
0
/*********************************************************************************************************
** 函数名称: TaskStart
** 功能描述: μCOS-II的第一个任务,通常由它初始化目标板和建立其它任务
** 输 入: 无
** 输 出: 无
** 全局变量: 无
** 调用模块: 
**
** 作 者: 陈明计
** 日 期: 2003年7月8日
**-------------------------------------------------------------------------------------------------------
** 修改人: 
** 日 期: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Task_Start(void *pdata)  
{ /*在第1个任务中设置定时器0及中断*/
    UBYTE iii;
    #if OS_CRITICAL_METHOD == 3              /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
	#endif
	
	
	ToggleWD();

	pdata = pdata;							/* 避免编译警告 */
	
	Create_Mux_Box();						/* 创建任务需要的信号量*/
	TargetInit();						    /* 目标板初始化 */
	System_Init();

	TaskStart_CreateTasks();				/* start任务创建任务*/
                 
	SetNetPort();
	InitNic(0);			//RTL8019芯片初始化,在global.c中定义
	Initial_arp();
	Tcp_Initial();
	Udp_Initial();
	
  	while(1)
	{ 
		OSTimeDly(4);
		do
		{
		    iii=Rec_Packet();
		}
		while(iii!=0);
	}
}
/***************************************************************************************************
 *         Main section                                                                            *
 ***************************************************************************************************/
void main(void) {
	error = 0;
	uint8 cntr;


	// Initialize system speed, communication interfaces and RF radio module
	exit_code = System_Init();
	Print_Error(exit_code);

	while (1) {

		payload_length = 0;

		// Construct the packet
		TxPacket[payload_length++] = 0x01;
		TxPacket[payload_length++] = 0x02;
		TxPacket[payload_length++] = 0x03;

		// Send data over radio
		exit_code = Radio_Tx(TxPacket, payload_length, ADDR_REMOTE);

		// Print out packet that was sent
		UART_Send_Data("\r\nSending:");
		for (cntr = 0; cntr < payload_length; cntr++) {
			UART0_Send_ByteToChar(&TxPacket[cntr]);
		}

		// Add some delay (around 1sec)
		__delay_cycles(5000000*SYSTEM_SPEED_MHZ);
	}

}		/* END: main */
Beispiel #3
0
/* With ARM and GHS toolsets, the entry point is main() - this will
   allow the linker to generate wrapper code to setup stacks, allocate
   heap area, and initialize and copy code and data segments. For GNU
   toolsets, the entry point is through __start() in the crt0_gnu.asm
   file, and that startup code will setup stacks and data */
int main(void)
{
	COORDINATE_Type point1,point2,point3;
	COLORCFG_Type tricfg;
	System_Init();                        // Initialize System

	GLCD_Clear(White);
	// Triangle coordinates
	point1.x = 20;
	point1.y = 20;
	point2.x = 80;
	point2.y = 80;
	point3.x = 30;
	point3.y = 120;
	tricfg.fill = YES;
	tricfg.bndry= YES;
	tricfg.bcolor = Blue;
	tricfg.fill_color=Green;
	// Display Triangle
	GLCD_Triangle(&point1,&point2,&point3,&tricfg);

	// Display Coordinates
    gprintf(point1.x+2,point1.y,1,Black,"(%d03,%d03)",point1.x,point1.y);
    gprintf(point2.x+2,point2.y,1,Black,"(%d03,%d03)",point2.x,point2.y);
    gprintf(point3.x+2,point3.y,1,Black,"(%d03,%d03)",point3.x,point3.y);

    while(1);
    return 1;
}
/*====================================================================================================*/
int main( void )
{
  u8 UART_BUF[32] = {0};

  System_Init();
  System_Corr(SampleRateFreg);   // SampleRateFreg = 500 Hz

  LED_G = LED_ON;
  Delay_100ms(5);
  LED_G = LED_OFF;

  while(1) {
    LED_B = !LED_B;

    UART_BUF[0]  = Byte8L((s16)(Acc.TrueX*1000)); // Acc.X 1 mg/LSB
    UART_BUF[1]  = Byte8H((s16)(Acc.TrueX*1000)); 
    UART_BUF[2]  = Byte8L((s16)(Acc.TrueY*1000)); // Acc.Y 1 mg/LSB
    UART_BUF[3]  = Byte8H((s16)(Acc.TrueY*1000));   
    UART_BUF[4]  = Byte8L((s16)(Acc.TrueZ*1000)); // Acc.Z 1 mg/LSB
    UART_BUF[5]  = Byte8H((s16)(Acc.TrueZ*1000));

    UART_BUF[6]  = Byte8L((s16)(Gyr.TrueX*100));  // Gyr.X 10 mdps/LSB
    UART_BUF[7]  = Byte8H((s16)(Gyr.TrueX*100));
    UART_BUF[8]  = Byte8L((s16)(Gyr.TrueY*100));  // Gyr.Y 10 mdps/LSB
    UART_BUF[9]  = Byte8H((s16)(Gyr.TrueY*100));
    UART_BUF[10] = Byte8L((s16)(Gyr.TrueZ*100));  // Gyr.Z 10 mdps/LSB
    UART_BUF[11] = Byte8H((s16)(Gyr.TrueZ*100));

//    UART_BUF[12] = Byte8L((s16)(Mag.TrueX));      // 100 nTesla/LSB
//    UART_BUF[13] = Byte8L((s16)(Mag.TrueX));
//    UART_BUF[14] = Byte8L((s16)(Mag.TrueY));      // 100 nTesla/LSB
//    UART_BUF[15] = Byte8H((s16)(Mag.TrueY));
//    UART_BUF[16] = Byte8L((s16)(Mag.TrueZ));      // 100 nTesla/LSB
//    UART_BUF[17] = Byte8H((s16)(Mag.TrueZ));

    UART_BUF[18] = Byte8L((s16)(Temp.TrueT*100)); // 0.01 degC/LSB
    UART_BUF[19] = Byte8H((s16)(Temp.TrueT*100));

    UART_BUF[20] = Byte8L((s16)(AngE.Pitch*100)); // 0.01 deg/LSB
    UART_BUF[21] = Byte8H((s16)(AngE.Pitch*100)); // 0.01 deg/LSB
    UART_BUF[22] = Byte8L((s16)(AngE.Roll*100));  // 0.01 deg/LSB
    UART_BUF[23] = Byte8H((s16)(AngE.Roll*100));  // 0.01 deg/LSB
    UART_BUF[24] = Byte8L((s16)(AngE.Yaw*10));    // 100 nTesla/LSB
    UART_BUF[25] = Byte8H((s16)(AngE.Yaw*10));    // 0.1 deg/LSB

//    UART_BUF[26] = Byte8L((s16)(Baro.Temp*100));  // 0.01 degC/LSB
//    UART_BUF[27] = Byte8H((s16)(Baro.Temp*100));

//    UART_BUF[28] = Byte8L((s16)(Baro.Press*10));  // 0.1 mbar/LSB
//    UART_BUF[29] = Byte8H((s16)(Baro.Press*10));

//    UART_BUF[30] = Byte8L((s16)(Baro.Height));
//    UART_BUF[31] = Byte8H((s16)(Baro.Height));

    if(KEY == 1)
      RS232_VisualScope(UART_BUF);    // Print Acc
    else
      RS232_VisualScope(UART_BUF+20); // Print AngE
  }
}
Beispiel #5
0
int main( void )
{
  System_Init();

  while(1) {

  }
}
Beispiel #6
0
void	Hardware_Init( void )
{
	System_Init();
	Vbl_Init();
	Video_Init();
	IKBD_Init();
	Graphic_Init();
}
Beispiel #7
0
//-----------------------------------------------------------------------------
// InitApp
// 函数说明: 初始化应用程序
// 参数    :  - 
//-----------------------------------------------------------------------------
void InitApp()
{
	init_timer();
	append_timer( (void *)target_incrementor, 0, 1193181/fps_limit );
	actual_cycle = target_cycle = 0;        /* 初始化 */
	System_Init();
	g_timer_event = CreateEvent(NULL, FALSE, FALSE, NULL);
}
Beispiel #8
0
/*
 *  Data  2016.5.22  Night
 *  Log   取消速度加减控制
 *        速度环变积分控制
 *        方向换取消不完全微分控制 加入分段控制
 *        直立环限幅了
 *        测试fabs()会改变内部的值吗
 */
void main (void)
 {
   DisableInterrupts;
    
    System_Init();
    //----------蜂鸣器-----------------------------------------------------------------------------------------------
    //  PTA9_O = 1;
    //  delayMs(10);
    //  PTA9_O = 0;     
    
    delayMs(30);
    SetNeutral();
    
    
    EnableInterrupts;
    
    //---------------------------等待车子到达直立---------------------------------------------------------------------
    while( g_nCarControlFlag==0 )
     {
        WaitCarStand();
        LED_FLOAT_PRINT(0,  0,"ANGLE: ",CAR_ANGLE_NOW, 4);
     }
    g_nDirectionPrior=0;// 1为方向控制优先 0为速度控制优先
    
    /*
    *  1:启动 
    *  0:关闭
    */
    g_nAngleControlFlag = 1;	/*****ANGLE_CONTROL_START*******/
    g_nSpeedControlFlag = 1;	/*****SPEED_CONTROL_START*******/
    g_nDirectionControlFlag = 1;  /*****DIRECTION_CONTROL_START***/
    
    while(1)
     { 
        //-----------------------数据发送选择区-----------------------------------
        //    switch(4)
        //    {
        //    case 1: SendData1();break;//1.MMA8451_Value   2.Angle_dot   3.Angle
        //    case 2: SendData2();break;//1.g_fAngleControlOut  2.g_fSpeedControlOut 3.g_fDirectionControlOut;
        //    case 3: SendData3();break;//1.g_nLeftMotorPulse 2.g_nRightMotorPulse
        //    case 4: SendData4();break;//1.fAngleAndSpeed  2.g_fCarSpeed
        //    case 5: SendData5();break;//1.VOLTAGE_LEFT    2.VOLTAGE_RIGHT
        //    case 6: SendData6();break;
        //    default:break;
        //    }
        //    LPLD_LPTMR_DelayMs(15);
        
        //-----------------------OLED显示区----------------------------------
        LED_FLOAT_PRINT(0,  0,"ANGLE: ",CAR_ANGLE_NOW, 4);
        LED_FLOAT_PRINT(0,  2,"L: ", VOLTAGE_LEFT, 4);
        LED_FLOAT_PRINT(0,  3,"R: ", VOLTAGE_RIGHT, 4);
        LED_FLOAT_PRINT(0,  5,"D:", g_fDirection, 4);
        
        
        
     }
 }
Beispiel #9
0
/*====================================================================================================*/
int main( void )
{
  System_Init();
  ble_init();

  while(1) {
    ble_power_manage();
  }
}
Beispiel #10
0
int main( void )
{
  System_Init();

  while(1) {
    LED_Toggle();
    delay_ms(100);
  }
}
Beispiel #11
0
/* With ARM and GHS toolsets, the entry point is main() - this will
   allow the linker to generate wrapper code to setup stacks, allocate
   heap area, and initialize and copy code and data segments. For GNU
   toolsets, the entry point is through __start() in the crt0_gnu.asm
   file, and that startup code will setup stacks and data */
int main(void)
{
	System_Init();                         // Initialize System

	GLCD_Clear(White);
	GLCD_Circle (80,80,30,YES,Blue,Green); // Draw Green Circle with Blue boundary
    while(1);
    return 1;
}
int main( void )
{
  System_Init();

  while(1) {
    LED_R_Toggle();
    LED_G_Toggle();
    LED_B_Toggle();
    delay_ms(500);
  }
}
int main( void )
{
  System_Init();

  while(1) {
    LED_R_Toggle();
    LED_G_Toggle();
    LED_B_Toggle();
    Delay_100ms(5);
  }
}
Beispiel #14
0
int main( void )
{
  System_Init();

  while(1) {
    LED1_Toggle();
    delay_ms(100);

    printf("ADC = %d\r\n", SAADC_Read(ADCx_CHANNEL));
  }
}
Beispiel #15
0
int32_t main ( void )
{
    System_Init();
 //   _ADC_START_CONVERT();                 // Start ADC convert

    while ( 1 )
        {
 //           maintask();
            UartFramePro ( &UartRcvFrame );

        }
}
int main( void )
{
  System_Init();

#if FLASH_RW_U8
  Flash_ErasePages(FLASH_USER_START_ADDR, WRITE_PAGE_NBPAGE);
  Flash_WritePageU8(FLASH_USER_START_ADDR, WriteDataU8, 1024);
  Flash_ReadPageU8(FLASH_USER_START_ADDR, ReadDataU8, 1024);
  if(Cmp_ArrU8(WriteDataU8, ReadDataU8, 1024) == SUCCESS)
    LED_R_Reset();
#endif
  Delay_100ms(5);

#if FLASH_RW_U16
  Flash_ErasePages(FLASH_USER_START_ADDR, WRITE_PAGE_NBPAGE);
  Flash_WritePageU16(FLASH_USER_START_ADDR, WriteDataU16, 512);
  Flash_ReadPageU16(FLASH_USER_START_ADDR, ReadDataU16, 512);
  if(Cmp_ArrU16(WriteDataU16, ReadDataU16, 512) == SUCCESS)
    LED_G_Reset();
#endif
  Delay_100ms(5);

#if FLASH_RW_U32
  Flash_ErasePages(FLASH_USER_START_ADDR, WRITE_PAGE_NBPAGE);
  Flash_WritePageU32(FLASH_USER_START_ADDR, WriteDataU32, 256);
  Flash_ReadPageU32(FLASH_USER_START_ADDR, ReadDataU32, 256);
  if(Cmp_ArrU32(WriteDataU32, ReadDataU32, 256) == SUCCESS)
    LED_B_Reset();
#endif
  Delay_100ms(5);

#if FLASH_RW_U64
  Flash_ErasePages(FLASH_USER_START_ADDR, WRITE_SECTOR_NSECTOR);
  Flash_WritePageU64(FLASH_USER_START_ADDR, WriteDataU64, 128);
  Flash_ReadPageU64(FLASH_USER_START_ADDR, ReadDataU64, 128);
  if(Cmp_ArrU64(WriteDataU64, ReadDataU64, 128) == SUCCESS) {
    LED_R_Toggle;
    Delay_100ms(5);
    LED_R_Toggle;
    Delay_100ms(5);
  }
#endif
  Delay_100ms(20);

  while (1) {
    LED_R_Toggle();
    LED_G_Toggle();
    LED_B_Toggle();
    Delay_100ms(2);
  }
}
Beispiel #17
0
int main( void )
{
  int16_t dataIMU[10] = {0};

  System_Init();

  while(1) {
    LED4_Toggle();
    Delay_100ms(5);

    MPU9250_getData(dataIMU);
    printf("Acc.X = %d\tAcc.Y = %d\tAcc.Z = %d\tGyr.X = %d\tGyr.Y = %d\tGyr.Z = %d\tMag.X = %d\tMag.Y = %d\tMag.Z = %d\tTemp = %d\r\n", dataIMU[1], dataIMU[2], dataIMU[3], dataIMU[4], dataIMU[5], dataIMU[6], dataIMU[7], dataIMU[8], dataIMU[9], dataIMU[0]);
  }
}
int main( void )
{
  int16_t dataIMU[10] = {0};

  System_Init();

  while(1) {
    LED_B_Toggle;
    Delay_100ms(1);

    IMU_getData(dataIMU);
    printf("AccX:%d\tAccY:%d\tAccZ:%d\tGyrX:%d\tGyrY:%d\tGyrZ:%d\tMagX:%d\tMagY:%d\tMagZ:%d\t\r\n", dataIMU[1], dataIMU[2], dataIMU[3], dataIMU[4], dataIMU[5], dataIMU[6], dataIMU[7], dataIMU[8], dataIMU[9]);
  }
}
Beispiel #19
0
int32_t main ( void )
{
    System_Init();
    _ADC_START_CONVERT();                 // Start ADC convert

    while ( 1 )
        {
					    P01 = 0;
    P00 = 0;
            maintask();
            UartFramePro ( &UartRcvFrame );
            I2cFramePro();
        }
}
Beispiel #20
0
int main( void )
{
  System_Init();

  while(1) {
    __GPIO_TOG(1);
    __GPIO_TOG(2);
    __GPIO_TOG(3);
    __GPIO_TOG(4);
    __GPIO_TOG(5);
    __GPIO_TOG(6);
    __GPIO_TOG(8);
    delay_ms(80);
  }
}
int main( void )
{
  int16_t IMU_Buf[10] = {0};

  System_Init();

  while(1) {
    LED_G_Toggle();
    Delay_1ms(5);

    MPU6050_getData(IMU_Buf);
    XIO_SerialQscilloscope(IMU_Buf+1, 6);
//    printf("Acc.X = %d\tAcc.Y = %d\tAcc.Z = %d\tGyr.X = %d\tGyr.Y = %d\tGyr.Z = %d\tTemp = %d\r\n", IMU_Buf[1], IMU_Buf[2], IMU_Buf[3], IMU_Buf[4], IMU_Buf[5], IMU_Buf[6], IMU_Buf[0]);
//    Serial_SendDataMATLAB(IMU_Buf, 7);
  }
}
Beispiel #22
0
/* With ARM and GHS toolsets, the entry point is main() - this will
   allow the linker to generate wrapper code to setup stacks, allocate
   heap area, and initialize and copy code and data segments. For GNU
   toolsets, the entry point is through __start() in the crt0_gnu.asm
   file, and that startup code will setup stacks and data */
int main(void)
{
	uchar buffer,buf[10];

	System_Init();

	// print welcome screen
	print_menu(LPC_UART0);
	print_menu(LPC_UART2);

    /* Read some data from the buffer */
    while (1)
    {
    	buffer = getche(LPC_UART0);

        /* Got some data */
        if (EscFlag)
        {
        	UART_Send(LPC_UART2, menu3, sizeof(menu3), BLOCKING);
        	break;
        }

        if (buffer == 'r')
        {
        	print_menu(LPC_UART2);
        	get_line(LPC_UART0,buf,6);
        	printf(LPC_UART2,buf);
        }
        else
        {
           /* Echo it back */
        	UART_SendByte((LPC_UART_TypeDef *)LPC_UART2, buffer);
        }
    }

    // wait for current transmission complete - THR must be empty
    while (UART_CheckBusy(LPC_UART0) == SET);
    while (UART_CheckBusy(LPC_UART2) == SET);

    // DeInitialize UART0 peripheral
    UART_DeInit(LPC_UART0);
    UART_DeInit(LPC_UART2);

    /* Loop forever */
    while(1);
    return 1;
}
Beispiel #23
0
/*----------------------------------------------------------------------------- */
void main(void)
{

   System_Init ();
   Usb_Init ();

   EA = 1;

   while (1)
   {
      if (BLINK_SELECTORUPDATE)
      {
         BLINK_SELECTORUPDATE = 0;
         SendPacket (IN_BLINK_SELECTORID);
      }
   }
}
//-----------------------------------------------------------------------------
// Main Routine
//-----------------------------------------------------------------------------
void main(void)
{

   System_Init ();	  // Init Sysclk, Ports, USB0, Timer2, Timer0, ADC, PCA
   Usb_Init ();

   EA = 1;
   P0 = 0xFF;
   while (1)
   {   /*
      if (BLINK_SELECTORUPDATE)
      {
         BLINK_SELECTORUPDATE = 0;
         SendPacket (IN_BLINK_SELECTORID);
      }	  */
   }
}
Beispiel #25
0
int main(void)
{
    System_Init();
    printf("bootloader start \r\n");
    while(1)
    {
        Boot_Loader_Call();
        delay_ms(500);
        if(USART_RX_CNT) {
            HF_Set_Led_State(0,2);
        }
        else{

            HF_Set_Led_State(0,1);
        }
    }
}
int main( void )
{
  uint8_t state = 0;
  uint32_t i = PWM_MIN;

  System_Init();

  while(1) {
    
    i = (state) ? (i - 1) : (i + 1);
    PWM = i;
    if(i == PWM_MAX){ state = 1; }
    if(i == PWM_MIN){ state = 0; Delay_1ms(1000);}

    LED_R_Toggle();
    LED_G_Toggle();
    LED_B_Toggle();
    Delay_10ms(4);
  }
}
int main( void )
{
  static uint8_t i = 0;
  static uint8_t recvData = 0;
  static int8_t state = ERROR;

  System_Init();

  while(1) {
    state = Serial_RecvDataWTO(&recvData, 1, 500);
    if(state == ERROR) {
      printf("timeout ... %d\r\n", i);
      i = (i == 255) ? 0 : i + 1;
    }
    else if(recvData == 0x0D)  // if press enter
      printf("\r\n");
    else
      Serial_SendData(&recvData, 1);
  }
}
/***************************************************************************************************
 *         Main section                                                                            *
 ***************************************************************************************************/
void main(void) {

	// Initialize system
	Print_Error(System_Init());

	WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

	/* Start : CPU clock configuration */

	if (CALBC1_1MHZ==0xFF)		    // If calibration constant erased
	{
		while(1);                   // do not load, trap CPU
	}
	DCOCTL = 0;                     // Select lowest DCOx and MODx settings
	BCSCTL1 = CALBC1_1MHZ;          // Set DCO to 1MHz
	DCOCTL = CALDCO_1MHZ;

	/* End : CPU clock configuration */

	/* Start : data pin configuration */

	P1IE |= DATA_PIN;					// DATA_PIN interrupt enabled
//    P1IES |= DATA_PIN;					// DATA_PIN HI to LOW edge
	P1IFG &= ~DATA_PIN;					// DATA_PIN IFG cleared

	/* End : data pin configuration */

	/* Start : Timer interrupt configuration */

	TACCTL0 = CCIE;						// TACCR0 interrupt enabled
	TACCR0 = 32768;						// Interrupt every one second (
	TACTL = TASSEL_1 + ID_0 + MC_1; 	// Set the timer A to ACLK, divide clock cycle by 1, Up mode

	/* End : Timer interrupt configuration */

	__enable_interrupt();				// Enabling interrupt
	__bis_SR_register(LPM0 + GIE);		// LPM0 with interrupts enabled

}		/* END: main */
int main (void)
{
	System_Init();
	Base_Peripheral_Init();
	Get_setting();
	RF_GPIO_Init();
	RF_Init();
	RF_PowerDown();
	LED_Peripheral_Init();
	LED1_ON;
	LED2_ON;
	Delay(LED_BLINK_DELAY);
	Peripheral_Power_Down();
	while(1)
	{
		switch(param.mode)
		{
		case MODE_IDLE:
			Mode_Idle_Handler();
			break;

		case MODE_ENABLED:
			Mode_Enabled_Hanler();
			break;

		case MODE_CONFIG:
			Mode_Configure_Handler();
			break;

		case MODE_ERROR:
		default:
			Mode_Error_Handler();
			break;
		}
		LPM3_GOTO;
	}
}
int main( void )
{
  System_Init();

  while(1) {
    LED_R_Toggle();
    LED_G_Toggle();
    LED_B_Toggle();
    delay_ms(100);
 
    while(KEY_WU_Read()) {
      LED_R_Toggle();
      LED_G_Toggle();
      LED_B_Toggle();
      delay_ms(200);
    }
    while(KEY_BO_Read()) {
      LED_R_Toggle();
      LED_G_Toggle();
      LED_B_Toggle();
      delay_ms(50);
    }
  }
}