mbedmicro/mbed — pull request #8 by oampo (2013-06-26 13:38:51+00:00)
Title: Start to STM32F4XX port

Initial porting includes:

* GPIOs
* Port APIs
* Analog In
* SPI master/slave
* I2C Master
* wait()

There are a couple of potentially iffy bits here which I'll do my best to draw attention to:

1. I don't have any hardware to test SPI slave with, but it's pretty much zero extra code, so I've included it here as I think that there's a fair chance that it will just work.
2. The way pins work on the STM32FXXX chips is slightly different to the way they do on the LPC1768 (which I've been using as reference). Pins have both a mode (input, output, analog etc), and an alternative function which selects which peripheral they are controlling. In order to accommodate this I've had to add an #ifdefed field and function in the core pinmap code, which is pretty ugly.
3. I'm using __builtin_ffs in the SPI code, which I guess will break for non-GCC compilers. What's the correct way to do this?
4. The startup code comes from STM, under a funky license. I would learn/rewrite this, but I don't really fancy spending days bricking and unbricking devices by messing up the PLL settings. Perhaps a nicely worded email to STM would suffice?
5. The startup code assumes an 8Mhz crystal, which I guess should be an option somewhere.

On second glance, that's starting to look like quite a long list of iffy bits :grinning:. Anyway, this should at least act as a jumping off point for getting this merged.

Joe