http://blog.csdn.net/w471176877/article/details/8009978

很值得借鉴!

还有stm32f4的例程(操作寄存器方式)。