void main(void){ //------------------------------------------------------------------------------ // Main Program // This is the main routine for the program. Execution of code starts here. // The operating system is Back Ground Fore Ground. // //------------------------------------------------------------------------------ Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); PJOUT |= LED1; // Turn LED 1 on to indicate boot Time_Sequence = 0; // Init_Timers(); // Initialize Timers Init_LEDs(); // Initialize LEDs //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run switch(Time_Sequence){ case 250: // 1000 msec if(one_time){ Init_LEDs(); // Initialize LEDs one_time = 0; } Time_Sequence = 0; // case 200: // 1000 msec if(one_time){ PJOUT |= LED4; // Change State of LED 4 P3OUT |= LED5; // Change State of LED 5 one_time = 0; } case 150: // 750 msec if(one_time){ PJOUT |= LED3; // Change State of LED 3 P3OUT |= LED6; // Change State of LED 6 one_time = 0; } case 100: // 500 msec if(one_time){ PJOUT |= LED2; // Change State of LED 2 P3OUT |= LED7; // Change State of LED 7 one_time = 0; } case 50: // 250 msec if(one_time){ PJOUT |= LED1; // Change State of LED 1 P3OUT |= LED8; // Change State of LED 8 one_time = 0; } break; // default: break; } Switches_Process(); // Check for switch state change if(Time_Sequence > 250){ Time_Sequence = 0; } } //------------------------------------------------------------------------------ }
void main(void){ //============================================================================== // Main Program // // Description: This function contains the while loop that runs continuously // to act for the operating system. It also calls all the functions to // initialize the system. // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: volatile unsigned int Time_Sequence; // volatile char one_time; // char* display_1 // char* display_2 // char* display_3 // char* display_4 // slow_input_down // control_state[CNTL_STATE_INDEX] // char big // char size_count; // char posL1 // char posL2 // char posL3 // char posL4 // // Author: David Pryor // Date: Feb 2016 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1) //============================================================================== Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Time_Sequence = SWITCH_OFF; // Init_Timers(); // Initialize Timers Init_LEDs(); // Initialize LEDs Init_LCD(); // Initialize LCD Init_ADC(); // Initialize ADC //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run Menu_Process(); ADC_Process(); // call sampling function if(display_count >= FOR_FOURTH_SECOND){ // update screen every 250 msec Display_Process(); display_count = SWITCH_OFF; } if(menu_items == FALSE){ display_4 = "SW2: Menu"; } if(switch_two_pressed){ menu_items = TRUE; switch_two_pressed = SWITCH_OFF; } } //------------------------------------------------------------------------------ }
void draw_circle(void){ Time_Sequence=0; int i=0; // 1234567890 display_1 = "FirstTask"; posL1 = 0; display_2 = "DrawCircle"; posL2 = 0; display_3 = "ECE306"; posL3 = 2; display_4 = "Skang"; posL4 = 3; big = 0; Display_Process(); while(Time_Sequence<300){} Time_Sequence=0; //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(i<10) { // Can the Operating system run switch(Time_Sequence){ case 20: // 100 msec if(one_time){ Init_LEDs(); // Initialize LEDs one_time = 0; i++; } Time_Sequence = 0; // case 18: // 50 msec if(one_time){ P3OUT |= LED5; // Change State of LED 5 one_time = 0; } case 1: // if(one_time){ P3OUT |= LED7; // Change State of LED 7 one_time = 0; } break; // default: break; } if(Time_Sequence > 20){ Time_Sequence = 0; } } current_job=circle; next_job=eight; }
void main(void){ //============================================================================== // Main Program // // Description: This function contains the while loop that runs continuously // to act for the operating system. It also calls all the functions to // initialize the system. // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: volatile unsigned int Time_Sequence; // volatile char one_time; // char* display_1 // char* display_2 // char* display_3 // char* display_4 // slow_input_down // control_state[CNTL_STATE_INDEX] // char big // char size_count; // char posL1 // char posL2 // char posL3 // char posL4 // // Author: David Pryor // Date: Feb 2016 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1) //============================================================================== Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Time_Sequence = SWITCH_OFF; // Init_Timers(); // Initialize Timers Init_LEDs(); // Initialize LEDs Init_LCD(); // Initialize LCD Init_ADC(); // Initialize ADC Init_Serial_UCA1(0); // BAUD rate 9600 Init_Serial_UCA0(1); // BAUD rate 9600 Five_msec_Delay(1); PJOUT |= IOT_STA_MINIAP; //turning on miniap (only works this way) IR_LED_OFF(); lcd_BIG_mid(); display_1 = " David "; display_2 = "Project 8"; display_3 = " Pryor "; display_4 = ""; Display_Process(); //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run ADC_Process(); // call sampling function if(MainFG){ Menu_Process(); } else if(BaudMenuFG==TRUE){ Baud_Menu(); } else if(IOTMenuFG==TRUE){ IOT_Menu(); } if(StartCommandFG){ //StartCommandFG is true once "." has been received commandTree(); } printMacAddress(); //prints mac address to screen macFG=FALSE; //turn off command to print mac address clearReceiveBuffer(); parseIOTData(); } //------------------------------------------------------------------------------ }
void main(void){ //============================================================================== // Main Program // // Description: This function contains the while loop that runs continuously // to act for the operating system. It also calls all the functions to // initialize the system. // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: volatile unsigned int Time_Sequence; // volatile char one_time; // char* display_1 // char* display_2 // char* display_3 // char* display_4 // slow_input_down // control_state[CNTL_STATE_INDEX] // char big // char size_count; // char posL1 // char posL2 // char posL3 // char posL4 // // Author: David Pryor // Date: Feb 2016 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1) //============================================================================== Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Time_Sequence = SWITCH_OFF; // Init_Timers(); // Initialize Timers five_msec_sleep(COUNT_TWOFIDDY_MSEC); // 250 msec delay for the clock to settle (50) Init_LEDs(); // Initialize LEDs Init_LCD(); // Initialize LCD // 1234567890 display_1 = "NCSU"; posL1 = LINE_POS_3; display_2 = "WOLFPACK"; posL2 = LINE_POS_1; display_3 = "ECE306"; posL3 = LINE_POS_2; display_4 = "D Pryor"; posL4 = LINE_POS_1; big = SWITCH_OFF; Display_Process(); //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run switch(Time_Sequence){ case COUNT_TWELVEFIDDY_MSEC: // 1250 msec (250) if(one_time){ Init_LEDs(); // Initialize LEDs one_time = SWITCH_OFF; } Time_Sequence = SWITCH_OFF; // case COUNT_ONETHOUSAND_MSEC: // 1000 msec (200) if(one_time){ one_time = SWITCH_OFF; } case COUNT_SEVENFIDDY_MSEC: // 750 msec (150) if(one_time){ one_time = SWITCH_OFF; } case COUNT_FIVEHUNNED_MSEC: // 500 msec (100) if(one_time){ one_time = SWITCH_OFF; } case COUNT_TWOFIDDY_MSEC: // 250 msec (50) if(one_time){ one_time = SWITCH_OFF; } size_count++; if(size_count > MAX_SIZE_COUNT){ size_count = SWITCH_OFF; if(big){ //lcd_BIG_mid(); big = SWITCH_OFF; }else{ //lcd_4line(); big = SWITCH_ON; } } Display_Process(); break; // default: break; } Switches_Process(); // Check for switch state change if(Time_Sequence > COUNT_TWELVEFIDDY_MSEC){ Time_Sequence = SWITCH_OFF; } } //------------------------------------------------------------------------------ }
void main(void){ //============================================================================== // Main Program // // Description: This function contains the while loop that runs continuously // to act for the operating system. It also calls all the functions to // initialize the system. // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: volatile unsigned int Time_Sequence; // volatile char one_time; // char* display_1 // char* display_2 // char* display_3 // char* display_4 // slow_input_down // control_state[CNTL_STATE_INDEX] // char big // char size_count; // char posL1 // char posL2 // char posL3 // char posL4 // // Author: David Pryor // Date: Feb 2016 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1) //============================================================================== Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Time_Sequence = SWITCH_OFF; // Init_Timers(); // Initialize Timers Init_LEDs(); // Initialize LEDs Init_LCD(); // Initialize LCD //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run if(do_this == TRUE){ Five_msec_Delay(FOR_ONE_SECOND); //pause display_2 = "FORWARD"; //change display posL2 = LINE_POS_1; Display_Process(); //push display straight_line(); //forward Five_msec_Delay(FOR_ONE_SECOND); //pause display_2 = "REVERSE"; //change display posL2 = LINE_POS_1; Display_Process(); //push display straight_line_reverse(); //reverse Five_msec_Delay(FOR_ONE_SECOND); display_2 = "FORWARD"; //change display posL2 = LINE_POS_1; Display_Process(); //push display straight_line(); //forward Five_msec_Delay(FOR_ONE_SECOND); display_2 = "CW-SPIN"; //change display posL2 = LINE_POS_1; Display_Process(); //push display clockwise_spin(); //forward Five_msec_Delay(FOR_ONE_SECOND); display_2 = "CCW-SPIN"; //change display posL2 = LINE_POS_1; Display_Process(); //push display counterclockwise_spin(); //forward Five_msec_Delay(FOR_ONE_SECOND); //pause display_2 = ""; //clear display posL2 = LINE_POS_1; Display_Process(); //push display do_this = FALSE; } } //------------------------------------------------------------------------------ }
int main( void ) { /****************UART SET*******************/ *pPICR2 &= ~(0x1F); //Sets the UART0 receive interrupt to P12 *pPICR2 |= (0x13<<0); initPLL_DDR2(); *pUART0LCR=0; *pUART0IER = UARTRBFIE; // enables UART0 receive interrupt /****************SYS INIT*******************/ initDPI(); initUART(); Init_LEDs(); Init_PushButtons(); sysreg_bit_clr(sysreg_MODE1, IRPTEN ); /* disable global interrupts */ /* unmask individual interrupts */ (*pDAI_IRPTL_PRI) = (SRU_EXTMISCA1_INT | SRU_EXTMISCA2_INT); /* make sure interrupts latch on the rising edge */ (*pDAI_IRPTL_RE) = (SRU_EXTMISCA1_INT | SRU_EXTMISCA2_INT); /* setup the IRQ pins to use the pushbuttons */ (*pSYSCTL) |= (IRQ1EN | IRQ2EN); sysreg_bit_set(sysreg_MODE2, (IRQ1E | IRQ2E) ); /* enable IRQ interrupts and make DAI interrupts high priority */ sysreg_bit_set(sysreg_IMASK, (IRQ1I | IRQ2I | DAIHI) ); sysreg_bit_clr(sysreg_IMASKP, (IRQ1I | IRQ2I | DAIHI) ); sysreg_bit_set(sysreg_LIRPTL, P12IMSK ); sysreg_bit_clr(sysreg_LIRPTL, P12IMSKP ); sysreg_bit_clr(sysreg_IRPTL, (IRQ1I | IRQ2I) ); sysreg_bit_clr(sysreg_LIRPTL, P12I ); /* register the interrut handlers */ Int_Init(); Int_IsrConnect(cn_int_line_IRQ2I,SW9_IRQ2_handler); Int_RestoreRealLine(cn_int_line_IRQ2I); Int_IsrConnect(cn_int_line_IRQ1I,SW8_IRQ1_handler); Int_RestoreAsynLine(cn_int_line_IRQ1I); Int_IsrConnect(cn_int_line_DAII,__int_engine_dai); Int_RestoreAsynLine(cn_int_line_DAII); Int_IsrConnect(cn_int_line_P12I,UARTisr); Int_RestoreAsynLine(cn_int_line_P12I); Int_CutTrunk(); Int_ContactTrunk(); sysreg_bit_clr(sysreg_IRPTL, (IRQ1I | IRQ2I) ); NOP;NOP; sysreg_bit_clr(sysreg_LIRPTL, P12I ); NOP;NOP; sysreg_bit_set(sysreg_MODE1, NESTM ); /* enable interrupts nest */ sysreg_bit_set(sysreg_MODE1, IRPTEN ); /* enable global interrupts */ // 测试通过 // atom_high_test=Int_HighAtomStart(); // Int_HighAtomEnd(atom_high_test); // atom_low_test=Int_LowAtomStart(); // Int_LowAtomEnd(atom_low_test); // 测试通过 Int_TapLine(cn_int_line_IRQ2I); // Int_TapLine(cn_int_line_DAII); // Int_TapLine(cn_int_line_P12I); Int_TapLine(cn_int_line_IRQ1I); // 测试通过 // bool_value=Int_QueryLine(cn_int_line_IRQ2I); // bool_value=Int_QueryLine(cn_int_line_IRQ1I); // bool_value=Int_QueryLine(cn_int_line_DAII); // bool_value=Int_QueryLine(cn_int_line_P12I); // 测试通过 // Int_CutLine(cn_int_line_SFT3I); // Int_CutLine(cn_int_line_P17I); // Int_CutLine(cn_int_line_IRQ2I); /****************UART TEST******************/ xmitUARTmessage(welcomemessage,sizeof(welcomemessage)); xmitUARTmessage("CYG Copyright \n\r",sizeof("CYG Copyright \n\r")); while(1) { Blink_LED(10000000); // Int_TapLine(cn_int_line_IRQ2I); // xmitUARTmessage("CYG Copyright \n\r",sizeof("CYG Copyright \n\r")); // Int_TapLine(cn_int_line_DAII); } /* Begin adding your custom code here */ return 0; }