Compiling error for SAMD21 board (Seeeduino Xiao)

Hello folks,
Maybe somebody can help to find the problem compiling for SAMD21 board with arduino IDE. The FOC library is the latest, as the arduin IDE and the hardware support for SAMD boards from Seeed.
I saw many of you using SAMD21 boards.

This is the code what I want to compile:

#include <SimpleFOC.h>

// SPI example
// MagneticSensorSPI(int cs, float bit_resolution, int angle_register)
MagneticSensorSPI sensor = MagneticSensorSPI(10, 14, 0x3FFF);

void setup() {
  // initialize magnetic sensor hardware

void loop() {


Here is the compiler error:

In file included from c:\Users\macwin\Documents\Arduino\libraries\Simple_FOC\src/SimpleFOC.h:116:0,
                 from C:\Users\macwin\AppData\Local\Temp\.arduinoIDE-unsaved2023228-13100-1g6xhr8.h9vvf\encoder_example\encoder_example.ino:8:
c:\Users\macwin\Documents\Arduino\libraries\Simple_FOC\src/communication/StepDirListener.h:56:5: error: 'PinStatus' does not name a type
     PinStatus polarity = RISING; //!< polarity of the step pin

exit status 1

Compilation error: exit status 1

Hey @eduard ,

Thanks for reporting it, I will look into it!

1 Like

Hello @runger,

I made some progress on the case. I managed to compile the code for the arduino Zero and upload it to the seeed xiao. But since the two devices are not pin compatible, it cannot be used, it only shows that it is translated to the M0 device. Could the problem be with Seeed Xiao’s hardware management? I’m interested in this now because the hardware is ready and it would be nice to run FOC on it. If it’s not too much to ask, could you look at it?

So I’ve looked at this, and it’s a problem only with the header files used in the Seeed board support vs. the Arduino SAMD board support :frowning: I tested on the Xiao and I get your error, I tested on the MKR1000 and I get no error.
Basically, Arduino defines PinStatus as an enum type, while Seeed does not define this type.
Its a big pain because this isn’t even MCU type-specific, but rather board-vendor specific - here we have two boards based on SAMD21 where one works and one does not…

If you want a quick fix, it is enough to add a
#define PinStatus int
to the top of the src/communications/StepDirListener.h file.

I will try to find a good solution for the next release of our library.


Hello! thanks for the suggestion and your time. I checked the StepDirListener.h file and already has the #define PinStatus int -in it. Still have the compiling problem. I tried to compile to Arduino Zero and upload to Xiao, but since the pins are not compatible, the SPI not working.
Just an idea, but how can I redefine the pin mapping for SPI, since this SMD21 chip has 2 SPI pinouts and the Zero uses the other than Xiao.

Maybe it’s possible to use a variant board file to do this?

Please explain this.

I don’t know for SAMD boards, but for STM32, you can extend the generic board with specific configuration file which tells it what UART pins, SPI, etc.
I’m not sure how the SAMD arduino core works, I am sure you can do a similar thing though?

No, it has it but not for SAMD21, you have to add it again, or change/remove the #if defined() statement surrounding it.

That’s all much too complicated. The problem is really with the undefined PinStatus, and the solution is to change the code in StepDirListener.h

If you start messing with creating variants or compiling with one variant for the other, this is all much too complicated and not the right solution…

Thanks! I paste it outside the IF statement and is working now!

1 Like

This worked for my Xiao SAMD21 board, thanks!