Code Review - Relay Driver Board

I've got a working version of my relay driver board now, using PCF8575 I/O expanders and IPS6041 Smart gate drivers. The code is documented, and seems to be put together well to my un-educated eyes, but it's 300 lines in one document and at points could be confusing. I would appreciate any critique of the code, no matter how scathing. There are a few spots where I know things should be fixed and have put comments there (particularly the timing function, since I'm still trying to grasp the concepts being discussed over in Robin2's architecture thread.)

The pastebin link is: 32 Channel Relay Driver

Also, if anyone has any good suggestions on links or tutorials describing the best way to move some of this code into smaller libraries, that would be helpful to me as well since I feel a code-base this large is starting to creep up on painful.