Skip to content
timeobossuetPublic

About

Embedded laser tag game for the STM32, built in C and ARM assembly with PWM audio, ADC/DMA acquisition, and real-time DSP.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

STM32 Laser Game

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.

Project status

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.

Main features

  • 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

Repository layout

.
├── 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.

Requirements

  • 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.

Build and run

  1. Open GestionSon.uvprojx in Keil uVision.
  2. Select CibleSondeKEIL for the hardware/debug-probe target or Simulation for the simulator target.
  3. Check that the STM32F103RB device pack is installed.
  4. Build the target with Build Target.
  5. 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.

Firmware entry point

The application starts in Principal/principal.c. It currently:

  1. Configures the STM32 clock.
  2. Initializes the laser-game sound service and its callback.
  3. Computes DFT values for the 64-sample input buffer.
  4. 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.

Hardware notes

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.

Contributing

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.

License

No license has been selected for this project yet. Until one is added, the source should be treated as all rights reserved.

About

Embedded laser tag game for the STM32, built in C and ARM assembly with PWM audio, ADC/DMA acquisition, and real-time DSP.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages