Simplicity Studio Class - Page 1
Forum section: electronics / general

author: lucasromeiro
author_rank: Newbie
timestamp: October 11, 2022, 03:05:08 pm
content: hello guys.I'm starting to use Simplicity Studio 5 to develop a Bluetooth solution.I'm using the EFR32BG22Apparently Simplicity Studio doesn't support some functions in C.I'm currently trying to use Classes and I can't.Shows syntax error.Does anyone know how I can resolve this?If you know of any other forums to discuss this specific subject, I would appreciate the indication.

author: paf
author_rank: Regular Contributor
timestamp: October 11, 2022, 03:20:57 pm
content: Is Simplicity Studio configured to accept C++ source files?What are the names of your source files?Those are errors that would appear giving C++ to a C compiler...

author: lucasromeiro
author_rank: Newbie
timestamp: October 11, 2022, 04:48:55 pm
content: Hi paf,File names: AHT_10.h and AHT_10.cIt really seems to be something related to the C compiler.I didn't do any configuration in Simplicity Studio. It is as it was installed. I didn't find instructions for modifying the settings to help me with anything.Can you help me?Any tips to better configure Simplicity studio I would appreciate it

author: hans
author_rank: Super Contributor
timestamp: October 11, 2022, 04:52:44 pm
content: You're using C++ features, not C.Naming the files at .c will compile with the C compiler.Try renaming them to .cpp. Many IDEs or buildscripts automatically will pickup them up as C++ code and use the C++ compiler.Simplicity Studio uses ARM GCC so it should come with a C++ compiler, but I haven't used it in a fair bit, so I'm not 100% confident it does.

author: lucasromeiro
author_rank: Newbie
timestamp: October 11, 2022, 07:43:30 pm
content: Oh yes. C++Thanks for the tip. It worked.I just renamed the file to CPP and the error disappeared.But now it doesn't recognize the class declaration.

author: cv007
author_rank: Frequent Contributor
timestamp: October 11, 2022, 09:06:31 pm
content: I have some efr32bg22 explorer boards, using Simplicity Studio 5 along with creating little C++ layer over the sdk as needed to make it easier to read/organize/use. Have had no problems (using cpp extensions of course). Not a fan of most ide's, but this implementation is ok. They seem well organized and have pretty good documentation.The ide is usually right when it points out errors, but it is not always clear what the error may be. When in doubt, let the compiler tell you what it thinks (it will be more specific, and correct). In the project settings you may need to set the 'dialect' of C++ (like C++17) if you are using specific C++ features, but otherwise not much to do to make C++ work.In your case, I think the ide may actually be complaining because of the enum before the class.https://godbolt.org/z/cbnrqMf8d

author: lucasromeiro
author_rank: Newbie
timestamp: October 12, 2022, 12:29:41 am
content: Cool, I'll try that.Thank you for the tip.I'm learning to use this platform.Very different for me.

author: lucasromeiro
author_rank: Newbie
timestamp: October 12, 2022, 02:13:32 am
content: Quote from: cv007 on October 11, 2022, 09:06:31 pmcv007, You who seem to have some experience with Simplicity Studio, can you recommend a place to help me learn and understand how their system works?I'm currently trying to integrate sensors but I haven't had any positive results, I haven't found any examples about the types of sensors I'd like to use, like the BME-280, AHT-10, or the ds18b20.I appreciate any tips that can make me evolve.

author: cv007
author_rank: Frequent Contributor
timestamp: October 12, 2022, 04:56:50 am
content: QuoteI have not been using it long, so not an expert. For me, it just takes some poking around, reading the datasheet and finding what is available in the sdk/emlib to do what I want. Start with the demos and example projects and work your way into it.They have an slcp file in the project you can open up (shows a gui) where you can add 'software components', which can help out. For example, they have an I2CSPM (simple mode) driver you can configure for an i2c device (speed, pins to use), then look in sl_i2cspm.h/.c to see what is then available to use. They will do the init for you (via sl_system_init), but you still have to figure out what to call.In my case using an STS35 temp sensor basically ends up quite simple-Code:static floatSTS35temp () //return values 201-205 are errors (return - 200 = I2C_TransferReturn_TypeDef value){ //blocking (~2.5ms)//single reading using sts35 clock stretching, low repeatabilityuint8_t buf0 = { 0x2C, 0x10 }; //cmd=0x2C10, use as both wr and rd bufferI2C_TransferSeq_TypeDef seq = {0x4A<<1, //addr (it uses the shifted address :( )I2C_FLAG_WRITE_READ, //flags (write, then read){ {buf0,2}, {buf0,2} } //using same buffer for wr/rd, 2 bytes write, 2 bytes read};I2C_TransferReturn_TypeDef rv = I2CSPM_Transfer( SL_I2CSPM_STS35_PERIPHERAL, &seq );if( rv ) return -rv+200; //using negative return values (errors) as a temperature-> 200+rv//tF = -49 + 315*m/65535return -49.0 + 315.0 * ((buf0<<8)|buf0) / 65535;}Without the gui help, its still not difficult, and you can see how the 'simple' version is using 'normal' i2c library code.If you are trying to use some arduino library (looks like it to me, since I see 'begin' in your code), then you will have to translate it to use the silabs libraries (to setup pins, setup i2c, do the transfer, etc.). Depending on how complicated the i2c device is, it may be simpler to skip the translation and just create something on your own using the silabs libraries. The AHT-10 seems to be as simple as the STS35 I am using, so a dozen lines of code similar to the above example should get you close (using the gui to enable the I2CSPM software component, specify speed/pins).

author: lucasromeiro
author_rank: Newbie
timestamp: October 12, 2022, 01:46:12 pm
content: Hi cv007!Interesting.Every day I am learning something new.I'm used to programming for esp32 or esp8266.So now using simplicity studio, everything being new to me.I'm still understanding how everything works and watching videos on youtube.I realized that there are few or almost no communities for this platform or this chip. I found few videos, little material.For ESP there is a lot, this helps a lot to advance in development.I usually have no problem with sensors or simpler issues. But now I'm having a hard time with everything haha.I took a look at your sensor, it looks great. I can change sensor but I need a low cost sensor. That's why I've been trying to use the sensors I mentioned, they seem to have the best cost on the market and they work in a very good voltage range.Now I'm learning what you told me, the platform and how to use the tools to simplify things for me, I'm still learning how it all works. Examples help a lot. The documentation too.I found a github with the code made by the sensor manufacturer BME280, but it will be a challenge to use it. There are many functions to be able to read the sensor =(https://github.com/BoschSensortec/BME280_driverYou noticed that I was trying to transcribe an Arduino code, that's right. I spent all day yesterday trying to solve the problems that the platform points out. It really is quite laborious. And in the end I couldn't make it work =(I'll try the way you told me, from your code as an example. But it looks like the sensor I want to use is more complicated. Requires more stuff to work.This part that complicates for me, because it's hard to find people with similar problems, talk and learn, because there seem to be few people using this MCU.

author: cv007
author_rank: Frequent Contributor
timestamp: October 13, 2022, 04:37:03 am
content: QuoteI would skip trying to make arduino code work and just get the datasheet of the device then start simple (but can look at other code for ideas). In the case of the bme-280, a quick look at the datasheet shows it has an id register, so start off by simply seeing if you can read it.Code:static intBME280id () //read id, should be 0x60, negative return values are error codes{ //assuming address is 0x76uint8_t buf = { 0xD0 }; //id register address= 0xD0, use as both wr and rd buffer (sized for max needed)I2C_TransferSeq_TypeDef seq = {0x76<<1, //bme-280 address- use the shifted address :(I2C_FLAG_WRITE_READ, //flags (write, then read){ {buf,1}, {buf,1} } //using same buffer for wr/rd, 1 bytes write, 1 bytes read};I2C_TransferReturn_TypeDef rv = I2CSPM_Transfer( SL_I2CSPM_BME280_PERIPHERAL, &seq ); //assuming BME280 is the name used in the config gui (setting up i2cspm driver)return rv == 0 ? buf : rv; //0x60 or -error}Once you can communicate, that is a good start and you just need to do more of the same to get what you want out of the device. You add little bits of code at a time, and before long you have something usable that you understand. For example, the next on the list to do would be to block read the data registers in the device- its the same code as above, just a different register address and number of bytes to read (and a buffer size to match the read size). It will require some work to read the device datasheet and create your own code, but will be worth the effort and will pay off when you get to the next device.