diff options
| author | [email protected] <[email protected]> | 2012-02-03 14:03:51 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2012-02-03 14:03:51 +0000 |
| commit | eedd490bd6a161c6b50d143e33d764fc3bc8eddb (patch) | |
| tree | 6f350b21cedbb631937b440f7ef78a10db070fc0 /components/drivers | |
| parent | f756b2584c5766fa9e15fbdbd9ab0a175d5bd656 (diff) | |
add const attribute to the ops.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1937 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/drivers')
| -rw-r--r-- | components/drivers/include/drivers/spi.h | 24 | ||||
| -rw-r--r-- | components/drivers/spi/spi_core.c | 2 |
2 files changed, 21 insertions, 5 deletions
diff --git a/components/drivers/include/drivers/spi.h b/components/drivers/include/drivers/spi.h index d7aad13c64..3d395a7bab 100644 --- a/components/drivers/include/drivers/spi.h +++ b/components/drivers/include/drivers/spi.h @@ -3,11 +3,27 @@ #include <rtthread.h>
-#define RT_SPI_CPHA (1<<0) /* bit[0]:CPHA */
-#define RT_SPI_CPOL (1<<1) /* bit[1]:CPOL */
+
+#define RT_SPI_CPHA (1<<0) /* bit[0]:CPHA, clock phase */
+#define RT_SPI_CPOL (1<<1) /* bit[1]:CPOL, clock polarity */
+/**
+ * At CPOL=0 the base value of the clock is zero
+ * - For CPHA=0, data are captured on the clock's rising edge (low��high transition)
+ * and data are propagated on a falling edge (high��low clock transition).
+ * - For CPHA=1, data are captured on the clock's falling edge and data are
+ * propagated on a rising edge.
+ * At CPOL=1 the base value of the clock is one (inversion of CPOL=0)
+ * - For CPHA=0, data are captured on clock's falling edge and data are propagated
+ * on a rising edge.
+ * - For CPHA=1, data are captured on clock's rising edge and data are propagated
+ * on a falling edge.
+ */
#define RT_SPI_LSB (0<<2) /* bit[2]: 0-LSB */
#define RT_SPI_MSB (1<<2) /* bit[2]: 1-MSB */
+#define RT_SPI_MASTER (0<<3) /* SPI master device */
+#define RT_SPI_SLAVE (1<<3) /* SPI slave device */
+
#define RT_SPI_MODE_0 (0 | 0) /* CPOL = 0, CPHA = 0 */
#define RT_SPI_MODE_1 (0 | RT_SPI_CPHA) /* CPOL = 0, CPHA = 1 */
#define RT_SPI_MODE_2 (RT_SPI_CPOL | 0) /* CPOL = 1, CPHA = 0 */
@@ -44,7 +60,7 @@ struct rt_spi_ops; struct rt_spi_bus
{
struct rt_device parent;
- struct rt_spi_ops *ops;
+ const struct rt_spi_ops *ops;
struct rt_mutex lock;
struct rt_spi_device* owner;
@@ -72,7 +88,7 @@ struct rt_spi_device #define SPI_DEVICE(dev) ((struct rt_spi_device*)(dev))
/* register a SPI bus */
-rt_err_t rt_spi_bus_register(struct rt_spi_bus* bus, const char* name, struct rt_spi_ops* ops);
+rt_err_t rt_spi_bus_register(struct rt_spi_bus* bus, const char* name, const struct rt_spi_ops* ops);
/* attach a device on SPI bus */
rt_err_t rt_spi_bus_attach_device(struct rt_spi_device* device, const char* name, const char* bus_name, void* user_data);
/* set configuration on SPI device */
diff --git a/components/drivers/spi/spi_core.c b/components/drivers/spi/spi_core.c index d4c265da6d..fc9f707979 100644 --- a/components/drivers/spi/spi_core.c +++ b/components/drivers/spi/spi_core.c @@ -3,7 +3,7 @@ extern rt_err_t rt_spi_bus_device_init(struct rt_spi_bus* bus, const char* name);
extern rt_err_t rt_spidev_device_init(struct rt_spi_device* dev, const char* name);
-rt_err_t rt_spi_bus_register(struct rt_spi_bus* bus, const char* name, struct rt_spi_ops* ops)
+rt_err_t rt_spi_bus_register(struct rt_spi_bus* bus, const char* name, const struct rt_spi_ops* ops)
{
rt_err_t result;
|
