Hummingbird Flight Software
Flight software for the Hummingbird FCU quadcopter flight controller. Designed to run on the Teensy 4.1. Developed with VSCode+PlatformIO.
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
FXAS21002Gyro Class Reference

NXP FXAS21002 gyro sensor driver. More...

#include <fxas21002_gyro.h>

Public Member Functions

 FXAS21002Gyro (TwoWire *wireInput=&SENSOR_I2C)
 FXAS21002 Constructor. More...
 
 ~FXAS21002Gyro ()
 
bool Initialize (GyroRanges_t rng=GYRO_RNG_1000DPS)
 Initialize and configure gyroscope sensor. More...
 
bool ReadSensor ()
 Read gyroscope data from device registers. More...
 
float GetTemperature ()
 Read device's 8-bit temperature register and return in degrees C. More...
 
float GetGx ()
 Return gyro x-measurement in [deg/s]. More...
 
float GetGy ()
 Return gyro y-measurement in [deg/s]. More...
 
float GetGz ()
 Return gyro z-measurement in [deg/s]. More...
 

Public Attributes

uint32_t prevMeasMicros
 Previous measurement micros() More...
 

Private Member Functions

void I2Cwrite8 (uint8_t regOfInterest, uint8_t valToWrite)
 Write to FXAS21002 device register over I2C. More...
 
uint8_t I2Cread8 (uint8_t regOfInterest)
 Read FXAS21002 register value over I2C. More...
 

Private Attributes

float _gx
 Gyro x reading, [deg/s]. More...
 
float _gy
 Gyro y reading, [deg/s]. More...
 
float _gz
 Gyro z reading, [deg/s]. More...
 
GyroRanges_t gyroRange
 Selected gyro measurement range. More...
 
TwoWire * _SensorWire
 I2C bus the sensor is connected to. More...
 

Detailed Description

NXP FXAS21002 gyro sensor driver.

Constructor & Destructor Documentation

◆ FXAS21002Gyro()

FXAS21002Gyro::FXAS21002Gyro ( TwoWire *  wireInput = &SENSOR_I2C)

FXAS21002 Constructor.

Constructor for the FXAS21002 gyro sensor.

Parameters
wireInputI2C/Wire interface the device is connected to.

◆ ~FXAS21002Gyro()

FXAS21002Gyro::~FXAS21002Gyro ( )
inline

Member Function Documentation

◆ GetGx()

float FXAS21002Gyro::GetGx ( )

Return gyro x-measurement in [deg/s].

◆ GetGy()

float FXAS21002Gyro::GetGy ( )

Return gyro y-measurement in [deg/s].

◆ GetGz()

float FXAS21002Gyro::GetGz ( )

Return gyro z-measurement in [deg/s].

◆ GetTemperature()

float FXAS21002Gyro::GetTemperature ( )

Read device's 8-bit temperature register and return in degrees C.

Temperature will not have any decimals, as it is an 8-bit signed int (-127C to 127C). Note that the temperature is not factory calibrated!

Returns
Temperature in [C]

◆ I2Cread8()

uint8_t FXAS21002Gyro::I2Cread8 ( uint8_t  regOfInterest)
private

Read FXAS21002 register value over I2C.

Parameters
regOfInterestRegister address on device.
Returns
Value stored in the register.

◆ I2Cwrite8()

void FXAS21002Gyro::I2Cwrite8 ( uint8_t  regOfInterest,
uint8_t  valToWrite 
)
private

Write to FXAS21002 device register over I2C.

Parameters
regOfInterestRegister address on device.
valToWriteValue to write to register.

◆ Initialize()

bool FXAS21002Gyro::Initialize ( GyroRanges_t  rng = GYRO_RNG_1000DPS)

Initialize and configure gyroscope sensor.

If unspecified, the default gyro measurement rage is GYRO_RNG_1000DPS

Parameters
rngGyro measurement range.
See also
GyroRanges_t
Returns
True if successful, false if failed.

◆ ReadSensor()

bool FXAS21002Gyro::ReadSensor ( )

Read gyroscope data from device registers.

Raw gyro readings are in [deg/s].

Returns
True if successful, false if failed.

Member Data Documentation

◆ _gx

float FXAS21002Gyro::_gx
private

Gyro x reading, [deg/s].

◆ _gy

float FXAS21002Gyro::_gy
private

Gyro y reading, [deg/s].

◆ _gz

float FXAS21002Gyro::_gz
private

Gyro z reading, [deg/s].

◆ _SensorWire

TwoWire* FXAS21002Gyro::_SensorWire
private

I2C bus the sensor is connected to.

◆ gyroRange

GyroRanges_t FXAS21002Gyro::gyroRange
private

Selected gyro measurement range.

◆ prevMeasMicros

uint32_t FXAS21002Gyro::prevMeasMicros

Previous measurement micros()


The documentation for this class was generated from the following files: