星瞳实验室APP,快速收到回复
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • arduino_spi_slave 从设备通信错误



    • #include <SPI.h>
      #define SS_PIN 10
      #define BAUD_RATE 19200
      #define CHAR_BUF 128

      void setup() {
      pinMode(SS_PIN, OUTPUT);
      Serial.begin(BAUD_RATE);
      SPI.begin();
      SPI.setBitOrder(MSBFIRST);
      SPI.setClockDivider(SPI_CLOCK_DIV16);
      SPI.setDataMode(SPI_MODE0);
      delay(1000); // Give the OpenMV Cam time to bootup.
      }

      void loop() {
      int32_t temp = 0;
      char buff[CHAR_BUF] = {0};
      digitalWrite(SS_PIN, LOW);
      delay(1); // Give the OpenMV Cam some time to setup to send data.

      if (SPI.transfer(1) == 85) { // saw sync char?
      SPI.transfer(&temp, 4); // get length
      int zero_legnth = 4 + ((temp + 1) % 4);
      if (temp) {
      SPI.transfer(&buff, min(temp, CHAR_BUF));
      temp -= min(temp, CHAR_BUF);
      }
      while (temp--) SPI.transfer(0); // eat any remaining bytes
      while (zero_legnth--) SPI.transfer(0); // eat zeros.
      }

      digitalWrite(SS_PIN, HIGH);
      Serial.print(buff);
      delay(1); // Don't loop to quickly.
      }

      sketch_jan03a.ino: In function 'void loop()':
      sketch_jan03a:23: error: no matching function for call to 'SPIClass::transfer(int32_t*&, int)'
      D:\360Downloads\Arduino\libraries\SPI/SPI.h:55: note: candidates are: static byte SPIClass::transfer(byte)
      sketch_jan03a:24: error: invalid operands of types 'int32_t*' and 'int' to binary 'operator%'
      sketch_jan03a:26: error: ISO C++ forbids comparison between pointer and integer
      sketch_jan03a:26: error: operands to ?: have different types 'int32_t*' and 'int'
      sketch_jan03a:27: error: ISO C++ forbids comparison between pointer and integer
      sketch_jan03a:27: error: operands to ?: have different types 'int32_t*' and 'int'



    • 这个是Arduino的错误?估计是你Arduino板子选错了。



    • @kidswong999 arduino UNO的板子应该没错吧 SPI.transfer(&temp, 4); // get length
      transfer第一个参数应该数传输的数组吧 这个程序传输的是数组吗?