fixed things that prevented xmega compile
abstracted away a SPDR write

also some formatting changes, my text editor did an autoformat, oops