embedded/projects/step-example/simulated_platform.c
uint32_t Platform_BlockOnNewSensorReadings() {
  uint32_t result =0;
  static uint32_t callCount =0;
  static uint32_t accelSampleIndex =0;
  static uint32_t magSampleIndex =0;
  static uint32_t gyroSampleIndex =0;

  #define TEN_MILLISECS_IN_MICROSECS 10000

  if ((callCount % SIMULATED_ACCEL_DECIMATION_VS_100Hz) == 0) {
    gCurrentAccelData.Data[0]= SIMULATED_ACCEL_DATA[accelSampleIndex][0];
    gCurrentAccelData.Data[1]= SIMULATED_ACCEL_DATA[accelSampleIndex][1];
    gCurrentAccelData.Data[2]= SIMULATED_ACCEL_DATA[accelSampleIndex][2];
    gCurrentAccelData.TimeStamp= gCurrentTimestamp;
    result|= 1<<OSP_SENSOR_TYPE_ACCELEROMETER;

    accelSampleIndex= ++accelSampleIndex % SIMULATED_ACCEL_NUM_SAMPLES;
  }

  if ((callCount % SIMULATED_MAG_DECIMATION_VS_100Hz) == 0) {
    gCurrentMagData.Data[0]= SIMULATED_MAG_DATA[magSampleIndex][0];
    gCurrentMagData.Data[1]= SIMULATED_MAG_DATA[magSampleIndex][1];
    gCurrentMagData.Data[2]= SIMULATED_MAG_DATA[magSampleIndex][2];
    gCurrentMagData.TimeStamp= gCurrentTimestamp;
    result|= 1<<OSP_SENSOR_TYPE_MAGNETIC_FIELD;
    
    magSampleIndex= ++magSampleIndex % SIMULATED_MAG_NUM_SAMPLES;                                       
  }

  if ((callCount % SIMULATED_GYRO_DECIMATION_VS_100Hz) == 0) {
    gCurrentGyroData.Data[0]= SIMULATED_GYRO_DATA[gyroSampleIndex][0];
    gCurrentGyroData.Data[1]= SIMULATED_GYRO_DATA[gyroSampleIndex][1];
    gCurrentGyroData.Data[2]= SIMULATED_GYRO_DATA[gyroSampleIndex][2];   
    gCurrentGyroData.TimeStamp= gCurrentTimestamp;
    result|= 1<<OSP_SENSOR_TYPE_GYROSCOPE;

    ++gyroSampleIndex;
    if (gyroSampleIndex == SIMULATED_GYRO_NUM_SAMPLES) {
      gShutdown= TRUE; 
    }
    gyroSampleIndex= gyroSampleIndex % SIMULATED_GYRO_NUM_SAMPLES;    
  }

  // Kick the other indexes along
  gCurrentTimestamp+= TEN_MILLISECS_IN_MICROSECS;
  callCount++;

  return result;
}
// make the current sample available in a global location, setting the quit flag at the end of them
make the current sample available in a global location, setting the quit flag at the end of them
make the current sample available in a global location setting the quit flag at the end of them
uint32_t Platform_BlockOnNewSensorReadings() {
  uint32_t result =0;
  static uint32_t callCount =0;
  static uint32_t accelSampleIndex =0;
  static uint32_t magSampleIndex =0;
  static uint32_t gyroSampleIndex =0;
  #define TEN_MILLISECS_IN_MICROSECS 10000
  if ((callCount % SIMULATED_ACCEL_DECIMATION_VS_100Hz) == 0) {
    gCurrentAccelData.Data[0]= SIMULATED_ACCEL_DATA[accelSampleIndex][0];
    gCurrentAccelData.Data[1]= SIMULATED_ACCEL_DATA[accelSampleIndex][1];
    gCurrentAccelData.Data[2]= SIMULATED_ACCEL_DATA[accelSampleIndex][2];
    gCurrentAccelData.TimeStamp= gCurrentTimestamp;
    result|= 1<<OSP_SENSOR_TYPE_ACCELEROMETER;
    accelSampleIndex= ++accelSampleIndex % SIMULATED_ACCEL_NUM_SAMPLES;
  }
  if ((callCount % SIMULATED_MAG_DECIMATION_VS_100Hz) == 0) {
    gCurrentMagData.Data[0]= SIMULATED_MAG_DATA[magSampleIndex][0];
    gCurrentMagData.Data[1]= SIMULATED_MAG_DATA[magSampleIndex][1];
    gCurrentMagData.Data[2]= SIMULATED_MAG_DATA[magSampleIndex][2];
    gCurrentMagData.TimeStamp= gCurrentTimestamp;
    result|= 1<<OSP_SENSOR_TYPE_MAGNETIC_FIELD;
    magSampleIndex= ++magSampleIndex % SIMULATED_MAG_NUM_SAMPLES;                                       
  }
  if ((callCount % SIMULATED_GYRO_DECIMATION_VS_100Hz) == 0) {
    gCurrentGyroData.Data[0]= SIMULATED_GYRO_DATA[gyroSampleIndex][0];
    gCurrentGyroData.Data[1]= SIMULATED_GYRO_DATA[gyroSampleIndex][1];
    gCurrentGyroData.Data[2]= SIMULATED_GYRO_DATA[gyroSampleIndex][2];   
    gCurrentGyroData.TimeStamp= gCurrentTimestamp;
    result|= 1<<OSP_SENSOR_TYPE_GYROSCOPE;
    ++gyroSampleIndex;
    if (gyroSampleIndex == SIMULATED_GYRO_NUM_SAMPLES) {
      gShutdown= TRUE; 
    }
    gyroSampleIndex= gyroSampleIndex % SIMULATED_GYRO_NUM_SAMPLES;    
  }
  gCurrentTimestamp+= TEN_MILLISECS_IN_MICROSECS;
  callCount++;
  return result;
}
uint32_t Platform_BlockOnNewSensorReadings ( ) { uint32_t result = 0 ; static uint32_t callCount = 0 ; static uint32_t accelSampleIndex = 0 ; static uint32_t magSampleIndex = 0 ; static uint32_t gyroSampleIndex = 0 ; #define TEN_MILLISECS_IN_MICROSECS  10000 if ( ( callCount % SIMULATED_ACCEL_DECIMATION_VS_100Hz ) == 0 ) { gCurrentAccelData . Data [ 0 ] = SIMULATED_ACCEL_DATA [ accelSampleIndex ] [ 0 ] ; gCurrentAccelData . Data [ 1 ] = SIMULATED_ACCEL_DATA [ accelSampleIndex ] [ 1 ] ; gCurrentAccelData . Data [ 2 ] = SIMULATED_ACCEL_DATA [ accelSampleIndex ] [ 2 ] ; gCurrentAccelData . TimeStamp = gCurrentTimestamp ; result |= 1 << OSP_SENSOR_TYPE_ACCELEROMETER ; accelSampleIndex = ++ accelSampleIndex % SIMULATED_ACCEL_NUM_SAMPLES ; } if ( ( callCount % SIMULATED_MAG_DECIMATION_VS_100Hz ) == 0 ) { gCurrentMagData . Data [ 0 ] = SIMULATED_MAG_DATA [ magSampleIndex ] [ 0 ] ; gCurrentMagData . Data [ 1 ] = SIMULATED_MAG_DATA [ magSampleIndex ] [ 1 ] ; gCurrentMagData . Data [ 2 ] = SIMULATED_MAG_DATA [ magSampleIndex ] [ 2 ] ; gCurrentMagData . TimeStamp = gCurrentTimestamp ; result |= 1 << OSP_SENSOR_TYPE_MAGNETIC_FIELD ; magSampleIndex = ++ magSampleIndex % SIMULATED_MAG_NUM_SAMPLES ; } if ( ( callCount % SIMULATED_GYRO_DECIMATION_VS_100Hz ) == 0 ) { gCurrentGyroData . Data [ 0 ] = SIMULATED_GYRO_DATA [ gyroSampleIndex ] [ 0 ] ; gCurrentGyroData . Data [ 1 ] = SIMULATED_GYRO_DATA [ gyroSampleIndex ] [ 1 ] ; gCurrentGyroData . Data [ 2 ] = SIMULATED_GYRO_DATA [ gyroSampleIndex ] [ 2 ] ; gCurrentGyroData . TimeStamp = gCurrentTimestamp ; result |= 1 << OSP_SENSOR_TYPE_GYROSCOPE ; ++ gyroSampleIndex ; if ( gyroSampleIndex == SIMULATED_GYRO_NUM_SAMPLES ) { gShutdown = TRUE ; } gyroSampleIndex = gyroSampleIndex % SIMULATED_GYRO_NUM_SAMPLES ; } gCurrentTimestamp += TEN_MILLISECS_IN_MICROSECS ; callCount ++ ; return result ; }
make the current sample available in a global location, setting the quit flag at the end of them
make the current sample available in a global location setting the quit flag at the end of them
// Kick the other indexes along