ROBOTIS-GIT / Dynamixel2Arduino

DYNAMIXEL protocol library for Arduino
Apache License 2.0
88 stars 55 forks source link

Using SPI_1 and SPI_2 on OpenCM-904 in Arduino mode #108

Open Roboteer1000 opened 2 years ago

Roboteer1000 commented 2 years ago

In Arduino mode, the OpenCM-904 already has drawn out nicely 2 SPI Ports on its two headers. In the file "SPI.h", Line 114, I saw that SPI is defined as extern SPIClass SPI; Then in the file "SPI.cpp", Line 25, I saw that only SPI1 is used by default. So I added SPI2 on Line 26 (and commented out Line 25).

Added_SPI2_904

With this setup, I can use EITHER SPI1 or SPI2 Port fine, but I need to use BOTH SPI Ports at the same time for my project. Header pins wise, there are no problems, but software wise how should I approach this issue?

I also saw the comments on Lines 63-66 - is that relevant/workable?

image

The way multiple SPI devices are handled as shown in "Arduino Cookbook" is very different from the way ROBOTIS is handling this issue for OpenCM-904. The use of "extern SPIClass SPI" - is that really needed? Did ROBOTIS write the OpenCM-904 library so that only ONE SPI can be used at any one time?

Thank you for any pointer.