void setup() { setupSystemClock(); setup_system_tick(SYSTEM_TICK_FREQ); setupUART(); #ifdef GPS setupGPS(); #endif I2C_Init(); FlashInit(); UpdateBoardVersion(false); #ifdef OPTION_RC RC_Init(); if(IsSSVConnected()) Battery_Init(); LED_Init(); TIMER_Init(); stabilizerInit(); #endif #ifdef ABROBOT ABRobotMotorInit(); #endif nvtAHRSInit(); SensorsInit(); ChronographSet(ChronMain); }
// Function called in void setup() that instantiates all the variables, attaches pins, ect // This funciton needs to be called before anything else will work void Communicator::initialize() { pinMode(TX_TO_DISCONNECT, INPUT); // Ensure it's in high impedance state pinMode(RX_TO_DISCONNECT, INPUT); // Ensure it's in high impedance state #ifdef DEBUG_COMMUNICATOR SerialUSB.begin(SERIAL_USB_BAUD); // This is to computer DEBUG_PRINTLN("at start of comm initialize"); #endif // Set initial values to 0 altitude = 0; //roll = 0; pitch = 0; altitudeAtDrop = 0; // Start without hardware attached dropBayAttached = 0; // Initialize serial commuication to Xbee. XBEE_SERIAL.begin(XBEE_BAUD); //this is to Xbee //Setup the GPS setupGPS(); }
void S4GPS::Configure() { setupGPS(remVTG,26); setupGPS(remRMC,26); setupGPS(remGSV,26); setupGPS(remGSA,26); setupGPS(remGLL,26); setupGPS(setNAV,44); setupGPS(setNAV2,56); setupGPS(setNAV5,52); }
int main(void) { // Initialise the GPIO block gpioInit(); #ifdef GPS // Initialise the UART0 block for printf output uart0Init(9600); #else // Initialise the UART0 block for printf output uart0Init(115200); #endif // Configure the multi-rate timer for 1ms ticks mrtInit(__SYSTEM_CLOCK/1000); // Configure the switch matrix (setup pins for UART0 and SPI) configurePins(); //Seed random number generator, we can use our 'unique' ID random_output = NODE_ID[0] + NODE_ID[1] + NODE_ID[2]; //printf("random: %d\r\n", random_output); RFM69_init(); #ifdef GPS int navmode = 9; setupGPS(); #endif #ifdef DEBUG printf("Node initialized, version %s\r\n",GIT_VER); #endif while(1) { #ifdef GPS mrtDelay(5000); navmode = gps_check_nav(); if (navmode != 6){ setupGPS(); } mrtDelay(500); gps_get_position(); mrtDelay(500); gps_check_lock(); mrtDelay(500); //printf("Data: %d,%d,%d,%d,%d,%d\r\n", lat, lon, alt, navmode, lock, sats); //printf("Errors: %d,%d\r\n", GPSerror, serialBuffer_write); #endif incrementPacketCount(); //Clear buffer data_temp[0] = '\0'; uint8_t n; //Create the packet int int_temp = RFM69_readTemp(); // Read transmitter temperature rx_rssi = RFM69_lastRssi(); floor_rssi = RFM69_sampleRssi(); #ifdef GPS n = sprintf(data_temp, "%d%cL%d,%d,%dT%dR%d[%s]", NUM_REPEATS, data_count, lat, lon, alt, int_temp, rx_rssi, NODE_ID); #else if(data_count == 97) { n = sprintf(data_temp, "%d%cL%s[%s]", NUM_REPEATS, data_count, LOCATION_STRING, NODE_ID); } else { n = sprintf(data_temp, "%d%cT%dR%d,%dC%d[%s]", NUM_REPEATS, data_count, int_temp, rx_rssi, floor_rssi, rx_packets, NODE_ID); } #endif transmitData(n); awaitData(TX_GAP); } }