--- name: Embedded-Driver-Review description: Review embedded firmware code with focus on safety, determinism, and correct hardware interaction. --- # Firmware Code Review ## Goal Review embedded firmware code with focus on safety, determinism, and correct hardware interaction. The review should help detect subtle firmware issues that may not be visible in standard software code reviews. --- ## Inputs The review should use the following context when available: - the **currently selected code** or **current file** - any **open files in the editor** - specification files under: docs/specs/*.md If a relevant specification exists, use it to validate register usage and device interaction. If required context is missing, ask for the relevant file. --- ## Review Focus Perform the review using embedded firmware best practices. Check for the following categories. ### RTOS and Concurrency - blocking calls inside ISR context - incorrect use of RTOS APIs - shared state without synchronization - potential race conditions - unsafe interrupt interaction --- ### Hardware Register Access - incorrect register addresses - incorrect bit masks - missing bit clearing before setting fields - unsafe register modification patterns - missing verification reads --- ### Integer and Memory Safety - integer overflow - narrowing conversions - signed / unsigned mismatches - unsafe casts - implicit type conversions --- ### Error Handling - inconsistent error propagation - ignored return values - missing timeout handling - silent failures --- ### Timing and Determinism - potential blocking behavior - unexpected loops - operations that may violate timing constraints --- ### Specification Consistency If a specification file exists under: docs/specs/ compare the implementation against the specification. Check: - register usage - bitfields - initialization sequence - configuration values Report any mismatch between the code and the specification. Do not assume undocumented behavior. --- ## Output Format Group findings by severity: ### Critical Issues that may cause: - incorrect hardware behavior - data corruption - system instability --- ### Major Issues that may cause: - incorrect edge-case behavior - maintainability problems - hidden firmware risks --- ### Minor Issues related to: - readability - defensive programming - minor safety improvements --- ## Constraints Do not suggest large architectural refactors. Prefer minimal fixes that: - preserve existing behavior - maintain the current API - avoid unnecessary complexity If the issue cannot be evaluated due to missing context, request the relevant files.