File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
FprimeZephyrReference/Components/Imu Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 66
77#include " FprimeZephyrReference/Components/Imu/Imu.hpp"
88
9+ #include < Fw/Types/Assert.hpp>
10+
911namespace 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
1723Imu ::~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
Original file line number Diff line number Diff line change 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+
1216namespace Components {
1317
1418class 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
You can’t perform that action at this time.
0 commit comments