Use (SPI.transfer) callback function in library

I’m modifying the Particle Adafruit Dotstar library so to use the DMA based transfer (

I try implementing a callback code (from this topic: Bug in SPI block transfer complete callback ).

However I get the error:

invalid use of non-static member function

I tried to put static in front of the function. However I probably do something wrong, because I’ll get an error like:

cannot declare member function ‘static void Adafruit_DotStar::hw_spi_DMA_TransferComplete_Callback()’ to have static linkage [-fpermissive]

Any idea how I could solve this?

My fork and the line to the error (the callback function above this function):

In dotstar.h, change these two declarations:

  static void hw_spi_DMA_TransferComplete_Callback(void); // DMA transfer done

  static bool hw_spi_DMA_TransferCompleted;

In dotstar.cpp, insert this near the top, say after the #define USE_HW_SPI:

bool Adafruit_DotStar::hw_spi_DMA_TransferCompleted;

And put back the line you commented out.

1 Like

Thanks that did the trick!