aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/include
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-06-07 21:47:46 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-06-07 21:47:46 -0400
commitcb1facd43e34920adadf5829751d779f92cf7681 (patch)
tree8fcce7d2d2c1e59c4260de02c97be1d125e1c734 /libmaple/include
parenta52fe9205cbb8f8a2e458e300c2048d889b26b54 (diff)
downloadlibrambutan-cb1facd43e34920adadf5829751d779f92cf7681.tar.gz
librambutan-cb1facd43e34920adadf5829751d779f92cf7681.zip
enum spi_mode: Add more descriptive enumerators, documentation.
Instead of requiring everyone to figure it out for themselves, add enumerators specifying the idle logic level and what clock edge triggers data capture. Yes, it's easy enough to figure it out. It's also convenient to have these. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple/include')
-rw-r--r--libmaple/include/libmaple/spi.h27
1 files changed, 16 insertions, 11 deletions
diff --git a/libmaple/include/libmaple/spi.h b/libmaple/include/libmaple/spi.h
index 45dc5a2..fab643f 100644
--- a/libmaple/include/libmaple/spi.h
+++ b/libmaple/include/libmaple/spi.h
@@ -236,19 +236,24 @@ extern void spi_config_gpios(spi_dev *dev,
/**
* @brief SPI mode configuration.
*
- * Determines a combination of clock polarity (CPOL), which determines
- * idle state of the clock line, and clock phase (CPHA), which
- * determines which clock edge triggers data capture.
+ * A SPI mode determines a combination of the idle state of the clock
+ * line (the clock polarity, or "CPOL"), and which clock edge triggers
+ * data capture (the clock phase, or "CPHA").
*/
typedef enum spi_mode {
- SPI_MODE_0, /**< Clock line idles low (0), data capture on first
- clock transition. */
- SPI_MODE_1, /**< Clock line idles low (0), data capture on second
- clock transition */
- SPI_MODE_2, /**< Clock line idles high (1), data capture on first
- clock transition. */
- SPI_MODE_3, /**< Clock line idles high (1), data capture on
- second clock transition. */
+ /** Clock idles low, data captured on rising edge (first transition) */
+ SPI_MODE_LOW_RISING = 0,
+ /** Clock idles low, data captured on falling edge (second transition) */
+ SPI_MODE_LOW_FALLING = 1,
+ /** Clock idles high, data captured on falling edge (first transition) */
+ SPI_MODE_HIGH_FALLING = 2,
+ /** Clock idles high, data captured on rising edge (second transition) */
+ SPI_MODE_HIGH_RISING = 3,
+
+ SPI_MODE_0 = SPI_MODE_LOW_RISING, /**< Same as SPI_MODE_LOW_RISING */
+ SPI_MODE_1 = SPI_MODE_LOW_FALLING, /**< Same as SPI_MODE_LOW_FALLING */
+ SPI_MODE_2 = SPI_MODE_HIGH_FALLING, /**< Same as SPI_MODE_HIGH_FALLING */
+ SPI_MODE_3 = SPI_MODE_HIGH_RISING, /**< Same as SPI_MODE_HIGH_RISING */
} spi_mode;
/**