I want to use PlatformIO to program my STM8 microcontrollers in the future.
I am writing my libraries on register level on my own and therefore I just want to include my header and C files into my main file and compile that using the SDCC compiler.
As I understood I need a “platformio.ini” file containing basic definitions:
Thanks for the reply.
Ok, I will delete the framework tag.
Did I understand this right, that I will just make a board definition for every microcontroller (not actually the board) I am using and will include that for each?
Do I have to add the MCU name in the “env” tag? Or can I just use “[env]”
I tried the following .json board file:
But when i use #include “LIB.h” I got the following error: #include errors detected. Please update your includePath. Squiggles are disabled for this translation unit
It doesn’t, but writing stm8s there is actually correct for OpenOCD, so I don’t see a point in writing an explicitly wrong value there.
With lib_deps you can point to a PlatformIO library (preferably has a library.json in it). You would write that file and put it in STM8.
If there are no source files in there, only .h files, then doing build_flags = -I... is also okay.
You can redirect the source directory to another source directory or to . (meaning directly the directory where the platformio.ini is per docs in the special [platformio] ini section.
The file “delay.c” also includes this “delay.h” header file:
#include "delay.h"
static inline void delay_ms(uint16_t ms)
{
for (uint32_t i = 0; i < ((F_CPU / 18000UL) * ms); i++)
{
__asm__("nop"); // assembly command "not operate"
}
}
static inline void delay_us(uint16_t us)
{
for (uint32_t i = 0; i < ((F_CPU / 18UL) * us); i++)
{
__asm__("nop"); // assembly command "not operate"
}
}
The compiler shows the error ASlink-Warning-Undefined Global '_delay_ms' referenced by module 'main', but when I include the “delay.c” into the main file (instead of “delay.h”) it works flawlessly. But the header file should be included not the .c file.
What to do about that?
If you want to use static inline, the definition of the function must be right there in the header file, not in a separate c file. Otherwise it can’t be static nor inline.
Removing “static inline” still produces the same error except if I include “delay.c” instead of “delay.h”…
So it seems that the compiler doesn’t know that there is a corresponding .c file which has to be used when incuding the .h file.
Ok, but that’s not ANSI-C! Header files do not contain code but only declarations…
Is there a possibility to incude the header files which are not containing the definitions?
A sensible approach would be to put the static inline functions in either a header file if they are to be widely used or just in the source files that use them if they are only ever used from one file.
In any case, this thread is getting too off-topic, the original question about PlatformIO configuration was solved.