Skip to content

Commit

Permalink
Fixes to the temp_sensor example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandervoord committed Nov 22, 2023
1 parent 097b3ec commit 3204939
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/temp_sensor/rakefile_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def run_tests(test_files)
next unless header =~ /Mock/

require '../../lib/cmock.rb'
@cmock ||= CMock.new($cfg_file)
@cmock ||= CMock.new('./targets/' + $cfg_file)
@cmock.setup_mocks([$cfg['compiler']['source_path'] + header.gsub('Mock', '')])
end

Expand All @@ -217,7 +217,7 @@ def run_tests(test_files)
runner_name = test_base + '_Runner.c'
if $cfg['compiler']['runner_path'].nil?
runner_path = $cfg['compiler']['build_path'] + runner_name
test_gen = UnityTestRunnerGenerator.new($cfg_file)
test_gen = UnityTestRunnerGenerator.new('./targets/' + $cfg_file)
test_gen.run(test, runner_path)
else
runner_path = $cfg['compiler']['runner_path'] + runner_name
Expand Down Expand Up @@ -254,7 +254,7 @@ def build_application(main)
report 'Building application...'

obj_list = []
load_configuration($cfg_file)
load_configuration('./targets/' + $cfg_file)
main_path = $cfg['compiler']['source_path'] + main + C_EXTENSION

# Detect dependencies and build required required modules
Expand Down
13 changes: 8 additions & 5 deletions examples/temp_sensor/src/TemperatureFilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ void TemperatureFilter_ProcessInput(float temperature)
{
if (temperature == +INFINITY ||
temperature == -INFINITY ||
temperature == +NAN ||
temperature == -NAN)
temperature != temperature)
{
/* Check if +/- Infinity or NaN... reset to -Inf in this instance. */
initialized = FALSE;
temperature = -INFINITY;
temperatureInCelcius = -INFINITY;
}
else
{
/* Otherwise apply our low-pass filter to smooth the values */
temperatureInCelcius = (temperatureInCelcius * 0.75f) + (temperature * 0.25);
}

temperatureInCelcius = (temperatureInCelcius * 0.75f) + (temperature * 0.25);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/temp_sensor/test/TestTimerInterruptConfigurator.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void testResetSystemTimeDelegatesTo_Timer_SetSystemTime_Appropriately(void)

void testConfigureInterruptShouldSetInterruptHandlerAppropriately(void)
{
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0] = (uint32)NULL;
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0] = (uint32)0;
Timer_ConfigureInterrupt();
TEST_ASSERT_EQUAL((uint32)Timer_InterruptHandler, AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0]);
}
Expand Down

0 comments on commit 3204939

Please sign in to comment.