Skip to content

Commit

Permalink
Add HW test for temperature sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
M-C-machts authored and PatrickKa committed Dec 14, 2024
1 parent 2f2dcb3 commit 71c80cd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sts1CobcSw/Periphery/TemperatureSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr auto channel = RODOS::ADC_CH_010;
auto Initialize() -> void
{
adc.init(channel);
const int32_t bitResolution = 12; // = 0.0403°C
const int32_t bitResolution = 12; // 3.3 V / 2^12 bits / (10 mV/°C) = 0.0806 °C/bit
adc.config(RODOS::ADC_PARAMETER_RESOLUTION, bitResolution);
}

Expand Down
7 changes: 7 additions & 0 deletions Tests/HardwareTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ target_link_libraries(
)
add_watchdog_version_of(SpiSupervisor)

add_program(TemperatureSensor TemperatureSensor.test.cpp)
target_link_libraries(
Sts1CobcSwTests_TemperatureSensor PRIVATE rodos::rodos Sts1CobcSw_Periphery
Sts1CobcSwTests_RfLatchupDisablePin
)
add_watchdog_version_of(TemperatureSensor)

add_program(Gpio Gpio.test.cpp)
target_link_libraries(
Sts1CobcSwTests_Gpio PRIVATE rodos::rodos Sts1CobcSw_Hal Sts1CobcSwTests_RfLatchupDisablePin
Expand Down
44 changes: 44 additions & 0 deletions Tests/HardwareTests/TemperatureSensor.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <Tests/HardwareTests/RfLatchupDisablePin.hpp>

#include <Sts1CobcSw/Periphery/TemperatureSensor.hpp>

#include <rodos_no_using_namespace.h>


namespace sts1cobcsw
{
class TermperatureSensorTest : public RODOS::StaticThread<>
{
public:
TermperatureSensorTest() : StaticThread("TermperatureSensorTest")
{
}


private:
void init() override
{
InitializeRfLatchupDisablePins();
rftemperaturesensor::Initialize();
}


void run() override
{
using RODOS::PRINTF;

EnableRfLatchupProtection();

PRINTF("\nRF temperature sensor test\n\n");

auto const conversionFactor = 0.0806; // °C/bit
auto const offset = -50; // °C at 0 V
TIME_LOOP(0, 1000 * RODOS::MILLISECONDS)
{
auto temperature = rftemperaturesensor::Read();
PRINTF("raw value = %5d\n", temperature);
PRINTF("temperature = %5.1f deg C\n", temperature * conversionFactor + offset);
}
}
} termperatureSensorTest;
}

0 comments on commit 71c80cd

Please sign in to comment.