diff --git a/examples/nucleo_f103rb/stts22h/main.cpp b/examples/nucleo_f103rb/stts22h/main.cpp new file mode 100644 index 0000000000..5286683e66 --- /dev/null +++ b/examples/nucleo_f103rb/stts22h/main.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021, Christopher Durand + * + * This file is part of the modm project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +// ---------------------------------------------------------------------------- + +#include +#include +#include + +using namespace Board; +using namespace std::literals; + +using I2cMaster = I2cMaster1; + +int +main() +{ + Board::initialize(); + LedD13::setOutput(); + + I2cMaster::connect(); + I2cMaster::initialize(); + + MODM_LOG_INFO << "Welcome to STTS22H Test" << modm::endl; + + modm::stts22h::Data data{}; + modm::Stts22h sensor{data, 0x3f}; + + bool success = RF_CALL_BLOCKING(sensor.initialize()); + if(!success) + { + MODM_LOG_ERROR << "Initialization failed" << modm::endl; + } + + modm::PeriodicTimer timer{500ms}; + while (true) + { + if (timer.execute()) + { + LedD13::toggle(); + + RF_CALL_BLOCKING(sensor.readTemperature()); + MODM_LOG_INFO << "temperature: " << data.getTemperatureFractional(); + MODM_LOG_INFO << " [1/100th °C]" << modm::endl; + } + } + + return 0; +} diff --git a/examples/nucleo_f103rb/stts22h/project.xml b/examples/nucleo_f103rb/stts22h/project.xml new file mode 100644 index 0000000000..71d25370ae --- /dev/null +++ b/examples/nucleo_f103rb/stts22h/project.xml @@ -0,0 +1,12 @@ + + modm:nucleo-f103rb + + + + + modm:build:scons + modm:processing:timer + modm:platform:i2c:1 + modm:driver:stts22h + +