SAM3 port: move some definitions in appropriate places, and add missing includes.