1
votes

I am trying to improve on my embedded programming skills by learning how to program each peripheral on an STM32 Nucleo board (STM32F401RE) and slowly building my own library from scratch (Without using HAL initially just toggling bits directly on the registers).

I am facing a problem though, when I try to encounter something that I haven't used before I am getting stuck on figuring what to include on the API.

Let's say that I want to use the ADC peripheral, is it enough to just copy the API from the mbed-src on github and start from there, or am I going to need any extra functions?

https://github.com/mbedmicro/mbed/blob/03fff9249b0ca5efb2e12506ce8fb3e6cc258d9d/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/analogin_api.c

Are there any universally accepted resources from where to start from?

Thanks for your help.

1
the datasheet/users guide/programmers reference manual for the mcuold_timer
Even though I don't disagree, I have to admit that I can't find something really conclusive when reading the reference manual for the aforementioned board. The NXP LPC1768 user manual is much more helpful in my opinion but still not very clear.Satrapes
The STM32 documentation is neither better nor worse than other companies' (including NXP) documentation. Problem is there are quite some places you have to experiment and which do not allow all freedom one would actually expect. However, it is at least understandable and better structured than the Freescale K-Series documentation.too honest for this site
If you think NXP docus are not clear try to fight with MX6SX Freescale's doc. You'll change your opinion ;)LPs
Where I am coming from is, take natural steps. If you want to learn to program the thing a the bare metal layer, then do that...THEN...when you have acquired enough knowledge and code you can design a library and an api from that knowledge. making the api first before you know how to program the thing is putting the cart before the horse. If you are just going to take an existing api, and tweak it then are you actually learning how it works? using existing code is great to learn how but you still need to do the work, otherwise just use someone elses api/library.old_timer

1 Answers

2
votes

Jacob Beningo has a white paper that he created that describes the basics of creating API's for embedded work. I would highly recommend reading this as a starting point: Developing Reusable Device Drivers for MCUs.

His paper walks you through the design of API's for digital I/O and for SPI. He describes why he makes a lot of the design decisions that he has made and has great tips on the use of pointer arrays, and configuration tables. I found it very informative when I was starting out.

Of course, as Olaf and dwelch point out in the comments, you have to familiarize yourself with the datasheet in order to properly implement any of the peripherals of your MCU.