PMW3360_Arduino icon indicating copy to clipboard operation
PMW3360_Arduino copied to clipboard

Works on the rpi pico (32 bit ARM board)

Open james1236 opened this issue 1 year ago • 0 comments

I saw on your wishlist in the README that you wanted to see if it works on 32 bit ARM boards. I can confirm that the PMW3360DM-Camera example works on a RPi Pico.

RPi Pico PMW3360 Breakout
VBUS VI
GND GD
GP5 MT
GP16 MI
GP17 SS
GP18 SC
GP19 MO

The relevant part of the code from the PMW3360DM-Camera example with changes is below

//Set this to a pin your interrupt feature is on
#define Motion_Interrupt_Pin 5 //Gp5 pin 7
#define Btn1_Interrupt_Pin 1  // left button
#define Btn2_Interrupt_Pin 0  // right button


const int ncs = 17;  // This is the SPI "slave select" pin that the sensor is hooked up to
//const int reset = 8; // Optional

unsigned long lastCheck = 0;
byte initComplete = 0;
volatile byte readflag = 0;

//Be sure to add the SROM file into this sketch via "Sketch->Add File"
extern const unsigned short firmware_length;
extern const unsigned char firmware_data[];

void setup() {
  Serial.begin(9600);
  delay(1000);

  pinMode (ncs, OUTPUT);
  //pinMode(reset, INPUT);
  
  pinMode(Motion_Interrupt_Pin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(Motion_Interrupt_Pin), UpdatePointer, FALLING);

  Serial.println("PIN_SPI_MISO");
  Serial.println(PIN_SPI_MISO); //16
  Serial.println("PIN_SPI_MOSI");
  Serial.println(PIN_SPI_MOSI); //19
  Serial.println("PIN_SPI_SCK");
  Serial.println(PIN_SPI_SCK); //18
  Serial.println("PIN_SPI_SS");
  Serial.println(PIN_SPI_SS); //17
  Serial.println("SPI_MISO");
  Serial.println(SPI_MISO); //16
  Serial.println("SPI_MOSI");
  Serial.println(SPI_MOSI); //19
  Serial.println("SPI_SCK");
  Serial.println(SPI_SCK); //18

  SPI.begin(); //SPI = spi 0 , SPI1 = spi1
  SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
  //SPI.setDataMode(SPI_MODE3);
  //SPI.setBitOrder(MSBFIRST);
  //SPI.setClockDivider(4);
  Serial.println("ON");

  performStartup();

james1236 avatar May 30 '23 21:05 james1236