void main(void) { DisableInterrupts; PLL_Init_64M(); UART_Init(); Init_Port(); Init_AD(); Init_PWM(); // LCD_init(); // LCD_clear(); // RST = 1; PAT_Init(); // PWMDTY23 =6300 ; // DDRA_DDRA7 = 1; EnableInterrupts; for(;;) { Mode(); // uart_putchar('a'); /* OutData[0] = (int16)(roadflag[2]); OutData[1] = (int16)(roadflag[3]); OutData[2] = (int16)(Steer); OutData[3] = (int16)(roadflag[1]); OutPut_Data(); */ // Ramp_Detection(); GetExpectSpeed(); Steer_PID(); stop_car(); //Motor(1800); } }
void main( void ) { WDTCTL = WDTPW + WDTHOLD ; // 关看门狗 BoardConfig(0xf0); Init_Port(); InitUART(); _EINT() ; PcdReset();//复位RC522 PcdAntennaOn();//开启天线发射 DisplayConfigMenu(); while(1) { Send1Char('>'); Send1Char('\n'); i=Get1Char(); HandleConfigMenu(i); } }
void main(void) { WDTCN = 0xDE; WDTCN = 0xAD; EA = 0; Init_Clock(); Init_Port(); Init_Timer0(SYSCLK); Init_Timer2(SYSCLK); Init_Timer3(SYSCLK); EA = 1; PIN_MOTOR_DIR = 0xFF; //set motor direction to clockwise; while(1) { } }
void main() { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; Init_Port(); Lcd_initial(); unsigned int count = 0; // unsigned int count = 0; while(1) { IntToStr(count++,Chinese_0); write_digital(Chinese_0,0,0,2); // write_Chinese(Chinese_1,8,0,3); write_Chinese(Chinese_2,16,0,8); write_Chinese(Chinese_3,24,0,8); delay(10); } }
void main(void) { u16 i; u8 shortcut = KEY_INVALID; // RS485 Node init_var(); //init data structure // System Initialization Init_Port(); // Init_Timers(); // Init_Ex_Interrupt(); Init_UART(); Enable_XMEM(); Init_554(); InitLED(); Key_Init(); // Global enable interrupts WDTCR = 0x00; //disable dog watch #asm("sei") /*********************************************************************/ // System hardware dection /*********************************************************************/ // intialize LED. nextwin = 0; sleepms(20*ONEMS); LCD_Init(); wnd_msgbox(&bootup); //init the DMM nav_command(NAV_INIT); sleepms(200*ONEMS); navto1v(); nav_command(NAV_SLOWMODE); sleepms(200*ONEMS); nav_command(NAV_AFLTON); sleepms(200*ONEMS); sleepms(2*ONEMS); //wait until all the node is ready after power up State_Init(); SET_BORE_MODE; nextwin = PG_BOOTTYPE; key = KEY_INVALID; curr_ch = 1; //channel for display curr_dispch = 1; while(1) { if(nextwin != 0) { SwitchWindow(nextwin); (*curr_window)(MSG_INIT); nextwin = 0; } if(key != KEY_INVALID) { if((key == KEY_BTN1)||(key == KEY_BTN2)||(key == KEY_BTN3)||(key == KEY_BTN4)) { shortcut = key; //processing shortcut key if(curr_window == pgmain_handler) { LCD_Cls(); wnd_msgbox(&modify); } if(shortcut == KEY_BTN1) //mode switch { SET_TOP1MA; SET_TOPT1000; if(IS_BORE_MODE){ SET_THERM_MODE; }else{ SET_BORE_MODE; } dlg_cnt = 0; onesec_cnt = 0; phase = 0; //reset the state machine } if(shortcut == KEY_BTN2) //auto ktt or not { if(IS_BORE_MODE) { SET_TOP1MA; SET_TOPT1000; if((IS_MODE_KTT)){ CLR_MODE_KTT; SET_PKTT; }else{ SET_MODE_KTT; SET_PKTT; } dlg_cnt = 0; onesec_cnt = 0; phase = 0; //reset the state machine } } if(shortcut == KEY_BTN3) //thermal probe type { display_buttons(KEY_BTN3,1); if(IS_THERM_MODE) { i = sysdata.tid[curr_dispch-1]; if(i != INVALID_PROBE) { if((tprbdata.type[i] >= PRBTYPE_K) &&\ (tprbdata.type[i] <= PRBTYPE_R)) { if(tprbdata.type[i] == PRBTYPE_R) tprbdata.type[i] = PRBTYPE_K; else tprbdata.type[i] +=1; } if(rundata.reading[curr_dispch-1] > -9000) rundata.temperature[curr_dispch-1] = MValueToTValue(rundata.reading[curr_dispch-1], tprbdata.type[i]); } } display_buttons(KEY_BTN3,0); } if(shortcut == KEY_BTN4) //remove zero { display_buttons(KEY_BTN4,1); if(IS_BORE_MODE){ sysdata.R0 = rundata.Rx; }else{ //sysdata.V0 = nav_read(); nav_command(NAV_ZEROON); sleepms(1000*ONEMS); } display_buttons(KEY_BTN4,0); } if(curr_window == pgmain_handler) //redraw the running window { pgmain_handler(MSG_INIT); } shortcut = KEY_INVALID; }else{ (*curr_window)(key); } key = KEY_INVALID; }else{ if(curr_window != pgmain_handler) continue; if(dlg_cnt > 1) { onesec_cnt++; if(onesec_cnt == (ONESEC-10)) { updatestate(); } if(onesec_cnt == ONESEC) onesec_cnt = 0 ; dlg_cnt--; continue; } updatestate(); if((IS_THERM_MODE)) { if(therm_state() == 0) continue; }else{ if(bore_state() == 0) continue; } //shift to next channel while(true) { ch_to_search += 1; if(ch_to_search >= MAX_CH_NUM) { ch_to_search = 0; break; } if(IS_THERM_MODE) { i = sysdata.tid[ch_to_search]; }else{ i = sysdata.rid[ch_to_search]; } if(i == INVALID_PROBE) continue; if(IS_THERM_MODE) { if((tprbdata.type[i] >= PRBTYPE_K) && (tprbdata.type[i] <= PRBTYPE_R)) break; }else{ if((rprbdata.type[i] <= PRBTYPE_MAX) && (rprbdata.type[i] >= PRBTYPE_MIN)) break; } } } } }