cembeddedstm8

How to import STM8S/A Standard peripheral library in a STM8 project (ST Visual Develop)?


I'm new to STM8 programming and I'm using the STM8S/A Standard peripheral library without importing it, that is, copying and pasting the files into my src and inc folders, which I don't think is the best way. Is there a better way to do this?

I've heard about cmake-ify and adding it as a library, but honestly I have no idea how to do it in this IDE.


Solution

  • It is not clear what you mean by "importing it". That only makes sense in the context of a particular IDE that may have some sort of package management. If you don't want to be locked in to a particular toolchain, and want to bring the code into your version control repo, then adding the source code to your project (and setting any necessary part specific build macros) is a perfectly reasonable way to do it.

    You could use a static library (.lib or .a), but much of the code is dependent on specific parts and clock frequencies, so you would necessarily have to build a new library for each project with matching build configuration. That is rather error prone, and makes debugging more complex if you need to step into and debug library code for example. You might then need a separate debug build if the library, and would still need access to the source code.

    Another good reason for including the source into your project is that you will need to fix the bugs that ST have ignored. For example Evaluation if conditional statement on ST Visual Developer with Cosmic for STM8. One thing you might do is import it into your SCM and share it over all your projects, so that you are maintaining it under one repository. ST themselves no longer seen to be maintaining it, so there is little danger of missing "official" updates.