Adding a new Device for SPI External Port

Hi,

I am fairly new to APM on Pixhawk board. I’m trying to make an external Arduino communicate with Pixhawk board running APM Plane 3.4 over SPI external bus.

I have created a Driver for Arduino based on MPU6000 driver and included in PX4 Firmware drivers. The driver compiles and links properly. Yet I couldn’t get the device listed in NuttX /dev.

I’m not sure what I’m missing. Without this I couldn’t get the File Descriptor at the APM Side.

Any help would be appreciated.

Thanks
Deena

Hi, I managed to get it listed once I use “arduino start” command in the NSH console. I’m still not sure where to add this so that it happens automatically during startup.

Since the device path is now available, I tried reading it from Arduplane.cpp by scheduling a task at 10 second.

void Plane::spi_read()
{
    int _arduino = open("/dev/arduino", O_RDONLY);
    ::printf("ARDUINO OPEN: %d\n", _arduino);

    ::read(_arduino, &_arduino_report, sizeof(_arduino_report));

    ::printf("Reading Complete...");

    close(_arduino);
} 

I have not programmed Arduino yet. Before that I wanted to see if the Chip Select pin goes down during the Read operation. But I don’t see that happening. It always stays high. Arduino Open and Reading complete messages are appearing in NSH without any problem.

Please help me to know if I’m missing something that is not making Chip Select to go down during read.

1 Like