Skip to content

Commit 2274fc8

Browse files
Cruz Monrreal IICruz Monrreal II
authored andcommitted
Merge branch 'doc-fix-spi_slave' of ssh://github.com/paul-szczepanek-arm/mbed-os into rollup
2 parents 975be7b + 7637c61 commit 2274fc8

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

drivers/SPISlave.h

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,18 @@
2626
namespace mbed {
2727
/** \addtogroup drivers */
2828

29-
/** A SPI slave, used for communicating with a SPI Master device
29+
/** A SPI slave, used for communicating with a SPI master device.
3030
*
31-
* The default format is set to 8-bits, mode 0, and a clock frequency of 1MHz
31+
* The default format is set to 8 bits, mode 0 and a clock frequency of 1MHz.
3232
*
3333
* @note Synchronization level: Not protected
3434
*
35-
* Example:
35+
* Example of how to reply to a SPI master as slave:
3636
* @code
37-
* // Reply to a SPI master as slave
3837
*
3938
* #include "mbed.h"
4039
*
41-
* SPISlave device(p5, p6, p7, p8); // mosi, miso, sclk, ssel
40+
* SPISlave device(SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS);
4241
*
4342
* int main() {
4443
* device.reply(0x00); // Prime SPI with first reply
@@ -57,21 +56,21 @@ class SPISlave : private NonCopyable<SPISlave> {
5756

5857
public:
5958

60-
/** Create a SPI slave connected to the specified pins
59+
/** Create a SPI slave connected to the specified pins.
6160
*
62-
* mosi or miso can be specified as NC if not used
61+
* @note Either mosi or miso can be specified as NC if not used.
6362
*
64-
* @param mosi SPI Master Out, Slave In pin
65-
* @param miso SPI Master In, Slave Out pin
66-
* @param sclk SPI Clock pin
67-
* @param ssel SPI chip select pin
63+
* @param mosi SPI Master Out, Slave In pin.
64+
* @param miso SPI Master In, Slave Out pin.
65+
* @param sclk SPI Clock pin.
66+
* @param ssel SPI Chip Select pin.
6867
*/
6968
SPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel);
7069

71-
/** Configure the data transmission format
70+
/** Configure the data transmission format.
7271
*
73-
* @param bits Number of bits per SPI frame (4 - 16)
74-
* @param mode Clock polarity and phase mode (0 - 3)
72+
* @param bits Number of bits per SPI frame (4 - 16).
73+
* @param mode Clock polarity and phase mode (0 - 3).
7574
*
7675
* @code
7776
* mode | POL PHA
@@ -84,40 +83,47 @@ class SPISlave : private NonCopyable<SPISlave> {
8483
*/
8584
void format(int bits, int mode = 0);
8685

87-
/** Set the spi bus clock frequency
86+
/** Set the SPI bus clock frequency.
8887
*
89-
* @param hz SCLK frequency in hz (default = 1MHz)
88+
* @param hz Clock frequency in hz (default = 1MHz).
9089
*/
9190
void frequency(int hz = 1000000);
9291

93-
/** Polls the SPI to see if data has been received
92+
/** Polls the SPI to see if data has been received.
9493
*
95-
* @returns
96-
* 0 if no data,
97-
* 1 otherwise
94+
* @return Presence of received data.
95+
* @retval 0 No data waiting.
96+
* @retval 1 Data waiting.
9897
*/
9998
int receive(void);
10099

101-
/** Retrieve data from receive buffer as slave
100+
/** Retrieve data from receive buffer as slave.
102101
*
103-
* @returns
104-
* the data in the receive buffer
102+
* @return The data in the receive buffer.
105103
*/
106104
int read(void);
107105

108106
/** Fill the transmission buffer with the value to be written out
109107
* as slave on the next received message from the master.
110108
*
111-
* @param value the data to be transmitted next
109+
* @param value The data to be transmitted next.
112110
*/
113111
void reply(int value);
114112

113+
#if !defined(DOXYGEN_ONLY)
114+
115115
protected:
116+
/* Internal SPI object identifying the resources */
116117
spi_t _spi;
117118

119+
/* How many bits in an SPI frame */
118120
int _bits;
121+
/* Clock phase and polarity */
119122
int _mode;
123+
/* Clock frequency */
120124
int _hz;
125+
126+
#endif //!defined(DOXYGEN_ONLY)
121127
};
122128

123129
} // namespace mbed

0 commit comments

Comments
 (0)