Software SPI allows non-standard SPI pins to be used for interfacing with SPI devices
Dependents: ADNS5090 PB_Emma_Ethernet spi_test Final_Project ... more
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 26 2022 20:01:51 by 1.7.2