Proposed addition to libi2c transfer mode structure for SPI chip select generation

Robert S. Grimes rsg at alum.mit.edu
Fri Sep 19 16:40:50 UTC 2008


Hi all,

The Xilinx Virtex-4 and Virtex II-Pro SPI peripherals support 
automatically generating per-byte chip selects (CS) for communicating 
over the SPI bus.  This mode is in addition to a manual mode, in which 
software must manually set CS.  The automatic mode is very cool for 
those devices that use CS to frame each byte (or in a custom version of 
the SPI peripheral I have, each 16-bit word).  However, other devices, 
such as Ramtron FRAM, expect the CS to be used as a "transaction" frame, 
which is where the manual mode comes in.

When I implemented my SPI driver, I needed to support both modes (as I 
have examples of each device type), but I couldn't find where to capture 
this option.  It seems to logically fit into the rtems_libi2c_tfr_mode_t 
structure, as it is related to those attributes, so that is what I did 
in my 4.8 installation.  I would like to see this incorporated into 
RTEMS (hopefully 4.9), so the Virtex SPI driver will work.  Here is the 
single change, in /cpukit/libi2c/libi2c.h:

  typedef struct {
    uint32_t baudrate;       /* maximum bits per second               */
                             /* only valid for SPI drivers:           */
    uint8_t  bits_per_char;  /* how many bits per byte/word/longword? */
    bool     lsb_first;      /* true: send LSB first                  */
    bool     clock_inv;      /* true: inverted clock (high active)    */
    bool     clock_phs;      /* true: clock starts toggling at start of 
data tfr */
    uint32_t  idle_char;     /* This character will be continuously 
transmitted in read only functions */
+   bool     spi_sel_mode;   /* SPI only - true = SS set per 
transaction; false = SS set per SPI word */
  } rtems_libi2c_tfr_mode_t;

Any comments?

I also can submit my SPI driver, though it is currently polled mode 
only; that was sufficient for my needs, and I couldn't get the 
interrupts to work correctly.  Perhaps by submitting it someone else 
could help?  Regardless, it does work fine as is, with that caveat.

Thanks,
-Bob




More information about the users mailing list