int main(void) { unsigned int wait = 0; int readcount = 0; Serial_init(); INTEnableSystemMultiVectoredInt(); mJTAGPortEnable(0); printf("\r\nUno A/D Test Harness\r\nThis will initialize all A/D pins and read them %d times", TIMES_TO_READ); printf("Value of pcfg before test: %X",AD1PCFG); AD_init(AD_PORTV3 | AD_PORTV4 | AD_PORTV5 | AD_PORTV6 | AD_PORTV7 | AD_PORTV8 | AD_PORTW3 | AD_PORTW4 | AD_PORTW5 | AD_PORTW6 | AD_PORTW7 | AD_PORTW8 | BAT_VOLTAGE); char numtoread = 13; unsigned char cur = 0; while (readcount <= TIMES_TO_READ) { for (wait = 0; wait <= 100000; wait++) asm("nop"); printf("\r\n"); for (cur = 0; cur < numtoread; cur++) { printf("%d\t", AD_readPin(1 << cur)); } printf("\r\n"); readcount++; } printf("Done Reading Them\r\n"); AD_end(); printf("Value of pcfg after test: %X",AD1PCFG); return 0; }
int main(void) { // Initialize the UART,Timers, and I2C1v Board_init(); Serial_init(); Encoder_init(); float angle; while(1){ if(Encoder_isLockPressed() || Encoder_isZeroPressed()){ Encoder_runSM(); // if(useZeroAngle){ // angle = Encoder_getAverageAngle(); // while(!Serial_isTransmitEmpty()); // printf("Angle: %.2f\n", angle); // } // else // zeroAngle = Encoder_getZeroAngle(); // // useZeroAngle = FALSE; // zeroFlag = FALSE; } } return (SUCCESS); }
int main(void){ // Initialize the UART,Timers, and I2C1 int count = 0; Board_init(); Timer_init(); Serial_init(); Thermal_init(); while(1){ if(count == 0){ readChipTemp(); calculateChipTemp(); } count++; if(count >= 16){ count = 0; } readPixelValue(); readCPixelValue(); calculateIRTemp(); int i; for(i = 0; i <= 63; ++i){ while(!Serial_isTransmitEmpty()); printf("V_ir[%d]: %.2f\n",i,finalPixelTempF[i]); } } }
int main(){ Board_init(); Serial_init(); Timer_init(); Xbee_init(XBEE_UART_ID); printf("Xbee Test 2\n"); while(1){ Xbee_runSM(); //if(!UART_isTransmitEmpty(UART1_ID)); //printf("%d\t",Mavlink_returnACKStatus(messageName_start_rescue)); if(!UART_isReceiveEmpty(UART1_ID)){ Serial_getChar(); Mavlink_send_start_rescue(UART2_ID, TRUE, 0xFF, 0x34FD, 0xAB54); Timer_new(TIMER_TIMEOUT, DELAY_TIMEOUT); printf("\nSENT\n"); } else if(Timer_isActive(TIMER_TIMEOUT) != TRUE && Mavlink_returnACKStatus(messageName_start_rescue) == ACK_STATUS_WAIT){ //else if(Timer_isActive(TIMER_TIMEOUT) != TRUE){ Mavlink_editACKStatus(messageName_start_rescue, ACK_STATUS_DEAD); printf("ACK DEAD\n"); } else if(Mavlink_returnACKStatus(messageName_start_rescue) == ACK_STATUS_DEAD){ Mavlink_send_start_rescue(UART2_ID, TRUE, 0xFF, 0x34FD, 0xAB54); Timer_new(TIMER_TIMEOUT, DELAY_TIMEOUT); } else if(Mavlink_returnACKStatus(messageName_start_rescue) == ACK_STATUS_RECIEVED){ Mavlink_editACKStatus(messageName_start_rescue, ACK_STATUS_NO_ACK); printf("GPS SENT AND ACKOWLEGED\n"); } } }
void setup( void ) { NVM_ResetReason_t resetReason; /* Assume data is invalid to begin with */ g_sampleDataValid = false; WDT_init(); LED_init(); /* Initialize serial UART drivers */ Serial_init(); /* Initialize sensors */ GPS_init(); OBD_init(); /* Print or initialize the reset reason */ if ( NVM_getResetReason( &resetReason ) ) { /* Valid reset reason */ if ( NVM_RESET_REASON_NORMAL != resetReason ) { Log_printf( "Reset Reason: 0x%02X\n", resetReason ); } } else { /* Invalid reset reason, initialize it */ NVM_setResetReason( NVM_RESET_REASON_NORMAL ); } /* Start the watchdog timer */ WDT_enable( WDT_TIMEOUT_MAX ); }
/** * Initialization routine for the software and hardware side of MIDI comm. */ void configure_MIDI() { MIDIpacket.Event = 0; MIDIpacket.Data1 = 0; MIDIpacket.Data2 = 0; MIDIpacket.Data3 = 0; MIDIpacket_out.Event = 0; MIDIpacket_out.Data1 = 0; MIDIpacket_out.Data2 = 0; MIDIpacket_out.Data3 = 0; Serial_init(); }
int main(void) { Board_init(); Serial_init(); LCD_init(); Timer_init(); printf("Testing the LCD display.\nYou should see: Hello World!\n"); LCD_writeString("Hello World!\nLine2\nLine3\nLine4\n"); Timer_new(TIMER_TEST,WRITE_DELAY); while (!Timer_isExpired(TIMER_TEST)) { asm("nop"); } printf("Overwriting line 1\n"); LCD_writeString("Testing overtop line1.\n"); Timer_new(TIMER_TEST,WRITE_DELAY); while (!Timer_isExpired(TIMER_TEST)) { asm("nop"); } printf("Clearing Display\n"); LCD_clearDisplay(); Timer_new(TIMER_TEST,WRITE_DELAY); while (!Timer_isExpired(TIMER_TEST)) { asm("nop"); } LCD_writeString("Here.we.go\n"); LCD_writeString("CLEARED!\n"); LCD_writeString("CLEARED2!\n"); LCD_writeString("CLEARED3!\n"); Timer_new(TIMER_TEST,WRITE_DELAY); while (!Timer_isExpired(TIMER_TEST)) { asm("nop"); } LCD_clearDisplay(); LCD_writeString("N: E: \n"); char tmp[10]; LCD_setPosition(0,3); sprintf(tmp,"%.2f",12.5f); LCD_writeString(tmp); LCD_setPosition(0,13); sprintf(tmp,"%.2f",-0.32f); LCD_writeString(tmp); return SUCCESS; }
int main(void) { // Initialize the UART,Timers, and I2C1v Board_init(); Serial_init(); I2C_init(MAGNETOMETER_I2C_ID, I2C_CLOCK_FREQ); Magnetometer_init(); while(1){ Magnetometer_runSM(); while(!Serial_isTransmitEmpty()); printf("Angle: %.1f\n", Magnetometer_getDegree()); } return (SUCCESS); }
int main(void) { /* Set these since libopencm3 expects them and the kernel has already * set the clock. */ rcc_ppre1_frequency = 24000000; rcc_ppre2_frequency = 24000000; LED_init(); GPIO_init(); Serial_init(); HTTP_init(); Serial_run(); }
int main(){ //Initializations Board_init(); Serial_init(); Timer_init(); Drive_init(); ENABLE_OUT_TRIS = OUTPUT; ENABLE_OUT_LAT = MICRO; #ifdef RECIEVE_CONTROL ENABLE_OUT_LAT = RECIEVER; while(1){ asm("nop"); } #endif printf("State machine test harness.\n\n"); // Test forward state printf("Forward state. Driving at 5, 10, 20, 40, 60, 80, 100, 125 \%.\n"); uint8_t speed[] = {5, 10, 20, 40, 60, 80, 100, 125}; int i, len = sizeof(speed); delayMillisecond(STATE_DELAY); for (i = 0; i < len; i++) { Drive_forward(speed[i]); delayMillisecond(STATE_DELAY); } Drive_stop(); delayMillisecond(STATE_DELAY); setRudder(STOP_PULSE); delayMillisecond(STATE_DELAY); // Forward with heading printf("Track state. Driving at 5, 10, 25, 50, 100 \% at 0 deg north.\n"); uint8_t speed2[] = {5, 10, 25, 50, 100}; len = sizeof(speed2); delayMillisecond(STATE_DELAY); for (i = 0; i < len; i++) { Drive_forwardHeading(speed2[i], 0); delayMillisecond(STATE_DELAY); } Drive_stop(); printf("Finished state machine test.\n\n"); return SUCCESS; }
int main(){ //Initializations Board_init(); Serial_init(); Timer_init(); if (Drive_init() != SUCCESS) { printf("Failed to initialize drive module.\n"); } I2C_init(TILT_COMPASS_I2C_ID, I2C_CLOCK_FREQ); if (TiltCompass_init() != SUCCESS) { printf("Failed to initialize tilt compass module.\n"); } ENABLE_OUT_TRIS = OUTPUT; while (1) { printf("Driving north at full speed.\n"); Timer_new(TIMER_TEST, COMMAND_DELAY); Drive_forwardHeading(100, 0); while(!Timer_isExpired(TIMER_TEST)) { //wait for finish DELAY(1); Drive_runSM(); TiltCompass_runSM(); } Drive_stop(); Drive_runSM(); TiltCompass_runSM(); printf("Driving south at full speed.\n"); Timer_new(TIMER_TEST, COMMAND_DELAY); Drive_forwardHeading(100, 180); while(!Timer_isExpired(TIMER_TEST)) { //wait for finish DELAY(1); Drive_runSM(); TiltCompass_runSM(); } Drive_stop(); Drive_runSM(); TiltCompass_runSM(); delayMillisecond(COMMAND_DELAY); printf("Waiting for retry...\n"); } return SUCCESS; }
int main(void) { Board_init(); Serial_init(); printf("\r\nUno Serial Test Harness\r\nAfter this Message the terminal should mirror anything you type.\r\n"); unsigned char ch = 0; while (1) { if (Serial_isTransmitEmpty() == TRUE) if (Serial_isReceiveEmpty() == FALSE) Serial_putChar(Serial_getChar()); } return 0; }
void Board_configure(uint8_t opts) { DELAY(STARTUP_DELAY ); if (opts & USE_TIMER) { Timer_init(); } if (opts & USE_SERIAL) { option.useSerial = TRUE; Serial_init(); } if (opts & USE_LCD) { option.useLCD = TRUE; //LCD_init(); } DELAY(STARTUP_DELAY ); }
int main(){ //Initializations Board_init(); Serial_init(); Timer_init(); Drive_init(); ENABLE_OUT_TRIS = OUTPUT; ENABLE_OUT_LAT = MICRO; setLeftMotor(100); setRightMotor(100); while (1) asm("nop"); return SUCCESS; }
int main() { ENABLE_OUT_TRIS = OUTPUT; //Set Enable output pin to be an output, fed to the AND gates ENABLE_OUT_LAT = MICRO; //Initialize control to that of Microcontroller Board_init(); Serial_init(); Timer_init(); Drive_init(); I2C_init(I2C_BUS_ID, I2C_CLOCK_FREQ); TiltCompass_init(); printf("Boat initialized.\n"); Drive_stop(); DELAY(5); #ifdef MOTOR_TEST Drive_pivot(0); #endif #ifdef RUDDER_TEST Drive_forwardHeading(0.0, desiredHeading); #endif int i = 0; int velocity[] = {1600, 1600, 1600, 1600, 1600}; velocityPulse = velocity[i]; Timer_new(TIMER_TEST,FINISH_DELAY); while (1) { if (Timer_isExpired(TIMER_TEST)) { i++; if (i == 5){ i = 0; } velocityPulse = velocity[i]; printf("CURRENT VELOCITY: %d\n\n",velocityPulse); Timer_new(TIMER_TEST,FINISH_DELAY); } Drive_runSM(); TiltCompass_runSM(); } Drive_stop(); return SUCCESS; }
/** * Function: initMasterSM * @return None. * @remark Initializes the master state machine for the command canter. * @author David Goodman * @date 2013.03.10 */ void initMasterSM() { Board_init(); Serial_init(); Timer_init(); // CC buttons LOCK_BUTTON_TRIS = 1; ZERO_BUTTON_TRIS = 1; Encoder_init(); #ifdef USE_XBEE Xbee_init(); #endif #ifdef USE_NAVIGATION Navigation_init(); #endif #ifdef USE_ENCODERS I2C_init(I2C_BUS_ID, I2C_CLOCK_FREQ); #endif #ifdef USE_ACCELEROMETER //printf("Initializing accelerometer...\n"); if (Accelerometer_init() != SUCCESS) { printf("Failed to initialize the accelerometer.\n"); //return; } //printf("Initialized the accelerometer.\n"); // Configure ports as outputs LED_N_TRIS = OUTPUT; LED_S_TRIS = OUTPUT; LED_E_TRIS = OUTPUT; LED_W_TRIS = OUTPUT; Timer_new(TIMER_ACCELEROMETER, LED_DELAY ); #endif }
int main(void) { //initializations Board_init(); Serial_init(); Timer_init(); LCD_init(); Interface_init(); printf("INITIALIZATIONS COMPLETE\n"); LCD_writeString("Interface online.\n"); Timer_new(TIMER_TEST, 100); while (1) { if (Timer_isExpired(TIMER_TEST)) { printf("%X -- C:%X F:%X\n",Interface_isOkPressed(), buttonCount.okay, buttonPressed.flag.okay); Timer_new(TIMER_TEST, 100); } Interface_runSM(); } }
/********************************************************************** * Function: initializeAtlas * @return None. * @remark Initializes the boat's master state machine and all modules. * @author David Goodman * @date 2013.04.24 **********************************************************************/ static void initializeAtlas() { Board_init(); Serial_init(); Timer_init(); #ifdef USE_DRIVE Drive_init(); #endif // I2C bus I2C_init(I2C_BUS_ID, I2C_CLOCK_FREQ); #ifdef USE_TILTCOMPASS TiltCompass_init(); #endif #ifdef USE_GPS GPS_init(); #endif #ifdef USE_NAVIGATION Navigation_init(); #endif #ifdef USE_OVERRIDE Override_init(); #endif #ifdef USE_BAROMETER Barometer_init(); Timer_new(TIMER_BAROMETER_SEND, BAROMETER_SEND_DELAY); #endif // Start calibrating before use startSetOriginSM(); Timer_new(TIMER_HEARTBEAT, HEARTBEAT_SEND_DELAY); Mavlink_sendStatus(MAVLINK_STATUS_ONLINE); }
int main(){ Board_init(); Serial_init(); printf("Welcome to Xbee Test1\n"); printf("UART INIT\n"); Timer_init(); printf("Timers Init\n"); if(Xbee_init(XBEE_UART_ID) == FAILURE){ printf("Xbee Failed to initilize\n"); return FAILURE; } printf("XBEE Initialized\n"); // Master sends packets and listens for responses #ifdef XBEE_1 Mavlink_send_Test_data(XBEE_UART_ID, 1); Timer_new(TIMER_TIMEOUT, DELAY_TIMEOUT); Timer_new(TIMER_STATUS, DELAY_STATUS); while(1){ Xbee_runSM(); //lost a packet, report it, and restart if(Timer_isActive(TIMER_TIMEOUT) != TRUE){ Mavlink_send_Test_data(XBEE_UART_ID, 1); count_lost++; Timer_new(TIMER_TIMEOUT, DELAY_TIMEOUT); printf("lost_packet: %d\n", get_time()); } //Printout the status if(Timer_isActive(TIMER_STATUS) != TRUE){ Timer_new(TIMER_STATUS, DELAY_STATUS); printf("Status: %d,%d [Recieved,Lost] TIME: %d\n", count_recieved, count_lost, get_time()); } } #else while(1){ Xbee_runSM(); } #endif }
int main(void) { // Initialize the UART, Timers, and I2C Board_init(); Serial_init(); Timer_init(); Override_init(); printf("Override board initialized.\n"); while(1){ if (inOverride && !Override_isTriggered()) { inOverride = FALSE; printf("Override disabled.\n"); } else if (!inOverride && Override_isTriggered()) { inOverride = TRUE; printf("Override enabled.\n"); } } return (SUCCESS); }
int main(void) { SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); Serial_init(Serial_module_debug, 115200); Serial_puts(Serial_module_debug, "Hello, world!\r\n"); kernel_init(kernel_stack + sizeof(kernel_stack)); sys_spawn(worker1_main, NULL); sys_spawn(worker2_main, NULL); while(1) { sys_yield(); } return 0; }
int main(void) { // Initialize the UART,Timers, and I2C1 //int row = 0; Board_init(); Timer_init(); Thermal_init(); Serial_init(); /*Timer_new(TIMER_TEST,100); while(!Timer_isExpired(TIMER_TEST);*/ #ifdef DEBUG_TEST2 printf("Initialized Thermal module.\n"); #endif uint8_t row = 0, col = 0; Timer_new(TIMER_TEST,PRINT_DELAY); while(1) { if (Timer_isExpired(TIMER_TEST)) { #ifdef DEBUG_TEST2 printf("Sending thermal data...\n"); #endif sendSerial32(0xFFFF1234); for(col = 0; col < TOTAL_PIXEL_COLS; col++) { for(row = 0; row < TOTAL_PIXEL_ROWS; row++){ uint8_t pixel = row + (col * TOTAL_PIXEL_ROWS); sendSerialFloat(finalPixelTempF[pixel]); } sendSerial32(END_COL_SEQUENCE); } #ifdef DEBUG_TEST2 printf("\nFinished sending thermal data.\n"); #endif Timer_new(TIMER_TEST,PRINT_DELAY); } // Timer_isExpired Thermal_runSM(); } // while }
char Serial_initSM() { canBlock = TRUE; return Serial_init(); }
int main(){ //Initializations Board_init(); Serial_init(); Timer_init(); Drive_init(); ENABLE_OUT_TRIS = OUTPUT; ENABLE_OUT_LAT = MICRO; #ifdef RECIEVE_CONTROL ENABLE_OUT_LAT = RECIEVER; while(1){ ; } #endif printf("Actuator Test Harness Initiated\n\n"); //Test Rudder printf("Centering rudder.\n"); setRudder(RUDDER_TURN_LEFT, 0); delayMillisecond(ACTUATOR_DELAY); printf("Turning rudder left.\n"); setRudder(RUDDER_TURN_LEFT, 100); //push to one direction delayMillisecond(ACTUATOR_DELAY); printf("Centering rudder.\n"); setRudder(RUDDER_TURN_LEFT, 0); delayMillisecond(ACTUATOR_DELAY); printf("Turning rudder right.\n"); setRudder(RUDDER_TURN_RIGHT, 100); delayMillisecond(ACTUATOR_DELAY); printf("Centering rudder.\n"); setRudder(RUDDER_TURN_LEFT, 0); //Test Motor Left printf("Testing left motor.\n"); setLeftMotor(0); delayMillisecond(ACTUATOR_DELAY); printf("Driving left motor forward.\n"); setLeftMotor(100); delayMillisecond(ACTUATOR_DELAY); setLeftMotor(0); delayMillisecond(ACTUATOR_DELAY); //printf("Driving left motor reverse.\n"); //setLeftMotor(MIN_PULSE); //delayMillisecond(ACTUATOR_DELAY); //setLeftMotor(0); //Test Motor Right printf("Testing right motor.\n"); setRightMotor(0); delayMillisecond(ACTUATOR_DELAY); printf("Driving right motor forward.\n"); setRightMotor(100); delayMillisecond(ACTUATOR_DELAY); setRightMotor(0); delayMillisecond(ACTUATOR_DELAY); //printf("Driving right motor reverse.\n"); //setRightMotor(MIN_PULSE); //delayMillisecond(ACTUATOR_DELAY); //setRightMotor(STOP_PULSE); //delayMillisecond(ACTUATOR_DELAY); // // Remove this code // setRightMotor(MAX_PULSE); // setLeftMotor(MAX_PULSE); // while (1) // asm("nop"); // // // printf("\nDone with drive test.\n"); return SUCCESS; }
int main(){ //Initializations Board_init(); Serial_init(); Timer_init(); Drive_init(); int spd = 10; ENABLE_OUT_TRIS = OUTPUT; //Set Enable output pin to be an output, fed to the AND gates ENABLE_OUT_LAT = MICRO; //Initialize control to that of Microcontroller enum{ MICRO_FORWARD = 0x01, //State where Microcontroller is driving forward MICRO_STOP = 0x02, //State where Micro is driving backwards MICRO_LIMBO = 0x03, RECIEVER_STATE = 0x04, //Reciever has taken over state }test_state; printf("Boat is Initialized\n"); //Initialize the state to begin at forward test_state = MICRO_FORWARD; Drive_stop(); Timer_new(TIMER_TEST,RECIEVER_DELAY); int state_flag = 0; Override_init(); while(1){ switch(test_state){ case MICRO_FORWARD: printf("STATE: MICRO_FORWARD\n\n\n"); Drive_forward(spd); //The input param is a pwm duty cycle percentage that gets translated to a RC Servo time pulse Timer_new(TIMER_TEST2,RECIEVER_DELAY); test_state = MICRO_STOP; break; case MICRO_STOP: if(Timer_isExpired(TIMER_TEST2)){ printf("STATE: MICRO_STOP\n\n\n:"); Drive_stop(); Timer_new(TIMER_TEST2,RECIEVER_DELAY); test_state = MICRO_LIMBO; } break; case MICRO_LIMBO: if(Timer_isExpired(TIMER_TEST2)){ printf("STATE: MICRO_LIMBO\n\n\n"); test_state = MICRO_FORWARD; } Drive_stop(); break; case RECIEVER_STATE: ; break; } //If we got a pulse, control to reciever. if (OVERRIDE_TRIGGERED == TRUE){ printf("Reciever Control\n\n"); Timer_new(TIMER_TEST, 1000); //Set timer that is greater than the pulsewidth of the CH3 signal(54Hz) OVERRIDE_TRIGGERED = FALSE; //Re-init to zero so that we know when our pulse is triggered again. test_state = RECIEVER_STATE; //Set state equal to reciever where we do nothing autonomous ENABLE_OUT_LAT = RECIEVER; //Give control over to Reciever using the enable line INTEnable(INT_CN,1); } if (Timer_isExpired(TIMER_TEST)){ //Reciever gave up control printf("Micro Has Control\n\n"); Timer_clear(TIMER_TEST); //Clear timer so that it doesn't keep registering an expired signal test_state = MICRO_LIMBO; //Set state equal to forward for regular function OVERRIDE_TRIGGERED = FALSE; //Set Override to false to be sure that we don't trigger falsely ENABLE_OUT_LAT = MICRO; //Give Control back to microcontroller using enable line Timer_new(TIMER_TEST2, RECIEVER_DELAY); } } }
int main(){ //Initializations Board_init(); Serial_init(); Timer_init(); Drive_init(); int spd = 10; ENABLE_TRIS = INPUT; //Set the direction of the Enable pin to be an input, a switch will be used for now ENABLE_OUT_TRIS = OUTPUT; //Set Enable output pin to be an output, fed to the AND gates ENABLE_OUT_LAT = MICRO; //Initialize control to that of Microcontroller enum{ MICRO_FORWARD = 0x01, //State where Microcontroller is driving forward MICRO_STOP = 0x02, //State where Micro is driving backwards MICRO_LIMBO = 0x03, RECIEVER_STATE = 0x04, //Reciever has taken over state }test_state; printf("Boat is Initialized\n"); //Initialize the state to begin at forward test_state = MICRO_FORWARD; Drive_stop(); Timer_new(TIMER_TEST,RECIEVER_DELAY); int state_flag = 0; while(1){ if(Timer_isExpired(TIMER_TEST)){ if ((ENABLE_BIT == 1)){ test_state = RECIEVER_STATE; printf("YOU HAVE TRIGGERED THE RECIEVER FOR CONTROL\n\n"); ENABLE_OUT_LAT = RECIEVER; //Set the Enable_out pin that will be routed to the AND gates state_flag = 1; }else if (ENABLE_BIT == 0){ printf("MICRO HAS CONTROL\n\n"); ENABLE_OUT_LAT = MICRO; //setting Enable_out that will be routed to AND gates if(state_flag == 1){ Timer_new(TIMER_TEST2,RECIEVER_DELAY); test_state = MICRO_FORWARD; state_flag = 0; } } Timer_new(TIMER_TEST,RECIEVER_DELAY); } switch(test_state){ case MICRO_FORWARD: printf("STATE: MICRO_FORWARD\n\n\n"); Drive_forward(spd); //The input param is a pwm duty cycle percentage that gets translated to a RC Servo time pulse Timer_new(TIMER_TEST2,RECIEVER_DELAY); test_state = MICRO_STOP; break; case MICRO_STOP: if(Timer_isExpired(TIMER_TEST2)){ printf("STATE: MICRO_STOP\n\n\n:"); Drive_stop(); Timer_new(TIMER_TEST2,RECIEVER_DELAY); test_state = MICRO_LIMBO; } break; case MICRO_LIMBO: if(Timer_isExpired(TIMER_TEST2)){ printf("STATE: MICRO_LIMBO\n\n\n"); test_state = MICRO_FORWARD; } Drive_stop(); break; case RECIEVER_STATE: ; break; } } }
int main(void) { Board_init(); Serial_init(); printf("If you can see this it worked"); }
int main() { enum{ forward = 0x01, backward = 0x02, idle = 0x03, }drive_state; Board_init(); Serial_init(); Timer_init(); Drive_init(); int spd = 20; //Magnetometer_init(); printf("Boat initialized.\n"); Drive_forward(spd); Timer_new(TIMER_TEST,TEST_DELAY); drive_state = forward; int flag = 0; while (1) { switch(drive_state){ case forward: Drive_forward(spd); if(Timer_isExpired(TIMER_TEST)){ drive_state = idle; Drive_stop(); Timer_new(TIMER_TEST,TEST_DELAY); flag = 0; } break; case idle: Drive_stop(); if(Timer_isExpired(TIMER_TEST)){ if (flag == 0){ drive_state = backward; Drive_backward(spd); }else if (flag == 1){ drive_state = forward; Drive_forward(spd); } Timer_new(TIMER_TEST,TEST_DELAY); } break; case backward: Drive_backward(spd); if(Timer_isExpired(TIMER_TEST)){ drive_state = idle; Drive_stop(); Timer_new(TIMER_TEST,TEST_DELAY); flag = 1; } } Drive_runSM(); } Drive_stop(); Drive_runSM(); return SUCCESS; }