FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
devices::magneto::MPU6050< MANAGER > Class Template Reference

I2C device driver for the MPU6050 gyroscope/accelerometer chip. More...

#include <fastarduino/devices/mpu6050.h>

Inheritance diagram for devices::magneto::MPU6050< MANAGER >:
Collaboration diagram for devices::magneto::MPU6050< MANAGER >:

Classes

class  BeginFuture
 Create a future to be used by asynchronous method begin(BeginFuture&). More...
 
class  EndFuture
 Create a future to be used by asynchronous method end(EndFuture&). More...
 
class  FifoBeginFuture
 Create a future to be used by asynchronous method begin(FifoBeginFuture&). More...
 
class  ResetFuture
 Create a future to be used by asynchronous method reset(ResetFuture&). More...
 

Public Types

using GyroFuture = Sensor3DFuture< GYRO_XOUT >
 Create a future to be used by asynchronous method gyro_measures(GyroFuture&). More...
 
using TemperatureFuture = TReadRegisterFuture< TEMP_OUT, int16_t >
 Create a future to be used by asynchronous method temperature(TemperatureFuture&). More...
 
using AccelFuture = Sensor3DFuture< ACCEL_XOUT >
 Create a future to be used by asynchronous method accel_measures(AccelFuture&). More...
 
using AllMeasuresFuture = TReadRegisterFuture< ACCEL_XOUT, AllSensors, functor::ChangeEndianness< AllSensors, int16_t > >
 Create a future to be used by asynchronous method all_measures(AllMeasuresFuture&). More...
 
using InterruptStatusFuture = TReadRegisterFuture< INT_STATUS, INTStatus >
 Create a future to be used by asynchronous method interrupt_status(InterruptStatusFuture&). More...
 
using ResetFifoFuture = TWriteRegisterFuture< USER_CTRL, uint8_t, functor::Constant< uint8_t, FIFO_ENABLE|FIFO_RESET > >
 Create a future to be used by asynchronous method reset_fifo(ResetFifoFuture&). More...
 
using FifoCountFuture = TReadRegisterFuture< FIFO_COUNT, uint16_t >
 Create a future to be used by asynchronous method fifo_count(FifoCountFuture&). More...
 
template<typename T >
using FifoPopFuture = TReadRegisterFuture< FIFO_R_W, T, functor::ChangeEndianness< T, int16_t > >
 Create a future to be used by asynchronous method fifo_pop(FifoPopFuture<T>&). More...
 
using FifoPushFuture = TWriteRegisterFuture< FIFO_R_W >
 Create a future to be used by asynchronous method fifo_push(FifoPushFuture&). More...
 
- Public Types inherited from i2c::I2CDevice< MANAGER >
using MANAGER = MANAGER
 the type of I2C Manager that can handle this device. More...
 

Public Member Functions

 MPU6050 (MANAGER &manager, AD0 ad0=AD0::LOW)
 Create a new device driver for a MPU6050 chip. More...
 
int begin (BeginFuture &future)
 Start operation of this gyroscope/accelerometer chip. More...
 
int begin (FifoBeginFuture &future)
 Start operation of this gyroscope/accelerometer chip. More...
 
int end (EndFuture &future) INLINE
 Put the chip to sleep mode (low-power mode); stops sampling operations if any. More...
 
int reset (ResetFuture &future) INLINE
 Reset the chip (register map §4.28). More...
 
int gyro_measures (GyroFuture &future)
 Get latest gyroscope measurements from the device (register map §4.19). More...
 
int temperature (TemperatureFuture &future)
 Get latest chip temperature measurement (register map §4.18). More...
 
int accel_measures (AccelFuture &future)
 Get latest accelerometer measurements from the device (register map §4.17). More...
 
int all_measures (AllMeasuresFuture &future)
 Get latest measurements of all device sensors (gyroscope, accelerometer, temperature). More...
 
int interrupt_status (InterruptStatusFuture &future)
 Get the interrupt status (register map §4.16) after an interrupt has occurred. More...
 
int reset_fifo (ResetFifoFuture &future)
 Reset the FIFO buffer (parameter map §4.27). More...
 
int fifo_count (FifoCountFuture &future)
 Get the number of bytes currently stored in the FIFO buffer (register map §4.30). More...
 
template<typename T >
int fifo_pop (FifoPopFuture< T > &future)
 Get one sample out of the FIFO buffer (register map §4.31). More...
 
int fifo_push (FifoPushFuture &future)
 Push one byte to the FIFO buffer (register map §4.31). More...
 
bool begin (GyroRange gyro_range=GyroRange::RANGE_250, AccelRange accel_range=AccelRange::RANGE_2G, DLPF low_pass_filter=DLPF::ACCEL_BW_260HZ, ClockSelect clock_select=ClockSelect::INTERNAL_8MHZ)
 Start operation of this gyroscope/accelerometer chip. More...
 
bool begin (FIFOEnable fifo_enable, INTEnable int_enable, uint8_t sample_rate_divider, GyroRange gyro_range=GyroRange::RANGE_250, AccelRange accel_range=AccelRange::RANGE_2G, DLPF low_pass_filter=DLPF::ACCEL_BW_260HZ, ClockSelect clock_select=ClockSelect::INTERNAL_8MHZ)
 Start operation of this gyroscope/accelerometer chip. More...
 
bool end () INLINE
 Put the chip to sleep mode (low-power mode); stops sampling operations if any. More...
 
bool reset () INLINE
 Reset the chip (register map §4.28). More...
 
bool gyro_measures (Sensor3D &gyro)
 Get latest gyroscope measurements from the device (register map §4.19). More...
 
int16_t temperature ()
 Get latest chip temperature measurement (register map §4.18). More...
 
bool accel_measures (Sensor3D &accel)
 Get latest accelerometer measurements from the device (register map §4.17). More...
 
bool all_measures (AllSensors &sensors)
 Get latest measurements of all device sensors (gyroscope, accelerometer, temperature). More...
 
INTStatus interrupt_status ()
 Get the interrupt status (register map §4.16) after an interrupt has occurred. More...
 
bool reset_fifo ()
 Reset the FIFO buffer (parameter map §4.27). More...
 
uint16_t fifo_count ()
 Get the number of bytes currently stored in the FIFO buffer (register map §4.30). More...
 
template<typename T >
bool fifo_pop (T &output)
 Get one sample out of the FIFO buffer (register map §4.31). More...
 
bool fifo_push (uint8_t data)
 Push one byte to the FIFO buffer (register map §4.31). More...
 

Static Public Member Functions

static constexpr int16_t convert_temp_to_centi_degrees (int16_t temp)
 Convert the raw temperature obtained from temperature() to centi-degrees Celsius. More...
 

Additional Inherited Members

- Protected Types inherited from i2c::I2CDevice< MANAGER >
using ABSTRACT_FUTURE = typename MANAGER::ABSTRACT_FUTURE
 The abstract base class of all futures to be defined for a device. More...
 
using FUTURE = typename MANAGER::template FUTURE< OUT, IN >
 The template base class of all futures to be defined for a device. More...
 
- Protected Member Functions inherited from i2c::I2CDevice< MANAGER >
 I2CDevice (MANAGER &manager, uint8_t device, UNUSED Mode< MODE > mode, bool auto_stop)
 Create a new I2C device. More...
 
 I2CDevice (const I2CDevice &)=delete
 
I2CDeviceoperator= (const I2CDevice &)=delete
 
void set_device (uint8_t device)
 Change the I2C address of this device. More...
 
int launch_commands (ABSTRACT_FUTURE &future, utils::range< I2CLightCommand > commands)
 Launch execution (asynchronously or synchronously, depending on MANAGER) of a chain of I2CLightCommand items (constructed with read() and write() methods). More...
 
int async_read (F &future, bool stop=true)
 Helper method that asynchronously launches I2C commands for a simple Future performing one write followed by one read (typically for device register reading). More...
 
bool sync_read (T &result)
 Helper method that launches I2C commands for a simple Future performing one write followed by one read (typically for device register reading); the method blocks until the end of the I2C transaction. More...
 
int async_write (F &future, bool stop=true)
 Helper method that asynchronously launches I2C commands for a simple Future performing only one write (typically for device register writing). More...
 
int async_multi_write (F &future, bool stop=true)
 Helper method that asynchronously launches I2C commands for a simple Future performing several register writes. More...
 
bool sync_write (const T &value)
 Helper method that launches I2C commands for a simple Future performing only one write (typically for device register writing); the method blocks until the end of the I2C transaction. More...
 
bool sync_write ()
 Helper method that launches I2C commands for a simple Future performing only one write (typically for device register writing); the method blocks until the end of the I2C transaction. More...
 
- Static Protected Member Functions inherited from i2c::I2CDevice< MANAGER >
static constexpr I2CLightCommand read (uint8_t read_count=0, bool finish_future=false, bool stop=false)
 Build a read I2CLightCommand that can be later pushed to the I2C Manager for proper handling. More...
 
static constexpr I2CLightCommand write (uint8_t write_count=0, bool finish_future=false, bool stop=false)
 Build a write I2CLightCommand that can be later pushed to the I2C Manager for proper handling. More...
 

Detailed Description

template<typename MANAGER>
class devices::magneto::MPU6050< MANAGER >

I2C device driver for the MPU6050 gyroscope/accelerometer chip.

Note that the I2C auxiliary mode of the chip is not supported by the driver.

Template Parameters
MANAGERone of FastArduino available I2C Manager

Definition at line 282 of file mpu6050.h.

Member Typedef Documentation

◆ GyroFuture

template<typename MANAGER >
using devices::magneto::MPU6050< MANAGER >::GyroFuture = Sensor3DFuture<GYRO_XOUT>

Create a future to be used by asynchronous method gyro_measures(GyroFuture&).

This is used by gyro_measures() to asynchronously launch the I2C transaction, and it shall be used by the caller to determine when the I2C transaction is finished.

See also
gyro_measures(GyroFuture&)

Definition at line 564 of file mpu6050.h.

◆ TemperatureFuture

template<typename MANAGER >
using devices::magneto::MPU6050< MANAGER >::TemperatureFuture = TReadRegisterFuture<TEMP_OUT, int16_t>

Create a future to be used by asynchronous method temperature(TemperatureFuture&).

This is used by temperature() to asynchronously launch the I2C transaction, and it shall be used by the caller to determine when the I2C transaction is finished.

The value returned by get() is internal raw value from the chip, it can be converted to human-readable temperature with convert_temp_to_centi_degrees().

See also
temperature(TemperatureFuture&)

Definition at line 598 of file mpu6050.h.

◆ AccelFuture

template<typename MANAGER >
using devices::magneto::MPU6050< MANAGER >::AccelFuture = Sensor3DFuture<ACCEL_XOUT>

Create a future to be used by asynchronous method accel_measures(AccelFuture&).

This is used by accel_measures() to asynchronously launch the I2C transaction, and it shall be used by the caller to determine when the I2C transaction is finished.

See also
accel_measures(AccelFuture&)

Definition at line 641 of file mpu6050.h.

◆ AllMeasuresFuture

template<typename MANAGER >
using devices::magneto::MPU6050< MANAGER >::AllMeasuresFuture = TReadRegisterFuture<ACCEL_XOUT, AllSensors, functor::ChangeEndianness<AllSensors, int16_t> >

Create a future to be used by asynchronous method all_measures(AllMeasuresFuture&).

This is used by all_measures() to asynchronously launch the I2C transaction, and it shall be used by the caller to determine when the I2C transaction is finished.

See also
all_measures(AllMeasuresFuture&)

Definition at line 672 of file mpu6050.h.

◆ InterruptStatusFuture

template<typename MANAGER >
using devices::magneto::MPU6050< MANAGER >::InterruptStatusFuture = TReadRegisterFuture<INT_STATUS, INTStatus>

Create a future to be used by asynchronous method interrupt_status(InterruptStatusFuture&).

This is used by interrupt_status() to asynchronously launch the I2C transaction, and it shall be used by the caller to determine when the I2C transaction is finished.

See also
interrupt_status(InterruptStatusFuture&)

Definition at line 705 of file mpu6050.h.

◆ ResetFifoFuture

template<typename MANAGER >
using devices::magneto::MPU6050< MANAGER >::ResetFifoFuture = TWriteRegisterFuture<USER_CTRL, uint8_t, functor::Constant<uint8_t, FIFO_ENABLE | FIFO_RESET> >

Create a future to be used by asynchronous method reset_fifo(ResetFifoFuture&).

This is used by reset_fifo() to asynchronously launch the I2C transaction, and it shall be used by the caller to determine when the I2C transaction is finished.

See also
reset_fifo(ResetFifoFuture&)

Definition at line 738 of file mpu6050.h.

◆ FifoCountFuture

template<typename MANAGER >
using devices::magneto::MPU6050< MANAGER >::FifoCountFuture = TReadRegisterFuture<FIFO_COUNT, uint16_t>

Create a future to be used by asynchronous method fifo_count(FifoCountFuture&).

This is used by fifo_count() to asynchronously launch the I2C transaction, and it shall be used by the caller to determine when the I2C transaction is finished.

See also
fifo_count(FifoCountFuture&)

Definition at line 770 of file mpu6050.h.

◆ FifoPopFuture

template<typename MANAGER >
template<typename T >
using devices::magneto::MPU6050< MANAGER >::FifoPopFuture = TReadRegisterFuture<FIFO_R_W, T, functor::ChangeEndianness<T, int16_t> >

Create a future to be used by asynchronous method fifo_pop(FifoPopFuture<T>&).

This is used by fifo_pop(FifoPopFuture<T>&) to asynchronously launch the I2C transaction, and it shall be used by the caller to determine when the I2C transaction is finished.

Template Parameters
Tthe type of measurement to read from FIFO; shall be one of Sensor3D (gyroscope or accelerometer measure), int16_t (temperature), AllSensors (eveything), or a combination of these.
See also
fifo_pop(FifoPopFuture<T>&)
Sensor3D
AllSensors

Definition at line 812 of file mpu6050.h.

◆ FifoPushFuture

template<typename MANAGER >
using devices::magneto::MPU6050< MANAGER >::FifoPushFuture = TWriteRegisterFuture<FIFO_R_W>

Create a future to be used by asynchronous method fifo_push(FifoPushFuture&).

This is used by fifo_push(FifoPushFuture&) to asynchronously launch the I2C transaction, and it shall be used by the caller to determine when the I2C transaction is finished.

Parameters
datathe byte value to be pushed
See also
fifo_push(FifoPushFuture&)

Definition at line 853 of file mpu6050.h.

Constructor & Destructor Documentation

◆ MPU6050()

template<typename MANAGER >
devices::magneto::MPU6050< MANAGER >::MPU6050 ( MANAGER manager,
AD0  ad0 = AD0::LOW 
)
inlineexplicit

Create a new device driver for a MPU6050 chip.

Parameters
managerreference to a suitable MANAGER for this device
ad0the level of the AD0 pin, which fixes the chip address on the I2C bus
See also
AD0

Definition at line 336 of file mpu6050.h.

Member Function Documentation

◆ begin() [1/4]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::begin ( BeginFuture future)
inline

Start operation of this gyroscope/accelerometer chip.

Once this method has been called, and future is ready, you may use other methods such as gyro_measures() to get sensors measurements from the device.

Warning
Asynchronous API!
Parameters
futurea BeginFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
BeginFuture
end()
begin(GyroRange, AccelRange, DLPF, ClockSelect)
begin(FifoBeginFuture&)
errors

Definition at line 390 of file mpu6050.h.

◆ begin() [2/4]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::begin ( FifoBeginFuture future)
inline

Start operation of this gyroscope/accelerometer chip.

Once this method has been called, and future is ready, you may use other methods such as gyro_measures() to get sensors measurements from the device. This shall be used when you want continuous measurements performed by the device.

Warning
Asynchronous API!
Parameters
futurea FifoBeginFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
FifoBeginFuture
end()
begin(FIFOEnable, INTEnable, uint8_t, GyroRange, AccelRange, DLPF, ClockSelect)
begin(BeginFuture&)
errors

Definition at line 460 of file mpu6050.h.

◆ end() [1/2]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::end ( EndFuture future)
inline

Put the chip to sleep mode (low-power mode); stops sampling operations if any.

Warning
Asynchronous API!
Parameters
futurean EndFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
begin(BeginFutre&)
begin(FifoBeginFuture&)
end()
errors

Definition at line 513 of file mpu6050.h.

◆ reset() [1/2]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::reset ( ResetFuture future)
inline

Reset the chip (register map §4.28).

Warning
Asynchronous API!
Parameters
futurea ResetFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
reset()
errors

Definition at line 551 of file mpu6050.h.

◆ gyro_measures() [1/2]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::gyro_measures ( GyroFuture future)
inline

Get latest gyroscope measurements from the device (register map §4.19).

Warning
Asynchronous API!
Parameters
futurea GyroFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
gyro_measures(Sensor3D&)
errors

Definition at line 582 of file mpu6050.h.

◆ temperature() [1/2]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::temperature ( TemperatureFuture future)
inline

Get latest chip temperature measurement (register map §4.18).

Warning
Asynchronous API!
Parameters
futurea TemperatureFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
TemperatureFuture
temperature()
convert_temp_to_centi_degrees()
errors

Definition at line 618 of file mpu6050.h.

◆ convert_temp_to_centi_degrees()

template<typename MANAGER >
static constexpr int16_t devices::magneto::MPU6050< MANAGER >::convert_temp_to_centi_degrees ( int16_t  temp)
inlinestaticconstexpr

Convert the raw temperature obtained from temperature() to centi-degrees Celsius.

Definition at line 627 of file mpu6050.h.

◆ accel_measures() [1/2]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::accel_measures ( AccelFuture future)
inline

Get latest accelerometer measurements from the device (register map §4.17).

Warning
Asynchronous API!
Parameters
futurean AccelFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
accel_measures(Sensor3D&)
errors

Definition at line 659 of file mpu6050.h.

◆ all_measures() [1/2]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::all_measures ( AllMeasuresFuture future)
inline

Get latest measurements of all device sensors (gyroscope, accelerometer, temperature).

Warning
Asynchronous API!
Parameters
futurean AllMeasuresFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
all_measures(AllSensors&)
errors

Definition at line 692 of file mpu6050.h.

◆ interrupt_status() [1/2]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::interrupt_status ( InterruptStatusFuture future)
inline

Get the interrupt status (register map §4.16) after an interrupt has occurred.

After this method is called, the Interrupt Status register is cleared.

Warning
Asynchronous API!
Parameters
futurean InterruptStatusFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
interrupt_status()
errors

Definition at line 725 of file mpu6050.h.

◆ reset_fifo() [1/2]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::reset_fifo ( ResetFifoFuture future)
inline

Reset the FIFO buffer (parameter map §4.27).

Warning
Asynchronous API!
Parameters
futurean ResetFifoFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
reset_fifo()
errors

Definition at line 757 of file mpu6050.h.

◆ fifo_count() [1/2]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::fifo_count ( FifoCountFuture future)
inline

Get the number of bytes currently stored in the FIFO buffer (register map §4.30).

This number is a multiple of the size of sensor samples as selected by FIFOEnable in begin(FIFOEnable, INTEnable, uint8_t, GyroRange, AccelRange, DLPF, ClockSelect).

Warning
Asynchronous API!
Parameters
futurean FifoCountFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
fifo_pop()
fifo_count()
errors

Definition at line 792 of file mpu6050.h.

◆ fifo_pop() [1/2]

template<typename MANAGER >
template<typename T >
int devices::magneto::MPU6050< MANAGER >::fifo_pop ( FifoPopFuture< T > &  future)
inline

Get one sample out of the FIFO buffer (register map §4.31).

Warning
You should first call fifo_count() to ensure the MPU6050 FIFO queue contains a sample of the right size! Otherwise this method will not return any error but set arbitrary values to output !
Asynchronous API!
Template Parameters
Tthe type of sample to get from the FIFO buffer; must be one of Sensor3D, int16_t or AllSensors, based on the sensor samples selected by FIFOEnable in begin(FIFOEnable, INTEnable, uint8_t, GyroRange, AccelRange, DLPF, ClockSelect).
Parameters
futurean FifoPopFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
fifo_count()
fifo_pop(T&)
errors

Definition at line 838 of file mpu6050.h.

◆ fifo_push() [1/2]

template<typename MANAGER >
int devices::magneto::MPU6050< MANAGER >::fifo_push ( FifoPushFuture future)
inline

Push one byte to the FIFO buffer (register map §4.31).

Warning
You should first call fifo_count() to ensure the MPU6050 FIFO queue contains a sample of the right size! Otherwise this method will not return any error but set arbitrary values to output !
Asynchronous API!
Parameters
futurean FifoPushFuture passed by the caller, that will be updated once the current I2C action is finished.
Return values
0if no problem occurred during the preparation of I2C transaction
Returns
an error code if something bad happened; for an asynchronous I2C Manager, this typically happens when its queue of I2CCommand is full; for a synchronous I2C Manager, any error on the I2C bus or on the target device will trigger an error here. the list of possible errors is in namespace errors.
See also
fifo_count()
fifo_push(uint8_t)
errors

Definition at line 875 of file mpu6050.h.

◆ begin() [3/4]

template<typename MANAGER >
bool devices::magneto::MPU6050< MANAGER >::begin ( GyroRange  gyro_range = GyroRange::RANGE_250,
AccelRange  accel_range = AccelRange::RANGE_2G,
DLPF  low_pass_filter = DLPF::ACCEL_BW_260HZ,
ClockSelect  clock_select = ClockSelect::INTERNAL_8MHZ 
)
inline

Start operation of this gyroscope/accelerometer chip.

Once this method has been called, you may use other methods such as gyro_measures() to get sensors measurements from the device.

Warning
Blocking API!
Parameters
gyro_rangethe GyroRange to use for the gyroscope measurements
accel_rangethe AccelRange to use for the accelerometer measurements
low_pass_filterthe DLPF bandwidth to use for operations
clock_selectthe ClockSelect to use as the device clock source
Return values
trueif the operation succeeded
falseif the operation failed
See also
end()
begin(FIFOEnable, INTEnable, uint8_t, GyroRange, AccelRange, DLPF, ClockSelect)
begin(BeginFuture&)

Definition at line 899 of file mpu6050.h.

◆ begin() [4/4]

template<typename MANAGER >
bool devices::magneto::MPU6050< MANAGER >::begin ( FIFOEnable  fifo_enable,
INTEnable  int_enable,
uint8_t  sample_rate_divider,
GyroRange  gyro_range = GyroRange::RANGE_250,
AccelRange  accel_range = AccelRange::RANGE_2G,
DLPF  low_pass_filter = DLPF::ACCEL_BW_260HZ,
ClockSelect  clock_select = ClockSelect::INTERNAL_8MHZ 
)
inline

Start operation of this gyroscope/accelerometer chip.

Once this method has been called, you may use other methods such as gyro_measures() to get sensors measurements from the device. This shall be used when you want continuous measurements performed by the device.

Warning
Blocking API!
Parameters
fifo_enablethe FIFOEnable settings for continuous measurements
int_enablethe INTEnable settings for interrupt generation; note that the device driver does not handle interrupts (ISR) itself, you need to use other FastArduino API for that.
sample_rate_dividerthe divider from the gyroscope output rate to generate the Sample Rate of the chip (register map §4.2)
gyro_rangethe GyroRange to use for the gyroscope measurements
accel_rangethe AccelRange to use for the accelerometer measurements
low_pass_filterthe DLPF bandwidth to use for operations
clock_selectthe ClockSelect to use as the device clock source
Return values
trueif the operation succeeded
falseif the operation failed
See also
end()
begin(GyroRange, AccelRange, DLPF, ClockSelect)
begin(FifoBeginFuture&)
interrupts::INTSignal
interrupts::PCISignal

Definition at line 936 of file mpu6050.h.

◆ end() [2/2]

template<typename MANAGER >
bool devices::magneto::MPU6050< MANAGER >::end ( )
inline

Put the chip to sleep mode (low-power mode); stops sampling operations if any.

Warning
Blocking API!
Return values
trueif the operation succeeded
falseif the operation failed
See also
begin()
end(EndFuture&)

Definition at line 961 of file mpu6050.h.

◆ reset() [2/2]

template<typename MANAGER >
bool devices::magneto::MPU6050< MANAGER >::reset ( )
inline

Reset the chip (register map §4.28).

Warning
Blocking API!
Return values
trueif the operation succeeded
falseif the operation failed
See also
reset(ResetFuture&)

Definition at line 975 of file mpu6050.h.

◆ gyro_measures() [2/2]

template<typename MANAGER >
bool devices::magneto::MPU6050< MANAGER >::gyro_measures ( Sensor3D gyro)
inline

Get latest gyroscope measurements from the device (register map §4.19).

Warning
Blocking API!
Parameters
gyroa reference to a Sensor3D variable that will be filled with latest gyroscope measurements on 3 axis.
Return values
trueif the operation succeeded
falseif the operation failed
See also
gyro_measures(GyroFuture&)

Definition at line 991 of file mpu6050.h.

◆ temperature() [2/2]

template<typename MANAGER >
int16_t devices::magneto::MPU6050< MANAGER >::temperature ( )
inline

Get latest chip temperature measurement (register map §4.18).

The returned value is nternal raw value from the chip, it can be converted to human-readable temperature with convert_temp_to_centi_degrees().

Warning
Blocking API!
Returns
the latest raw temperature in degrees if no error occurred
Return values
-32768if the operation failed
See also
temperature(TemperatureFuture&)
convert_temp_to_centi_degrees()

Definition at line 1008 of file mpu6050.h.

◆ accel_measures() [2/2]

template<typename MANAGER >
bool devices::magneto::MPU6050< MANAGER >::accel_measures ( Sensor3D accel)
inline

Get latest accelerometer measurements from the device (register map §4.17).

Warning
Blocking API!
Parameters
accela reference to a Sensor3D variable that will be filled with latest accelerometer measurements on 3 axis.
Return values
trueif the operation succeeded
falseif the operation failed
See also
accel_measures(AccelFuture&)

Definition at line 1026 of file mpu6050.h.

◆ all_measures() [2/2]

template<typename MANAGER >
bool devices::magneto::MPU6050< MANAGER >::all_measures ( AllSensors sensors)
inline

Get latest measurements of all device sensors (gyroscope, accelerometer, temperature).

Warning
Blocking API!
Parameters
sensorsa reference to an AllSensors variable that will be filled with all latest measurements.
Return values
trueif the operation succeeded
falseif the operation failed
See also
all_measures(AllMeasuresFuture&)

Definition at line 1043 of file mpu6050.h.

◆ interrupt_status() [2/2]

template<typename MANAGER >
INTStatus devices::magneto::MPU6050< MANAGER >::interrupt_status ( )
inline

Get the interrupt status (register map §4.16) after an interrupt has occurred.

After this method is called, the Interrupt Status register is cleared.

Warning
Blocking API!
Returns
the latest interrupt status as an INTStatus structure where each field maps to the interrupt that occurred; in case of an error, the returned status is fully cleared.
See also
interrupt_status(InterruptStatusFuture&)

Definition at line 1060 of file mpu6050.h.

◆ reset_fifo() [2/2]

template<typename MANAGER >
bool devices::magneto::MPU6050< MANAGER >::reset_fifo ( )
inline

Reset the FIFO buffer (parameter map §4.27).

Warning
Blocking API!
Return values
trueif the operation succeeded
falseif the operation failed
See also
reset_fifo(ResetFifoFuture&)

Definition at line 1076 of file mpu6050.h.

◆ fifo_count() [2/2]

template<typename MANAGER >
uint16_t devices::magneto::MPU6050< MANAGER >::fifo_count ( )
inline

Get the number of bytes currently stored in the FIFO buffer (register map §4.30).

This number is a multiple of the size of sensor samples as selected by FIFOEnable in begin(FIFOEnable, INTEnable, uint8_t, GyroRange, AccelRange, DLPF, ClockSelect).

Warning
Blocking API!
Returns
the number of bytes currently present in the FIFO buffer; when not 0, you should read the samples with fifo_pop().
Return values
0if the FIFO buffer is empty or if the operation failed
See also
fifo_pop()
fifo_count(FifoCountFuture&)

Definition at line 1095 of file mpu6050.h.

◆ fifo_pop() [2/2]

template<typename MANAGER >
template<typename T >
bool devices::magneto::MPU6050< MANAGER >::fifo_pop ( T &  output)
inline

Get one sample out of the FIFO buffer (register map §4.31).

Warning
You should first call fifo_count() to ensure the MPU6050 FIFO queue contains a sample of the right size! Otherwise this method will not return any error but set arbitrary values to output !
Blocking API!
Template Parameters
Tthe type of sample to get from the FIFO buffer; must be one of Sensor3D, int16_t or AllSensors, based on the sensor samples selected by FIFOEnable in begin(FIFOEnable, INTEnable, uint8_t, GyroRange, AccelRange, DLPF, ClockSelect).
Parameters
outputa reference to a T-type variable that will be filled with the required sample.
Return values
trueif a sample has been read into output
falseif no sample was ready or if the operation failed
See also
fifo_count()
fifo_pop(FifoPopFuture<T>&)

Definition at line 1121 of file mpu6050.h.

◆ fifo_push() [2/2]

template<typename MANAGER >
bool devices::magneto::MPU6050< MANAGER >::fifo_push ( uint8_t  data)
inline

Push one byte to the FIFO buffer (register map §4.31).

Warning
Blocking API!
Parameters
datathe byte value to be pushed
Return values
trueif data has been correctly pushed to the FIFO
falseif the operation failed
See also
fifo_push(FifoPushFuture&)

Definition at line 1136 of file mpu6050.h.


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