![]() |
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Basic I2C slave driver. More...
#include <PropWare/serial/i2c/i2cslave.h>
Inheritance diagram for PropWare::I2CSlave:
Collaboration diagram for PropWare::I2CSlave:Public Member Functions | |
| template<size_t BUFFER_SIZE, size_t STACK_SIZE> | |
| I2CSlave (const uint8_t address, uint8_t(&buffer)[BUFFER_SIZE], const uint32_t(&stack)[STACK_SIZE], const Pin::Mask sclMask=DEFAULT_SCL_MASK, const Pin::Mask sdaMask=DEFAULT_SDA_MASK) | |
| Create an I2CSlave object (requires static allocation of buffer and stack) More... | |
| I2CSlave (const uint8_t address, uint8_t *buffer, const size_t bufferSize, const uint32_t *stack, const size_t stackSize, const Pin::Mask sclMask=DEFAULT_SCL_MASK, const Pin::Mask sdaMask=DEFAULT_SDA_MASK) | |
| Create an I2C slave object (Allows dynamic allocation of buffer and stack) More... | |
| void | run () |
| Enter the loop that will watch and operate the bus. | |
| size_t | available () const |
| Get the amount of bytes in the receive buffer. More... | |
| int | read () |
| Read the next byte from the receiveBuffer. More... | |
| void | write (const uint8_t data) |
| Send the given byte of data on the bus during a request from the bus master. More... | |
Static Public Member Functions | |
| template<class T > | |
| static int8_t | invoke (T &runnable) |
| Start a new cog running the given object. More... | |
Static Public Attributes | |
| static const Pin::Mask | DEFAULT_SCL_MASK = Pin::Mask::P28 |
| static const Pin::Mask | DEFAULT_SDA_MASK = Pin::Mask::P29 |
Basic I2C slave driver.
Requires that the SDA and SCL pins have sufficient pull-ups. These should be selected based on the capacitance of the devices on the I2C bus, and the expected clock speed.
The driver supports restarts and only 7-bit addressing. The driver does not support clock stretching.
Definition at line 47 of file i2cslave.h.
| PropWare::I2CSlave::I2CSlave | ( | const uint8_t | address, |
| uint8_t(&) | buffer[BUFFER_SIZE], | ||
| const uint32_t(&) | stack[STACK_SIZE], | ||
| const Pin::Mask | sclMask = DEFAULT_SCL_MASK, |
||
| const Pin::Mask | sdaMask = DEFAULT_SDA_MASK |
||
| ) |
Create an I2CSlave object (requires static allocation of buffer and stack)
| [in] | address | Address to join the bus as slave with |
| [in] | sclMask | Pin mask for the SCL pin |
| [in] | sdaMask | Pin mask for the SDA pin |
| [in] | buffer | Receive buffer to store messages as they arrive |
| [in] | stack | Reserved stack space that can be used for a new cog to execute the run() method |
| <UserDataType> | Type of the userData that can be set and is then passed to all callback functions |
buffer that is too small will lead to received messages being truncated. Definition at line 67 of file i2cslave.h.
| PropWare::I2CSlave::I2CSlave | ( | const uint8_t | address, |
| uint8_t * | buffer, | ||
| const size_t | bufferSize, | ||
| const uint32_t * | stack, | ||
| const size_t | stackSize, | ||
| const Pin::Mask | sclMask = DEFAULT_SCL_MASK, |
||
| const Pin::Mask | sdaMask = DEFAULT_SDA_MASK |
||
| ) |
Create an I2C slave object (Allows dynamic allocation of buffer and stack)
| [in] | address | Address to join the bus as slave with |
| [in] | sclMask | Pin mask for the SCL pin |
| [in] | sdaMask | Pin mask for the SDA pin |
| [in] | buffer | Receive buffer to store messages as they arrive |
| [in] | bufferSize | Size of the receive buffer, that will hold a received message (-> maximal message size) |
| [in] | stack | Reserved stack space that can be used for a new cog to execute the run() method |
| [in] | stackSize | Size of the reserved stack (in measured in 32-bit words, not bytes) |
buffer that is too small will lead to received messages being truncated. Definition at line 92 of file i2cslave.h.
| size_t PropWare::I2CSlave::available | ( | ) | const |
Get the amount of bytes in the receive buffer.
Definition at line 144 of file i2cslave.h.
|
staticinherited |
Start a new cog running the given object.
| [in] | runnable | Object that should be invoked in a new cog |
Definition at line 85 of file runnable.h.
Here is the call graph for this function:| int PropWare::I2CSlave::read | ( | ) |
Read the next byte from the receiveBuffer.
-1 when none is available. Definition at line 153 of file i2cslave.h.
| void PropWare::I2CSlave::write | ( | const uint8_t | data | ) |
Send the given byte of data on the bus during a request from the bus master.
| [in] | data | Byte to send to the requesting master. |
Definition at line 167 of file i2cslave.h.
Here is the caller graph for this function:
1.8.17