Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ on:
push:
branches:
- main
schedule:
- cron: "0 12 * * 0"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
library_check:
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# limitations under the License.
cmake_minimum_required(VERSION 3.15)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_COLOR_DIAGNOSTICS ON)

project(libhal-sensor LANGUAGES CXX)

libhal_test_and_make_library(
Expand Down
8 changes: 3 additions & 5 deletions demos/applications/icm20948.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ void application(resource_list& p_map)
auto& console = *p_map.console.value();
auto& i2c = *p_map.i2c.value();

hal::print(console, "icm Application Starting...\n\n");
hal::print(console, "icm20948 Demo Application Starting...\n\n");
hal::delay(clock, 200ms);
hal::sensor::icm20948 icm_device(i2c);

hal::delay(clock, 200ms);
icm_device.init_mag();
hal::delay(clock, 100ms);
hal::sensor::icm20948 icm_device(i2c, clock);

hal::delay(clock, 200ms);
icm_device.auto_offsets();

while (true) {
Expand Down
6 changes: 3 additions & 3 deletions include/libhal-sensor/imu/icm20948.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include <libhal/i2c.hpp>
#include <libhal/steady_clock.hpp>
#include <libhal/timeout.hpp>
#include <libhal/units.hpp>

Expand Down Expand Up @@ -224,9 +225,8 @@ class icm20948
* @brief private constructor for icm20948 objects
* @param p_i2c The I2C peripheral used for communication with the device.
*/
[[deprecated(
"Use the constructor with hal::steady_clock instead.")]] icm20948(hal::i2c&
p_i2c);
[[deprecated("Use the constructor with hal::steady_clock instead.")]]
icm20948(hal::i2c& p_i2c);

/**
* @brief private constructor for icm20948 objects
Expand Down
15 changes: 9 additions & 6 deletions src/imu/icm20948.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <array>
#include <cmath>

#include <array>
#include <chrono>

#include <libhal-sensor/imu/icm20948.hpp>
#include <libhal-util/i2c.hpp>
#include <libhal-util/steady_clock.hpp>
#include <libhal/error.hpp>
#include <libhal/steady_clock.hpp>

namespace hal::sensor {

Expand Down Expand Up @@ -183,10 +187,10 @@ icm20948::icm20948(hal::i2c& p_i2c, hal::steady_clock& p_steady_clock)
m_current_bank = 0;

reset_icm20948();
hal::delay(*p_steady_clock, 100ms);
hal::delay(p_steady_clock, 100ms);
set_clock_auto_select();
sleep(false);
hal::delay(*p_steady_clock, 10ms);
hal::delay(p_steady_clock, 10ms);
reset_mag();

std::uint8_t tries = 0;
Expand All @@ -196,9 +200,8 @@ icm20948::icm20948(hal::i2c& p_i2c, hal::steady_clock& p_steady_clock)
if (mag_whoami_ok()) {
break;
}

i2c_master_reset();
hal::delay(*p_steady_clock, 10ms);
reset_i2c_master();
hal::delay(p_steady_clock, 10ms);
}

if (auto id = whoami(); id != who_am_i_content) {
Expand Down