The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
Diff: drivers/SPI.h
- Revision:
- 145:64910690c574
- Parent:
- 128:9bcdf88f62b0
- Child:
- 146:22da6e220af6
--- a/drivers/SPI.h Thu Jun 08 14:53:05 2017 +0100 +++ b/drivers/SPI.h Wed Jun 21 17:31:38 2017 +0100 @@ -18,7 +18,7 @@ #include "platform/platform.h" -#if DEVICE_SPI +#if defined (DEVICE_SPI) || defined(DOXYGEN_ONLY) #include "platform/PlatformMutex.h" #include "hal/spi_api.h" @@ -34,16 +34,15 @@ namespace mbed { /** \addtogroup drivers */ -/** @{*/ /** A SPI Master, used for communicating with SPI slave devices * * The default format is set to 8-bits, mode 0, and a clock frequency of 1MHz * * Most SPI devices will also require Chip Select and Reset signals. These - * can be controlled using <DigitalOut> pins + * can be controlled using DigitalOut pins * - * @Note Synchronization level: Thread safe + * @note Synchronization level: Thread safe * * Example: * @code @@ -71,6 +70,7 @@ * * } * @endcode + * @ingroup drivers */ class SPI { @@ -115,9 +115,25 @@ * * @returns * Response from the SPI slave - */ + */ virtual int write(int value); + /** Write to the SPI Slave and obtain the response + * + * The total number of bytes sent and recieved will be the maximum of + * tx_length and rx_length. The bytes written will be padded with the + * value 0xff. + * + * @param tx_buffer Pointer to the byte-array of data to write to the device + * @param tx_length Number of bytes to write, may be zero + * @param rx_buffer Pointer to the byte-array of data to read from the device + * @param rx_length Number of bytes to read, may be zero + * @returns + * The number of bytes written and read from the device. This is + * maximum of tx_length and rx_length. + */ + virtual int write(const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length); + /** Acquire exclusive access to this SPI bus */ virtual void lock(void); @@ -261,5 +277,3 @@ #endif #endif - -/** @}*/