TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle
TM_MPU6050_Functions

Library Functions. More...

Functions

TM_MPU6050_Result_t TM_MPU6050_Init (TM_MPU6050_t *DataStruct, TM_MPU6050_Device_t DeviceNumber, TM_MPU6050_Accelerometer_t AccelerometerSensitivity, TM_MPU6050_Gyroscope_t GyroscopeSensitivity)
 Initializes MPU6050 and I2C peripheral. More...
 
TM_MPU6050_Result_t TM_MPU6050_SetGyroscope (TM_MPU6050_t *DataStruct, TM_MPU6050_Gyroscope_t GyroscopeSensitivity)
 Sets gyroscope sensitivity. More...
 
TM_MPU6050_Result_t TM_MPU6050_SetAccelerometer (TM_MPU6050_t *DataStruct, TM_MPU6050_Accelerometer_t AccelerometerSensitivity)
 Sets accelerometer sensitivity. More...
 
TM_MPU6050_Result_t TM_MPU6050_SetDataRate (TM_MPU6050_t *DataStruct, uint8_t rate)
 Sets output data rate. More...
 
TM_MPU6050_Result_t TM_MPU6050_EnableInterrupts (TM_MPU6050_t *DataStruct)
 Enables interrupts. More...
 
TM_MPU6050_Result_t TM_MPU6050_DisableInterrupts (TM_MPU6050_t *DataStruct)
 Disables interrupts. More...
 
TM_MPU6050_Result_t TM_MPU6050_ReadInterrupts (TM_MPU6050_t *DataStruct, TM_MPU6050_Interrupt_t *InterruptsStruct)
 Reads and clears interrupts. More...
 
TM_MPU6050_Result_t TM_MPU6050_ReadAccelerometer (TM_MPU6050_t *DataStruct)
 Reads accelerometer data from sensor. More...
 
TM_MPU6050_Result_t TM_MPU6050_ReadGyroscope (TM_MPU6050_t *DataStruct)
 Reads gyroscope data from sensor. More...
 
TM_MPU6050_Result_t TM_MPU6050_ReadTemperature (TM_MPU6050_t *DataStruct)
 Reads temperature data from sensor. More...
 
TM_MPU6050_Result_t TM_MPU6050_ReadAll (TM_MPU6050_t *DataStruct)
 Reads accelerometer, gyroscope and temperature data from sensor. More...
 

Detailed Description

Library Functions.

Function Documentation

TM_MPU6050_Result_t TM_MPU6050_DisableInterrupts ( TM_MPU6050_t DataStruct)

Disables interrupts.

Parameters
*DataStructPointer to TM_MPU6050_t structure indicating MPU6050 device
Return values
Memberof TM_MPU6050_Result_t enumeration
TM_MPU6050_Result_t TM_MPU6050_EnableInterrupts ( TM_MPU6050_t DataStruct)

Enables interrupts.

Parameters
*DataStructPointer to TM_MPU6050_t structure indicating MPU6050 device
Return values
Memberof TM_MPU6050_Result_t enumeration
TM_MPU6050_Result_t TM_MPU6050_Init ( TM_MPU6050_t DataStruct,
TM_MPU6050_Device_t  DeviceNumber,
TM_MPU6050_Accelerometer_t  AccelerometerSensitivity,
TM_MPU6050_Gyroscope_t  GyroscopeSensitivity 
)

Initializes MPU6050 and I2C peripheral.

Parameters
*DataStructPointer to empty TM_MPU6050_t structure
DeviceNumberMPU6050 has one pin, AD0 which can be used to set address of device. This feature allows you to use 2 different sensors on the same board with same library. If you set AD0 pin to low, then this parameter should be TM_MPU6050_Device_0, but if AD0 pin is high, then you should use TM_MPU6050_Device_1

Parameter can be a value of TM_MPU6050_Device_t enumeration

Parameters
AccelerometerSensitivitySet accelerometer sensitivity. This parameter can be a value of TM_MPU6050_Accelerometer_t enumeration
GyroscopeSensitivitySet gyroscope sensitivity. This parameter can be a value of TM_MPU6050_Gyroscope_t enumeration
Return values
Initializationstatus:
  • TM_MPU6050_Result_t: Everything OK
  • Other member: in other cases
TM_MPU6050_Result_t TM_MPU6050_ReadAccelerometer ( TM_MPU6050_t DataStruct)

Reads accelerometer data from sensor.

Parameters
*DataStructPointer to TM_MPU6050_t structure to store data to
Return values
Memberof TM_MPU6050_Result_t:
  • TM_MPU6050_Result_Ok: everything is OK
  • Other: in other cases
TM_MPU6050_Result_t TM_MPU6050_ReadAll ( TM_MPU6050_t DataStruct)

Reads accelerometer, gyroscope and temperature data from sensor.

Parameters
*DataStructPointer to TM_MPU6050_t structure to store data to
Return values
Memberof TM_MPU6050_Result_t:
  • TM_MPU6050_Result_Ok: everything is OK
  • Other: in other cases
TM_MPU6050_Result_t TM_MPU6050_ReadGyroscope ( TM_MPU6050_t DataStruct)

Reads gyroscope data from sensor.

Parameters
*DataStructPointer to TM_MPU6050_t structure to store data to
Return values
Memberof TM_MPU6050_Result_t:
  • TM_MPU6050_Result_Ok: everything is OK
  • Other: in other cases
TM_MPU6050_Result_t TM_MPU6050_ReadInterrupts ( TM_MPU6050_t DataStruct,
TM_MPU6050_Interrupt_t InterruptsStruct 
)

Reads and clears interrupts.

Parameters
*DataStructPointer to TM_MPU6050_t structure indicating MPU6050 device
*InterruptsStructPointer to TM_MPU6050_Interrupt_t structure to store status in
Return values
Memberof TM_MPU6050_Result_t enumeration
TM_MPU6050_Result_t TM_MPU6050_ReadTemperature ( TM_MPU6050_t DataStruct)

Reads temperature data from sensor.

Parameters
*DataStructPointer to TM_MPU6050_t structure to store data to
Return values
Memberof TM_MPU6050_Result_t:
  • TM_MPU6050_Result_Ok: everything is OK
  • Other: in other cases
TM_MPU6050_Result_t TM_MPU6050_SetAccelerometer ( TM_MPU6050_t DataStruct,
TM_MPU6050_Accelerometer_t  AccelerometerSensitivity 
)

Sets accelerometer sensitivity.

Parameters
*DataStructPointer to TM_MPU6050_t structure indicating MPU6050 device
AccelerometerSensitivityGyro sensitivity value. This parameter can be a value of TM_MPU6050_Accelerometer_t enumeration
Return values
Memberof TM_MPU6050_Result_t enumeration
TM_MPU6050_Result_t TM_MPU6050_SetDataRate ( TM_MPU6050_t DataStruct,
uint8_t  rate 
)

Sets output data rate.

Parameters
*DataStructPointer to TM_MPU6050_t structure indicating MPU6050 device
rateData rate value. An 8-bit value for prescaler value
Return values
Memberof TM_MPU6050_Result_t enumeration
TM_MPU6050_Result_t TM_MPU6050_SetGyroscope ( TM_MPU6050_t DataStruct,
TM_MPU6050_Gyroscope_t  GyroscopeSensitivity 
)

Sets gyroscope sensitivity.

Parameters
*DataStructPointer to TM_MPU6050_t structure indicating MPU6050 device
GyroscopeSensitivityGyro sensitivity value. This parameter can be a value of TM_MPU6050_Gyroscope_t enumeration
Return values
Memberof TM_MPU6050_Result_t enumeration