-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[driver] add stm32f469_disco example for max31865
- Loading branch information
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// coding: utf-8 | ||
/* | ||
* Copyright (c) 2023, Henrik Hose | ||
* | ||
* 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 <modm/board.hpp> | ||
#include <modm/driver/temperature/max31865.hpp> | ||
#include <modm/processing.hpp> | ||
|
||
using namespace Board; | ||
|
||
using SpiMaster = modm::platform::SpiMaster2; | ||
|
||
using Cs = D9; | ||
using Mosi = D11; | ||
using Miso = D12; | ||
using Sck = D13; | ||
|
||
class ThermocoupleThread : public modm::pt::Protothread | ||
{ | ||
public: | ||
ThermocoupleThread() : data{}, pt100(data) {} | ||
|
||
bool | ||
run() | ||
{ | ||
PT_BEGIN(); | ||
PT_CALL(pt100.initialize()); | ||
|
||
while (true) | ||
{ | ||
MODM_LOG_INFO << "\nNew readout:" << modm::endl; | ||
PT_CALL(pt100.readout()); | ||
|
||
MODM_LOG_INFO << " resistance : " << data.getResistance() << " Ohm" | ||
<< modm::endl; | ||
MODM_LOG_INFO << " temperature fast: " << data.getTemperatureFast() << " degrees" | ||
<< modm::endl; | ||
MODM_LOG_INFO << " temperature precise: " << data.getTemperaturePrecise() << " degrees" | ||
<< modm::endl; | ||
|
||
timeout.restart(std::chrono::milliseconds(1000)); | ||
PT_WAIT_UNTIL(timeout.isExpired()); | ||
} | ||
|
||
PT_END(); | ||
} | ||
|
||
private: | ||
using Max31865 = modm::Max31865<SpiMaster, Cs, modm::max31865::pt100>; | ||
Max31865::Data data; | ||
Max31865 pt100; | ||
|
||
modm::ShortTimeout timeout; | ||
}; | ||
|
||
ThermocoupleThread pt100Thread{}; | ||
|
||
int | ||
main() | ||
{ | ||
Board::initialize(); | ||
Cs::setOutput(modm::Gpio::High); | ||
|
||
SpiMaster::connect<Miso::Miso, Mosi::Mosi, Sck::Sck>(); | ||
SpiMaster::initialize<Board::SystemClock, 351_kHz>(); | ||
|
||
MODM_LOG_INFO << "==========MAX 31865 Test==========" << modm::endl; | ||
MODM_LOG_DEBUG << "Debug logging here" << modm::endl; | ||
MODM_LOG_INFO << "Info logging here" << modm::endl; | ||
MODM_LOG_WARNING << "Warning logging here" << modm::endl; | ||
MODM_LOG_ERROR << "Error logging here" << modm::endl; | ||
MODM_LOG_INFO << "===============================" << modm::endl; | ||
|
||
while (true) | ||
{ | ||
pt100Thread.run(); | ||
Board::LedOrange::toggle(); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<library> | ||
<extends>modm:disco-f469ni</extends> | ||
<options> | ||
<option name="modm:build:build.path">../../../build/stm32f469_discovery/max31865</option> | ||
</options> | ||
<modules> | ||
<module>modm:driver:max31865</module> | ||
<module>modm:platform:gpio</module> | ||
<module>modm:platform:spi:2</module> | ||
<module>modm:processing:protothread</module> | ||
<module>modm:processing:timer</module> | ||
<module>modm:build:scons</module> | ||
</modules> | ||
</library> |