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.
SWSPI Class Reference
A software implemented SPI that can use any digital pins. More...
#include <SWSPI.h>
Public Member Functions | |
SWSPI (PinName mosi_pin, PinName miso_pin, PinName sclk_pin) | |
Create SWSPI object. | |
~SWSPI () | |
Destructor. | |
void | format (int bits, int mode=0) |
Specify SPI format. | |
void | frequency (int hz=10000000) |
Specify SPI clock frequency. | |
int | write (int value) |
Write data and read result. |
Detailed Description
A software implemented SPI that can use any digital pins.
Useful when don't want to share a single SPI hardware among attached devices or when pinout doesn't match exactly to the target's SPI pins
#include "mbed.h" #include "SWSPI.h" SWSPI spi(p5, p6, p7); // mosi, miso, sclk int main() { DigitalOut cs(p8); spi.format(8, 0); spi.frequency(10000000); cs.write(0); spi.write(0x9f); int jedecid = (spi.write(0) << 16) | (spi.write(0) << 8) | spi.write(0); cs.write(1); }
Definition at line 49 of file SWSPI.h.
Constructor & Destructor Documentation
SWSPI | ( | PinName | mosi_pin, |
PinName | miso_pin, | ||
PinName | sclk_pin | ||
) |
Member Function Documentation
void format | ( | int | bits, |
int | mode = 0 |
||
) |
void frequency | ( | int | hz = 10000000 ) |
Generated on Tue Jul 12 2022 21:27:01 by
