I am currently working with the library libwiringpi which include some very useful functions. One of them is for the spi protocol of raspberry pi. This library has as prototype the function wiringPiSPIDataRW(channel:longint; data: Pointer; len:longint):longint;cdecl;external;
Could please inform me how i could pass an array on the data section.
Currently i try to make an array as buffer with 5 elements integer. I try many pointer example without success. The problem is i always take as result our of memory , or garbage from random memory position ( i think because i am not in medium or advance in pascal).
The following code in C it works (i do not know if that helps).
unsigned char buffer[3];
buffer[0] |= 0b11000000| ((adc_channel)<<4);
printf("value to send is %d \n",buffer[0]);
wiringPiSPIDataRW(spi_channel, buffer, 1);
delay(2000);//wait to make the convertion
wiringPiSPIDataRW(spi_channel, buffer, 3);
result=buffer[1]<<7;
result|=buffer[2];
final=result;
final*=3.3;
final/=4096;
printf ("results = %f \n",final);
printf("return value is %s \n",buffer);
I am attaching the source code form my pascal program and the outputs form the C and the pascal program. I upload the attachment in following link
http://www.filedropper.com/problemincodeAny new ideas perhaps?