Skip to content

feat(main): firmware integration by wiring all three modules into main.c and updating the full test runner#41

Draft
Rohith-Kalarikkal wants to merge 14 commits intodevelopfrom
feat/main-build
Draft

feat(main): firmware integration by wiring all three modules into main.c and updating the full test runner#41
Rohith-Kalarikkal wants to merge 14 commits intodevelopfrom
feat/main-build

Conversation

@Rohith-Kalarikkal
Copy link
Copy Markdown
Member

Summary

Completes the Sprint 2 firmware integration by wiring all three modules into main.c and updating the full test runner. main.c now has a clean superloop that calls sensor_init(), motor_init(), reads all sensors every 10 ms, applies brake-override motor control logic, and rate-limits UART Teleplot logging to every 100 ms. test_runner.c is updated to include all 69 Sprint 2 tests across the three modules using the handoff .inc pattern so future sprints can add tests without touching test_runner.c. Both CMakeLists.txt files are confirmed correct and all stub HAL headers are stable.

Type of Change

  • 🆕 New feature / user story
  • 🐛 Bug fix
  • ♻️ Refactor (no behaviour change)
  • 📝 Documentation only
  • 🔧 CI/CD or tooling change
  • 🔒 Security fix

Related Issue

Closes #31 #32

Changes Made

  • Updated core/src/main.c - Sprint 2 additions: sensor_init() and motor_init() calls with blink-on-failure error handling, main_loop_run() calling sensor_read_all() every 10 ms, motor_control_update() implementing brake-overrides-throttle safety rule, uart_log_sensors() emitting Teleplot-format >label:value\n lines every 100 ms, and system_hal_init() setting up stub HAL handles with correct ARR=3599 for 20 kHz PWM at 72 MHz
  • Updated tests/test_runner.c - added extern declarations for all 63 Sprint 2 tests across all three modules; replaced individual RUN_TEST() calls with #include "handoff/dev1_tests.inc", #include "handoff/dev2_tests.inc", and #include "handoff/dev3_tests.inc" in the correct s_active_module context so setUp()/tearDown() dispatches correctly for each module group
  • Updated tests/test_placeholder.c - no functional changes; confirmed Sprint 1 framework tests still pass
  • Confirmed CMakeLists.txt (root) - FIRMWARE_SOURCES list includes all three new module .c files; linker script path correct
  • Confirmed tests/CMakeLists.txt - TEST_SOURCES includes test_sensor_hal.c, test_motor_ctrl.c, test_protocol_prep.c, and test_runner.c; MOCK_SOURCES includes all five mock files; FIRMWARE_SOURCES_UNDER_TEST includes sensor_hal.c, motor_ctrl.c, and fault_logger.c
  • Confirmed all drivers/STM32_HAL/stm32f1xx_hal*.h stub headers - no changes required; all peripheral types used by Sprint 2 modules are already defined

How to Test This PR

  1. Checkout the branch: git checkout feat/main-build
  2. Confirm PRs 1, 2, and 3 have all merged - check git log --oneline develop and verify commits from feat/sensor-hal, feat/motor-ctrl, and feat/fault-log are present
  3. Verify all handoff files exist: ls tests/handoff/ - must show dev1_tests.inc, dev2_tests.inc, dev3_tests.inc
  4. Build the firmware: cmake --build build - must complete with 0 errors and 0 warnings
  5. Build and run the full test suite: cd tests && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug && make && ./test_runner
  6. Confirm final output shows exactly 69 Tests 0 Failures 0 Ignored
  7. Run Cppcheck across all sources: cppcheck --error-exitcode=1 -I core/inc core/src/

Testing Done by Author

  • Unit tests written for new/changed code
  • All existing tests pass locally (cd Tests/build && ./test_runner → 0 Failures)
  • Cppcheck passes locally (cppcheck --error-exitcode=1 -I core/Inc core/src/)
  • Code compiled successfully (cmake --build build)
  • Tested in Wokwi simulation (if applicable)
  • UART output verified (if applicable)
  • No new compiler warnings (-Wall -Wextra clean)

Code Quality Checklist

  • Code follows naming conventions from 06_CODING_STANDARDS.md
  • All public functions have Doxygen-style comments (@brief, @param, @retval)
  • No magic numbers — all constants are in ev_config.h
  • All function parameters are validated (null checks where applicable)
  • Return values of all called functions are checked
  • All switch statements have a default case
  • All if/for/while blocks use { braces even for single lines

Documentation

  • README.md updated if new setup steps are needed
  • Inline /* TODO: */ comments added for any deferred work

Screenshots / Logs (if applicable)

./tests/build/test_runner
..............................................................................
 
-----------------------
69 Tests 0 Failures 0 Ignored 
OK

---
<!-- Do not edit below this line -->
**Reviewer checklist:**
- [ ] Code logic is correct and matches the linked issue requirements
- [ ] Tests are meaningful (not just "assert(1 == 1)")
- [ ] No obvious security or safety issues
- [ ] Comments are clear and accurate

@Rohith-Kalarikkal Rohith-Kalarikkal self-assigned this Apr 30, 2026
@Rohith-Kalarikkal Rohith-Kalarikkal added user-story A user story / feature ci-cd CI/CD pipeline related sensor-hal Sensor HAL module motor-ctrl Motor control module sprint-2 Sprint 2 item labels Apr 30, 2026
@Rohith-Kalarikkal Rohith-Kalarikkal changed the title Feat/main build feat(main): firmware integration by wiring all three modules into main.c and updating the full test runner Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-cd CI/CD pipeline related motor-ctrl Motor control module sensor-hal Sensor HAL module sprint-2 Sprint 2 item user-story A user story / feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants