Ejemplo n.º 1
0
/*********************************************************************
 * @fn      gyroChangeCB
 *
 * @brief   Callback from GyroProfile indicating a value change
 *
 * @param   paramID - parameter ID of the value that was changed.
 *
 * @return  none
 */
static void gyroChangeCB( uint8 paramID )
{
    if (paramID == GYROSCOPE_CONF)
    {
        uint8 newValue;
        Gyro_GetParameter( GYROSCOPE_CONF, &newValue );
        if (newValue == 0)
        {
            // All three axes off, put sensor to sleep
            if (gyroEnabled)
            {
                gyroEnabled = FALSE;
                osal_set_event( sensorTag_TaskID, ST_GYROSCOPE_SENSOR_EVT);
            }
        }
        else
        {
            // Bitmap tells which axis to enable (bit 0: X, but 1: Y, but 2: Z)
            gyroEnabled = TRUE;
            sensorGyroAxes = newValue & 0x07;
            sensorGyroUpdateAxes = TRUE;
            osal_set_event( sensorTag_TaskID,  ST_GYROSCOPE_SENSOR_EVT);
        }
    } // should not get here
}
Ejemplo n.º 2
0
/*********************************************************************
 * @fn      gyroChangeCB
 *
 * @brief   Callback from GyroProfile indicating a value change
 *
 * @param   paramID - parameter ID of the value that was changed.
 *
 * @return  none
 */
static void gyroChangeCB( uint8 paramID )
{
  uint8 newValue;
  
  switch (paramID) {
  case SENSOR_CONF:
    Gyro_GetParameter( SENSOR_CONF, &newValue );
    
    if (newValue == 0)
    {
      // All three axes off, put sensor to sleep
      if (gyroEnabled)
      {
        gyroEnabled = FALSE;
        osal_set_event( sensorTag_TaskID, ST_GYROSCOPE_SENSOR_EVT);
      }
    }
    else
    {
      // Bitmap tells which axis to enable (bit 0: X, but 1: Y, but 2: Z)
      gyroEnabled = TRUE;
      sensorGyroAxes = newValue & 0x07;
      sensorGyroUpdateAxes = TRUE;
      osal_set_event( sensorTag_TaskID,  ST_GYROSCOPE_SENSOR_EVT);
    }
    break;
    
  case SENSOR_PERI:
    Gyro_GetParameter( SENSOR_PERI, &newValue );
    sensorGyrPeriod = newValue*SENSOR_PERIOD_RESOLUTION;
    break;
    
  default:
    // Should not get here
    break;
  }
}