feat(sensor): Added sensor hal modules#39
Merged
RoshanMGanesh merged 3 commits intodevelopfrom May 3, 2026
Merged
Conversation
Rohith-Kalarikkal
approved these changes
May 3, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the full Sensor HAL module for Sprint 2. Adds
sensor_hal.candsensor_hal.hwith ADC reads for battery temperature (LM35, CH0), motor temperature (LM35, CH1), battery current (ACS712-20A, CH2), battery voltage (resistor divider, CH3), and throttle position (potentiometer, CH4).Type of Change
Related Issue
Closes #23 #22 #24 #25 #26 #27 #28
Changes Made
core/src/sensor_hal.c- full implementation of all 8 sensor read functions plussensor_init(),sensor_read_all(),sensor_enable_i2c_temp()(stub), andsensor_get_temp_backend()core/inc/sensor_hal.h- public interface with Doxygen comments for every function, including Sprint 5 I2C preparation stubsdrivers/STM32_HAL/stm32_stubs.c- added stub implementations for all HAL GPIO, ADC, and timer functions used by the sensor moduletests/test_sensor_hal.c- 22 unit tests covering all sensor read functions, boundary conditions, null pointer guards, ADC channel isolation, and GPIO debounce logictests/mocks/mock_stm32_hal_adc.c/.h- full mock with per-channel value injection, start error, and poll timeout injectiontests/mocks/mock_stm32_hal_gpio.c/.h- full mock with per-pin state control andmock_hal_set_tick()for debounce testingtests/mocks/mock_stm32_hal_tim.c/.h- mock with encoder count injection, ARR/CCR1 access, and PWM start error injectionHow to Test This PR
git checkout feat/sensor-halcd tests && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug && makeTesting Done by Author
cd Tests/build && ./test_runner→ 0 Failures)cppcheck --error-exitcode=1 -I core/Inc core/src/)cmake --build build)-Wall -Wextraclean)Code Quality Checklist
06_CODING_STANDARDS.md@brief,@param,@retval)ev_config.hswitchstatements have adefaultcaseif/for/whileblocks use{braces even for single linesDocumentation
README.mdupdated if new setup steps are needed/* TODO: */comments added for any deferred workReviewer checklist: