Mbed OS Reference
|
A SPI slave, used for communicating with a SPI master device. More...
#include <SPISlave.h>
Public Member Functions | |
SPISlave (PinName mosi, PinName miso, PinName sclk, PinName ssel) | |
Create a SPI slave connected to the specified pins. More... | |
SPISlave (const spi_pinmap_t &pinmap) | |
Create a SPI slave connected to the specified pins. More... | |
~SPISlave () | |
Destructor. More... | |
void | format (int bits, int mode=0) |
Configure the data transmission format. More... | |
int | receive (void) |
Polls the SPI to see if data has been received. More... | |
int | read (void) |
Retrieve data from receive buffer as slave. More... | |
void | reply (int value) |
Fill the transmission buffer with the value to be written out as slave on the next received message from the master. More... | |
A SPI slave, used for communicating with a SPI master device.
The default format is set to 8 bits, mode 0.
Example of how to reply to a SPI master as slave:
Definition at line 59 of file SPISlave.h.
SPISlave | ( | PinName | mosi, |
PinName | miso, | ||
PinName | sclk, | ||
PinName | ssel | ||
) |
SPISlave | ( | const spi_pinmap_t & | pinmap | ) |
Create a SPI slave connected to the specified pins.
pinmap | reference to structure which holds static pinmap. |
void format | ( | int | bits, |
int | mode = 0 |
||
) |
Configure the data transmission format.
bits | Number of bits per SPI frame (4 - 16). |
mode | Clock polarity and phase mode (0 - 3). |
int receive | ( | void | ) |
Polls the SPI to see if data has been received.
0 | No data waiting. |
1 | Data waiting. |
int read | ( | void | ) |
Retrieve data from receive buffer as slave.
void reply | ( | int | value | ) |
Fill the transmission buffer with the value to be written out as slave on the next received message from the master.
value | The data to be transmitted next. |