Skip to content

arosspope/usnake

Repository files navigation

usnake 🐍

Build Status

A rust implementation of the game snake for the stm32f3 discovery board.

Using the stm32f3, an 8x8 LED display and an analog joystick, I implemented snake using Rust's real-time embedded framework for Cortex-M microcontrollers - Real Time For the Masses (RTFM). This project was primarily a learning exercise in understanding how Rust can be used to solve some of the challenges inherent in embedded application development. It includes examples of how to:

  • Initialise peripherals and interact with them (i.e. digital pins for the display, and ADCs for the joystick).
  • Use RTFM to orchestrate software tasks that share mutable resources (i.e. peripherals).
  • Write macros! to simplify repeated code patterns, in this case:
    • Logging messages through, and ensuring exclusive access to, Cortex's standard ITM peripheral.
    • Scheduling tasks based on the sysclk frequency and a desired delay (in seconds).

Getting started

Hardware setup

The hardware required for gameplay includes:

Pin configuration is described in main.rs as part of the init() routine.

Playing the game

To build and flash this game, I would suggest following the stm32f3-discovery tutorial here to prepare your development environment. Assuming one has the necessary tools installed, the contained Makefile can be used to build and flash the board.

$ make flash

Once the binary has been flashed the LED display will start to cycle through a binary pattern - this means the system is now ready for play. To start the game, click the joystick.

License

All source code (including code snippets) is licensed under either of

at your option.

About

A rust implementation of the game snake for the stm32f3 discovery board.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages