<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    This turns out to be just as trivial as one would hope, but there is
    a sea of confusion about this on the 'Net and this is one case where
    carefully reading the Atmel docs beats looking at this subject on
    the Internet. <br>
    <br>
    Here's how this works:<br>
    <br>
    1) The <b>AtMega328p</b> chip internal circuity in the <b>Uno</b>
    flavor of Arduino hard-wires "pin 10" to something that determines
    the master/slave mode of SPI. An API label meant to be private
    inside Arduino library and system code that designates this pin is
    "SS". <br>
    2) The first thing SPI.begin() does privately is set SS as an
    output. This sets the internal SPI hardware to master mode, which is
    what 99.9999999% of Arduino users need. The begin method (function)
    also sets SS HIGH because <b>coincidentally by design</b> many
    common SPI devices have their chip select line tied to this pin.<br>
    3) Pin 10 is used as a peripheral device chip select line by many
    common Arduino shields.  This assignment is assigned by <b>specific
      library code</b> and/or users for a <b>specific device</b>.<br>
    4) All SPI device chip select lines must be set initially HIGH to
    avoid glitching the device with a first interaction. This is often
    redundantly set by device-specific library init code, again by user
    code, etc. <br>
    <br>
    So in my case, my "P_SD_CS" is defined as "10" for my SD card I/O
    select, but I also have a "P_ACCEL_CS" that defines "3" for my
    accelerometer device select, and I have to explicitly set this to
    OUTPUT and it's state to HIGH before I start using the
    accelerometer. But if I used any of the 106 versions of demo and
    library code for this accelerometer the init code there would
    probably set pin <b>10</b> to OUTPUT and HIGH, and that would be <b>BAD</b>,
    because this pin is for SD interface use with my hardware and I
    don't want it to be fiddled with by some other code that might
    execute at an inconvenient time. So I'd have to extend that library
    or demo code's init method with a parameter or go in and change it's
    code to use the chip select pin specific to my hardware.<br>
    <br>
    You might ask yourself "What about my other flavor of Arduino that
    has a different chip in it?" I have no clue and haven't spent a
    millisecond looking for the general API and specific device answers
    to this question. :-)<br>
    <br>
    -Pete
  </body>
</html>