api / mbed / trunk / SPI
SPI
class SPI : public Base
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);
}SPI
SPI( PinName mosi, PinName miso, PinName sclk, const char * name = NULL )
Create a SPI master connected to the specified pins
Variables
| mosi | SPI Master Out, Slave In pin |
| miso | SPI Master In, Slave Out pin |
| sclk | SPI Clock pin |
| name | (optional) A string to identify the object |
Pin Options
(5, 6, 7) or (11, 12, 13)
mosi or miso can be specfied as NC if not used
A SPI Master, used for communicating with SPI slave devices
class SPI : public Base
Create a SPI master connected to the specified pins
SPI( PinName mosi, PinName miso, PinName sclk, const char * name = NULL )
Configure the data transmission format
void format( int bits, int mode = 0 )
Set the spi bus clock frequency
void frequency( int hz = 1000000 )
Write to the SPI Slave and return the response
virtual int write( int value )
A digital output, used for setting the state of a pin
class DigitalOut : public Base
