#include <SPI.hh>
|
enum | Clock {
DIV2_CLOCK = 0x04,
DIV4_CLOCK = 0x00,
DIV8_CLOCK = 0x05,
DIV16_CLOCK = 0x01,
DIV32_CLOCK = 0x06,
DIV64_CLOCK = 0x02,
DIV128_CLOCK = 0x03,
DEFAULT_CLOCK = DIV4_CLOCK
} |
|
enum | Order { MSB_ORDER = 0,
LSB_ORDER = 1,
DEFAULT_ORDER = MSB_ORDER
} |
|
enum | Pulse {
ACTIVE_LOW = 0,
ACTIVE_HIGH = 1,
PULSE_LOW = 2,
PULSE_HIGH = 3,
DEFAULT_PULSE = ACTIVE_LOW
} |
|
Soft Serial Peripheral Interface (SPI) device class.
Definition at line 37 of file SPI.hh.
Clock selectors.
Enumerator |
---|
DIV2_CLOCK |
Divide system clock by 2.
|
DIV4_CLOCK |
Divide system clock by 4.
|
DIV8_CLOCK |
Divide system clock by 8.
|
DIV16_CLOCK |
Divide system clock by 16.
|
DIV32_CLOCK |
Divide system clock by 32.
|
DIV64_CLOCK |
Divide system clock by 64.
|
DIV128_CLOCK |
Divide system clock by 128.
|
DEFAULT_CLOCK |
Default clock rate.
|
Definition at line 40 of file SPI.hh.
Bit order selectors.
Enumerator |
---|
MSB_ORDER |
Most significant bit first.
|
LSB_ORDER |
Least significant bit first.
|
DEFAULT_ORDER |
Default is MSB.
|
Definition at line 52 of file SPI.hh.
Chip select mode.
Enumerator |
---|
ACTIVE_LOW |
Active low logic during transaction.
|
ACTIVE_HIGH |
Active high logic during transaction.
|
PULSE_LOW |
Pulse low on end of transaction.
|
PULSE_HIGH |
Pulse high on end of transaction.
|
DEFAULT_PULSE |
Default is low logic.
|
Definition at line 59 of file SPI.hh.
Construct soft serial peripheral interface master.
Definition at line 157 of file SPI.hh.
void SPI::acquire |
( |
Driver * |
dev | ) |
|
Acquire the SPI device driver. Initiate SPI hardware registers and disable SPI interrupt sources. The function will yield until the device driver has been acquired. Interrupts from SPI devices are disabled until the device driver is released. Used in the below format for a device driver:
Each transfer that requires chip select should be enclosed in a block with begin() and end(). There may be several transfer blocks in a transaction. The transaction is terminated with release().
- Parameters
-
[in] | dev | device driver context. |
Definition at line 43 of file SOFT_SPI.cpp.
bool SPI::attach |
( |
Driver * |
dev | ) |
|
Attach given SPI device driver context.
- Parameters
-
[in] | dev | device driver context. |
- Returns
- true(1) if successful otherwise false(0)
Definition at line 78 of file SOFT_SPI.cpp.
void Soft::SPI::begin |
( |
| ) |
|
|
inline |
Mark the beginning of a transfer block. Select the device by asserting the chip select pin according to the pulse pattern. Used in the format:
The transfer block should be terminated with end(). Typically the transfer block is a command (read/write) with a possible parameter block.
Definition at line 216 of file SPI.hh.
Mark the end of a transfer block. Deselect the device chip according to the pulse pattern.
Definition at line 226 of file SPI.hh.
void Soft::SPI::read |
( |
void * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
inline |
Read package from the device slave. Should only be used within a SPI transfer; begin()-end() block.
- Parameters
-
[in] | buf | buffer for read data. |
[in] | count | number of bytes to read. |
Definition at line 308 of file SPI.hh.
Release the SPI device driver. Enable SPI interrupt sources.
Definition at line 64 of file SOFT_SPI.cpp.
uint8_t SPI::transfer |
( |
uint8_t |
data | ) |
|
Exchange data with slave. Slave select must be done before exchange of data. Returns always zero(0) in soft variant.
- Parameters
-
- Returns
- zero
Definition at line 87 of file SOFT_SPI.cpp.
void Soft::SPI::transfer |
( |
void * |
buf, |
|
|
size_t |
count |
|
) |
| |
Exchange package with slave. Received data from slave is stored in given buffer. Should only be used within a SPI transfer; begin()-end() block.
- Parameters
-
[in] | buf | with data to transfer (send/receive). |
[in] | count | size of buffer. |
void Soft::SPI::transfer |
( |
void * |
dst, |
|
|
const void * |
src, |
|
|
size_t |
count |
|
) |
| |
|
inline |
Exchange package with slave. Received data from slave is stored in given destination buffer. Should only be used within a SPI transfer; begin()-end() block.
- Parameters
-
[in] | dst | destination buffer for received data. |
[in] | src | source buffer with data to send. |
[in] | count | size of buffers. |
Definition at line 294 of file SPI.hh.
uint8_t Soft::SPI::transfer_await |
( |
| ) |
|
|
inline |
Wait for exchange with slave. Should only be used within a SPI transaction; begin()-end() block. Return received value.
- Returns
- value received.
Definition at line 249 of file SPI.hh.
uint8_t Soft::SPI::transfer_next |
( |
uint8_t |
data | ) |
|
|
inline |
Next data to exchange with slave. Should only be used within a SPI transaction; begin()-end() block.
- Parameters
-
- Returns
- value received.
Definition at line 261 of file SPI.hh.
void Soft::SPI::transfer_start |
( |
uint8_t |
data | ) |
|
|
inline |
Start exchange data with slave. Should only be used within a SPI transaction; begin()-end() block.
- Parameters
-
Definition at line 238 of file SPI.hh.
void Soft::SPI::write |
( |
const void * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
inline |
Write package to the device slave. Should only be used within a SPI transaction; begin()-end() block.
- Parameters
-
[in] | buf | buffer with data to write. |
[in] | count | number of bytes to write. |
Definition at line 321 of file SPI.hh.
void Soft::SPI::write |
( |
const iovec_t * |
vec | ) |
|
|
inline |
Write null terminated io buffer vector to the device slave. Should only be used within a SPI transfer; begin()-end() block.
- Parameters
-
[in] | vec | null terminated io buffer vector pointer. |
Definition at line 345 of file SPI.hh.
void Soft::SPI::write_P |
( |
const uint8_t * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
inline |
Write package to the device slave. Should only be used within a SPI transaction; begin()-end() block.
- Parameters
-
[in] | buf | buffer with data to write. |
[in] | count | number of bytes to write. |
Definition at line 334 of file SPI.hh.
The documentation for this class was generated from the following files: