I've compiled the two tests and the write program works but perror reports an "illegal seek" when I try to read SPI. Tried a bunch of stuff but I'm still getting it. The example looks like this:
===================================================================================
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdlib.h>
#include <asm/mcf5485_dspi_ioctl.h>
#define BUF 10
int main()
{
int f, k, num;
char c[BUF];
f = open("/dev/dspi", O_RDONLY, 0);
if(f < 0)
{
printf("error of the opening\n");
exit(0);
}
ioctl(f, DSPIIOCS_MSTR, 1);
ioctl(f, DSPIIOCS_CSIS0, 1);
for (num = 0; num < BUF
{
k = read(f, &c[num], BUF - num);
perror("read");
if (k < 0)
{
printf("error of the reading\n");
break;
}
num += k;
}
for(k = 0; k < BUF; ++k)
printf("%i ", c[k]);
printf("\n");
close(f);
exit(0);
}
Any idea where I could be going wrong on such a simple program.....?
James