MCU Components
In this project, the STM32L432KC MCU board was used. The two major comopnents on the MCU included I2C communication, initialization and reading the LiDAR sensors, SPI communication, and sequencing the game.
I2C
The VL53L0X sensors use I2C protocol to communicate. Thus, the I2C1 peripheral on the MCU was implemented. Basic functions for the communication were written, such as init_i2c1() , read_i2c1(), and write_i2c2().
Research uncovered a git repository that contained code for the VL53L0X sensors, using a different STM32 family. This code was adapted from the provided API for the VL53L0X, simplifying and providing access to the major features of the sensor, while taking out uncommon and unnecessary configurations and commands. After attempting to work directly with the API at register level, using this repository became the clear better choice for the purposes of this design.
Upon startup, each sensor was time-multiplexed via the XSHUT pin to set a unique address for simultaneous communication on the SDA bus. An initialization protocol was then followed for each sensor. From there, a command could be sent to the sensors to measure distances every new round.
LiDAR
A major new hardware component were the VL53L0X ToF sensors, which use LiDAR to read distances of up to 2 meters.
The HiLetGo breakout boards were used to house the sensors and provide easier connection to the pins, including those for I2C communication, which was used to retrieve distance measurements.
Throughout development, issues with the VL53L0X modules were encountered. Whenever more than four sensors were implemented at a time, at least one failed to return valid distance readings, producing error codes. In the end, the design was constrained to this number of sensors for gesture processing.
SPI
This design attempted unidirectional SPI communication from the MCU to the FPGA. For the purposes of producing a result on demo day, this was replaced by parallel communication due to bugs related to the rates at which data was processed on different ends of the design. However, SPI communciation between the two boards was used and proven successful during the midpoint check in, when tight timing was not a constraint.
Game Flow
The flow of the game was directed by the MCU. This came in the form of sequencing the different screen signals and placing different delays between the stages of the game, allowing users to play at a normal pace.