|
Exploring BeagleBone
V1.0
|
Generic SPI Device class that can be used to connect to any type of SPI device and read or write to its registers. More...
#include <SPIDevice.h>


Public Types | |
| enum | SPIMODE { MODE0 = 0, MODE1 = 1, MODE2 = 2, MODE3 = 3 } |
| The SPI Mode. More... | |
Public Member Functions | |
| SPIDevice (unsigned int bus, unsigned int device) | |
| virtual int | open () |
| virtual unsigned char | readRegister (unsigned int registerAddress) |
| virtual unsigned char * | readRegisters (unsigned int number, unsigned int fromAddress=0) |
| virtual int | writeRegister (unsigned int registerAddress, unsigned char value) |
| virtual void | debugDumpRegisters (unsigned int number=0xff) |
| virtual int | write (unsigned char value) |
| virtual int | write (unsigned char value[], int length) |
| virtual int | setSpeed (uint32_t speed) |
| virtual int | setMode (SPIDevice::SPIMODE mode) |
| virtual int | setBitsPerWord (uint8_t bits) |
| virtual void | close () |
| virtual | ~SPIDevice () |
| virtual int | transfer (unsigned char read[], unsigned char write[], int length) |
Public Member Functions inherited from exploringBB::BusDevice | |
| BusDevice (unsigned int bus, unsigned int device) | |
| virtual | ~BusDevice () |
Additional Inherited Members | |
Protected Attributes inherited from exploringBB::BusDevice | |
| unsigned int | bus |
| unsigned int | device |
| int | file |
Generic SPI Device class that can be used to connect to any type of SPI device and read or write to its registers.
| exploringBB::SPIDevice::SPIDevice | ( | unsigned int | bus, |
| unsigned int | device | ||
| ) |
The constructor for the SPIDevice that sets up and opens the SPI connection. The destructor will close the SPI file connection.
| bus | The SPI bus number X (first digit after spidevX.Y) |
| device | The device on the bus Y (second digit after spidevX.Y) |
|
virtual |
The destructor closes the SPI bus device
|
virtual |
|
virtual |
A simple method to dump the registers to the standard output – useful for debugging
| number | the number of registers to dump |
Implements exploringBB::BusDevice.
|
virtual |
This method opens the file connection to the SPI device.
Implements exploringBB::BusDevice.
|
virtual |
A method to read a single register at the SPI address
| registerAddress | the address of the register from the device datasheet |
Implements exploringBB::BusDevice.
|
virtual |
A method to read a number of registers as a data array
| number | the number of registers to read |
| fromAddress | the starting address of the block of data |
Implements exploringBB::BusDevice.
|
virtual |
Set the number of bits per word of the SPI bus
| bits | the number of bits per word |
|
virtual |
Set the mode of the SPI bus
| mode | the enumerated SPI mode |
|
virtual |
Set the speed of the SPI bus
| speed | the speed in Hz |
|
virtual |
Generic method to transfer data to and from the SPI device. It is used by the following methods to read and write registers.
| send | The array of data to send to the SPI device |
| receive | The array of data to receive from the SPI device |
| length | The length of the array to send |
|
virtual |
A write method that writes a single character to the SPI bus
| value | the value to write to the bus |
Implements exploringBB::BusDevice.
|
virtual |
A write method that writes a block of data of the length to the bus.
| value | the array of data to write to the device |
| length | the length of the data array |
|
virtual |
Writes a value to a defined register address (check the datasheet for the device)
| registerAddress | the address of the register to write to |
| value | the value to write to the register |
Implements exploringBB::BusDevice.
1.8.8