SAMD21 compilation issue

Hi, I’m trying out SimpleFoC with Arduino Nano 33 IoT + BLDC and have got it working quite well.

SimpleFoC has an experimental low side current sensing support for SAMD21 and I wanted to try it. However, it’s not compiled in and hence cannot work.

The problem seems to be circular dependency. Some headers in Simple_FOC\src\current_sense\hardware_specific\samd\samd21_mcu.cpp are included inside a #ifdef block that depends of a define that is set by said headers. Moving the headers before the #ifdef fixes the issue.

#include "../../hardware_api.h"
#include "samd21_mcu.h"

#ifdef _SAMD21_
...

Maybe this is Arduino IDE specific issue?

This is an old old code that apart from its author, nobody really used.
Its very experimental and easily the least stable and supported part of the simplefoc code-base. :slight_smile:

The SAMD21 should be defined in the “Arduino.h” so this might be the Arduino IDE issue yes.

Let us know how it goes. I’d be happy to spend some more time on this in the future.