Skip to content

Commit b4203c9

Browse files
committed
Initial imu data pull
1 parent 74bf7a6 commit b4203c9

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

FprimeZephyrReference/Components/Imu/Imu.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
66

77
#include "FprimeZephyrReference/Components/Imu/Imu.hpp"
88

9+
#include <Fw/Types/Assert.hpp>
10+
911
namespace Components {
1012

1113
// ----------------------------------------------------------------------
1214
// Component construction and destruction
1315
// ----------------------------------------------------------------------
1416

15-
Imu ::Imu(const char* const compName) : ImuComponentBase(compName) {}
17+
Imu ::Imu(const char* const compName) : ImuComponentBase(compName) {
18+
lis2mdl = device_get_binding("LIS2MDL");
19+
FW_ASSERT(lis2mdl != nullptr);
20+
FW_ASSERT(device_is_ready(lis2mdl));
21+
}
1622

1723
Imu ::~Imu() {}
1824

@@ -24,6 +30,11 @@ void Imu ::run_handler(FwIndexType portNum, U32 context) {
2430
this->imuCallCount++;
2531
this->tlmWrite_ImuCalls(this->imuCallCount);
2632
this->log_ACTIVITY_HI_ImuTestEvent();
33+
34+
sensor_sample_fetch_chan(lis2mdl, SENSOR_CHAN_MAGN_XYZ);
35+
sensor_channel_get(lis2mdl, SENSOR_CHAN_MAGN_X, &magnetic_field_x);
36+
sensor_channel_get(lis2mdl, SENSOR_CHAN_MAGN_Y, &magnetic_field_y);
37+
sensor_channel_get(lis2mdl, SENSOR_CHAN_MAGN_Z, &magnetic_field_z);
2738
}
2839

2940
} // namespace Components

FprimeZephyrReference/Components/Imu/Imu.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
#include "FprimeZephyrReference/Components/Imu/ImuComponentAc.hpp"
1111

12+
#include <zephyr/device.h>
13+
#include <zephyr/drivers/sensor.h>
14+
#include <zephyr/kernel.h>
15+
1216
namespace Components {
1317

1418
class Imu final : public ImuComponentBase {
@@ -32,10 +36,15 @@ class Imu final : public ImuComponentBase {
3236
//! Handler implementation for TODO
3337
//!
3438
//! TODO
35-
U64 imuCallCount;
3639
void run_handler(FwIndexType portNum, //!< The port number
3740
U32 context //!< The call order
3841
) override;
42+
43+
U64 imuCallCount;
44+
const struct device* lis2mdl;
45+
struct sensor_value magnetic_field_x;
46+
struct sensor_value magnetic_field_y;
47+
struct sensor_value magnetic_field_z;
3948
};
4049

4150
} // namespace Components

0 commit comments

Comments
 (0)