Initializing the Library

From Custom Pinball Index
Revision as of 12:23, 1 July 2023 by DickHamill (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In the .ino file, the setup() function will initialize the RPU library and prepare the MPU for booting.

There are several options for the RPU_InitializeMPU function that allow the developer to choose how the machine will boot.

unsigned long RPU_InitializeMPU(unsigned long initOptions=RPU_CMD_PERFORM_MPU_TEST, byte creditResetSwitch=0xFF);

By default, the RPU_InitializeMPU function will assume that it should boot to the new code running on the Arduino. The parameters will describe the situations when the developer wants the board to boot to the original (M6800) code.

RPU_CMD_BOOT_ORIGINAL - This will boot to original unconditionally (disables new code completely for this install)

RPU_CMD_BOOT_ORIGINAL_IF_CREDIT_RESET - Only supported on Rev 4 or greater, boots original if the C/R button is held at power on

RPU_CMD_BOOT_ORIGINAL_IF_NOT_CREDIT_RESET - Only supported on Rev 4 or greater, boots original if the C/R button is NOT held at power on

RPU_CMD_BOOT_ORIGINAL_IF_SWITCH_CLOSED - boots to original if the switch is closed at power on

RPU_CMD_BOOT_ORIGINAL_IF_NOT_SWITCH_CLOSED - boots to original if the switch is NOT closed at power on

There are also parameters to control other boot behavior:

RPU_CMD_AUTODETECT_ARCHITECTURE - For Rev 101 and greater--the code detects architecture of board (mainly for diagnostics applications) RPU_CMD_PERFORM_MPU_TEST - perform basic tests on PIAs and return result codes

These defines are used as Bit flags in the first parameter of the function.

To tell the board to boot to original code if the jumper switch is not set, or the credit/reset button is held at power on, these parameters can be used:

RPU_InitializeMPU(RPU_CMD_BOOT_ORIGINAL_IF_CREDIT_RESET | RPU_CMD_BOOT_ORIGINAL_IF_NOT_SWITCH_CLOSED, SW_CREDIT_RESET);

Note: the second parameter must tell the library the ID of the Credit/Reset switch if that's being used for a boot condition.