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.
Fork of mbed-src by
SPI Class Reference
A SPI Master, used for communicating with SPI slave devices. More...
#include <SPI.h>
Public Member Functions | |
SPI (PinName mosi, PinName miso, PinName sclk, PinName _unused=NC) | |
Create a SPI master connected to the specified pins. | |
void | format (int bits, int mode=0) |
Configure the data transmission format. | |
void | frequency (int hz=1000000) |
Set the spi bus clock frequency. | |
virtual int | write (int value) |
Write to the SPI Slave and return the response. |
Detailed Description
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
Example:
// Send a byte to a SPI slave, and record the response #include "mbed.h" SPI device(p5, p6, p7); // mosi, miso, sclk int main() { int response = device.write(0xFF); }
Definition at line 47 of file SPI.h.
Constructor & Destructor Documentation
SPI | ( | PinName | mosi, |
PinName | miso, | ||
PinName | sclk, | ||
PinName | _unused = NC |
||
) |
Member Function Documentation
void format | ( | int | bits, |
int | mode = 0 |
||
) |
void frequency | ( | int | hz = 1000000 ) |
Generated on Tue Jul 12 2022 21:21:34 by
