예제 #1
0
/*
 * Application entry point.
 */
int main(void) {
  /*
   * Shell thread
   */
  Thread *shelltp = NULL;

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /*
   * Activate custom stuff
   */
  mypwmInit();
  myADCinit();

  /*
   * Creates the blinker thread.
   */
  startBlinker();

  /*
   * Activates the USB driver and then the USB bus pull-up on D+.
   */
  myUSBinit();


  /*
   * Main loop, does nothing except spawn a shell when the old one was terminated
   */
  while (TRUE) {
    if (!shelltp && isUsbActive())
      {
        shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
      }
    else if (chThdTerminated(shelltp)) {
      chThdRelease(shelltp);    /* Recovers memory of the previous shell.   */
      shelltp = NULL;           /* Triggers spawning of a new shell.        */
    }
    chThdSleepMilliseconds(1000);
  }
}
예제 #2
0
/*
* Application entry point.
*/
int main(void) {
  int8_t accelData[2]={0,0};     	   // Discovery Board's Accelerometer
  uint8_t receivedBuff[4]={0,0,0,0}; 	   // Received request/information from PandaBoard
  uint8_t sentData[4] = {0,0,0,0}; // Returned Information (reply) to the PandaBoard
  float imuData[7]={0,0,0,0,0,0,0};        	   // IMU calculated data based on Razor Boad
  int* razorInfo;                  // Razor Board Data
  int steering = 0;
  int speed = 0;
  int ir_data[3]={0,0,0}; 
  int16_t us_data[3]={0,0,0};

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit(); 
  
  mypwmInit();
   
 // Initializing Motor
  motorInit();

  // Initializing IR Thread
  ADCinit();

  // Initializing US Thread
 // myUltrasonicInit();
  
  // Initializing Discovery Board's Accelerometer
  //mySPIinit();

  // Initializing Razor Board
  myRazorInit();

  // Activates the USB driver and then the USB bus pull-up on D+.
  myUSBinit();

  // Initializing IMU Calculations. 
  initIMU();

  //Starting the usb configuration
  sdStart(&SDU1,&portConfig2);
  char receivedInfo[11];
 
  /*
   * Main loop, it takes care of reciving the requests from Panda Board using USB protocol,
   * and reply with the requested data.
   */
  while (TRUE) {
   receivedInfo[0]='T';
   sdRead(&SDU1, receivedInfo, 10);
   
  // getImuValues(imuData);
   //   getAccel(accelData);
  // getIR(ir_data);  
   //  getUS(us_data);

   if(receivedInfo[0] != 'T'){
	receivedInfo[11]='\0';
	parse(receivedInfo);
      
	//setMotorData(-(rcvData[1]-28),rcvData[2]-2);
        setMotorData(rcvData[1],1550);
	translate(rcvData[0],ir_data,us_data,razorInfo,imuData,accelData,sentData);
       	sdWrite(&SDU1, sentData, 4);
    }
  }   
}