feat(mcan): MCAN driver implementation and host unit tests #98
No reviewers
Labels
No labels
Category
App
Category
Documentation
Category
Firmware
Category
Hardware
Category
Qms
PR_Size
L
PR_Size
M
PR_Size
S
PR_Size
XL
PR_Size
XS
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Priority
Very Low Priority
Size
Epic
Size
Feature
Size
Task
Status
Blocked
Status
Draft
Status
Needs-review
Team
Board
Team
Dev
Team
Management
Type
Bug
Type
Capa
Type
Improvement
Type
New-feature
Type
Regulatory
Type
Usability
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
opendutchsolutions.public/hal_awr6843!98
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/97-mcan-driver"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Adds
hal/mss/mcan/hal_mcan.c/.h— the MCAN (Bosch M_CAN / CAN-FD controller) driver: MEM_INIT_DONE-then-reset-then-CCCR.INIT bring-up sequence (cross-checked against the mmwave SDK'sCANFD_open()), nominal bit-timing derivation (fixed 16-time-quantum, 75% sample point), an "accept everything into Rx FIFO 0" global filter configuration, blocking transmit (dedicated Tx buffer 0, decodes PSR.LEC/BO into NACK/bus-error/bus-off status) and blocking receive (Rx FIFO 0, pop-and-acknowledge), and the two raw device handlers (MCAN_LVL0_IRQHandler/MCANB_LVL0_IRQHandler) decoding IR to a weak, application-overridablehal_mcan_irq_handler()hook. Both MCAN instances (MCANA/MCANB) supported. Self-contained — no cross-module dependency.This is the final driver in the current driver-implementation batch.
Why
Continues and completes the driver-implementation phase started by GPIO (#75/#76), ESM (#77/#78), UART (#79/#80), I2C (#81/#82), SPI (#83/#84), ADCBUF (#85/#86), CBUFF (#87/#88), HWA (#89/#90), DMM (#91/#92), EPWM (#93/#94), and SOC (#95/#96).
Related Issue
Closes #97
Type of Change
Impact Assessment
Testing
testing/mss/unit/hal_functionality/test_mcan_functionallocally (20 test cases, 130 assertions, all passing) alongside the full existingctestsuite (329/329 passing, no regressions); ran a full MISRA C:2025 pass (0 unsuppressed findings,-DENABLE_MCAN_MODULEadded); reformatted and re-verified against the exact clang-format 18.1.3 the CI runner uses; sanity-checked by changing the NTSEG1 bit-timing constant from 11 to 12, confirming the test suite fails (3 test cases, 4 assertions), then reverting.PR Size
Size justification / exemption (if L or XL):
1447 raw lines across 6 files, all hand-reviewed (no mechanically-generated content). Not split further — the driver (
hal_mcan.c/.h, 801 lines) and its comprehensive Catch2 spec (test_mcan.c, 638 lines, covering the bit-timing derivation math, the bring-up sequence, both transmit/receive paths and their error decoding, and both instances' IRQ handlers) don't decompose into independently-reviewable sub-PRs, same rationale as prior driver PRs (#78, #80, #82, #84, #86, #88, #90, #92, #94, #96). Only 3 files (CMake/MISRA wiring) needed touching beyond the driver/test pair —zephyr/Kconfig/zephyr/CMakeLists.txt/hal/util/hal_config_mss.hwere already pre-wired for MCAN from the original module list, before this driver existed.Checklist
type(scope): descriptionconvention withRelates to #<issue>footerSummary
hal/mss/mcan/hal_mcan.c/.h: MCAN driver (bring-up, bit-timing derivation, filter config, blocking Tx/Rx, IRQ handlers) — CAN-FD/extended-ID filtering/Tx-Event-FIFO/bus-off-recovery out of scope, documented in the header's top-of-file commenttesting/mss/unit/hal_functionality/test_mcan.c(+CMakeLists.txt): Catch2 functional test suite. Namedtest_mcan_functional(nottest_mcan) to avoid a CMake target-name collision withti_hal_comparison/test_mcan.c's register-layout comparison test.tools/misra/run_misra.sh:-DENABLE_MCAN_MODULEadded (Kconfig/CMake/hal_config_mss.h bridges were already in place)