Just a suggestion.
Why not using Processor Expert, configure your peripheral using the GUI and let it generate low level drivers for you.
You can then look at the generated code and either use it as it is or take it as sample code for your application?
That website has a lot of great stuff. I would like to see more sites like that if anyone has any.
Retrieving data ...