Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TBSense2_Sensor_Demo
ICM20648 Class Reference
#include <ICM20648.h>
Public Member Functions | |
| ICM20648 (PinName mosi, PinName miso, PinName sclk, PinName cs, PinName irq=NC) | |
| Create an ICM20648 object connected to the specified SPI pins. | |
| ~ICM20648 (void) | |
| ICM20648 destructor. | |
| bool | open () |
| Probe for the ICM20648 and try to initialize the sensor. | |
| bool | measure () |
| Perform a measurement. | |
| bool | get_gyroscope (float *gyr_x, float *gyr_y, float *gyr_z) |
| Do a measurement on the gyroscope. | |
| bool | get_accelerometer (float *acc_x, float *acc_y, float *acc_z) |
| Do a measurement on the accelerometer. | |
| bool | get_temperature (float *temperature) |
| Do a measurement of the temperature sensor. | |
Detailed Description
ICM20648 class.
Used for taking accelerometer and gyroscope measurements.
Example:
#include "mbed.h" #include "ICM20648.h " //Create an ICM20648 object ICM20648 sensor(PC4, PC5); int main() { //Try to open the ICM20648 if (sensor.open()) { printf("Device detected!\n"); while (1) { float acc_x, acc_y, acc_z; float gyr_x, gyr_y, gyr_z; sensor.measure(); sensor.get_accelerometer(&acc_x, &acc_y, &acc_z); sensor.get_gyroscope(&gyr_x, &gyr_y, &gyr_z); //Print the current accelerometer measurement printf("acc: %.3f %.3f %.3f\n", acc_x, acc_y, acc_z); //Print the current gyroscope measurement printf("gyr: %.3f %.3f %.3f\n", gyr_x, gyr_y, gyr_z); //Sleep for 0.5 seconds wait(0.5); } } else { error("Device not detected!\n"); } }
Definition at line 69 of file ICM20648.h.
Constructor & Destructor Documentation
| ICM20648 | ( | PinName | mosi, |
| PinName | miso, | ||
| PinName | sclk, | ||
| PinName | cs, | ||
| PinName | irq = NC |
||
| ) |
Create an ICM20648 object connected to the specified SPI pins.
- Parameters:
-
mosi The SPI MOSI pin. miso The SPI MISO pin. sclk The SPI clock pin. cs The SPI Chip Select pin. irq The ICM20648 irq pin.
Definition at line 279 of file ICM20648.cpp.
| ~ICM20648 | ( | void | ) |
ICM20648 destructor.
Definition at line 285 of file ICM20648.cpp.
Member Function Documentation
| bool get_accelerometer | ( | float * | acc_x, |
| float * | acc_y, | ||
| float * | acc_z | ||
| ) |
Do a measurement on the accelerometer.
- Parameters:
-
[out] acc_x Accelerometer measurement on X axis [out] acc_y Accelerometer measurement on Y axis [out] acc_z Accelerometer measurement on Z axis
- Returns:
- true if measurement was successful
Definition at line 355 of file ICM20648.cpp.
| bool get_gyroscope | ( | float * | gyr_x, |
| float * | gyr_y, | ||
| float * | gyr_z | ||
| ) |
Do a measurement on the gyroscope.
- Parameters:
-
[out] gyr_x Gyroscope measurement on X axis [out] gyr_y Gyroscope measurement on Y axis [out] gyr_z Gyroscope measurement on Z axis
- Returns:
- true if measurement was successful
Definition at line 335 of file ICM20648.cpp.
| bool get_temperature | ( | float * | temperature ) |
Do a measurement of the temperature sensor.
- Parameters:
-
[out] temperature Measured temperature
- Returns:
- true if measurement was successful
Definition at line 367 of file ICM20648.cpp.
| bool measure | ( | ) |
Perform a measurement.
- Returns:
- true if measurement was successful
Definition at line 322 of file ICM20648.cpp.
| bool open | ( | ) |
Probe for the ICM20648 and try to initialize the sensor.
- Returns:
- 'true' if the device exists on the bus, 'false' if the device doesn't exist on the bus.
Definition at line 289 of file ICM20648.cpp.
Generated on Sat Jul 16 2022 11:18:59 by
1.7.2