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

RE: SPI driver




Hello, I tried this configuration:
  
     devspi = open ("/dev/syncser0", O_RDWR | O_SYNC);    
     if (devspi == -1)
      {
        fprintf (stderr, "\nError: %s\n", strerror (errno));
        exit (1);
      }
    ioctl (devspi, SSP_MODE,       MASTER_BIDIR);        
  
    tmp = NORMAL_SYNC | BIT_SYNC | SYNC_ON | WORD_SIZE_8 | 
 BIT_ORDER_MSB | FLOW_CONTROL_DISABLE | CLOCK_GATED;
    if (ioctl(devspi, SSP_FRAME_SYNC, tmp)) {
      fprintf(stderr, "Couldn't change sync SSP_FRAME_SYNC\n");
      err++;
    }
  
    tmp = CLOCK_INEGEDGE | FRAME_NORMAL | STATUS_NORMAL;
    if (ioctl(devspi, SSP_IPOLARITY, tmp)) {
      fprintf(stderr, "Couldn't change polarity SSP_IPOLARITY\n");
      err++;
    }
    tmp = CLOCK_NORMAL | FRAME_NORMAL | STATUS_NORMAL;
    if (ioctl(devspi, SSP_OPOLARITY, tmp)) {
      fprintf(stderr, "Couldn't change polarity SSP_OPOLARITY\n");
      err++;
    }
  
    /* 64 kHz, word_sync: 8 bits/sync, frame_sync: 1 (no framing) */  
    if (ioctl(devspi, SSP_SPEED, CODEC_VAL(FREQ_64kHz, 8, 1))) {
      fprintf(stderr, "Couldn't change sync SSP_SPEED\n");
    }
    /* 160 bytes (160 samples = 20 ms) buffering */
    if (ioctl(devspi, SSP_INBUFCHUNK, 160)) {
      fprintf(stderr, "Couldn't change sync SSP_BUFCHUNK\n");
      err++;
    }
  }
  
  
  But after this, an attempt to 'write' blocks and never 
 returns. If I open the device using O_NONBLOCK, 'write' 
 returns 0 bytes written.
  
  I am using a version of syncser driver Mikael Starvik sent 
 me today. With the old driver, I got SPI transmission but 
 the problem was that old syncser driver caused high CPU load 
 in master bidirectional mode.
  
So old driver causes high CPU load in master bidirectional mode, and
Mikael Starvik's new driver blocks and don't send bytes, with 'read'
returning a 'Resource temporarily unavailable' error.

Async serial port ser1 and USB are disabled, /dev/syncser0 is used.
  
Any ideas?
Regards,
Carlos