{"id":18708576,"url":"https://github.com/va1da5/tm-th8a-emulator-research-stm32","last_synced_at":"2025-11-09T10:30:23.915Z","repository":{"id":106645976,"uuid":"584703451","full_name":"va1da5/tm-th8a-emulator-research-stm32","owner":"va1da5","description":"Thrustmaster TH8A shifter emulator research using TinyGo and STM32 uC","archived":false,"fork":false,"pushed_at":"2023-02-04T08:48:31.000Z","size":1250,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-28T07:31:27.593Z","etag":null,"topics":["i2c","stm32","th8a","thrustmaster","tinygo"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/va1da5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-03T09:49:53.000Z","updated_at":"2024-09-26T19:34:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2690a02-91db-40eb-b8d1-1682a19bff99","html_url":"https://github.com/va1da5/tm-th8a-emulator-research-stm32","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/va1da5%2Ftm-th8a-emulator-research-stm32","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/va1da5%2Ftm-th8a-emulator-research-stm32/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/va1da5%2Ftm-th8a-emulator-research-stm32/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/va1da5%2Ftm-th8a-emulator-research-stm32/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/va1da5","download_url":"https://codeload.github.com/va1da5/tm-th8a-emulator-research-stm32/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239571585,"owners_count":19661165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["i2c","stm32","th8a","thrustmaster","tinygo"],"created_at":"2024-11-07T12:24:00.494Z","updated_at":"2025-11-09T10:30:23.876Z","avatar_url":"https://github.com/va1da5.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Thrustmaster TH8A Emulator Research\n\nThis repository contains a research on an attempt to simulate the Thrustmaster's TH8A shifter add-on using I2C protocol. It heavily relies on [the original project](https://github.com/azzajess/USB-Shifter-to-Thrustmaster-Wheelbase) which implemented this functionality using the Arduino ecosystem. In this case, [TinyGo with STM32 'Bluepill' controller](https://tinygo.org/docs/reference/microcontrollers/bluepill/) was used for this purpose. This project lacks support for a generic USB shifter, because STM32 does not support USB host functionality. However, the core functionality is in place and the human input could be registered using controller's GPIO/ADC capabilities.\n\n\n## Project Structure\n\n```bash\nshifter/                    # contains code for simulating the th8a shifter \n    gears\n    gears/gears_test.go\n    gears/gears.go\n    go.mod\n    Makefile\n    main.go\n\nlogic-capture/              # contains signal capture data going from the actual th8a to TM wheel base\n    TH8A seq.vcd            # sequential gear mode: up, down, center\n    TH8A N-1-N-1.logicdata  # H type gear neutral to first gear\n    TH8A seq.logicdata\n    TH8A N-1-N-1.vcd\n\nDockerfile                  # defines development container setup for VS code\nMakefile                    # used to automate common tasks\n\narduino/                    # sample Arduino code related to TH8A simulation \n    TH8A_FX.ino\n    TH8A_FX_TEST.ino\n    i2c-scanner.ino\n    G27_to_TH8A.ino\n    USBShifter2PS2.ino\n\n.devcontainer/devcontainer.json # VSCode development container configuration\n\ngo.work                     # defines go workspaces\nREADME.md\n\nwheel/                      # simulates TM wheel based in order to enable quicker development cycle when testing the th8s emulator\n    i2c\n    i2c/i2c.go\n    gears\n    gears/gears_test.go\n    gears/gears.go\n    go.mod\n    Makefile\n    main.go\n```\n\n## Development\n\n***Note**: The project uses [Visual Studio Code development containers](https://code.visualstudio.com/docs/devcontainers/containers) to bootstrap TinyGo development environment. If you would choose to use some other way for development, please adjust accordingly.*\n\nThe TH8A emulator code is stored in the [`shifter`](./shifter/) directory. The current default functionality is to read key presses from UART and switch gears accordingly. However, it could be changed in any other way. The most common commands during the development and testing are presented below. The same commands apply for the [`wheel`](./wheel/) module.\n\n```bash\n# switch directory\ncd ./wheel\n\n# build binary for STM32 'blue pill'\ntinygo build -target=bluepill -o main.bin main.go\n\n# flash controller using the compiled binary\ntinygo flash -target=bluepill\n```\n\n### Uploading Binaries\n\n[TinyGo](https://tinygo.org/docs/reference/microcontrollers/bluepill/#flashing) uses [openocd](https://github.com/STMicroelectronics/OpenOCD) with [ST-LINK/V2](https://www.st.com/en/development-tools/st-link-v2.html) for flashing compiled binaries to STM32 controllers. Please see the connection diagram below.\n\n![st-link connection](./images/bluepill_connections_stlink.png)\n\n\n### I2C Connection\n\n*The below are personal notes on the cable used for connecting different pins. Please adjust it according to your own cable setup.*\n\n- VDD -\u003e RED\n- VSS -\u003e GND\n- I2C-SCL -\u003e WHITE\n- I2C-SDA -\u003e GREEN\n\n## Connection Diagram\n\nThe image below describes how to connect two STM32 modules to simulate both the wheel base and the shifter add-on. Each module needs to be flashed with appropriated binary.\n\n![connection diagram](./images/diagram.png)\n\nThe below presents the DIN9 (PS2) pin out for TM wheel base.\n\n![din9 connector](./images/th8a-ps2-pinout.jpg)\n\n## STM32 \"Blue Pill\" Pin Diagram\n\n![pinout](./images/STM32-Pin-Details.png)\n\n---\n\n## Notes\n\nTSS Sparco handbrake I2C data\n\n```\n02 0C 02 00 FF 80 81 80 81 00 00 00 00 00\n\n02 0C 02 00 8A 80 4D 80 4D 00 00 00 00 00\n\n02 0C 02 00 82 80 4A 80 4A 00 00 00 00 00\n\n02 0C 02 01 17 7F 20 7F 20 00 00 00 00 00\n\n02 0C 02 01 0F 7F 1D 7F 1D 00 00 00 00 00\n```\n\n\u003e Above TSS handbrake's I2C data mean about 0-100% brake force. Of course you need to send out every row maybe 100 times. Because of 250ms. Elsewhere you won't see anything.\n\n```\n0  02 02 02 02 02 // TSS handbrake\n1  0C 0C 0C 0C 0C // Unknown\n2  02 02 02 02 02 // ?? Device ID\n3  00 00 00 01 01 // Unknown\n4  FF 8A 82 17 0F // Unknown\n5  80 80 80 7F 7F // Unknown ◄─┐\n6  81 4D 4A 20 1D // Unknown ◄─│─┐\n7  80 80 80 7F 7F // Unknown ◄─┘ │\n8  81 4D 4A 20 1D // Unknown ◄───┘\n9  00 00 00 00 00 // Unknown\nA  00 00 00 00 00 // Unknown\nB  00 00 00 00 00 // Unknown\nC  00 00 00 00 00 // Unknown\nD  00 00 00 00 00 // Unknown\n```\n\n## References\n\n- [USB Shifter to Thrustmaster Wheelbase](https://github.com/azzajess/USB-Shifter-to-Thrustmaster-Wheelbase)\n- [Awesome Arduino](https://github.com/Lembed/Awesome-arduino)\n- [Program \"blue pill\" with STM32 Cores in Arduino IDE](https://www.onetransistor.eu/2020/01/stm32-bluepill-arduino-support.html)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fva1da5%2Ftm-th8a-emulator-research-stm32","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fva1da5%2Ftm-th8a-emulator-research-stm32","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fva1da5%2Ftm-th8a-emulator-research-stm32/lists"}