Bringing up an MRF89XAM9A radio

I'd like to document the process I went through recently when I was bringing up an MRF89XAM9A (link at bottom of post). This is a pretty cool little radio module that costs lest than $10 from Newark and has FCC/IC modular certification, which should dramatically reduce the amount of hassle required to put it in a product.

Lately I've been using the ST Micro STM32F042 for a few projects, and this one is no different. I've already got a solid USB stack put together for it, and I'm at the point where I pretty much just drop it into designs without thinking too much about it. Looking at the datasheet for the radio, there's two chip select pins, two interrupt pins, and standard SPI pins for communicating with it.

Starting out, the thing I care most about is verifying that I can even talk to the thing. For that, the interrupts don't matter, just SPI and the CS pins. So that's where we start!

First, let's initialize all of the clocks, GPIO pins, and the SPI controller.

That's all pretty generic stuff. Note that this all goes in its own function, not right in main(). Even when it's a prototype and simple, don't put it right in main(). Get your project structure in place first, because there's a good chance that this codebase is going to end up in your final product.