2016-11-30 11:46 AM
Hello,
Has anyone had success using the Spirit1 library (provided as part of http://www.st.com/en/embedded-software/stsw-connect009.html) in a project for an STM8 MCU using a free toolchain?The library was written in the C99 standard and uses features that are not supported by the SDCC or COSMIC compilers. The library is also >8kb, so the IAR compiler with the free license also throws an error.Appreciate any help,-David2016-12-01 05:01 AM
2016-12-01 10:40 PM
Thanks Luca,
With -pc99 the I get some errors compiling with Cosmic.The following files in the Spirit1 library and example STM8 implementation declare variables in for loops (i.e. ''for(int i = (cDataLength-1); i>=0; i--)''), which the Cosmic compiler does not handle:SPIRIT_Aes.cSPIRIT_Irq.cSPIRIT_PktBasic.cSPIRIT_pktcommon.cSPIRIT_pktstack.cSPIRIT_radio.cSDK_EVAL_Gpio.cSDK_EVAL_Spi_Driver.cI moved those declarations outside of the for statements which satisfies the compiler. This changes the scope of those variables and could cause issues since most of those functions reuse the variable ''i''.During linking I also get errors that the following symbols are not defined:#error clnk Debug\spirit1_lib.lkf:1 symbol _lroundf not defined (Debug\spirit_radio.o )#error clnk Debug\spirit1_lib.lkf:1 symbol _pow not defined (Debug\spirit_radio.o )#error clnk Debug\spirit1_lib.lkf:1 symbol _log2 not defined (Debug\spirit_radio.o )#error clnk Debug\spirit1_lib.lkf:1 symbol _round not defined (Debug\spirit_radio.o )I think these are standard math functions in c99. I see references to them in the IAR <math.h> header, but it looks like they are missing from the Cosmic <math.h> header. Do you know a workaround for this?Thank you for the help,-David2016-12-06 01:57 AM
Hello,
I confirm that the variable declaration in the for loop is not supported.
As for the missing symbols at the linker stage, 3 out of the 4 that you mention are already supported (make sure you link the libf in the linker file) and the fourth (lroundf()) will be added in the next release.
Regards,
Luca
2016-12-08 04:22 AM
You might want to check with a current development version of SDCC instead of the 3.6.0 release. Support for variable declarations in for loops as been added to SDCC after the 3.6.0 release. So current development versions (and the future 3.7.0 release) have it.
Philipp