hal: renesas: ra: r_usb_device: Add support for 5-pipe USBFS peripherals (RA2L2, RA2A1, RA4E2, RA6E2, RA6T3) #208
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 317 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.345
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #208"
general
weight: 0.35
Hoog-V
Add support for 5-pipe USBFS peripherals (RA2L2, RA2A1, RA4E2, RA6E2, RA6T3)
I'm a big fan of the FSP and Renesas hardware. I recently picked up an RA4E2 devkit for a project and ran into issues getting USB working out of the box. Digging into the driver, I noticed the 5-pipe USBFS variant wasn't supported, but most of the code was already in place, it just needed some hardware-specific touch-ups to handle the different pipe layout and FIFO access pattern.
Since I had some spare time over the weekend, I figured I'd try to fill in the gaps. The change is fairly minimal and gated behind a feature macro, so it shouldn't affect any existing supported boards.
Hope this is useful! Happy to make any adjustments based on your feedback!
Problem
The existing
r_usb_device.cdriver only supported the 10-pipe USBFS peripheral variant. On MCUs with the 5-pipe USBFS module (RA2L2, RA2A1, RA4E2, RA6E2, RA6T3), the driver failed in two ways:1. Pipe allocation:
find_pipe()returned pipe numbers (1–3, 8–9) that don't physically exist on 5-pipe hardware. According to the RA4E2 datasheet (Section 25.1), the 5-pipe USBFS module exposes only pipes 0, 4, 5, 6, and 7, with pipes 4–7 being configurable for endpoints.2. FIFO access: The driver used the
D0FIFO/D1FIFOports for common-pipe data transfers. On the 5-pipe USBFS variant, common-pipe transfers must go through theCFIFOport instead.Fix
Introduced a
BSP_FEATURE_USB_HAS_PIPE04567feature macro to gate the hardware-specific code paths. When set:find_pipe()uses a 5-pipe lookup table:pipe_xfer_in()/pipe_xfer_out()/process_pipe_xfer()/pipe_wait_for_ready()route throughCFIFOSEL/CFIFO/CFIFOCTRinstead ofD0FIFO*.The original 10-pipe code path is preserved verbatim under
#else, so existing supported MCUs are unaffected.Testing
Verified the change works on both peripheral variants and does not introduce regressions:
Tested via USB CDC ACM sample code with bidirectional data transfer (host→device and device→host) confirmed working on both peripherals.
Affected MCUs
Adds support for these MCU groups (5-pipe USBFS):