Skip to content
Richard Hodges edited this page Nov 15, 2018 · 6 revisions

Welcome to the stm8_libs wiki!

Goals and philosophy: My goal with these libraries is to get the smallest and fastest code for the STM8 CPU family. They are lightweight so that even the stm8s103 with only 8K of Flash can do very useful things. I use inline assembly when the compiler output looks bloated, or I want to get the device timings correct.

My philosophy is that main program code SHOULD NOT use inline assembly. It would be harder to maintain, even for the original author. Main program code should be maintainable by anybody. Library code, however, will be left alone after debugging. It will be used by many projects, and any improvements in size or speed will echo through every project that uses it. So libary code MAY use inline assembly in carefully selected parts. In some cases, the size savings can be great. Ten bytes here, twenty there, multiplied by the number of libraries used in a project can make it worthwhile. An extreme example is my AES-128 encryption/decryption code. It would be hideously larger and slower without inline assembly.

Please note that most of the libraries are written for SDCC (Small Device C Compiler).

I want the libraries to be easy to use. Just add #include "lib_xxxx.h" and don't worry about interrupts. Initialization is with a function called xxxx_init(). Options are described in the .h file. Generally, configuration settings go in the .h file so that the C source file avoids changes if possible.

Also, I want the library functions to be easily used WITHOUT needing to look up details in the data sheet.

For keypads and displays, I want everything to be ASCII chars and strings. So you give a key map for your keypad and the library gives you whatever ASCII chars you want. An LCD, an LED 7-segment display, and an LED dot matrix all accept ASCII chars and strings. So changing or adding displays is very easy.

I use both the stm8s103 and stm8s105 chips, so I have a main libs/ directory with -DSTM8103 to compile for the -103. And I have a separate libs_105/ directory full of symlinks to the main libs/ directory and they compile with -DSTM8105. It works for me.

I have some test and example code for the libraries in stm8_tests.