void setup() { video_clear(); printf("-= o00oO =- Starting....\n\n"); init_serial_uart(PORT_COM1); printf("serial1 ready\n"); // init_serial_uart(PORT_COM2); printf("serial2 ready\n"); // init_serial_uart(PORT_COM3); printf("serial3 ready\n"); // init_serial_uart(PORT_COM4); printf("serial4 ready\n"); printf("-= o00oO =- Crash OS ready.\n\n"); }
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(); Init_Clocks(); Init_Conditions(); init_timers(); five_msec_delay(QUARTER_SECOND); Init_LCD(); setup_sw_debounce(); init_adc(); P1OUT |= IR_LED; init_serial_uart(); WDTCTL = WDTPW + WDTHOLD; setup_pwm(); set_motor_speed(R_FORWARD, PWM_RES); set_motor_speed(L_FORWARD, PWM_RES); unsigned int time_sequence = START_VAL; // counter for switch loop unsigned int previous_count = START_VAL; // automatic variable for // comparing timer_count unsigned int display_count = START_VAL; is_follow_running = FALSE; //------------------------------------------------------------------------------ // Begining of the "While" Operating System //------------------------------------------------------------------------------ while(ALWAYS) { // Can the Operating system run if(get_timer_count() > display_count + QUARTER_SECOND) { display_count = get_timer_count(); Display_Process(); time_sequence = START_VAL; } update_switches(); // Check for switch state change update_menu(); if(is_follow_running) run_follow(); if(uca0_is_message_received()) { BufferString message = uca0_read_buffer(TRUE); receive_command(message.head + message.offset); } if(uca1_is_message_received()) { update_menu(); BufferString message = uca1_read_buffer(TRUE); uca0_transmit_message(message.head, message.offset); if(find(WIFI_COMMAND_SYMBOL, message)) { receive_command(message.head + message.offset); } if(find(LOST_WIFI_COMMAND_SYMBOL, message)) { receive_command(CONNECT_NCSU); } } if(time_sequence > SECOND_AND_A_QUARTER) time_sequence = START_VAL; unsigned int current_timer_count = get_timer_count(); if(current_timer_count > previous_count) { previous_count = current_timer_count % UINT_16_MAX; time_sequence++; } } //------------------------------------------------------------------------------ }