Arducam library on Mesh devices


I found this project that shows the Arducam library can run on a Photon:

I was now trying to get this to work on the Argon, but I’m hitting the following compiler errors:

In file included from ArduCAM.cpp:106:0:
ArduCAM.h:201:38: error: 'NRF5x_Pin_Info {aka struct NRF5x_Pin_Info}' has no member named 'gpio_peripheral'
   #define pinHI(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRRL = PIN_MAP[_pin].gpio_pin)


ArduCAM.cpp: In constructor 'ArduCAM::ArduCAM(byte, int)':
ArduCAM.cpp:138:51: error: 'digitalPinToPort' was not declared in this scope
     P_CS  = portOutputRegister(digitalPinToPort(CS));

I think I can fix the first compiler error by replacing:

  #define pinLO(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRRH = PIN_MAP[_pin].gpio_pin)
  #define pinHI(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRRL = PIN_MAP[_pin].gpio_pin)


  #define pinLO(_pin) pinResetFast(_pin)
  #define pinHI(_pin) pinSetFast(_pin)

Would that be correct or am I missing something here?

Next, I currently don’t see how to fix the absence of digitalPinToPort, digitalPinToBitMask and portOutputRegister on the Argon platform. I understood from other threads in this forum that these macros also should not exist for the Photon. However, the code does compile and work on the Photon, so why am I seeing these errors when I target the Argon?
I also suspect the port was a bit of a hack to make things work (I’m not intending this negatively!), and, by running over the code, I suspect these macro’s may actually have no purpose in the port to the Photon…

I also realize I’m just poking around here :wink: I don’t have experience diving into library implementations at this low level (yet), so any pointers to help me dive into the subject are appreciated as well.


There is an open issue about the lack of the Arduino compatibility macros already

That’s what I’d do too.

Could you file an issue on @Dave’s GitHub repo about that?

Hi @ScruffR,

Thanks for the reply and the pointer towards the open issue.
Yes, I had already opened an issue on the github repo, but I still need to amend it with the info I typed in the thread.

Actually, I think the code lines that use the macro are unnecessary because the resulting values of the statement are only used in the cbi and sbi macros, where the arguments are unused and the correct pin is hardcoded into. So… it might just actually work by simply removing them… I’ll be back :wink:


Even if these macros are not really doing anything useful having them would still be good as this will reduce the need for manual adaptation of vanilla Arduino libraries even more.

For those interested in this topic, see further on

1 Like