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) { Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Init_Interrupts(); TimeMsec = RESET_TIME; Init_Timers(); // Initialize Timers Init_LCD(); // Initialize LCD // "0123456789abcdef" display_1 = " Homework 9 "; display_2 = " "; Display_Process(); /* ---------- Begining of the "While" Operating System ------------- */ while(ALWAYS) // Can the Operating system run { ADC_Process(); Control_Process(); Menu_Process(); if(TimeMsec % EVERY_50 == RESET_TIME) { Display_Process(); } } }
int video_init(void *dst) { #ifdef CONFIG_MK_BF527_EZKIT_REV_2_1 lq035q1_control(LQ035_SHUT_CTL, LQ035_ON); lq035q1_control(LQ035_DRIVER_OUTPUT_CTL, (CONFIG_LQ035Q1_LCD_MODE & LQ035_DRIVER_OUTPUT_MASK) | LQ035_DRIVER_OUTPUT_DEFAULT); #endif Init_Ports(); Init_DMA(dst); EnableDMA(); InitTIMER0(); InitTIMER1(); Init_PPI(); EnablePPI(); #ifdef CONFIG_MK_BF527_EZKIT_REV_2_1 EnableTIMER12(); #else /* Frame sync 2 (VS) needs to start at least one PPI clk earlier */ EnableTIMER1(); /* Add Some Delay ... */ SSYNC(); SSYNC(); SSYNC(); SSYNC(); /* now start frame sync 1 */ EnableTIMER0(); #endif return 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 Init_StartUp(VOID) { __disable_interrupt(); // Disable global interrupts Init_Ports(); // Init ports (do first ports because clocks do change ports) SetVCore(3); // USB core requires the VCore set to 1.8 volt, independ of CPU clock frequency Init_Clock(); __enable_interrupt(); // enable global interrupts }
int video_init(void *dst) { Init_Ports(); Init_DMA(dst); EnableDMA(); Init_PPI(); EnablePPI(); return 0; }
void Init_Peripherals(void) { Init_Ports(); Init_ADC_Pin(); Init_ADC0(); Init_ADC1(); Init_Sensor_Switch_Pin(); SPI1_Init(); Init_PWM(); }
int main(void) { Init_Ports(); Init_Lcd(); usart_init(); while(1) { } }
VOID Init_StartUp(VOID) { unsigned short bGIE; bGIE = (__get_SR_register() &GIE); //save interrupt status __disable_interrupt(); // Disable global interrupts # ifdef __MSP430F6638 // only for F663x devices! while (BAKCTL & LOCKBAK) // check if bit for backup subsystem is cleared { BAKCTL &= ~LOCKBAK; // clear lock backup bit for backup subsystem } # endif Init_Ports(); // Init ports (do first ports because clocks do change ports) SetVCore(3); // USB core requires the VCore set to 1.8 volt, independ of CPU clock frequency Init_Clock(); __bis_SR_register(bGIE); //restore interrupt status }
void main(void) { Init_Ports(); // Initialize Ports Init_Clocks(); // Initialize Clock System Init_Conditions(); Init_Interrupts(); //PJOUT |= LED1; // Turn LED 1 on to indicate boot TimeMsec = RESET_TIME; Init_Timers(); // Initialize Timers Init_LCD(); // Initialize LCD //Init_LEDs(); // Initialize LEDs // "0123456789abcdef" display_1 = " PROJECT 5 "; display_2 = " "; Display_Process(); P1OUT |= IR_LED; waitMsec(10); /* ---------- Begining of the "While" Operating System ------------- */ while(ALWAYS) // Can the Operating system run { if(TimeMsec % EVERY_50 == RESET_TIME) Display_Process(); //Refreshes screen every 50 'ticks' if(TimeMsec % EVERY_2 == RESET_TIME) { Switches_Process(); // Poll for switch state change every other 'tick' ADC_Process(); } Motors_Process(); Control_Process(); } }
//---------------------------------------------------------------------------- VOID Init_StartUp(VOID) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer __disable_interrupt(); // Disable global interrupts Init_Ports(); // Init ports (do first ports because clocks do change ports) SetVCore(3); // USB core requires the VCore set to 1.8 volt, independ of CPU clock frequency Init_Clock(); __enable_interrupt(); // enable global interrupts Port_Mapping(); #ifdef UART0_INTFNUM InitUart0(9600); #endif #ifdef UART1_INTFNUM InitUart1(9600); #endif }
VOID Init_StartUp(VOID) { unsigned short bGIE; bGIE = (__get_SR_register() &GIE); //save interrupt status __disable_interrupt(); // Disable global interrupts # ifdef __MSP430F6638 // only for F663x devices! while (BAKCTL & LOCKBAK) // check if bit for backup subsystem is cleared { BAKCTL &= ~LOCKBAK; // clear lock backup bit for backup subsystem } # endif Init_Ports(); // Init ports (do first ports because clocks do change ports) SetVCore(3); // USB core requires the VCore set to 1.8 volt, independ of CPU clock frequency Init_Clock(); # if 0 // Use for FET boards // Configure P1.6 as a button input P1DIR &= ~BIT6; // Input P1OUT |= BIT6; P1REN |= BIT6; // Together with P1OUT, creates a pullup P1IFG &= ~BIT6; // Clear the flag P1IE |= BIT6; // Enable interrupts # else // Use for F5529 EXP board P1DIR &= ~BIT7; // Input P1OUT |= BIT7; P1REN |= BIT7; // Together with P1OUT, creates a pullup P1IFG &= ~BIT7; // Clear the flag P1IE |= BIT7; // Enable interrupts # endif __bis_SR_register(bGIE); //restore interrupt status }
int video_init(void *dst) { Init_Ports(); Init_DMA(dst); EnableDMA(); InitTIMER0(); InitTIMER1(); Init_PPI(); EnablePPI(); /* Frame sync 2 (VS) needs to start at least one PPI clk earlier */ EnableTIMER1(); /* Add Some Delay ... */ SSYNC(); SSYNC(); SSYNC(); SSYNC(); /* now start frame sync 1 */ EnableTIMER0(); return 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 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; } } //------------------------------------------------------------------------------ }
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(); } //------------------------------------------------------------------------------ }
/* * ======== main ======== */ VOID main (VOID) { WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer Init_Ports(); //Init ports (do first ports because clocks do change ports) SetVCore(3); Init_Clock(); //Init clocks USB_init(); //Init USB Init_TimerA1(); //Enable various USB event handling routines USB_setEnabledEvents( kUSB_VbusOnEvent + kUSB_VbusOffEvent + kUSB_receiveCompletedEvent + kUSB_dataReceivedEvent + kUSB_UsbSuspendEvent + kUSB_UsbResumeEvent + kUSB_UsbResetEvent); //See if we're already attached physically to USB, and if so, connect to it //Normally applications don't invoke the event handlers, but this is an exception. if (USB_connectionInfo() & kUSB_vbusPresent){ USB_handleVbusOnEvent(); } __enable_interrupt(); //Enable interrupts globally while (1) { BYTE i; //Check the USB state and directly main loop accordingly switch (USB_connectionState()) { case ST_USB_DISCONNECTED: __bis_SR_register(LPM3_bits + GIE); //Enter LPM3 w/ interrupts enabled _NOP(); //For Debugger break; case ST_USB_CONNECTED_NO_ENUM: break; case ST_ENUM_ACTIVE: __bis_SR_register(LPM0_bits + GIE); //Enter LPM0 (can't do LPM3 when active) _NOP(); //For Debugger //Exit LPM on USB receive and perform a receive //operation if (bCDCDataReceived_event){ //Some data is in the buffer; begin receiving a //command char pieceOfString[MAX_STR_LENGTH] = ""; //Holds the new addition to the string char outString[MAX_STR_LENGTH] = ""; //Holds the outgoing string //Add bytes in USB buffer to theCommand cdcReceiveDataInBuffer((BYTE*)pieceOfString, MAX_STR_LENGTH, CDC0_INTFNUM); //Get the next piece of the string strcat(wholeString,pieceOfString); cdcSendDataInBackground((BYTE*)pieceOfString, strlen(pieceOfString),CDC0_INTFNUM,0); //Echoes back the characters received (needed //for Hyperterm) if (retInString(wholeString)){ //Has the user pressed return yet? if (!(strcmp(wholeString, "LED ON"))){ //Compare to string #1, and respond TA1CTL &= ~MC_1; //Turn off Timer P1OUT |= BIT0; //Turn on LED P1.0 strcpy(outString,"\r\nLED is ON\r\n\r\n"); //Prepare the outgoing string cdcSendDataInBackground((BYTE*)outString, strlen(outString),CDC0_INTFNUM,0); //Send the response over USB } else if (!(strcmp(wholeString, "LED OFF"))){ //Compare to string #2, and respond TA1CTL &= ~MC_1; //Turn off Timer P1OUT &= ~BIT0; //Turn off LED P1.0 strcpy(outString,"\r\nLED is OFF\r\n\r\n"); //Prepare the outgoing string cdcSendDataInBackground((BYTE*)outString, strlen(outString),CDC0_INTFNUM,0); //Send the response over USB } else if (!(strcmp(wholeString, "LED TOGGLE - SLOW"))){ //Compare to string #3, and respond TA1CTL &= ~MC_1; //Turn off Timer TA1CCR0 = SlowToggle_Period; //Set Timer Period for slow LED toggle TA1CTL |= MC_1; //Start Timer strcpy(outString, "\r\nLED is toggling slowly\r\n\r\n"); //Prepare the outgoing string cdcSendDataInBackground((BYTE*)outString, strlen(outString),CDC0_INTFNUM,0); //Send the response over USB } else if (!(strcmp(wholeString, "LED TOGGLE - FAST"))){ //Compare to string #4, and respond TA1CTL &= ~MC_1; //Turn off Timer TA1CCR0 = FastToggle_Period; //Set Timer Period for fast LED toggle TA1CTL |= MC_1; strcpy(outString,"\r\nLED is toggling fast\r\n\r\n"); //Prepare the outgoing string cdcSendDataInBackground((BYTE*)outString, strlen(outString),CDC0_INTFNUM,0); //Send the response over USB } else { //Handle other strcpy(outString,"\r\nNo such command!\r\n\r\n"); //Prepare the outgoing string cdcSendDataInBackground((BYTE*)outString, strlen(outString),CDC0_INTFNUM,0); //Send the response over USB } for (i = 0; i < MAX_STR_LENGTH; i++){ //Clear the string in preparation for the next //one wholeString[i] = 0x00; } } bCDCDataReceived_event = FALSE; } break; case ST_ENUM_SUSPENDED: P1OUT &= ~BIT0; //When suspended, turn off LED __bis_SR_register(LPM3_bits + GIE); //Enter LPM3 w/ interrupts _NOP(); break; case ST_ENUM_IN_PROGRESS: break; case ST_NOENUM_SUSPENDED: P1OUT &= ~BIT0; __bis_SR_register(LPM3_bits + GIE); _NOP(); break; case ST_ERROR: _NOP(); break; default:; } } //while(1) } //main()
void Init_Peripherals(void) { Init_Ports(); Timer0_Init(); }
void lcdInit(void) { Init_Ports(); // configure the ports Init_Lcd(); // initialize the LCD delay(100); // wait for the LCD to boot up }
void Init_Peripherals(void) { Init_Ports(); Init_UART0(); }
void Init_Peripherals(void) { Init_Ports(); }