Hi,
Have not fully read this post through, lots and lots of pages... so if this has already been mentioned then ignore this post.
The standard perhipheral library is a load of crap! It is extremely bloated and performs things an exteremely backwards way. I have been programming on the STM32 since they were originally released, and I am also the original author of the open source stm32flash project for serial flashing.
There are three alternatives to using the std perhipheral lib..
1) Read the docs and write to the registers manually (fastest and smallest code results). Once you get familiar with the registers this usually ends up being the best option.
2) Use
libopencm3 (formally libopenstm32), very well written, very easy to use with well written examples and a lot of support.
3) Got space for C++ in your project, use
libstm32pp... although this project seems to be rather dated with little support.
Personally I opt for option 2 when hacking something together, but when I need raw power, or smaller code, I will configure the registers myself.
Example blinky program
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
int main(void)
{
rcc_clock_setup_hsi(&hsi_8mhz[CLOCK_44MHZ]);
rcc_periph_clock_enable(RCC_GPIOE);
gpio_mode_setup(GPIOE, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO12);
while(1)
{
gpio_toggle(GPIOE, GPIO12);
for (i = 0; i < 2000000; i++)
__asm__("nop");
}
}
A bit shorter no?