SPI communication knows much more variation than e.g. I2C. This "how to" looks at the four modes induced by CPOL (default clock state) and CPHA (data valid phase).
Arduino has the following table giving an overview of the modes.
The sketch is available. The traces are made with Saleae.
(end)