MCU firmware protocol
This page documents protocols used to communicate with the on-board STM32 MCU via SPI.
This is the default mode after resetting with BOOT0 pulled high.
For details on this protocol, please refer to the ST Application note AN4286.
This is the default mode after resetting with BOOT0 pulled low.
To initiate a transaction, send a 16-bit little endian value (two bytes) declaring the command ID (in bits 0-6) and parameter (bits 7-15, values 0-511).
Every packet except “Switch to mode” has a response. The response always consists of the length (two bytes) and the data.
Test command. The parameter is the number of bytes to echo, followed by the bytes to echo.
The parameter is the ID of the mode of communication to use going forward:
0x00
- command mode0x01
- EEPROM emulation mode0x02
- RTC S-3511A emulation mode0x03
- CDC output mode (transferred SPI bytes are output via USB CDC)0xFF
- standby mode (requires reset to respond to SPI again)
The parameter is the maximum SPI transfer frequency that the MCU should be configured for (clock/pin speeds):
0x00
- 384 KHz0x01
- 6 MHz0x02
- 24 MHz
The response is 1 on success, 0 on failure.
So far, speeds faster than 384 KHz have been tested with the exception of commands with large (> 2-4 bytes) input parameter buffers.
The response is the unique ID of the chip.
Set the size of the emulated EEPROM:
0x00
- no EEPROM0x01
- M93LC060x02
- M93LC46 compatible0x03
- M93LC56 compatible0x04
- M93LC66 compatible0x05
- M93LC76 compatible0x06
- M93LC86 compatible
The response is 1 on success, 0 on failure.
The response is empty.
The parameter is the number of words to read; the following word is the offset.
The response is the bytes read.
The parameter is the number of words to write; the following word is the offset, then the words to write.
The response is empty.
The parameter is the packet type to send to the emulated S-3511A, followed by the relevant bytes.
The response is the data returned by the emulated S-3511A.
The response is 1 byte - the EEPROM emulation mode.
The parameter specifies the save ID location:
0x01
: SRAM2 (if the save ID depends on data stored in SRAM2, such as EEPROM),0x02
: RTC backup domain (if it doesn’t),0x03
: both.
The command is followed by four bytes of the save ID.
The save ID 0xFFFFFFFF
is reserved and means “no save is stored”.
The response is 1 on success, 0 on failure.
The parameter specifies the save ID location.
The response is four bytes of the save ID.
The parameter is the maximum number of bytes to read. The value 0 is treated as 512 bytes.
The response is the data read from the CDC.
The parameter is the number of bytes to write. The value 0 is treated as 512 bytes.
The response is two bytes in size and is the number of bytes successfully written.
The parameter is the length of the packet.
The data sent is two bytes - the result of a keypad scan.
The response is zero bytes in size.
The response is the number of bytes that can be read from the CDC.
Clears the write and read buffers, removing any unread data.
No parameter, no response data.
If the parameter is 1 the accelerometer is powered up and is polled at 100 Hz. If the parameter is 0 it is powered down and polling is stopped.
A one byte response is given, 1 if the operation was successful and the accelerometer is present and 0 for the opposite.
Returns three signed 16-bit words representing the measured acceleration on three axis X, Y and Z.
Plane representing Swan as held when playing horizontally.
Coordinate system is the local coordinate system of the accelerometer. -Z is equivalent to the normal of the plane.
^ +Y
/
________/________
+X / / /
<----------0 /
/ | /
/_________|______/
|
v +Z
The accelerometer is configured work in a range of +/- 2 g with 10 bit fractional precision. This means that when the console is resting the accelerometer will read a vector of magnitude 1024 the direction opposite to Earth’s gravitational pull. E.g. if the console sits on the side with the EXT port a value of approximately (1024, 0, 0) will be read. See also: https://en.wikipedia.org/wiki/Accelerometer#Physical_principles and the datasheet of the used MXC400xXC series accelerometer.
### 0x7F - Reserved
Reserved to distinguish 0xFF bytes from commands.