[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Sync serial interface as SPI

Title: Mensaje
Hello !:
Have you been able to get SPI working?
I enabled the synchronous serial port in kernel configuration to use syncser0 and disabled serial port 1, the 'open' call works fine but when I attempt to read or write to SPI my program hangs.
Do I need to call 'ioctl' to write or read to SPI?
Here is part of my code:
  devspi = open ("/dev/syncser0", O_RDWR);
  if (devspi == -1)
      fprintf (stderr, "\nSPI open error : %s\n", strerror (errno));
      exit (1);
  ioctl (devspi, SSP_SPI,        SPI_MASTER);     // Master.
  ioctl (devspi, SSP_MODE,       MASTER_BIDIR);   // Master Bidireccional.
  ioctl (devspi, SSP_SPEED,      SSP921600);      // 921.600 bps
  ioctl (devspi, SSP_FRAME_SYNC, SYNC_ON);        // Frame:      Sync ON.
  ioctl (devspi, SSP_FRAME_SYNC, NORMAL_SYNC);    // Frame:      Sync normal.
  ioctl (devspi, SSP_FRAME_SYNC, WORD_SIZE_8);    // Frame:      8 bits 
  ioctl (devspi, SSP_FRAME_SYNC, FLOW_CONTROL_DISABLE);// Frame: No flow control
  ioctl (devspi, SSP_FRAME_SYNC, CLOCK_NOT_GATED);// Frame:      Clock not gated.
  read (devspi, pointer_byte, 1);       // Here my program hangs
  byte = 0x55;                               // Byte tx
  pointer_byte[0] = byte;
  write (devspi, pointer_byte, 1);      // My program may hang here too
Is my code ok?
Thanks in advance. Regards,
Carlos Ojea