bool InitGameplay(uint8_t Priority) { MyPriority = Priority; // initialize servo ServoInit(); SetFlagsInactive(); // initialize audio AudioControlInit(); ExternalLineInit(); // set currentState to INIT currentState = INIT; ES_Event ThisEvent; ThisEvent.EventType = ES_INIT; // post ES_INIT to itself if (ES_PostToService(MyPriority, ThisEvent) == true) { return true; } else { return false; } }
int main(void) { delay_init(); GPIOCLKInit(); UserLEDInit(); LCD1602Init(); //IRCtrolInit(); TIM2_Init(); MotorInit(); ServoInit(); RedRayInit(); //USART3Conf(9600); while(1) { if(tick_5ms >= 5) { tick_5ms = 0; tick_200ms++; if(tick_200ms >= 40) { tick_200ms = 0; LEDToggle(LED_PIN); } // continue_time--;//200ms 无接收指令就停车 // if(continue_time == 0) // { // continue_time = 1; // CarStop(); // } //do something SearchRun(); if(ctrl_comm_last != ctrl_comm)//指令发生变化 { ctrl_comm_last = ctrl_comm; switch(ctrl_comm) { case COMM_UP: CarGo();break; case COMM_DOWN: CarBack();break; case COMM_LEFT: CarLeft();break; case COMM_RIGHT: CarRight();break; case COMM_STOP: CarStop();break; default : break; } Delayms(10);//防抖 LCD1602WriteCommand(ctrl_comm); } } } }
int main(void) { delay_init(); GPIOCLKInit(); UserLEDInit(); //LCD1602Init(); //IRCtrolInit(); TIM2_Init(); MotorInit(); UltraSoundInit(); //RedRayInit(); ServoInit(); while(1) { if(tick_5ms >= 5) { tick_5ms = 0; tick_200ms++; if(tick_200ms >= 40) { tick_200ms = 0; LEDToggle(LED_PIN); //LCD1602WriteDistance(distance_cm);//更新距离 } // continue_time--;//200ms 无接收指令就停车 // if(continue_time == 0) // { // continue_time = 1; // CarStop(); // } //do something Distance();//计算距离 BarrierProc(); // if(ctrl_comm_last != ctrl_comm)//接收到红外信号 // { // ctrl_comm_last = ctrl_comm; // switch(ctrl_comm) // { // case COMM_UP: CarGo();break; // case COMM_DOWN: CarBack();break; // case COMM_LEFT: CarLeft();break; // case COMM_RIGHT: CarRight();break; // case COMM_STOP: CarStop();break; // default : break; // } // LCD1602WriteCommand(ctrl_comm); // } } } }
int main(void) { delay_init(); GPIOCLKInit(); UserLEDInit(); LCD1602Init(); IRCtrolInit(); TIM2_Init(); MotorInit(); ServoInit(); while(1) { if(tick_5ms >= 5) { tick_5ms = 0; tick_200ms++; if(tick_200ms >= 40) { tick_200ms = 0; LEDToggle(LED_PIN); } continue_time--;//200ms 无接收指令就停车 if(continue_time == 0) { continue_time = 1; CarStop(); } //do something if(ir_rec_flag == 1)//接收到红外信号 { ir_rec_flag = 0; switch(ctrl_comm) { case COMM_UP: CarGo();break; case COMM_DOWN: CarBack();break; case COMM_LEFT: CarLeft();break; case COMM_RIGHT: CarRight();break; case COMM_STOP: CarStop();break; default : break; } LCD1602WriteCommand(ctrl_comm); } } } }
/******************************************************************************************************** Function Name: main Description : Inputs : None Outputs : None Notes : Revision : ********************************************************************************************************/ int main(void) { SystemInit(); //ϵͳʱÖÓ³õʼ»¯ InputIOInit(); //Êý×ÖÊäÈë³õʼ»¯ OutputIOInit();//Êý×ÖÊä³ö³õʼ»¯ SensorInit(); //Ä£ÄâÊäÈë³õʼ»¯ ZLG7290Init(); //¼üÅ̳õʼ»¯ MotorInit(); //µç»ú³õʼ»¯ ServoInit(); //¶æ»ú³õʼ»¯ EncoderInit(); //±àÂëÆ÷³õʼ»¯ /* V_PIDInit(); //µç»ú±Õ»·Êä³ö */ SystemStart(); //UsartInit(); //´®¿Ú³õʼ»¯ }
int main() { initVision(); InitGameSystem(); ServoInit(RC_STR_SERVO); ServoInit(RC_VEL_SERVO); vsRunControl = 1; xil_printf("press any key to continue...\r\n"); char c; read(0,&c,1); if(c == '~') { useHeartbeat = TRUE; } else { useHeartbeat = FALSE; } vsInit(); // SetServo(RC_STR_SERVO, 10); xTaskCreate( heartbeat, ( signed portCHAR * ) "Heartbeat", configMINIMAL_STACK_SIZE, NULL, ( tskIDLE_PRIORITY + 10 ), hbHandle ); xTaskCreate( comm, ( signed portCHAR * ) "Communications", configMINIMAL_STACK_SIZE, NULL, ( tskIDLE_PRIORITY + 5 ), commHandle ); xTaskCreate( vision, ( signed portCHAR * ) "Vision", configMINIMAL_STACK_SIZE, NULL, ( tskIDLE_PRIORITY + 6 ), visionHandle ); xTaskCreate( control, ( signed portCHAR * ) "Control", configMINIMAL_STACK_SIZE, NULL, ( tskIDLE_PRIORITY + 9 ), controlHandle ); xTaskCreate( nav, ( signed portCHAR * ) "Navigation", configMINIMAL_STACK_SIZE, NULL, ( tskIDLE_PRIORITY + 7 ), navHandle ); xTaskCreate( ai, ( signed portCHAR * ) "AI", configMINIMAL_STACK_SIZE, NULL, ( tskIDLE_PRIORITY + 8 ), aiHandle ); //This is the start of image processing // SetServo(RC_STR_SERVO, 40); // SetServo(RC_VEL_SERVO, 8); vTaskStartScheduler(); // loopFrame(); return 0; }
void InitApp(void) { /* Send Low Level Voltage to all ports */ LATA = 0x0000; LATB = 0x0000; LATC = 0x0000; LATD = 0x0000; LATE = 0x0000; LATF = 0x0000; LATG = 0x0000; #if defined(__dsPIC33EP512MU814__) LATH = 0x0000; LATJ = 0x0000; LATK = 0x0000; #endif /* Disable all analog inputs */ ANSELA = 0x0000; ANSELB = 0x0000; ANSELC = 0x0000; ANSELD = 0x0000; ANSELE = 0x0000; ANSELG = 0x0000; /* Configure all digital ports as outputs */ TRISA = 0x0000; TRISB = 0x0000; TRISC = 0x0000; TRISD = 0x0000; TRISE = 0x0000; TRISF = 0x0000; TRISG = 0x0000; #if defined(__dsPIC33EP512MU814__) TRISH = 0x0000; TRISJ = 0x0000; TRISK = 0x0000; #endif #if STARTKITBOARD mInitAllLEDs(); mInitAllSwitches(); #endif /* Configure Nested Interrupts */ INTCON1bits.NSTDIS = 0b0; // Interrupt nesting enabled initClock(); #if USE_UART1 serial_assign(&Serial1, 1u); Serial1.init(); Serial1.open(); XBeeInit(&Xbee1, XBEE1_ATAP, &Serial1); #endif /*USE_UART1*/ #if USE_UART2 serial_assign(&Serial2, 2u); Serial2.init(); Serial2.open(); XBeeInit(&Xbee2, XBEE2_ATAP, &Serial2); #endif /*USE_UART2*/ #if USE_UART3 serial_assign(&Serial3, 3u); Serial3.init(); Serial3.open(); XBeeInit(&Xbee3, XBEE3_ATAP, &Serial3); #endif /*USE_UART3*/ #if USE_UART4 serial_assign(&Serial4, 4u); Serial4.init(); Serial4.open(); XBeeInit(&Xbee4, XBEE4_ATAP, &Serial4); #endif /*USE_UART4*/ #if USE_ADC1 ADC1Init(); ADC1Start(); #endif #if USE_ENC EncInit(); #endif #if USE_PWM PWMxInit(); PWMxStart(); #endif #if USE_PWM && USE_ADC1 ServoInit(); asm ("repeat #640;"); Nop(); ServoStart(); #endif /* USE_PWM && USE_ADC1 */ #if USE_IMU IMUInit(); IMUStart(); #endif #if USE_SPIS SPISInit(); SPISStart(); #endif }