SPI Chipseclect Define

Hello Arduino Expert

Would you please look at the codes attached and tell me what I did wrong and help me to correct it.

I tried to use the SPI camera for my project but I was not sure that I define correct for “SPI for chipselect” in either “c.pp file codes and arduino codes”. What I used the “Teensy 3.6 board” and tried to define “PIN_0” for chipselect. but when I compiled it said “PIN_0” was not declared in both “c.pp file and arduino”

if you can look at the c.pp file attached line # 19, 186, 187, 188, 226, 227, and 228 where I define Chipselect PIN_0

and from arduino file attached line # 4, 12, 13, 15, and 16.

Thanks for your time.

CameraC329SPI.cpp (5.82 KB)

Teensy-SPI-1.ino (1.33 KB)

There is not a single define in your code. Also you can't carry defines between compilation units (e.g. code-files like .cpp or .c). Put your define in a header file (.hpp or .h) and include it in both code-files.

I don't see you defining PIN_0 anywhere in your code (Line #19 doesn't even use PIN_0). Do you have something like this somewhere?

#define PIN_0 13

Here's a reference article about Teensy pin definitions.

There isn't a pin with reference PIN_0

Did you mean PIN_D0? PIN_B0? Something else?

Thanks for comments. should I change the line # 19 c.pp file and in Arduino file define as "int const CS PIN_B0". please advice.


CameraC329SPI::CameraC329SPI(int _spi_cs_pin):spi_cs_pin(_spi_cs_pin)


CameraC329SPI::CameraC329SPI(int _spi_cs_pin):spi_cs_pin(_spi_cs_pin_B0)

honestly. I am not sure how to define the SPI for chipselect in this case.