Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
Diff: SPI.h
- Revision:
- 122:f9eeca106725
- Parent:
- 102:da0ca467f8b5
- Child:
- 123:b0220dba8be7
--- a/SPI.h Wed May 25 16:44:06 2016 +0100
+++ b/SPI.h Thu Jul 07 14:34:11 2016 +0100
@@ -39,6 +39,8 @@
* Most SPI devices will also require Chip Select and Reset signals. These
* can be controlled using <DigitalOut> pins
*
+ * @Note Synchronization level: Thread safe
+ *
* Example:
* @code
* // Send a byte to a SPI slave, and record the response
@@ -56,10 +58,13 @@
* // hardware ssel (where applicable)
* //int response = device.write(0xFF);
*
+ * device.lock();
* // software ssel
* cs = 0;
* int response = device.write(0xFF);
* cs = 1;
+ * device.unlock();
+ *
* }
* @endcode
*/
@@ -109,6 +114,14 @@
*/
virtual int write(int value);
+ /** Acquire exclusive access to this SPI bus
+ */
+ virtual void lock(void);
+
+ /** Release exclusive access to this SPI bus
+ */
+ virtual void unlock(void);
+
#if DEVICE_SPI_ASYNCH
/** Start non-blocking SPI transfer using 8bit buffers.
@@ -233,6 +246,7 @@
void aquire(void);
static SPI *_owner;
+ PlatformMutex _mutex;
int _bits;
int _mode;
int _hz;


