From e88367d7224134f9ef81fc6fbfc11d1e93ae0c3b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 22 Jan 2016 17:11:46 +0100 Subject: [PATCH] SPI: Support setting the lock mode --- src/drivers/device/spi.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/drivers/device/spi.h b/src/drivers/device/spi.h index 9c3bf36f25..986a322432 100644 --- a/src/drivers/device/spi.h +++ b/src/drivers/device/spi.h @@ -77,6 +77,15 @@ protected: int irq = 0); virtual ~SPI(); + /** + * Locking modes supported by the driver. + */ + enum LockMode { + LOCK_PREEMPTION, /**< the default; lock against all forms of preemption. */ + LOCK_THREADS, /**< lock only against other threads, using SPI_LOCK */ + LOCK_NONE /**< perform no locking, only safe if the bus is entirely private */ + }; + virtual int init(); /** @@ -117,13 +126,14 @@ protected: void set_frequency(uint32_t frequency); /** - * Locking modes supported by the driver. + * Set the SPI bus locking mode + * + * This set the SPI locking mode. For devices competing with NuttX SPI + * drivers on a bus the right lock mode is LOCK_THREADS. + * + * @param mode Locking mode */ - enum LockMode { - LOCK_PREEMPTION, /**< the default; lock against all forms of preemption. */ - LOCK_THREADS, /**< lock only against other threads, using SPI_LOCK */ - LOCK_NONE /**< perform no locking, only safe if the bus is entirely private */ - }; + void set_lockmode(enum LockMode mode) { locking_mode = mode; } LockMode locking_mode; /**< selected locking mode */