int main (/* TODO: add args */) { int i; // Set up the eight magazine threads magInit(); // TODO: Test that the threads started. // Sequence streams of packets into VBI fields i=piThreadCreate(Stream); if (i != 0) { // printf ("Stream thread! It didn't start\n"); return 1; } // Copy VBI to stdout i=piThreadCreate(OutputStream); if (i != 0) { // printf ("OutputStream thread! It didn't start\n"); return 1; } while (1) { } puts("Finished\n"); // impossible to get here return 1; }
//======================== compass =================== uint8_t compassInit(void) { int ret1,ret2,ret3; ret1=gyroInit(); ret2=accInit(); ret3=magInit(); // return ret3; }
int main (int argc, char** argv) { int i; char filename[MAXPATH]; if(argc > 2){ if(!strcmp(argv[1],"--dir")){ #ifdef _DEBUG_ fprintf(stderr,"got directory %s from command line\n",argv[2]); #endif strncpy(pagesPath, argv[2], MAXPATH-1); /* copy directory string to global */ } } // construct default config file filename from pages directory and default config file name // TODO: allow specifying any file from command line strncpy(filename,pagesPath,MAXPATH-1); i = filename[(strlen(filename)-1)]; if (i != '/' && i != '\\' && strlen(filename) + 1 < MAXPATH) strcat(filename, "/"); // append missing trailing slash i = strlen(filename) + strlen(CONFIGFILE); if (i < MAXPATH){ strncat(filename,CONFIGFILE, i); } #ifdef _DEBUG_ fprintf(stderr,"using config file %s\n",filename); #endif i = readConfigFile(filename); // read in config from config file switch (i){ case NOCONFIG: fprintf(stderr,"No config file found. Using default settings.\n"); break; case BADCONFIG: fprintf(stderr,"Config file contains invalid setting: %s\n",configErrorString); return 1; } /* initialize the mutexes we're going to use! */ init_mutex(0); init_mutex(1); InitNu4(); // Prepare the buffers used by Newfor subtitles // Start the network port (commands and subtitles) i=piThreadCreate(runClient); //while(1); // Set up the eight magazine threads magInit(); // TODO: Test that the threads started. // Sequence streams of packets into VBI fields i=piThreadCreate(Stream); if (i != 0) { // printf ("Stream thread! It didn't start\n"); return 1; } // Copy VBI to stdout i=piThreadCreate(OutputStream); if (i != 0) { // printf ("OutputStream thread! It didn't start\n"); return 1; } while (1) { } fputs("Finished\n",stderr); // impossible to get here return 1; }
//Initialize all sensors on the IMU board void IMUinit() { //Initialize the I2C bus i2cInit(); //Disable interrupts while everything is being set up CRITICAL_SECTION_START; //Initialize the gyro if(gyroInit(GYRO_RANGE_250DPS)) { theFlags.gyroEnabled = TRUE; //Set the pin as input cbi(DDRE, DDE4); //Disable the pullup on the relevant pin cbi(PORTE, PORTE4); //Attach the DRDY interrupt sbi(EICRB, ISC40); //Writing 1 to ISC40 and ISC41 sets interrupt on rising edge sbi(EICRB, ISC41); sbi(EIMSK, INT4); //Setting INT4 in EIMSK enables the interrupt (if they are globally enabled (but they are cause i2cinit did that)) //Now wait for DRDY to go low and reenmable it to start everything off while(inb(PINE) & _BV(PINE4)) { ; //Wait for the port to go low } gyroEnableDrdy(); } else { #ifdef IMU_DEBUG printf("Error intitializing the gyro!\r\n"); #endif theFlags.gyroEnabled = FALSE; } //Intialize the accelerometer if(accelInit()) { theFlags.accelEnabled = TRUE; //Set the pin as input cbi(DDRD, DDD2); //Disable the pullup on the relevant pin cbi(PORTD, PORTD2); //Attach the DRDY interrupt sbi(EICRA, ISC20); //Writing 1 to ISC20 and ISC21 sets interrupt on rising edge sbi(EICRA, ISC21); sbi(EIMSK, INT2); //Setting INT2 in EIMSK enables the interrupt (if they are globally enabled (but they are cause i2cinit did that)) //Now wait for DRDY to go low and reenable it to start everything off while(inb(PINB) & _BV(PINB2)) { ; //Wait for the port to go low } accelEnableDrdy(); } else { #ifdef IMU_DEBUG printf("Error intitializing the accelerometer!\r\n"); #endif theFlags.accelEnabled = FALSE; } //Initialize the magnetometer if(magInit()) { theFlags.magEnabled = TRUE; //Set the pin as input cbi(DDRD, DDD3); //Disable the pullup on the DRDY pin cbi(PORTD, PORTD3); //Attach the DRDY interrupt sbi(EICRA, ISC30); //Writing 1 to ISC30 and ISC31 sets interrupt on rising edge sbi(EICRA, ISC31); sbi(EIMSK, INT3); //Setting INT3 in EIMSK enables the interrupt (if they are globally enabled (but they are cause i2cinit did that)) } else { #ifdef IMU_DEBUG printf("Error intitializing the magnetometer!\r\n"); #endif theFlags.magEnabled = FALSE; } //Initialize the BMP180 pressure/temp sensor if(bmpInit()) { theFlags.bmpEnabled = TRUE; //Attach the interrupt handler for the timer ticks timerSetInterruptCallback( imuTimerTick ); //Start a temperature measurrement to set everything off const u08 toSend[2] = {BMP180_REGISTER_CONTROL, BMP180_REGISTER_READTEMPCMD}; i2cMasterSendNI(BMP180_ADDRESS, 2, (u08*)&toSend); myBmpState = TEMPERATURE_MEASURING; bmpLastStateChange = millis(); } else { #ifdef IMU_DEBUG printf("Error intitializing the BMP180!\r\n"); #endif theFlags.bmpEnabled = FALSE; } //Attach the custom stop handler after all sensors are initialized i2cSetStopHandler( customStopHandler ); //Re-enable the interrupts CRITICAL_SECTION_END; }