Adding sensor to Sparrow

I have my sensor code working in a separate project in STM32CubeIDE and now wish to incorporate this into the Sparrow Reference Code. As per the instructions, I’ve added a new folder in “sparrow-application” but I have a few hurdles to get over:

  1. The folder I added and it’s contents are grayed out and have a stripe through them. I understand that means the compiler doesn’t see these files. What’s the fix?
  2. I need to enable the A1, A2 and A3 pins for my sensor. The instructions say: " To enable the analog pins on the header rail (i.e. A1 , A2 , A3 ), the macro Ax_ENABLE where x corresponds to the desired analog pin (e.g. A1_ENABLE)." Where exactly do I find this macro?
  3. Related to #2, I need to configure some of these pins. Where can I do that? I have opened the .IOC file and configured them in there but when it came time for it to update the code, I got an ominous warning.
    warning
    Thanks, Ray

Hi @rberkelm!

  1. I think you will need to add the folder to the STM32CubeIDE project. Also, you will need to make sure you have opened the correct project, because there are two of them in the source tree. The project folder you should be working with is, <sparrow-reference-firmware>/.STM32CubeIDE.

  2. You would add it as a project define, then it would be compiled into every source file.

  3. I’m sorry, I don’t use the IOC. Personally, I configure GPIOs manually. Here is where the sparrow-reference-firmware initializes the analog pins, and you are free to modify them in any way that suits you.

Best,
Zak

Thanks Zac. Good to get going again. I think I’m over the folder issue now, thanks! I’m still not sure on the GPIO configuration though. I can see in your link where the A1 - A3 pins are enabled, but not where they are configured. When I use IOC, I end up with a “static void MX_GPIO_Init(void)” function that has all the configuration, but I don’t see any of this in your bme.c file. Should I add such a function to my new scales.c file?
Another issue is that I am getting “fatal error: scales/scales.h: No such file or directory” I’ve added my new folder (“scales”) to the includes in the init.c file, plus “scalesInit()” to the schedAppInit function as per the examples of the other sensors. I have a “scales.h” in my scales folder and have added this folder to my path, but somehow the compiler is not seeing it. Any ideas?

Hi Ray,

The STM32CubeIDE can be fiddly.

When you say you added the scales folder to your path, what do you mean by that mean exactly? Is this something you did at the operating system level, or in your project settings? I don’t have the STM32CubeIDE installed on this machine, but as i remember it, you must add the folder to your project settings under the compiler options.

Can you explain more by what you mean about configuring the pins? What are you trying to accomplish? Perhaps I can provide better guidance from that angle.

Cheers,
Zak