stm: Factor out GPIO code to its own file.  Add functions to set GPIO mode.

GPIO functions are crude, and need to be replaced with better ones!