Fix G27 shifter buttons and add SPI3 support for wheel rim#182
Fix G27 shifter buttons and add SPI3 support for wheel rim#182OrlandoEduardo101 wants to merge 4 commits into
Conversation
## ShifterAnalog G27 Mode Fix - Fix SPI clock configuration for 74HC165 (CLKPhase, CLKPolarity) - Add CS polarity configuration for active-low operation - Change to synchronous SPI read for reliable button reading - Fix CS pin index off-by-one error in setMode() and setCSPin() - Add startRead() method to trigger SPI before processing data ## SPI Buttons 3 (SPI3 Support) - Add SPI_Buttons_3 class using SPI3 peripheral for separate button source - Required because 74HC165 lacks tri-state output (cannot share MISO) - Allows G27 shifter (SPI2) and wheel rim (SPI3) to work simultaneously - SPI3 pins: PC10 (SCK), PC11 (MISO), PA15 (CS1) ## Hardware Configuration (F407VG) - Reduce SPI3 baud rate for reliable 74HC165 communication - Initialize SPI CS pins HIGH (inactive) to prevent bus contention - Enable SPIBUTTONS3 feature flag ## Documentation - Add complete wiring guide for all G27 components - Add technical reports documenting bugs and solutions - Bilingual documentation (English/Portuguese) Tested with Logitech G27 on STM32F407VET6 board. Made-with: Cursor
4ec89a2 to
f2c8df3
Compare
Changed Clutch pedal pin from PA6 to PC3 (AIN2) to match the actual F407VG hardware configuration in main.h: - AIN0 = PA3 (Brake) - AIN1 = PA2 (Throttle) - AIN2 = PC3 (Clutch) ← was incorrectly listed as PA6 Co-authored-by: Cursor <cursoragent@cursor.com>
Documented the G27 shifter X/Y analog axis connections: - X Axis: PC0 (Analog 6) - configurable via shifter.xchan - Y Axis: PC1 (Analog 5) - configurable via shifter.ychan Updated files: - G27_COMPLETE_WIRING_GUIDE.md: Added pin info to tables, diagram - G27_SHIFTER_ISSUE_REPORT.md: Added analog pins to hardware setup - README.md: Updated shifter pin summary Co-authored-by: Cursor <cursoragent@cursor.com>
|
Spi 2 has 3 cs pins and is intended for button inputs and addons while spi3 is for high speed addons. Bissc for example does reserve the whole port with no cs pin. It would make more sense to just use a different cs pin on spi2. The current shift register modules have a tristate buffer to allow shared ports |
|
Thanks for the clarification — that makes sense for the official OpenFFBoard design. I agree SPI2 (with CS1/CS2/CS3) is the right place for button/addon inputs, and SPI3 should stay available for high-speed addons like BISS-C. In my case I used the stock G27 shifter + wheel rim PCBs, which use bare 74HC165 shift registers without a tri-state buffer on MISO. I first tried the intended setup:
Result:
That’s why I moved the rim to SPI3 in my fork as a hardware-specific workaround. For this PR I can revise it to:
I’ll update the docs to state clearly:
Happy to adjust the PR accordingly. Thanks again. |
Per maintainer feedback on PR Ultrawipf#182: SPI2 is the preferred bus for buttons/addons; SPI3 is reserved for high-speed encoders (BISS-C, SSI). Removed from this PR: - SPI_Buttons_3 class and SPIBUTTONS3 define - EEPROM addresses ADR_SPI_BTN_3_CONF / _CONF_2 - Slow SPI3 prescaler (reverted to upstream PRESCALER_4) - Restore TIM_TMC_ARR and TIM_FFB accidentally removed in initial commit - G27-specific SPI3 comments in cpp_target_config.cpp Kept: - ShifterAnalog G27 H-pattern fix (cs_pin indexing, DMA read, SPI config) - SPI2 CS pins initialized HIGH (PB12, PD8, PD9) for correct operation - SPIBUTTONS2 define SPI3 wheel rim workaround preserved in tag g27-full-working for personal use. Upstream preferred solution: SPI2 CS2 with tri-state buffer on MISO.
|
Thanks for the review — you're right about SPI bus boundaries. I've updated this PR accordingly. What I changed: Agreed on the architecture: SPI2 is for buttons/addons; SPI3 is reserved for high-speed peripherals (BISS-C, SSI, MT encoder). I've removed all SPI3 wheel rim code from this PR. Why CS1 + CS2 on SPI2 failed on my hardware: I did test wheel rim on SPI2 CS2 (PD8) alongside the shifter on CS1 (PB12). It failed — not a firmware issue, but a hardware limitation of the stock G27: the 74HC165 shift register has no tri-state output. Both chips continuously drive the MISO line regardless of CS state, causing bus contention the moment both are connected physically. The upstream approach (SPI2 CS2) is correct in general but requires adding a 74HC125 tri-state buffer on MISO for stock G27 hardware. I've documented this in the docs. What's in this PR now:
What was removed:
The SPI3 wheel rim workaround is preserved in tag |
Summary
This PR fixes G27 shifter buttons not working in ShifterAnalog G27 mode and adds SPI3 support for connecting the G27 wheel rim buttons on a separate SPI bus.
Problem
Solution
ShifterAnalog Fixes
SPI3 Support (SPI_Buttons_3)
Testing
Tested on STM32F407VET6 board with:
Documentation
Added
doc/logitech g27/folder with:Checklist