Using SPI with User Hooks in Pixhawk

I am trying to communicate from an I/O expander to the SPI port of Pixhawk. The expander will have a push-button, two power status LEDs, a buzzer, and an OptoIso circuit for notification of potential power failure.

The idea is that while armed, I can push the button, a 10 second countdown will sound from the buzzer, and the drone will auto-takeoff to a certain height.

I have learned that users can add custom code to the Ardupilot firmware through User Hooks, but I am finding very little information online for guidance on what to put into the User Hooks and haven’t been successful with looking through the code. Has anyone attempted a similar takeoff situation? Or successfully added push-button communication through User Hooks?

If anyone has any example code of how they set up their UserCode.cpp and UserVariables.h files to do something like this, I would be very appreciative to take a look at it.

Thank you

FYI, these are the best resources I’ve found on this: