-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lsm9ds1HalI2c.h
54 lines (43 loc) · 1.4 KB
/
Lsm9ds1HalI2c.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Lsm9ds1.h
*
* Created on: 03.06.2021
* Author: Cedric Boes
*/
#ifndef SENSORS_LSM9DS1HAL_H_
#define SENSORS_LSM9DS1HAL_H_
#include "rodos.h"
#include "matlib.h"
#include "../utils.h"
#include "HalI2c.h"
#include "constants/lsm9ds1_const.h"
#include "i2c/lsm9ds1_i2c.h"
#include "registers/lsm9ds1_reg.h"
class Lsm9ds1HalI2c : public HalI2c {
public:
Lsm9ds1HalI2c(HAL_I2C *device);
virtual ~Lsm9ds1HalI2c();
bool initLsm9ds1();
bool setup() override;
bool setupI2c() override;
bool readTemp(float &temp);
bool readAcceleration(Vector3D &acc);
bool readRotation(Vector3D &rot);
bool readMagneticField(Vector3D &mag);
void setNormalizationValues(float linearAccelSens, float angularRateSens, float magneticSens);
float getLinearAccelSens();
float getAngularRateSens();
float getMagneticSens();
private:
// Blocking operation
bool detectSensor(I2cDevice *device, Register *whoAmI, uint8_t expectedValue);
bool inline readGxlI2c(Register* reg, uint8_t *data, size_t bytesToRead);
bool inline writeGxlI2c(Register* reg, uint8_t *data, size_t bytesToWrite);
bool inline readMI2c(Register* reg, uint8_t *data, size_t bytesToRead);
bool inline writeMI2c(Register* reg, uint8_t *data, size_t bytesToWrite);
uint8_t dataBuffer[6];
float linearAccelSens;
float angularRateSens;
float magneticSens;
};
#endif /* SENSORS_LSM9DS1HAL_H_ */