mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-05-21 12:01:47 +02:00
chg: dev: specified interface for the imu
This commit is contained in:
parent
31f4a2b281
commit
ce5f00a848
@ -1,6 +1,100 @@
|
||||
/**
|
||||
* @file MotionDetection.h
|
||||
* @author Hans Haupt
|
||||
* @brief This component controls the IMU (Accelerometer & Gyroscope) ICM-42670-P
|
||||
* @version 0.1
|
||||
* @date 2023-12-15
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#ifndef MotionDetection_h
|
||||
#define MotionDetection_h
|
||||
class MotionDetection{
|
||||
#include "driver/spi_master.h"
|
||||
|
||||
struct IMUResult{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
}
|
||||
|
||||
|
||||
class MotionDetection{
|
||||
protected:
|
||||
static const uint8_t MCU_HOST = SPI2_HOST;
|
||||
static const uint8_t PIN_NUM_MISO = 37;
|
||||
static const uint8_t PIN_NUM_MOSI = 35;
|
||||
static const uint8_t PIN_NUM_CLK = 36;
|
||||
static const uint8_t PIN_NUM_CS = 34;
|
||||
|
||||
static const uint8_t PIN_INT0 = 28;
|
||||
|
||||
|
||||
static const uint8_t CMD_READ = 0x80;
|
||||
static const uint8_t CMD_WRITE = 0x00;
|
||||
static const uint8_t ADDR_MASK = 0x7F;
|
||||
|
||||
//Registers
|
||||
static const uint8_t REG_TEMP_LOW = 0x0A;
|
||||
static const uint8_t REG_TEMP_HIGH = 0X09;
|
||||
|
||||
static const uint8_t ACCEL_DATA_X_HIGH = 0x0B;
|
||||
static const uint8_t ACCEL_DATA_X_LOW = 0x0C;
|
||||
static const uint8_t ACCEL_DATA_Y_HIGH = 0x0D;
|
||||
static const uint8_t ACCEL_DATA_Y_LOW = 0x0E;
|
||||
static const uint8_t ACCEL_DATA_Z_HIGH = 0x0F;
|
||||
static const uint8_t ACCEL_DATA_Z_LOW = 0x10;
|
||||
|
||||
static const uint8_t GYRO_DATA_X_HIGH = 0x11;
|
||||
static const uint8_t GYRO_DATA_X_LOW = 0x12;
|
||||
static const uint8_t GYRO_DATA_Y_HIGH = 0x13;
|
||||
static const uint8_t GYRO_DATA_Y_LOW = 0x14;
|
||||
static const uint8_t GYRO_DATA_Z_HIGH = 0x15;
|
||||
static const uint8_t GYRO_DATA_Z_LOW = 0x16;
|
||||
|
||||
uint16_t imu_read_double_register(uint8_t lowerByteAddress, spi_device_handle_t * spi);
|
||||
esp_err_t spi_imu_read(spi_device_handle_t * ctx, uint8_t addr, uint8_t* out_data);
|
||||
esp_err_t spi_imu_write(spi_device_handle_t* ctx, uint8_t addr, uint8_t data);
|
||||
void cs_high(spi_transaction_t* t);
|
||||
void cs_low(spi_transaction_t* t);
|
||||
|
||||
public
|
||||
MotionDetection();
|
||||
|
||||
/**
|
||||
* @brief initialized the IMU Component.
|
||||
* Wakes the IMU from Standby
|
||||
* Set configuration
|
||||
*
|
||||
*/
|
||||
void begin(void);
|
||||
|
||||
/**
|
||||
* @brief stops the component
|
||||
* Sets the IMU to Low-Power-Mode
|
||||
*
|
||||
*/
|
||||
void end(void);
|
||||
|
||||
/**
|
||||
* @brief Triggers a new Reading of the accelerationvalues and reads them from the IMU
|
||||
*
|
||||
* @return IMUResult that contains the new read values
|
||||
*/
|
||||
IMUResult getAcceleration();
|
||||
|
||||
/**
|
||||
* @brief Triggers a new reading of the gyroscope and reads the values from the imu
|
||||
*
|
||||
* @return IMUResult
|
||||
*/
|
||||
IMUResult getRotation();
|
||||
|
||||
/**
|
||||
* @brief Reads the current On Chip temperature of the IMU
|
||||
*
|
||||
* @return normalized temperature in degree Centigrade
|
||||
*/
|
||||
float getTemperature();
|
||||
};
|
||||
#endif //MotionDetection
|
Loading…
x
Reference in New Issue
Block a user