Skip to content

Commit

Permalink
✨ (imu): Add basic spike for imu
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Feb 20, 2024
1 parent 3522d75 commit b54d52e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spikes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ add_subdirectory(${SPIKES_DIR}/lk_rfid)
add_subdirectory(${SPIKES_DIR}/lk_sensors_battery)
add_subdirectory(${SPIKES_DIR}/lk_sensors_imu)
add_subdirectory(${SPIKES_DIR}/lk_sensors_imu_fusion_calibration)
add_subdirectory(${SPIKES_DIR}/lk_sensors_imu_wakeup_calibration)
add_subdirectory(${SPIKES_DIR}/lk_sensors_light)
add_subdirectory(${SPIKES_DIR}/lk_sensors_microphone)
add_subdirectory(${SPIKES_DIR}/lk_sensors_temperature_humidity)
Expand Down Expand Up @@ -73,6 +74,7 @@ add_dependencies(spikes_leka
spike_lk_sensors_battery
spike_lk_sensors_imu
spike_lk_sensors_imu_fusion_calibration
spike_lk_sensors_imu_wakeup_calibration
spike_lk_sensors_light
spike_lk_sensors_microphone
spike_lk_sensors_temperature_humidity
Expand Down
22 changes: 22 additions & 0 deletions spikes/lk_sensors_imu_wakeup_calibration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Leka - LekaOS
# Copyright 2022 APF France handicap
# SPDX-License-Identifier: Apache-2.0

add_mbed_executable(spike_lk_sensors_imu_wakeup_calibration)

target_include_directories(spike_lk_sensors_imu_wakeup_calibration
PRIVATE
.
)

target_sources(spike_lk_sensors_imu_wakeup_calibration
PRIVATE
main.cpp
)

target_link_libraries(spike_lk_sensors_imu_wakeup_calibration
CoreIMU
CoreI2C
)

target_link_custom_leka_targets(spike_lk_sensors_imu_wakeup_calibration)
54 changes: 54 additions & 0 deletions spikes/lk_sensors_imu_wakeup_calibration/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Leka - LekaOS
// Copyright 2022 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#include <cinttypes>

#include "rtos/ThisThread.h"

#include "CoreI2C.h"
#include "CoreIMU.hpp"
#include "HelloWorld.h"
#include "LogKit.h"

using namespace std::chrono;
using namespace leka;

namespace {

namespace imu {

namespace internal {

auto irq = CoreInterruptIn {PinName::SENSOR_IMU_IRQ};
auto i2c = CoreI2C {PinName::SENSOR_IMU_TH_I2C_SDA, PinName::SENSOR_IMU_TH_I2C_SCL};

} // namespace internal

CoreIMU coreimu(internal::i2c, internal::irq);

} // namespace imu

} // namespace

auto main() -> int
{
logger::init();

log_info("Hello, World!\n\n");

HelloWorld hello;
hello.start();

imu::coreimu.init();
imu::coreimu.setPowerMode(CoreIMU::PowerMode::Normal);

auto callback = [] {};

imu::coreimu.registerOnWakeUpCallback(callback);
imu::coreimu.enableOnWakeUpInterrupt();

while (true) {
rtos::ThisThread::sleep_for(10min);
}
}

0 comments on commit b54d52e

Please sign in to comment.