Embedded laser game project for the STM32F103RB, written in C and ARM assembly. The firmware combines GPIO, timers, PWM audio output, ADC/DMA sampling, and frequency analysis.
This repository contains the Keil uVision project and the current firmware sources. It is an educational and hardware-oriented project; the exact laser-game rules and external hardware wiring depend on the target board and connected peripherals.
- STM32F103RB target with an ARM Cortex-M3 core
- 72 MHz system clock configuration
- Timer, GPIO, PWM, ADC, DMA, and SysTick helpers
- Sound playback through a PWM output on PB0 using TIM3 channel 3
- Periodic sound callback driven by TIM4
- 64-sample ADC acquisition through ADC1 and DMA1
- DFT-based signal analysis
- Fixed-point trigonometric and signal tables implemented in ARM assembly
- Keil uVision targets for hardware debugging and simulation
.
├── Driver/ Low-level STM32 peripheral and laser-game services
├── GestionSon/ Sound playback interface and ARM assembly data
├── Principal/ Firmware entry point
├── Service_DFT_Fract/ Fixed-point DSP tables and assembly routines
├── Service_DFT_float/ DFT service and floating-point DSP sources
├── Service_DFT_float/ DFT service and floating-point DSP sources
│ └── legacy/ Superseded floating-point experiments
├── RTE/ Keil CMSIS/RTE device files
├── DebugConfig/ Keil debug configurations
├── docs/ Project documentation
├── Listings/ Keil listing output, ignored by Git
├── Objects/ Keil build output, ignored by Git
└── GestionSon.uvprojx Keil uVision project file
See the architecture document and the structure guide for more detail.
- Keil MDK/uVision with the ARM Compiler 6 toolchain
- Keil STM32F1xx device family pack, configured for the STM32F103RB
- A compatible STM32F103RB board and debug probe for hardware execution
- The board wiring expected by the driver, especially the PWM audio output on PB0
The project file records the expected device pack: Keil.STM32F1xx_DFP.2.4.1. A compatible installed pack may be required when opening the project on another machine.
- Open
GestionSon.uvprojxin Keil uVision. - Select
CibleSondeKEILfor the hardware/debug-probe target orSimulationfor the simulator target. - Check that the STM32F103RB device pack is installed.
- Build the target with Build Target.
- For hardware execution, configure the debug probe and use Download or Start/Stop Debug Session.
Keil writes intermediate and output files to Objects/ and listing files to Listings/. These directories are intentionally excluded from version control. The generated .hex file is also ignored; release binaries should be attached to a GitHub Release when needed.
The application starts in Principal/principal.c. It currently:
- Configures the STM32 clock.
- Initializes the laser-game sound service and its callback.
- Computes DFT values for the 64-sample input buffer.
- Enters the main loop.
The low-level API is declared in Driver/DriverJeuLaser.h, while the sound-service API is declared in Driver/ServiceJeuLaser.h.
The current source documents these important peripheral assignments:
| Function | Peripheral / pin |
|---|---|
| System and timer clock | 72 MHz |
| Sound sample timing | TIM4 |
| PWM sound output | TIM3 channel 3 on PB0 |
| ADC sampling | ADC1 channel 2 |
| ADC trigger | TIM2 channel 2 |
| ADC transfer | DMA1, 64 samples |
Confirm the electrical design and pin mapping before connecting a laser emitter, photodiode, amplifier, or speaker. The firmware alone does not define electrical protection or power requirements.
Keep hardware-specific changes documented in docs/, preserve the Keil project paths unless the project file is updated at the same time, and do not commit generated files from Objects/ or Listings/. Small, focused pull requests are preferred.
No license has been selected for this project yet. Until one is added, the source should be treated as all rights reserved.