How to use Arduino call from standard C

I am trying to port some arduino code over to particle. It has a bunch of files written in standard C. A couple files include the wiring.h header and call pinMode and digitalWrite.

Is it poissible to use these calls in a C file?

Including wiring.h results in header not found

including application.h or Particle.h results in a lot of errors

including spark_wiring.h also generates a lot of errors.

I can make a cpp wrapper for these fucntions but if there is an easier way…

You need to name the file with the .cpp extension, even if it contains only C code. You should

#include "Particle.h"

In most cases, that will be sufficient you should not have to make any other changes to the source.

3 Likes