Hey guys!
I am currently working on a project where I need to connect a pixy cam to an NXP board. The board is not running any kernel, it is a simple micro-kernel running C++.
When trying to initiate the Pixy2 object using the .init() method, I get the following error:
“error : no response”
I followed the steps on a trouble shooting guide to connect to Arduino “including training the pixy an object in CCC”.
I found this wiki page: https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
It explains how to port the Tpixy.h to C++. Any help to connect would be greatly appreciated!
PS: Here is my port:
// Arduino SPI with slave select link class
#ifndef _PIXY2SPI_SS_H
#define _PIXY2SPI_SS_H
#include “TPixy2.h”
extern “C”{
#include “Interfaces/iSpi.h”
#include “Interfaces/iDio.h”
#include “Modules/mSpi.h”
#include “Pixy2Line.h”
#include “Pixy2CCC.h”
}
#define PIXY_SPI_CLOCKRATE 2000000
class Link2SPI_SS
{
public:
int8_t open(uint32_t arg)
{
/* if (arg==PIXY_DEFAULT_ARGVAL)
ssPin = SS; // default slave select pin
else
ssPin = arg;
pinMode(ssPin, OUTPUT);
SPI.begin();
SPI.beginTransaction(SPISettings(PIXY_SPI_CLOCKRATE, MSBFIRST, SPI_MODE1));
*/
mSpi_Open();
return 0;
}
void close()
{
mSpi_Close();
}
int16_t recv(uint8_t *buf, uint8_t len, uint16_t *cs=NULL)
{
uint8_t i;
if (cs){
*cs = 0;
}
// CS camera OFF
iDio_SetPort(kPortD,kMaskIo4,kIoOff);
for (i=0; i<len; i++)
{
buf[i] = (uint8_t)mSpi_SP1ReadWrite(0x00);
if (cs)
*cs += buf[i];
}
// CS camera ON
iDio_SetPort(kPortD,kMaskIo4,kIoOn);
return len;
}
int16_t send(uint8_t *buf, uint8_t len)
{
uint8_t i;
// CS camera OFF
iDio_SetPort(kPortD,kMaskIo4,kIoOff);
for (i=0; i<len; i++)
{
mSpi_SP1ReadWrite(buf[i]);
}
// CS camera ON
iDio_SetPort(kPortD,kMaskIo4,kIoOn);
return len;
}
void setArg(uint16_t arg)
{
}
private:
uint16_t ssPin;
};
typedef TPixy2<Link2SPI_SS> Pixy2SPI_SS;
#endif