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

Notes about syncser0 (SPI)





Hello:

Finally I get syncser0 working in my devboard 82.
If there is someone interested in using syncser0, those are some things
I MUST had to do:
- syncser0 in kernel configuration MUST use DMA.
- To open "/dev/syncser0" I MUST use 'O_SYNC', this is:
  devspi = open ("/dev/syncser0", O_RDWR | O_SYNC);


Here is part of my code:

//______________________________________________________________________
_______
//
//   void Spi_init (void)
//______________________________________________________________________
_______


void Spi_init (void)
{
  devspi = open ("/dev/syncser0", O_RDWR | O_SYNC);
  if (devspi == -1)
    {
      fprintf (stderr, "\nError: %s\n", strerror (errno));
      exit (1);
    }
  ioctl (devspi, SSP_SPI,        SPI_MASTER);     
  ioctl (devspi, SSP_MODE,       MASTER_BIDIR);   
  ioctl (devspi, SSP_FRAME_SYNC, WORD_SIZE_8);    
}

//______________________________________________________________________
_______
//
//   int Spi_write (int byte)
//______________________________________________________________________
_______


int Spi_write (int byte)
{ 
  int nbytes_written;
  int pointer_byte [2];

  pointer_byte[0] = byte;
  nbytes_written = write (devspi, pointer_byte, 1); 
  return (nbytes_written);
}

//______________________________________________________________________
_______


Regards,
Carlos Ojea