#include <TWI.h>
|
| TWI (uint32_t freq=DEFAULT_FREQ) |
|
virtual bool | acquire () |
|
virtual bool | release () |
|
virtual int | read (uint8_t addr, void *buf, size_t count) |
|
virtual int | write (uint8_t addr, iovec_t *vp) |
|
| TWI (uint32_t freq=DEFAULT_FREQ) |
|
virtual bool | acquire () |
|
virtual bool | release () |
|
virtual int | read (uint8_t addr, void *buf, size_t count) |
|
virtual int | write (uint8_t addr, iovec_t *vp) |
|
virtual int | write (uint8_t addr, const void *buf, size_t count) |
|
|
enum | {
START = 0x08,
REP_START = 0x10,
ARB_LOST = 0x38,
MT_SLA_ACK = 0x18,
MT_SLA_NACK = 0x20,
MT_DATA_ACK = 0x28,
MT_DATA_NACK = 0x30,
MR_SLA_ACK = 0x40,
MR_SLA_NACK = 0x48,
MR_DATA_ACK = 0x50,
MR_DATA_NACK = 0x58,
MASK = 0xF8,
BUS_ERROR = 0x00
} |
|
enum | state_t { IDLE_STATE,
BUSY_STATE,
WRITE_STATE
} |
|
Definition at line 28 of file TWI.h.
Status codes for Master Transmitter Mode.
Enumerator |
---|
START |
Start condition transmitted.
|
REP_START |
Repeated start transmitted.
|
ARB_LOST |
Arbitration lost.
|
MT_SLA_ACK |
Slave address/write sent, ACK received.
|
MT_SLA_NACK |
dito, NACK received.
|
MT_DATA_ACK |
Data write sent, ACK received.
|
MT_DATA_NACK |
dito, NACK received.
|
MR_SLA_ACK |
Slave address/read sent, ACK received.
|
MR_SLA_NACK |
dito, NACK received.
|
MR_DATA_ACK |
Data received, ACK sent.
|
MR_DATA_NACK |
dito, NACK sent.
|
MASK |
Mask status code.
|
BUS_ERROR |
Bus error state.
|
Definition at line 155 of file TWI.h.
Device driver states.
Enumerator |
---|
IDLE_STATE |
|
BUSY_STATE |
|
WRITE_STATE |
|
Definition at line 180 of file TWI.h.
Construct Two-Wire Interface (TWI).
- Parameters
-
[in] | freq | bus manager clock frequency (HZ). |
Definition at line 34 of file TWI.h.
Construct Two-Wire Interface (TWI).
- Parameters
-
[in] | freq | bus manager clock frequency (HZ). |
Definition at line 36 of file TWI.h.
virtual bool Hardware::TWI::acquire |
( |
| ) |
|
|
inlinevirtual |
Start transaction for given device driver. Return true(1) if successful otherwise false(0).
- Returns
- bool.
Implements TWI.
Definition at line 48 of file TWI.h.
virtual bool Hardware::TWI::acquire |
( |
| ) |
|
|
inlinevirtual |
Start transaction for given device driver. Return true(1) if successful otherwise false(0).
- Returns
- bool.
Implements TWI.
Definition at line 59 of file TWI.h.
bool Hardware::TWI::iowait |
( |
uint8_t |
status | ) |
|
|
inlineprotected |
Wait for command to complete and check status. Return true(1) if correct status has been reached otherwise false(0).
- Parameters
-
- Returns
- bool.
Definition at line 178 of file TWI.h.
Lock bus manager.
Definition at line 176 of file TWI.h.
virtual int Hardware::TWI::read |
( |
uint8_t |
addr, |
|
|
void * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
inlinevirtual |
Read data from device with given address into given buffer.
- Parameters
-
[in] | addr | device address. |
[in] | buf | buffer pointer. |
[in] | count | buffer size in bytes. |
- Returns
- number of bytes read or negative error code.
Implements TWI.
Definition at line 85 of file TWI.h.
virtual int Hardware::TWI::read |
( |
uint8_t |
addr, |
|
|
void * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
inlinevirtual |
Read data from device with given address into given buffer.
- Parameters
-
[in] | addr | device address. |
[in] | buf | buffer pointer. |
[in] | count | buffer size in bytes. |
- Returns
- number of bytes read or negative error code.
Implements TWI.
Definition at line 94 of file TWI.h.
virtual bool Hardware::TWI::release |
( |
| ) |
|
|
inlinevirtual |
Stop transaction. Mark the bus as available. Return true(1) if successful otherwise false(0).
- Returns
- bool.
Implements TWI.
Definition at line 63 of file TWI.h.
virtual bool Hardware::TWI::release |
( |
| ) |
|
|
inlinevirtual |
Stop transaction. Mark the bus as available. Return true(1) if successful otherwise false(0).
- Returns
- bool.
Implements TWI.
Definition at line 73 of file TWI.h.
bool Hardware::TWI::stop_condition |
( |
| ) |
|
|
inlineprotected |
Unlock bus manager.
Definition at line 185 of file TWI.h.
virtual int Hardware::TWI::write |
( |
uint8_t |
addr, |
|
|
iovec_t * |
vp |
|
) |
| |
|
inlinevirtual |
Write data to device with from given io vector.
- Parameters
-
[in] | addr | device address. |
[in] | vp | io vector pointer. |
- Returns
- number of bytes written or negative error code.
Implements TWI.
Definition at line 123 of file TWI.h.
virtual int Hardware::TWI::write |
( |
uint8_t |
addr, |
|
|
iovec_t * |
vp |
|
) |
| |
|
inlinevirtual |
Write data to device with from given io vector.
- Parameters
-
[in] | addr | device address. |
[in] | vp | io vector pointer. |
- Returns
- number of bytes written or negative error code.
Implements TWI.
Definition at line 134 of file TWI.h.
virtual int TWI::write |
( |
uint8_t |
addr, |
|
|
const void * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
inlinevirtualinherited |
Write data to device with given address from given buffer.
- Parameters
-
[in] | addr | device address. |
[in] | buf | buffer pointer. |
[in] | count | buffer size in bytes. |
- Returns
- number of bytes written or negative error code.
Definition at line 151 of file TWI.h.
const uint32_t TWI::DEFAULT_FREQ = 100000L |
|
staticinherited |
Default Two-Wire Interface clock: 100 KHz.
Definition at line 108 of file TWI.h.
volatile bool TWI::m_busy |
|
protectedinherited |
Bus manager semaphore.
Definition at line 171 of file TWI.h.
bool Hardware::TWI::m_start |
|
protected |
Start condition issued flag.
Definition at line 185 of file TWI.h.
Twi* Hardware::TWI::m_twi |
|
protected |
TWI instance (libsam/twi).
Definition at line 177 of file TWI.h.
const uint32_t Hardware::TWI::RETRY_MAX = 100000 |
|
staticprotected |
Maximum number of retries.
Definition at line 174 of file TWI.h.
The documentation for this class was generated from the following file: