Hello every body;
I’m traying to do an spi communication between my raspberry PI 2 and the oscilloscope and logic analyzer shield for raspberry Pi VM205.
The spi protocol to reading the data can be desribed as follows :
[color=#FF0000]To reset the system and to start the data acquisition, send byte 0x81 to the SPI port. Then check if the data acquisition is
complete:
1. Wait 20ms.
2. Send byte 0x82 to the SPI port
3. Read the response from the SPI port.
If the response is 0x02, the data acquisition is complete.
If the response is 0x00, the data acquisition is not yet complete.
In this case repeat the sequence 1-3 above.[/color]
After getting response 0x02, the acquired data can be read. Send 801 times 0x01 to the SPI port and read the response. You’ll get 800 values containing the oscilloscope data.
Then send 801 times 0x02 to the SPI port and read the response. You’ll now get 800 values containing the logic analyzer data for
the eight first channels.
Then send 801times 0x03 to the SPI port and read the response. You’ll now get 800 values containing the logic analyzer data for
the channels 9 and 10. Bit #0 is channel 9 data and bit #1 is channel 10 data.
In the logic analyzer data each bit corresponds the input channel state:
bit value 0 = input state low
bit value 1 = input state high
We can found the all protocol here :
vellemanprojects.eu/download … _vm205.pdf
So I implemeted the following code using the wiringPiSPI library to start the communication (just the first paragraph selected in red) and to see if I will have response :
#include
#include <wiringPiSPI.h>
#include <wiringPi.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
static int myFd;
int main()
{
int speed = 1000000;
int spi_chan = 0;
if ((myFd = wiringPiSPISetup (spi_chan, speed)) < 0)
{
cout << (stderr, "Can't open the SPI bus: %s\n", strerror (errno)) << endl;
exit (EXIT_FAILURE) ;
}
unsigned char byte = 0x81;
wiringPiSPIDataRW(spi_chan, &byte, spi_chan); /*reset the system and start the data acquisition*/
unsigned char reponse = 0x82;
bool out = false;
while((reponse == 0x00)&&(out == false)){
usleep(20000);
unsigned char reponse = 0x82;
wiringPiSPIDataRW(spi_chan, &reponse, spi_chan);
cout << int(reponse) << endl;
if (reponse == 0x02){out = true;}
}
}
But the problem now is, I don’t have any response about my card vm205.
So if you can give some helps ….
thank you